h;h++)for(i=h-1;i>=0;i--)if(p[i]k;++k){var l=a.chains()[k],m=d.chains()[k],n=f(l,m),o=n[0],p=n[1];if(o.length!==p.length)return console.errors("chains",l.name()," and",m.name()," do not contain the same number of residues."),null;for(var q=g.addChain(l),r=h.addChain(m),s=0;ss*t&&(f[8]=-1,h.mul(k,k,f)),h.mul(d,h.transpose(l,l),k),h.transpose(d,d);for(var u=m.full().atoms(),v=0;v=h;++h)for(var i=2;5>i;++i)if(!(h+i>=c.length())){var j=e.dist(c.posAt(a,h),c.posAt(b,h+i));if(Math.abs(j-f[i-2])>g)return!1}return!0}}(),g=function(a,b){var c=[5.45,5.18,6.37],d=2.1;return f(a,b,c,d)},h=function(a,b){var c=[6.1,10.4,13],d=1.42;return f(a,b,c,d)};return{Mol:U.Mol,MolView:U.MolView,assignHelixSheet:d,superpose:b.superpose,matchResiduesByIndex:b.matchResiduesByIndex,matchResiduesByNum:b.matchResiduesByNum}}(L),N=function(b){function c(){this._N={},this._S=null}function d(a){if(" "!==a[0]){var b=a.trim();if(4===b.length){for(var c=0,d=b.charCodeAt(c);4>c&&(65>d||d>122||d>90&&97>d);)++c,d=b.charCodeAt(c);return b[c]}var e=b.charCodeAt(0);return e>=48&&57>=e?b[1]:b.substr(0,2)}return a[1]}function e(a){this._b9=[],this._bQ=[],this._cn=[],this._bR={},this._i=new U.Mol,this._cF=new c,this._bL=null,this._br=null,this._et=null,this._b={},this._b.conectRecords=!!a.conectRecords}function f(a){return a.split(/\r\n|\r|\n/g)}function g(a,b){for(var c=b||{},d=f(a),g=new e(c),h=0;ho;++o)n[o]=parseFloat(a.substr(30+8*o,8));var p=a.substr(76,2).trim();""===p&&(p=d(g));var q=parseFloat(a.substr(54,6).trim()),r=parseFloat(a.substr(60,6).trim()),s=this._br.addAtom(h,n,p,c,isNaN(q)?null:q,isNaN(r)?null:r);if(this._b.conectRecords){var t=parseInt(a.substr(6,5).trim(),10);this._bR[t]=s}return!0},parseConectRecord:function(a){for(var b=parseInt(a.substr(6,5).trim(),10),c=[],d=0;4>d;++d){var e=parseInt(a.substr(11+5*d,6).trim(),10);isNaN(e)||e>b||c.push(e)}return this._cn.push({from:b,to:c}),!0},processLine:function(a){var b=a.substr(0,6);if("ATOM "===b||"HETATM"===b)return this.parseAndAddAtom(a);if("REMARK"===b){var c=a.substr(7,3);return"350"===c&&this._cF.nextLine(a),!0}return"HELIX "===b?this.parseHelixRecord(a):"SHEET "===b?this.parseSheetRecord(a):this._b.conectRecords&&"CONECT"===b?this.parseConectRecord(a):"END "===b||"ENDMDL"===b?!1:!0},finish:function(){var a,b=null;for(a=0;ab){if(0===b){var c=a.trim();if(0===c.length)return!1;this._cx=c}return this._bS=!1,this._7++,!0}if(3===b){if(this._cf=parseInt(a.substr(0,3).trim(),10),this._db=parseInt(a.substr(3,3).trim(),10),isNaN(this._cf)||isNaN(this._db))return!1;this._7++;var d=""+(this._i.chains().length+1);this._dd=this._i.addChain(d),this._cm=this._dd.addResidue(this._cx,1)}if(4===b){for(var e=[0,0,0],f=0;3>f;++f)if(e[f]=parseFloat(a.substr(10*f,10).trim()),isNaN(e[f]))return!1;var g=a.substr(31,3).trim();this._cm.addAtom(g,e,g,!1),this._dk++,this._dk===this._cf&&this._7++}if(5===b){var h=parseInt(a.substr(0,3).trim(),10)-1,i=parseInt(a.substr(3,3).trim(),10)-1;if(isNaN(h)||isNaN(i))return!1;var j=this._cm.atoms();this._i.connect(j[h],j[i]),this._di++,this._di===this._db&&this._7++}return"M END"===a.substr(0,6)&&(this._bS=!0,this._7++),"$$$$"===a.substr(0,4)&&this._cE(),!0},_cE:function(){this._7=0,this._cm=null,this._dd=null,this._cf=null,this._es=null,this._dk=0,this._di=0,this._cx=""},finish:function(){return this._bS?this._i:null}},{pdb:g,sdf:i,Remark350Reader:c,fetchPdb:k,fetchSdf:l,guessAtomElementFromName:d}}(C),O=function(){var b=a.vec3,c=a.mat3,d=function(){var a=b.create(),c=b.create();return function(d,e){b.set(a,0,0,0);var f=0;d.eachCentralAtom(function(c,d){b.add(a,a,d),f+=1}),0!==f&&(b.scale(a,a,1/f),e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0,d.eachCentralAtom(function(d,f){b.sub(c,f,a);var g=c[0],h=c[1],i=c[2];e[0]+=h*h+i*i,e[1]-=g*h,e[2]-=g*i,e[5]-=h*i,e[4]+=g*g+i*i,e[8]+=g*g+h*h}),e[3]=e[1],e[6]=e[2],e[7]=e[5])}}(),e=function(){var a=c.create(),e=c.create(),f=b.create(),g=b.create(),h=b.create(),i=b.create(),j=b.create(),k=b.create(),m=b.create();return function(n){d(n,a);var o=l.diagonalizer(a);c.fromQuat(e,o);var p=!0;n.eachCentralAtom(function(a,c){b.transformMat3(h,c,e),p?(b.copy(f,h),b.copy(g,h),p=!1):(b.min(f,f,h),b.max(g,g,h))}),b.sub(i,g,f);var q=[[i[0],0],[i[1],1],[i[2],2]];q.sort(function(a,b){return b[0]-a[0]});var r=q[0][1],s=q[1][1];b.set(j,e[r+0],e[r+3],e[r+6]),b.set(k,e[s+0],e[s+3],e[s+6]),b.cross(m,j,k);var t=c.create();return t[0]=j[0],t[1]=k[0],t[2]=m[0],t[3]=j[1],t[4]=k[1],t[5]=m[1],t[6]=j[2],t[7]=k[2],t[8]=m[2],t}}();return{principalAxes:e}}(),P=function(){return{Viewer:B.Viewer,isWebGLSupported:B.isWebGLSupported,io:N,color:b,mol:U,rgb:{setColorPalette:b.setColorPalette,hex2rgb:b.hex2rgb},vec3:a.vec3,vec4:a.vec4,mat3:a.mat3,mat4:a.mat4,quat:a.quat,viewpoint:O}}()});
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/pv/bio-pv.min.js b/src/main/webapp/resources/js/pv/bio-pv.min.js
new file mode 100644
index 00000000000..5da8718b8d4
--- /dev/null
+++ b/src/main/webapp/resources/js/pv/bio-pv.min.js
@@ -0,0 +1,12 @@
+/**
+ * PV - WebGL protein viewer v1.5.0
+ * http://biasmv.github.io/pv
+ *
+ * Copyright 2013-2015 Marco Biasini
+ * Released under the MIT license
+ */
+!function(a,b){if("function"==typeof define&&define.amd)define([],b);else{var c=b();a.pv=c,a.io=c.io,a.mol=c.mol,a.color=c.color,a.rgb=c.rgb,a.viewpoint=c.viewpoint,a.vec3=c.vec3,a.vec4=c.vec4,a.mat3=c.mat3,a.mat4=c.mat4,a.quat=c.quat}}(this,function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S;return a=function(){var a={};if(!b)var b=1e-6;if(!c)var c="undefined"!=typeof Float32Array?Float32Array:Array;if(!d)var d=Math.random;var e={};e.setMatrixArrayType=function(a){c=a},a.glMatrix=e;var f={};f.create=function(){var a=new c(3);return a[0]=0,a[1]=0,a[2]=0,a},f.clone=function(a){var b=new c(3);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b},f.fromValues=function(a,b,d){var e=new c(3);return e[0]=a,e[1]=b,e[2]=d,e},f.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a},f.set=function(a,b,c,d){return a[0]=b,a[1]=c,a[2]=d,a},f.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a},f.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a},f.sub=f.subtract,f.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a},f.mul=f.multiply,f.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},f.div=f.divide,f.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a},f.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a},f.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a},f.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a},f.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return Math.sqrt(c*c+d*d+e*e)},f.dist=f.distance,f.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return c*c+d*d+e*e},f.sqrDist=f.squaredDistance,f.length=function(a){var b=a[0],c=a[1],d=a[2];return Math.sqrt(b*b+c*c+d*d)},f.len=f.length,f.squaredLength=function(a){var b=a[0],c=a[1],d=a[2];return b*b+c*c+d*d},f.sqrLen=f.squaredLength,f.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a},f.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=c*c+d*d+e*e;return f>0&&(f=1/Math.sqrt(f),a[0]=b[0]*f,a[1]=b[1]*f,a[2]=b[2]*f),a},f.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},f.cross=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a},f.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a},f.random=function(a,b){b=b||1;var c=2*d()*Math.PI,e=2*d()-1,f=Math.sqrt(1-e*e)*b;return a[0]=Math.cos(c)*f,a[1]=Math.sin(c)*f,a[2]=e*b,a},f.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12],a[1]=c[1]*d+c[5]*e+c[9]*f+c[13],a[2]=c[2]*d+c[6]*e+c[10]*f+c[14],a},f.transformMat3=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=d*c[0]+e*c[3]+f*c[6],a[1]=d*c[1]+e*c[4]+f*c[7],a[2]=d*c[2]+e*c[5]+f*c[8],a},f.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},f.forEach=function(){var a=f.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=3),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2];return b}}(),f.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"},a.vec3=f;var g={};g.create=function(){var a=new c(4);return a[0]=0,a[1]=0,a[2]=0,a[3]=0,a},g.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},g.fromValues=function(a,b,d,e){var f=new c(4);return f[0]=a,f[1]=b,f[2]=d,f[3]=e,f},g.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},g.set=function(a,b,c,d,e){return a[0]=b,a[1]=c,a[2]=d,a[3]=e,a},g.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a[3]=b[3]+c[3],a},g.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a[3]=b[3]-c[3],a},g.sub=g.subtract,g.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a},g.mul=g.multiply,g.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a[3]=b[3]/c[3],a},g.div=g.divide,g.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a[3]=Math.min(b[3],c[3]),a},g.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a[3]=Math.max(b[3],c[3]),a},g.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a},g.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a[3]=b[3]+c[3]*d,a},g.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return Math.sqrt(c*c+d*d+e*e+f*f)},g.dist=g.distance,g.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return c*c+d*d+e*e+f*f},g.sqrDist=g.squaredDistance,g.length=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return Math.sqrt(b*b+c*c+d*d+e*e)},g.len=g.length,g.squaredLength=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return b*b+c*c+d*d+e*e},g.sqrLen=g.squaredLength,g.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=-b[3],a},g.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f;return g>0&&(g=1/Math.sqrt(g),a[0]=b[0]*g,a[1]=b[1]*g,a[2]=b[2]*g,a[3]=b[3]*g),a},g.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},g.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2],h=b[3];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a[3]=h+d*(c[3]-h),a},g.random=function(a,b){return b=b||1,a[0]=d(),a[1]=d(),a[2]=d(),a[3]=d(),g.normalize(a,a),g.scale(a,a,b),a},g.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12]*g,a[1]=c[1]*d+c[5]*e+c[9]*f+c[13]*g,a[2]=c[2]*d+c[6]*e+c[10]*f+c[14]*g,a[3]=c[3]*d+c[7]*e+c[11]*f+c[15]*g,a},g.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},g.forEach=function(){var a=g.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=4),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],a[3]=b[h+3],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2],b[h+3]=a[3];return b}}(),g.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},a.vec4=g;var h={};h.create=function(){var a=new c(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},h.fromMat4=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[4],a[4]=b[5],a[5]=b[6],a[6]=b[8],a[7]=b[9],a[8]=b[10],a},h.clone=function(a){var b=new c(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},h.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},h.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},h.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[5];a[1]=b[3],a[2]=b[6],a[3]=c,a[5]=b[7],a[6]=d,a[7]=e}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8];return a},h.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=k*g-h*j,m=-k*f+h*i,n=j*f-g*i,o=c*l+d*m+e*n;return o?(o=1/o,a[0]=l*o,a[1]=(-k*d+e*j)*o,a[2]=(h*d-e*g)*o,a[3]=m*o,a[4]=(k*c-e*i)*o,a[5]=(-h*c+e*f)*o,a[6]=n*o,a[7]=(-j*c+d*i)*o,a[8]=(g*c-d*f)*o,a):null},h.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},h.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8];return b*(j*f-g*i)+c*(-j*e+g*h)+d*(i*e-f*h)},h.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},h.mul=h.multiply,h.translate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1];return a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=m*d+n*g+j,a[7]=m*e+n*h+k,a[8]=m*f+n*i+l,a},h.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=Math.sin(c),n=Math.cos(c);return a[0]=n*d+m*g,a[1]=n*e+m*h,a[2]=n*f+m*i,a[3]=n*g-m*d,a[4]=n*h-m*e,a[5]=n*i-m*f,a[6]=j,a[7]=k,a[8]=l,a},h.fromQuat=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c+c,h=d+d,i=e+e,j=c*g,k=c*h,l=c*i,m=d*h,n=d*i,o=e*i,p=f*g,q=f*h,r=f*i;return a[0]=1-(m+o),a[3]=k+r,a[6]=l-q,a[1]=k-r,a[4]=1-(j+o),a[7]=n+p,a[2]=l+q,a[5]=n-p,a[8]=1-(j+m),a},h.normalFromMat4=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(i*A-g*D-j*z)*E,a[2]=(g*C-h*A+j*y)*E,a[3]=(e*C-d*D-f*B)*E,a[4]=(c*D-e*A+f*z)*E,a[5]=(d*A-c*C-f*y)*E,a[6]=(p*x-q*w+r*v)*E,a[7]=(q*u-o*x-r*t)*E,a[8]=(o*w-p*u+r*s)*E,a):null},h.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"},a.mat3=h;var i={};i.create=function(){var a=new c(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},i.fromValues=function(a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=new c(16);return r[0]=a,r[1]=b,r[2]=d,r[3]=e,r[4]=f,r[5]=g,r[6]=h,r[7]=i,r[8]=j,r[9]=k,r[10]=l,r[11]=m,r[12]=n,r[13]=o,r[14]=p,r[15]=q,r},i.clone=function(a){var b=new c(16);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b},i.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},i.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},i.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[3],f=b[6],g=b[7],h=b[11];a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=c,a[6]=b[9],a[7]=b[13],a[8]=d,a[9]=f,a[11]=b[14],a[12]=e,a[13]=g,a[14]=h}else a[0]=b[0],a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=b[1],a[5]=b[5],a[6]=b[9],a[7]=b[13],a[8]=b[2],a[9]=b[6],a[10]=b[10],a[11]=b[14],a[12]=b[3],a[13]=b[7],a[14]=b[11],a[15]=b[15];return a},i.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(e*C-d*D-f*B)*E,a[2]=(p*x-q*w+r*v)*E,a[3]=(m*w-l*x-n*v)*E,a[4]=(i*A-g*D-j*z)*E,a[5]=(c*D-e*A+f*z)*E,a[6]=(q*u-o*x-r*t)*E,a[7]=(k*x-m*u+n*t)*E,a[8]=(g*C-h*A+j*y)*E,a[9]=(d*A-c*C-f*y)*E,a[10]=(o*w-p*u+r*s)*E,a[11]=(l*u-k*w-n*s)*E,a[12]=(h*z-g*B-i*y)*E,a[13]=(c*B-d*z+e*y)*E,a[14]=(p*t-o*v-q*s)*E,a[15]=(k*v-l*t+m*s)*E,a):null},i.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15];return a[0]=h*(m*r-n*q)-l*(i*r-j*q)+p*(i*n-j*m),a[1]=-(d*(m*r-n*q)-l*(e*r-f*q)+p*(e*n-f*m)),a[2]=d*(i*r-j*q)-h*(e*r-f*q)+p*(e*j-f*i),a[3]=-(d*(i*n-j*m)-h*(e*n-f*m)+l*(e*j-f*i)),a[4]=-(g*(m*r-n*q)-k*(i*r-j*q)+o*(i*n-j*m)),a[5]=c*(m*r-n*q)-k*(e*r-f*q)+o*(e*n-f*m),a[6]=-(c*(i*r-j*q)-g*(e*r-f*q)+o*(e*j-f*i)),a[7]=c*(i*n-j*m)-g*(e*n-f*m)+k*(e*j-f*i),a[8]=g*(l*r-n*p)-k*(h*r-j*p)+o*(h*n-j*l),a[9]=-(c*(l*r-n*p)-k*(d*r-f*p)+o*(d*n-f*l)),a[10]=c*(h*r-j*p)-g*(d*r-f*p)+o*(d*j-f*h),a[11]=-(c*(h*n-j*l)-g*(d*n-f*l)+k*(d*j-f*h)),a[12]=-(g*(l*q-m*p)-k*(h*q-i*p)+o*(h*m-i*l)),a[13]=c*(l*q-m*p)-k*(d*q-e*p)+o*(d*m-e*l),a[14]=-(c*(h*q-i*p)-g*(d*q-e*p)+o*(d*i-e*h)),a[15]=c*(h*m-i*l)-g*(d*m-e*l)+k*(d*i-e*h),a},i.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8],k=a[9],l=a[10],m=a[11],n=a[12],o=a[13],p=a[14],q=a[15],r=b*g-c*f,s=b*h-d*f,t=b*i-e*f,u=c*h-d*g,v=c*i-e*g,w=d*i-e*h,x=j*o-k*n,y=j*p-l*n,z=j*q-m*n,A=k*p-l*o,B=k*q-m*o,C=l*q-m*p;return r*C-s*B+t*A+u*z-v*y+w*x},i.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3];return a[0]=t*d+u*h+v*l+w*p,a[1]=t*e+u*i+v*m+w*q,a[2]=t*f+u*j+v*n+w*r,a[3]=t*g+u*k+v*o+w*s,t=c[4],u=c[5],v=c[6],w=c[7],a[4]=t*d+u*h+v*l+w*p,a[5]=t*e+u*i+v*m+w*q,a[6]=t*f+u*j+v*n+w*r,a[7]=t*g+u*k+v*o+w*s,t=c[8],u=c[9],v=c[10],w=c[11],a[8]=t*d+u*h+v*l+w*p,a[9]=t*e+u*i+v*m+w*q,a[10]=t*f+u*j+v*n+w*r,a[11]=t*g+u*k+v*o+w*s,t=c[12],u=c[13],v=c[14],w=c[15],a[12]=t*d+u*h+v*l+w*p,a[13]=t*e+u*i+v*m+w*q,a[14]=t*f+u*j+v*n+w*r,a[15]=t*g+u*k+v*o+w*s,a},i.fromMat3=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=0,a[4]=b[3],a[5]=b[4],a[6]=b[5],a[7]=0,a[8]=b[6],a[9]=b[7],a[10]=b[8],a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},i.mul=i.multiply,i.translate=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=c[0],q=c[1],r=c[2];return b===a?(a[12]=b[0]*p+b[4]*q+b[8]*r+b[12],a[13]=b[1]*p+b[5]*q+b[9]*r+b[13],a[14]=b[2]*p+b[6]*q+b[10]*r+b[14],a[15]=b[3]*p+b[7]*q+b[11]*r+b[15]):(d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=j,a[7]=k,a[8]=l,a[9]=m,a[10]=n,a[11]=o,a[12]=d*p+h*q+l*r+b[12],a[13]=e*p+i*q+m*r+b[13],a[14]=f*p+j*q+n*r+b[14],a[15]=g*p+k*q+o*r+b[15]),a},i.scale=function(a,b,c){var d=c[0],e=c[1],f=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*e,a[5]=b[5]*e,a[6]=b[6]*e,a[7]=b[7]*e,a[8]=b[8]*f,a[9]=b[9]*f,a[10]=b[10]*f,a[11]=b[11]*f,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},i.rotate=function(a,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D=e[0],E=e[1],F=e[2],G=Math.sqrt(D*D+E*E+F*F);return Math.abs(G)h?(f.cross(a,b,e),f.length(a)<1e-6&&f.cross(a,c,e),f.normalize(a,a),j.setAxisAngle(d,a,Math.PI),d):h>.999999?(d[0]=0,d[1]=0,d[2]=0,d[3]=1,d):(f.cross(a,e,g),d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=1+h,j.normalize(d,d))}}(),j.setAxes=function(){var a=h.create();return function(b,c,d,e){return a[0]=d[0],a[3]=d[1],a[6]=d[2],a[1]=e[0],a[4]=e[1],a[7]=e[2],a[2]=c[0],a[5]=c[1],a[8]=c[2],j.normalize(b,j.fromMat3(b,a))}}(),j.clone=g.clone,j.fromValues=g.fromValues,j.copy=g.copy,j.set=g.set,j.identity=function(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a},j.setAxisAngle=function(a,b,c){c=.5*c;var d=Math.sin(c);return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=Math.cos(c),a},j.add=g.add,j.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*k+g*h+e*j-f*i,a[1]=e*k+g*i+f*h-d*j,a[2]=f*k+g*j+d*i-e*h,a[3]=g*k-d*h-e*i-f*j,a},j.mul=j.multiply,j.scale=g.scale,j.rotateX=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+g*h,a[1]=e*i+f*h,a[2]=f*i-e*h,a[3]=g*i-d*h,a},j.rotateY=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i-f*h,a[1]=e*i+g*h,a[2]=f*i+d*h,a[3]=g*i-e*h,a},j.rotateZ=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+e*h,a[1]=e*i-d*h,a[2]=f*i+g*h,a[3]=g*i-f*h,a},j.calculateW=function(a,b){var c=b[0],d=b[1],e=b[2];return a[0]=c,a[1]=d,a[2]=e,a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a},j.dot=g.dot,j.lerp=g.lerp,j.slerp=function(a,b,c,d){var e,f,g,h,i,j=b[0],k=b[1],l=b[2],m=b[3],n=c[0],o=c[1],p=c[2],q=c[3];return f=j*n+k*o+l*p+m*q,0>f&&(f=-f,n=-n,o=-o,p=-p,q=-q),1-f>1e-6?(e=Math.acos(f),g=Math.sin(e),h=Math.sin((1-d)*e)/g,i=Math.sin(d*e)/g):(h=1-d,i=d),a[0]=h*j+i*n,a[1]=h*k+i*o,a[2]=h*l+i*p,a[3]=h*m+i*q,a},j.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f,h=g?1/g:0;return a[0]=-c*h,a[1]=-d*h,a[2]=-e*h,a[3]=f*h,a},j.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},j.length=g.length,j.len=j.length,j.squaredLength=g.squaredLength,j.sqrLen=j.squaredLength,j.normalize=g.normalize,j.fromMat3=function(){var a="undefined"!=typeof Int8Array?new Int8Array([1,2,0]):[1,2,0];return function(b,c){var d,e=c[0]+c[4]+c[8];if(e>0)d=Math.sqrt(e+1),b[3]=.5*d,d=.5/d,b[0]=(c[7]-c[5])*d,b[1]=(c[2]-c[6])*d,b[2]=(c[3]-c[1])*d;else{var f=0;c[4]>c[0]&&(f=1),c[8]>c[3*f+f]&&(f=2);var g=a[f],h=a[g];d=Math.sqrt(c[3*f+f]-c[3*g+g]-c[3*h+h]+1),b[f]=.5*d,d=.5/d,b[3]=(c[3*h+g]-c[3*g+h])*d,b[g]=(c[3*g+f]+c[3*f+g])*d,b[h]=(c[3*h+f]+c[3*f+h])*d}return b}}(),j.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},a.quat=j,a}(),b=function(){function b(a,b){this._3=a;for(var c=0;c0&&"#"===a[0])return g.hex2rgb(a)}return 3===a.length?[a[0],a[1],a[2],1]:a},b.prototype={colorAt:function(a,b){if(b<=this._O[0])return f.copy(a,this._3[0]);if(b>=this._O[this._O.length-1])return f.copy(a,this._3[this._O.length-1]);for(var c=0,d=1;db);++d)c=d;var e=c+1,g=this._O[c],i=this._O[e],j=(b-g)/(i-g);return h.mix(a,this._3[e],this._3[c],j)}};var j={};g.gradient=function(a,c){if("string"==typeof a)return j[a];if(c=c||"equal","equal"===c){c=[];for(var d=0;d0?g.max:1));var j=[0,0,0,0];a.colorAt(j,i),d[e]=j[0],d[e+1]=j[1],d[e+2]=j[2],d[e+3]=j[3]},function(a){var b=a.chains();this.chainLimits={};for(var c=0;c1?1/(b.length-1):1},function(){this.chainIndices=null});return b};var m=function(){var a=f.create();return function(b,c,d,e){d.colorAt(a,e),b[c+0]=a[0],b[c+1]=a[1],b[c+2]=a[2],b[c+3]=a[3]}}();return g.byAtomProp=function(a,b,c){return e(a,b,c,"eachAtom",function(a){return a})},g.byResidueProp=function(a,b,c){return e(a,b,c,"eachResidue",function(a){return a.residue()})},g.interpolateColor=function(a,b){for(var c=new Float32Array(4*(b*(a.length/4-1)+1)),d=0,e=f.create(),g=f.create(),h=1/b,i=0;ij;++j){var k=h*j;c[d+0]=e[0]*(1-k)+g[0]*k,c[d+1]=e[1]*(1-k)+g[1]*k,c[d+2]=e[2]*(1-k)+g[2]*k,c[d+3]=e[3]*(1-k)+g[3]*k,d+=4}}return c[d+0]=g[0],c[d+1]=g[1],c[d+2]=g[2],c[d+3]=g[3],c},g.initGradients(),g}(),c=function(){function a(a,b,c){this._cI=a,this._bj=b,this._bC=b,this._d3=c}function b(){this.clear()}return a.prototype={nextId:function(a){var b=this._bC;return this._bC++,this._cI._l[b]=a,b},recycle:function(){this._cI.recycle(this)},length:function(){return this._d3-this._bj}},b.prototype={MAX_ID:16777216,getContinuousRange:function(b){for(var c=-1,d=null,e=0;e=b&&(null===d||d>g)&&(d=g,c=e)}if(-1!==c){var h=this._ba[c];return this._ba.splice(c,1),this._bw++,h}var i=this._cu,j=i+b;if(j>this.MAX_ID)return null;this._cu=j;var k=new a(this,i,j);return this._bw++,k},clear:function(){this._l={},this._cu=0,this._ba=[],this._bw=0},recycle:function(a){for(var b=a._bj;b0&&0===this._bw&&this.clear()},objectForId:function(a){return this._l[a]}},b}(),d=function(){function a(a,b){return b>a}function b(a,b){void 0===a||void 0===b?(this._bL=!0,this._u=this._y=null):(this._bL=!1,this._u=a,this._y=b)}var c={};return c.derive=function(a,b,c){for(var d in b.prototype)a.prototype[d]=b.prototype[d];if(void 0!==c)for(var e in c)a.prototype[e]=c[e]},c.bind=function(a,b){return function(){return b.apply(a,arguments)}},c.copy=function(a){a=a||{};var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b},c.binarySearch=function(b,c,d){if(0===b.length)return-1;d=d||a;for(var e=0,f=b.length,g=e+f>>1;;){var h=b[g];if(d(c,h))f=g;else{if(!d(h,c))return g;e=g}var i=e+f>>1;if(i===g)return-1;g=i}return-1},c.indexFirstLargerEqualThan=function(b,c,d){if(d=d||a,0===b.length||d(b[b.length-1],c))return-1;for(var e=0,f=b.length,g=e+f>>1;;){var h=b[g];d(c,h)?f=g:d(h,c)?e=g+1:f=g;var i=e+f>>1;if(i===g)return g;g=i}},c.indexLastSmallerThan=function(b,c,d){if(d=d||a,0===b.length||d(b[b.length-1],c))return b.length-1;if(d(c,b[0])||!d(b[0],c))return-1;for(var e=0,f=b.length,g=e+f>>1;;){var h=b[g];d(c,h)||!d(h,c)?f=g:e=g;var i=e+f>>1;if(i===g)return g;g=i}},c.indexLastSmallerEqualThan=function(b,c,d){if(d=d||a,0===b.length||d(b[b.length-1],c))return b.length-1;if(d(c,b[0]))return-1;for(var e=0,f=b.length,g=e+f>>1;;){var h=b[g];d(c,h)?f=g:e=g;var i=e+f>>1;if(i===g)return g;g=i}},b.prototype={min:function(){return this._u},max:function(){return this._y},length:function(){return this._y-this._u},empty:function(){return this._bL},center:function(){return.5*(this._y+this._u)},extend:function(a){this._u-=a,this._y+=a},update:function(a){return this._bL?(this._u=this._y=a,void(this._bL=!1)):void(athis._y&&(this._y=a))}},c.Range=b,c}(),e=function(){function a(a){if("complete"!==document.readyState&&"loaded"!==document.readyState&&"interactive"!==document.readyState)return!1;if(void 0===a)try{var b=document.createElement("canvas");return!(!window.WebGLRenderingContext||!b.getContext("experimental-webgl"))}catch(c){return!1}return!!a}function b(a,b){this._k=b.width,this._dk=b.antialias,this._m=b.height,this._W=!1,this._dR=null,this._H=a,this._b5(),this._cp=b.backgroundColor,this._c4=b.forceManualAntialiasing}return b.prototype={_ce:function(){if(this._W){this._W=!1;var a=this._k*this._bl,b=this._m*this._bl;this._6=a,this._7=b,this._c.viewport(0,0,a,b),this._.width=a,this._.height=b,this._bl>1&&this._cV(this._bl)}},resize:function(a,b){(a!==this._k||b!==this._m)&&(this._W=!0,this._k=a,this._m=b)},fitParent:function(){var a=this._H.getBoundingClientRect();this.resize(a.width,a.height)},gl:function(){return this._c},imageData:function(){return this._.toDataURL()},_d0:function(){try{var a={antialias:this._dk&&!this._c4,preserveDrawingBuffer:!0};this._c=this._.getContext("experimental-webgl",a)
+}catch(b){return!1}return this._c?!0:!1},_cV:function(a){var b=1/a,c=.5*-(1-b)*this._6,d=.5*-(1-b)*this._7,e="translate("+c+"px, "+d+"px)",f="scale("+b+", "+b+")",g=e+" "+f;this._.style.webkitTransform=g,this._.style.transform=g,this._.style.ieTransform=g,this._.width=this._6,this._.height=this._7},initGL:function(){var a=1;if(!this._d0())return!1;var b=this._c;return b.getContextAttributes().antialias&&!this._c4||!this._dk||(a=2),this._6=this._k*a,this._7=this._m*a,this._bl=a,a>1&&this._cV(a),b.viewportWidth=this._6,b.viewportHeight=this._7,b.clearColor(this._cp[0],this._cp[1],this._cp[2],1),b.lineWidth(2),b.cullFace(b.FRONT),b.enable(b.CULL_FACE),b.enable(b.DEPTH_TEST),!0},_cA:function(a,b,c){var d,e=this._c;if("fragment"===b)d=e.createShader(e.FRAGMENT_SHADER);else{if("vertex"!==b)return null;d=e.createShader(e.VERTEX_SHADER)}var f=a.replace("${PRECISION}",c);return e.shaderSource(d,f),e.compileShader(d),e.getShaderParameter(d,e.COMPILE_STATUS)?d:null},initShader:function(a,b,c){var e=this._c,f=this._cA(b,"fragment",c),g=this._cA(a,"vertex",c),h=e.createProgram();if(e.attachShader(h,g),e.attachShader(h,f),e.linkProgram(h),!e.getProgramParameter(h,e.LINK_STATUS))return null;var i=d.bind(e,e.getAttribLocation),j=d.bind(e,e.getUniformLocation);return h.posAttrib=i(h,"attrPos"),h.colorAttrib=i(h,"attrColor"),h.normalAttrib=i(h,"attrNormal"),h.objIdAttrib=i(h,"attrObjId"),h.symId=j(h,"symId"),h.projection=j(h,"projectionMat"),h.modelview=j(h,"modelviewMat"),h.rotation=j(h,"rotationMat"),h.fog=j(h,"fog"),h.fogFar=j(h,"fogFar"),h.fogNear=j(h,"fogNear"),h.fogColor=j(h,"fogColor"),h.outlineColor=j(h,"outlineColor"),h},on:function(a,b){this._.addEventListener(a,b,!1)},removeEventListener:function(a,b){this._.removeEventListener(a,b,!1)},onWheel:function(a,b){"onwheel"in this._?this.on("wheel",a):this.on("mousewheel",b)},domElement:function(){return this._},bind:function(){this._ce(),this._c.viewport(0,0,this._6,this._7)},superSamplingFactor:function(){return this._bl},viewportWidth:function(){return this._6},viewportHeight:function(){return this._7},width:function(){return this._k},height:function(){return this._m},_b5:function(){this._=document.createElement("canvas"),this._.width=this._k,this._.height=this._m,this._H.appendChild(this._)},isWebGLSupported:function(){return a(this._c)},destroy:function(){this._.width=1,this._.height=1,this._.parentElement.removeChild(this._),this._=null}},{Canvas:b,isWebGLSupported:a}}(),f=function(){function a(a,b){this._k=b.width,this._m=b.height,this._df=this._k,this._dg=this._m,this._c=a,this._de=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this._de),this._bq=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,this._bq),a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_COMPONENT16,this._k,this._m),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,this._bq),this._bs=a.createTexture(),this._d1()}return a.prototype={width:function(){return this._k},height:function(){return this._m},bind:function(){var a=this._c;a.bindFramebuffer(a.FRAMEBUFFER,this._de),a.bindRenderbuffer(a.RENDERBUFFER,this._bq),(this._df!==this._k||this._dg!==this._m)&&this._dz(),a.viewport(0,0,this._k,this._m)},colorTexture:function(){return this._bs},_d1:function(){this.bind();var a=this._c;a.bindTexture(a.TEXTURE_2D,this._bs),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this._k,this._m,0,a.RGBA,a.UNSIGNED_BYTE,null),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this._bs,0),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.bindTexture(a.TEXTURE_2D,null),this.release()},_dz:function(){var a=this._c;a.bindRenderbuffer(a.RENDERBUFFER,this._bq),a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_COMPONENT16,this._k,this._m),a.bindTexture(a.TEXTURE_2D,this._bs),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this._k,this._m,0,a.RGBA,a.UNSIGNED_BYTE,null),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this._bs,0),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,this._bq),a.bindTexture(a.TEXTURE_2D,null),this._df=this._k,this._dg=this._m},resize:function(a,b){this._k=a,this._m=b},release:function(){var a=this._c;a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindRenderbuffer(a.RENDERBUFFER,null)}},a}(),g=function(){function a(a){this._bp=[],this._ec=a}return a.prototype.request=function(a){for(var b=-1,c=null,d=0;d=a&&(null===c||c>f)&&(c=f,b=d)}if(-1!==b){var g=this._bp[b];return this._bp.splice(b,1),g}return new this._ec(a)},a.prototype.release=function(a){this._bp.push(a)},a}(),h=function(){function b(a){this._bU=d.create(),this._K=d.create(),this._cN=d.create(),this._o=d.create(),this._bx=d.create(),this._8=.1,this._2=4e3,this._c5=-5,this._c6=50,this._bK=!0,this._c3=45*Math.PI/180,this._c7=c.fromValues(1,1,1),this._dG=c.fromValues(.1,.1,.1),this._R=c.create(),this._M=50,this._bh=!0,this._D=!0,this._ct=1,this._c=a,this._cj=null,this._bi=0,this.setViewportSize(a.viewportWidth,a.viewportHeight)}var c=a.vec3,d=a.mat4;return b.prototype={_c0:function(){this._bi+=1,this._bi>68719476735&&(this._bi=0)},setRotation:function(a){16===a.length?d.copy(this._o,a):d.fromMat3(this._o,a),this._D=!0},upsamplingFactor:function(){return this._ct},setUpsamplingFactor:function(a){this._ct=a},mainAxes:function(){return[c.fromValues(this._o[0],this._o[4],this._o[8]),c.fromValues(this._o[1],this._o[5],this._o[9]),c.fromValues(this._o[2],this._o[6],this._o[10])]},fieldOfViewY:function(){return this._c3},aspectRatio:function(){return this._k/this._m},rotation:function(){return this._o},_dr:function(){var a=!1;return this._D&&(d.identity(this._K),d.translate(this._K,this._K,[-this._R[0],-this._R[1],-this._R[2]]),d.mul(this._K,this._o,this._K),d.identity(this._bx),d.translate(this._bx,this._bx,[0,0,-this._M]),d.mul(this._K,this._bx,this._K),a=!0),this._bh&&(d.identity(this._bU),d.perspective(this._bU,this._c3,this._k/this._m,this._8,this._2),a=!0),this._bh=!1,this._D=!1,a&&this._c0(),a},setViewportSize:function(a,b){this._bh=!0,this._k=a,this._m=b},viewportWidth:function(){return this._k},viewportHeight:function(){return this._m},setCenter:function(a){this._D=!0,c.copy(this._R,a)},fog:function(a){return void 0!==a&&a!==this._bK&&(this._bK=a,this._c0()),this._bK},rotateZ:function(){var a=d.create();return function(b){d.identity(a),this._D=!0,d.rotate(a,a,b,[0,0,1]),d.mul(this._o,a,this._o)}}(),rotateX:function(){var a=d.create();return function(b){d.identity(a),this._D=!0,d.rotate(a,a,b,[1,0,0]),d.mul(this._o,a,this._o)}}(),rotateY:function(){var a=d.create();return function(b){d.identity(a),this._D=!0,d.rotate(a,a,b,[0,1,0]),d.mul(this._o,a,this._o)}}(),panX:function(a){return this.panXY(a,0)},panY:function(a){return this.panXY(0,a)},panXY:function(){var a=d.create(),b=c.create();return function(e,f){d.transpose(a,this._o),this._D=!0,c.set(b,-e,f,0),c.transformMat4(b,b,a),c.add(b,b,this._R),this.setCenter(b)}}(),nearOffset:function(){return this._8},farOffset:function(){return this._2},setNearFar:function(a,b){(a!==this._8||b!==this._2)&&(this._8=a,this._2=b,this._bh=!0)},setFogNearFar:function(a,b){this._c5=a,this._c6=b,this._bh=!0},setZoom:function(a){return this._D=!0,this._M=a,this._M},zoom:function(a){if(void 0===a)return this._M;this._D=!0;var b=1+.1*a;return this._M=Math.min(1e3,Math.max(2,b*this._M)),this._M},center:function(){return this._R},setFogColor:function(a){this._c7=c.clone(a)},currentShader:function(){return this._cj},bind:function(a,b){var c=!1,e=this._c;if(this._cj!==a&&(this._cj=a,e.useProgram(a),c=!0),c=this._dr()||c,b?(d.mul(this._cN,this._K,b),e.uniformMatrix4fv(a.modelview,!1,this._cN)):e.uniformMatrix4fv(a.modelview,!1,this._K),this._bi!==a.stateId){a.stateId=this._bi,e.uniformMatrix4fv(a.projection,!1,this._bU),a.rotation&&e.uniformMatrix4fv(a.rotation,!1,this._o),e.uniform1i(a.fog,this._bK);var f=this._M;e.uniform1f(a.fogFar,this._c6+f),e.uniform1f(a.fogNear,this._c5+f),e.uniform3fv(a.fogColor,this._c7),e.uniform3fv(a.outlineColor,this._dG)}}},b}(),i={LINES_FS:"\nprecision ${PRECISION} float;\n\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\nuniform float fogNear;\nuniform float fogFar;\nuniform vec3 fogColor;\nuniform bool fog;\n\nvoid main(void) {\n gl_FragColor = vec4(vertColor);\n if (gl_FragColor.a == 0.0) { discard; }\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n if (fog) {\n float fog_factor = smoothstep(fogNear, fogFar, depth);\n gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w),\n fog_factor);\n }\n}",HEMILIGHT_FS:"\nprecision ${PRECISION} float;\n\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\nuniform float fogNear;\nuniform float fogFar;\nuniform vec3 fogColor;\nuniform bool fog;\n\nvoid main(void) {\n float dp = dot(vertNormal, vec3(0.0, 0.0, 1.0));\n float hemi = max(0.0, dp)*0.5+0.5;\n hemi *= vertColor.a;\n gl_FragColor = vec4(vertColor.rgb*hemi, vertColor.a);\n if (gl_FragColor.a == 0.0) { discard; }\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n if (fog) {\n float fog_factor = smoothstep(fogNear, fogFar, depth);\n gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w),\n fog_factor);\n }\n}",HEMILIGHT_VS:"\nattribute vec3 attrPos;\nattribute vec4 attrColor;\nattribute vec3 attrNormal;\n\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n vec4 n = (modelviewMat * vec4(attrNormal, 0.0));\n vertNormal = n.xyz;\n vertColor = attrColor;\n}",OUTLINE_FS:"\nprecision ${PRECISION} float;\nvarying float vertAlpha;\n\nuniform vec3 outlineColor;\nuniform float fogNear;\nuniform float fogFar;\nuniform vec3 fogColor;\nuniform bool fog;\n\nvoid main() {\n gl_FragColor = vec4(outlineColor, vertAlpha);\n if (gl_FragColor.a == 0.0) { discard; }\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n if (fog) { \n float fog_factor = smoothstep(fogNear, fogFar, depth);\n gl_FragColor = mix(gl_FragColor, vec4(fogColor, vertAlpha),\n fog_factor);\n }\n}",OUTLINE_VS:"\nprecision ${PRECISION} float;\n\nattribute vec3 attrPos;\nattribute vec3 attrNormal;\nattribute vec4 attrColor;\n \nuniform vec3 outlineColor;\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nvarying float vertAlpha;\n\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n vec4 normal = modelviewMat * vec4(attrNormal, 0.0);\n vertAlpha = attrColor.a;\n gl_Position.xy += normal.xy*0.200;\n}",TEXT_VS:"\nprecision ${PRECISION} float;\n\nattribute vec3 attrCenter;\nattribute vec2 attrCorner;\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nuniform mat4 rotationMat;\nvarying vec2 vertTex;\nuniform float width;\nuniform float height;\nvoid main() { \n vec4 pos = modelviewMat* vec4(attrCenter, 1.0);\n pos.z += 4.0;\n gl_Position = projectionMat * pos;\n gl_Position.xy += vec2(width,height)*attrCorner*gl_Position.w; \n vertTex = (attrCorner+abs(attrCorner))/(2.0*abs(attrCorner)); \n}",TEXT_FS:"\nprecision ${PRECISION} float;\n\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nuniform sampler2D sampler;\nuniform float xScale;\nuniform float yScale;\nvarying vec2 vertTex;\nvoid main() { \n vec2 texCoord = vec2(vertTex.x*xScale, vertTex.y*yScale);\n gl_FragColor = texture2D(sampler, texCoord);\n if (gl_FragColor.a == 0.0) { discard; }\n}",SELECT_VS:"\nprecision ${PRECISION} float;\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nattribute vec3 attrPos;\nattribute float attrObjId;\n\nvarying float objId;\n\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n objId = attrObjId;\n}",SELECT_FS:"\nprecision ${PRECISION} float;\n\nvarying float objId;\nuniform int symId;\n\nint intMod(int x, int y) { \n int z = x/y;\n return x-y*z;\n}\nvoid main(void) {\n // ints are only required to be 7bit...\n int integralObjId = int(objId+0.5);\n int red = intMod(integralObjId, 256);\n integralObjId/=256;\n int green = intMod(integralObjId, 256);\n integralObjId/=256;\n int blue = intMod(integralObjId, 256);\n int alpha = symId;\n gl_FragColor = vec4(float(red), float(green), \n float(blue), float(alpha))/255.0;\n}"},j=function(){function a(a,b,c){this._bb=a,this._bb.addEventListener("touchmove",d.bind(this,this._du)),this._bb.addEventListener("touchstart",d.bind(this,this._dt)),this._bb.addEventListener("touchend",d.bind(this,this._cv)),this._bb.addEventListener("touchcancel",d.bind(this,this._cv)),this._4={scale:1,rotation:0,center:null},this._bG=null,this._r=b,this._e=c}function b(a){for(var b=0,c=0,d=0;dc&&this._r._cL({clientX:a.targetTouches[0].clientX,clientY:a.targetTouches[0].clientY})}this._bG=b}else this._bG=null;this._4=this._c9(this._4,a)},_cv:function(a){a.preventDefault()}},a}(),k=function(){function b(a,b,c,d){this._r=b,this._=a,this._e=c,this._=a,this._dl=d,this._d2()}var c=a.vec3;return b.prototype={_d9:function(a){if(null!==a){var b=c.create(),d=a.object().atom,e=d.pos();a.transform()?(c.transformMat4(b,e,a.transform()),this._r.setCenter(b,this._dl)):this._r.setCenter(e,this._dl)}},_dM:function(){var a=this._;a.removeEventListener("mousemove",this._bE),a.removeEventListener("mousemove",this._bF),a.removeEventListener("mouseup",this._bD),document.removeEventListener("mouseup",this._bD),document.removeEventListener("mousemove",this._bE),document.removeEventListener("mousemove",this._bF)},setCam:function(a){this._e=a},_d2:function(){return this._bF=d.bind(this,this._dO),this._bE=d.bind(this,this._dN),this._bD=d.bind(this,this._dM),this._.onWheel(d.bind(this,this._dK),d.bind(this,this._dL)),this._.on("dblclick",d.bind(this,this._cL)),this._.on("mousedown",d.bind(this,this._dP)),!0},_dL:function(a){this._e.zoom(a.wheelDelta<0?-1:1),a.preventDefault(),this._r.requestRedraw()},_dK:function(a){this._e.zoom(a.deltaY<0?1:-1),a.preventDefault(),this._r.requestRedraw()},_cL:function(){return function(a){var b=this._.domElement().getBoundingClientRect(),c=this._r.pick({x:a.clientX-b.left,y:a.clientY-b.top});this._r._ch(a,"atomDoubleClicked",c),this._r.requestRedraw()}}(),_dP:function(a){if(0===a.button){var b=(new Date).getTime();if("undefined"==typeof this.lastClickTime||b-this.lastClickTime>300){this.lastClickTime=b;var c=this._.domElement().getBoundingClientRect(),d=this._r.pick({x:a.clientX-c.left,y:a.clientY-c.top});this._r._ch(a,"atomClicked",d)}a.preventDefault(),a.shiftKey===!0?(this._.on("mousemove",this._bF),document.addEventListener("mousemove",this._bF,!1)):(this._.on("mousemove",this._bE),document.addEventListener("mousemove",this._bE,!1)),this._.on("mouseup",this._bD),document.addEventListener("mouseup",this._bD,!1),this._9={x:a.pageX,y:a.pageY}}},_dN:function(a){var b={x:a.pageX,y:a.pageY},c={x:b.x-this._9.x,y:b.y-this._9.y},d=.005;this._e.rotateX(d*c.y),this._e.rotateY(d*c.x),this._9=b,this._r.requestRedraw()},_dO:function(a){var b={x:a.pageX,y:a.pageY},c={x:b.x-this._9.x,y:b.y-this._9.y},d=.001*this._e.zoom();this._e.panXY(d*c.x,d*c.y),this._9=b,this._r.requestRedraw()}},b}(),l=function(){function b(a,b,c){return c?a*b:b*(a-1)+1}function c(a,c,d,f,g,h){g=g||!1,f=f||.5;var i=null,j=3*b(c,d,g);i=h?h.request(j):new Float32Array(j);var l,m,n,o=0,p=1/d,q=e.create(),r=e.create(),s=e.create(),t=e.create(),u=e.create(),v=e.create();for(e.set(t,a[0],a[1],a[2]),e.set(u,a[3],a[4],a[5]),g?(e.set(s,a[a.length-3],a[a.length-2],a[a.length-1]),e.sub(q,u,s),e.scale(q,q,f)):(e.set(s,a[0],a[1],a[2]),e.set(q,0,0,0)),l=1,n=c-1;n>l;++l){for(e.set(v,a[3*(l+1)],a[3*(l+1)+1],a[3*(l+1)+2]),e.sub(r,v,t),e.scale(r,r,f),m=0;d>m;++m)k(i,t,q,u,r,p*m,o),o+=3;e.copy(s,t),e.copy(t,u),e.copy(u,v),e.copy(q,r)}for(g?(e.set(v,a[0],a[1],a[3]),e.sub(r,v,t),e.scale(r,r,f)):e.set(r,0,0,0),m=0;d>m;++m)k(i,t,q,u,r,p*m,o),o+=3;if(!g)return i[o]=a[3*(c-1)+0],i[o+1]=a[3*(c-1)+1],i[o+2]=a[3*(c-1)+2],i;for(e.copy(s,t),e.copy(t,u),e.copy(u,v),e.copy(q,r),e.set(v,a[3],a[4],a[5]),e.sub(r,v,t),e.scale(r,r,f),m=0;d>m;++m)k(i,t,q,u,r,p*m,o),o+=3;return i}function d(a,b){this._R=a||e.create(),this._dB=b||1}var e=a.vec3,f=a.mat3,g=a.quat,h=function(){var a=e.create();return function(b,c,d){return e.cross(a,b,c),Math.atan2(e.dot(a,d),e.dot(b,c))}}(),i=function(){var a=e.create();return function(b,c){return e.copy(a,c),Math.abs(c[0])n;++n){f.fromQuat(a,m);var o=f.transpose(c,a);f.mul(b,a,f.mul(d,k,o)),e.set(i,b[5],b[2],b[1]),e.set(j,Math.abs(i[0]),Math.abs(i[1]),Math.abs(i[2]));var p=j[0]>j[1]&&j[0]>j[2]?0:j[1]>j[2]?1:2,q=(p+1)%3,r=(p+2)%3;if(0===i[p])break;var s=(b[3*r+r]-b[3*q+q])/(2*i[p]),t=s>0?1:-1;s*=t;var u=s+(1e6>s?Math.sqrt(s*s+1):s),v=t/u,w=1/Math.sqrt(v*v+1);if(1===w)break;if(e.set(h,0,0,0,0),h[p]=t*Math.sqrt((1-w)/2),h[p]*=-1,h[3]=Math.sqrt(1-h[p]*h[p]),1===h[3])break;m=g.mul(m,m,h),g.normalize(m,m)}return m}}();d.prototype.center=function(){return this._R},d.prototype.radius=function(){return this._dB};var m=function(){return function(a,b,c,d,f){f?e.cross(d,b,c):i(d,b),e.cross(c,d,b),e.normalize(d,d),e.normalize(c,c),a[0]=c[0],a[1]=c[1],a[2]=c[2],a[3]=d[0],a[4]=d[1],a[5]=d[2],a[6]=b[0],a[7]=b[1],a[8]=b[2]}}();return{signedAngle:h,axisRotation:j,ortho:i,diagonalizer:l,catmullRomSpline:c,cubicHermiteInterpolate:k,catmullRomSplineNumPoints:b,Sphere:d,buildRotation:m}}(),m=function(){function b(a,b){this._f=b,this._bP=a,this._h=new Uint16Array(3*b*a*2),this._n=new Float32Array(3*b*a);var c,d,e=Math.PI/(a-1),f=2*Math.PI/b;for(c=0;cp;++p)e.set(a,f*n[3*p],f*n[3*p+1],0),e.transformMat3(a,a,g),e.add(a,a,d),e.set(b,m[3*p],m[3*p+1],0),e.transformMat3(b,b,g),c.addVertex(a,b,h,k);if(!i)if(0!==j)for(p=0;l>p;++p)c.addTriangle(o+(p+j)%l,o+p+l,o+(p+1)%l+l),c.addTriangle(o+(p+j)%l,o+(p+1)%l+l,o+(p+1+j)%l);else for(p=0;pq;++q){e.set(a,g*n[3*q],g*n[3*q+1],f*n[3*q+2]),e.transformMat3(a,a,h),e.add(a,a,d),e.set(b,o[3*q],o[3*q+1],o[3*q+2]),e.transformMat3(b,b,h);var r=p>q?k:l;c.addVertex(a,b,p>q?i:j,r)}var s=this._h;for(q=0;qa)return c[d].matrix(a);a-=c[d].matrices().length}return null},showRelated:function(){return this._cz},select:function(a){return this.structure().select(a)},structure:function(){return this._T[0]._i},getColorForAtom:function(a,b){return this._T[0].getColorForAtom(a,b)},addIdRange:function(a){this._b7.push(a)},destroy:function(){O.prototype.destroy.call(this);for(var a=0;ad;++d)b=d*this._x,e[0]+=this._d[b+0],e[1]+=this._d[b+1],e[2]+=this._d[b+2],isNaN(e[0]),isNaN(e[2]),isNaN(e[2]);c.scale(e,e,1/a);var f=0;for(d=0;a>d;++d){b=d*this._x;var g=e[0]-this._d[b+0],h=e[1]-this._d[b+1],i=e[2]-this._d[b+2];
+f=Math.max(f,g*g+h*h+i*i)}return new l.Sphere(e,Math.sqrt(f))},destroy:function(){this._c.deleteBuffer(this._cs),this._z.release(this._d)},bindBuffers:function(){this._c.bindBuffer(this._c.ARRAY_BUFFER,this._cs),this._p||(this._c.bufferData(this._c.ARRAY_BUFFER,this._d,this._c.STATIC_DRAW),this._p=!0)},updateSquaredSphereRadius:function(){var a=c.create();return function(b,d,e){var f=this.boundingSphere();if(!f)return d;if(e)return c.transformMat4(a,f.center(),e),Math.max(c.sqrDist(a,b),d);var g=f.radius()*f.radius();return Math.max(c.sqrDist(f.center(),b)+g,d)}}(),updateProjectionIntervals:function(){var a=c.create();return function(b,d,e,f,g,h,i){var j=this.boundingSphere();if(j){i?c.transformMat4(a,j.center(),i):c.copy(a,j.center());var k=c.dot(b,a),l=c.dot(d,a),m=c.dot(e,a);f.update(k-j.radius()),f.update(k+j.radius()),g.update(l-j.radius()),g.update(l+j.radius()),h.update(m-j.radius()),h.update(m+j.radius())}}}()},b}(),q=function(){function a(a,b,c){P.call(this,a,b,c),this._bB=0}return d.derive(a,P,{_x:8,_dm:0,_bv:3,_ej:7,numVerts:function(){return 2*this._bB},addLine:function(a,b,c,d,e,f){var g=this._x*this._bB*2;this._d[g++]=a[0],this._d[g++]=a[1],this._d[g++]=a[2],this._d[g++]=b[0],this._d[g++]=b[1],this._d[g++]=b[2],this._d[g++]=b[3],this._d[g++]=e,this._d[g++]=c[0],this._d[g++]=c[1],this._d[g++]=c[2],this._d[g++]=d[0],this._d[g++]=d[1],this._d[g++]=d[2],this._d[g++]=d[3],this._d[g++]=f,this._bB+=1,this._p=!1,this._et=null},bindAttribs:function(a){this._c.vertexAttribPointer(a.posAttrib,3,this._c.FLOAT,!1,4*this._x,4*this._dm),-1!==a.colorAttrib&&(this._c.vertexAttribPointer(a.colorAttrib,4,this._c.FLOAT,!1,4*this._x,4*this._bv),this._c.enableVertexAttribArray(a.colorAttrib)),this._c.enableVertexAttribArray(a.posAttrib),-1!==a.objIdAttrib&&(this._c.vertexAttribPointer(a.objIdAttrib,1,this._c.FLOAT,!1,4*this._x,4*this._ej),this._c.enableVertexAttribArray(a.objIdAttrib))},releaseAttribs:function(a){this._c.disableVertexAttribArray(a.posAttrib),-1!==a.colorAttrib&&this._c.disableVertexAttribArray(a.colorAttrib),-1!==a.objIdAttrib&&this._c.disableVertexAttribArray(a.objIdAttrib)},bind:function(a){this.bindBuffers(),this.bindAttribs(a)},draw:function(){this._c.drawArrays(this._c.LINES,0,2*this._bB)}}),a}(),r=Q=function(){function a(a,b,c,d,e){P.call(this,a,b,d),this._cW=a.createBuffer(),this._E=e,this._P=0,this._cO=b,this._bo=0,this._C=e.request(c)}return d.derive(a,P,{destroy:function(){P.prototype.destroy.call(this),this._c.deleteBuffer(this._cW),this._E.release(this._C)},setIndexData:function(a){this._p=!1,this._bo=a.length/3;for(var b=0;b=this._C.length||(this._C[d++]=a,this._C[d++]=b,this._C[d++]=c,this._bo+=1,this._p=!1)},bindBuffers:function(){var a=this._p,b=this._c;P.prototype.bindBuffers.call(this),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._cW),a||b.bufferData(b.ELEMENT_ARRAY_BUFFER,this._C,b.STATIC_DRAW)},bindAttribs:function(a){var b=this._c,c=this._el;b.enableVertexAttribArray(a.posAttrib),b.vertexAttribPointer(a.posAttrib,3,b.FLOAT,!1,c,this._eg),-1!==a.normalAttrib&&(b.enableVertexAttribArray(a.normalAttrib),b.vertexAttribPointer(a.normalAttrib,3,b.FLOAT,!1,c,this._ei)),-1!==a.colorAttrib&&(b.vertexAttribPointer(a.colorAttrib,4,b.FLOAT,!1,c,this._ek),b.enableVertexAttribArray(a.colorAttrib)),-1!==a.objIdAttrib&&(b.vertexAttribPointer(a.objIdAttrib,1,b.FLOAT,!1,c,this._eh),b.enableVertexAttribArray(a.objIdAttrib))},releaseAttribs:function(a){var b=this._c;b.disableVertexAttribArray(a.posAttrib),-1!==a.colorAttrib&&b.disableVertexAttribArray(a.colorAttrib),-1!==a.normalAttrib&&b.disableVertexAttribArray(a.normalAttrib),-1!==a.objIdAttrib&&b.disableVertexAttribArray(a.objIdAttrib)},bind:function(a){this.bindBuffers(),this.bindAttribs(a)},draw:function(){var a=this._c;a.drawElements(a.TRIANGLES,3*this._bo,a.UNSIGNED_SHORT,0)}}),a}(),s=function(a){function b(b,c,d,e){a.call(this,c,d,e),this._I=b}function c(a,b,c,d,e,f){Q.call(this,b,c,d,e,f),this._I=a}return d.derive(b,a,{chain:function(){return this._I},drawSymmetryRelated:function(a,b,c){this.bind(b);for(var d=0;d=a)return c;this._bz-=c.numVerts(),this._bn-=c.numIndices(),a=this._cn(this._bz);var f=null;return f=c instanceof e?new e(c.chain(),this._c,a,this._bn,this._z,this._E):new b(this._c,a,this._bn,this._z,this._E),this._v.push(f),f},vertArray:function(a){return this._v[a]},destroy:function(){R.prototype.destroy.call(this);for(var a=0;a1?b.interpolateColor(h,this._bH):h)}for(d=0;d1?b.interpolateColor(h,this._bH):h)}for(d=0;dd;++d)a.addTriangle(b,b+1+d,b+2+d);a.addTriangle(b,b+c,b+1)}function h(a,b,c){for(var d=b+c,e=0;c-1>e;++e)a.addTriangle(d,b+e+1,b+e);a.addTriangle(d,b,b+c-1)}var i=a.vec3,j=a.vec4,k=a.mat3,m=c.TubeProfile,n=c.ProtoSphere,o=c.ProtoCylinder,p=f.TraceVertexAssoc,q=f.AtomVertexAssoc,r=b.interpolateColor,s={},t=.7071,u=[-t,-t,0,t,-t,0,t,t,0,-t,t,0],v=[-6*t,-1*t,0,6*t,-1*t,0,6*t,1*t,0,-6*t,1*t,0],w=[-10*t,-1*t,0,10*t,-1*t,0,10*t,1*t,0,-10*t,1*t,0],x=function(){var a=i.create(),b=i.create(),c=i.create();return function(d,e,f,g){e=Math.max(e,1),f=Math.min(g-1,f);var h=3*(e-1);i.set(a,d[h],d[h+1],d[h+2]),i.set(c,d[3*e],d[3*e+1],d[3*e+2]);for(var j=e;f>j;++j)h=3*(j+1),i.set(b,d[h],d[h+1],d[h+2]),d[3*j+0]=.25*b[0]+.5*c[0]+.25*a[0],d[3*j+1]=.25*b[1]+.5*c[1]+.25*a[1],d[3*j+2]=.25*b[2]+.5*c[2]+.25*a[2],i.copy(a,c),i.copy(c,b)}}(),y=function(){var a=j.fromValues(0,0,0,1);return function(b,c,d,e){var f=e.atomCount(),g=d.idPool.getContinuousRange(f);b.addIdRange(g);var h=d.protoSphere.numVerts(),i=d.protoSphere.numIndices(),j=1.5*d.radiusMultiplier;b.addChainVertArray(e,h*f,i*f),e.eachAtom(function(e){var f=b.vertArrayWithSpaceFor(h);d.color.colorFor(e,a,0);var i=f.numVerts(),k=g.nextId({geom:b,atom:e});d.protoSphere.addTransformed(f,e.pos(),j,a,k);var l=f.numVerts();c.addAssoc(e,f,i,l)})}}();s.spheres=function(a,b,c){var e=new n(c.sphereDetail,c.sphereDetail);c.protoSphere=e;var f=new d(b,c.float32Allocator,c.uint16Allocator),g=new q(a,!0);return f.addVertAssoc(g),f.setShowRelated(c.showRelated),c.color.begin(a),a.eachChain(function(a){y(f,g,c,a)}),c.color.end(a),f};var z=function(){var a=i.create(),b=i.create(),c=j.fromValues(0,0,0,1),d=i.create(),e=i.create(),f=k.create();return function(g,h,j,k){var m=k.atomCount(),n=0;k.eachAtom(function(a){n+=a.bonds().length});var o=m*j.protoSphere.numVerts()+n*j.protoCyl.numVerts(),p=m*j.protoSphere.numIndices()+n*j.protoCyl.numIndices();g.addChainVertArray(k,o,p);var q=j.idPool.getContinuousRange(m);g.addIdRange(q),k.eachAtom(function(k){var m=j.protoSphere.numVerts()+k.bondCount()*j.protoCyl.numVerts(),n=g.vertArrayWithSpaceFor(m),o=n.numVerts(),p=q.nextId({geom:g,atom:k});j.color.colorFor(k,c,0),j.protoSphere.addTransformed(n,k.pos(),j.radius,c,p),k.eachBond(function(g){g.mid_point(a),i.sub(b,k.pos(),a);var h=i.length(b);i.scale(b,b,1/h),l.buildRotation(f,b,d,e,!1),i.add(a,a,k.pos()),i.scale(a,a,.5),j.protoCyl.addTransformed(n,a,h,j.radius,f,c,c,p,p)});var r=n.numVerts();h.addAssoc(k,n,o,r)})}}();s.ballsAndSticks=function(a,b,c){var e=new q(a,!0),f=new n(c.sphereDetail,c.sphereDetail),g=new o(c.arcDetail);c.protoSphere=f,c.protoCyl=g;var h=new d(b,c.float32Allocator,c.uint16Allocator);return h.addVertAssoc(e),h.setShowRelated(c.showRelated),c.color.begin(a),a.eachChain(function(a){z(h,e,c,a)}),c.color.end(a),h};var A=function(){var a=i.create(),b=j.fromValues(0,0,0,1);return function(c,d,e,f){var g=0,h=e.atomCount(),i=f.idPool.getContinuousRange(h);c.addIdRange(i),e.eachAtom(function(a){var b=a.bonds().length;g+=b?b:3});var j=c.addChainVertArray(e,2*g);e.eachAtom(function(e){var g=j.numVerts(),h=i.nextId({geom:c,atom:e});if(e.bonds().length)e.eachBond(function(c){c.mid_point(a),f.color.colorFor(e,b,0),j.addLine(e.pos(),b,a,b,h,h)});else{var k=.2,l=e.pos();f.color.colorFor(e,b,0),j.addLine([l[0]-k,l[1],l[2]],b,[l[0]+k,l[1],l[2]],b,h,h),j.addLine([l[0],l[1]-k,l[2]],b,[l[0],l[1]+k,l[2]],b,h,h),j.addLine([l[0],l[1],l[2]-k],b,[l[0],l[1],l[2]+k],b,h,h)}var m=j.numVerts();d.addAssoc(e,j,g,m)})}}();s.lines=function(a,b,c){var d=new q(a,!0);c.color.begin(a);var f=new e(b,c.float32Allocator);return f.setLineWidth(c.lineWidth),f.addVertAssoc(d),f.setShowRelated(c.showRelated),a.eachChain(function(a){A(f,d,a,c)}),c.color.end(a),f};var B=function(a){for(var b=0,c=0;ck;++k){a[0]=v[3*(k-1)],a[1]=v[3*(k-1)+1],a[2]=v[3*(k-1)+2],b[0]=v[3*(k-0)],b[1]=v[3*(k-0)+1],b[2]=v[3*(k-0)+2],c[0]=w[4*(k-1)+0],c[1]=w[4*(k-1)+1],c[2]=w[4*(k-1)+2],c[3]=w[4*(k-1)+3],d[0]=w[4*(k-0)+0],d[1]=w[4*(k-0)+1],d[2]=w[4*(k-0)+2],d[3]=w[4*(k-0)+3];var A=Math.floor((k+y)/h.splineDetail);u=p[Math.min(p.length-1,A)],g.addLine(a,c,b,d,t,u),t=u;var B=g.numVerts();f.addAssoc(i,g,m+k,B-1,B+(k===j.length-1?0:1))}return f.setPerResidueColors(i,o),h.float32Allocator.release(n),h.float32Allocator.release(v),i+1}}(),G=function(a,b,c,d,e){for(var f=d.backboneTraces(),g=E(f,c.splineDetail),h=a.addChainVertArray(d,g),i=0;io;++o)i.set(a,e.getFloat32(h+0),e.getFloat32(h+4),e.getFloat32(h+8)),h+=12,i.set(b,e.getFloat32(h+0),e.getFloat32(h+4),e.getFloat32(h+8)),h+=12,p.addVertex(a,b,c,0);for(h=l+4,o=0;m>o;++o){var q=e.getUint32(h+0),r=e.getUint32(h+4),s=e.getUint32(h+8);h+=12,p.addTriangle(q-1,s-1,r-1)}return n}}();var O=function(){var a=k.create(),b=i.create();return function(c,d,e,f,g,h,j,k,m,n,o){var p=m.coilProfile;"C"===f||m.forceTube?k?l.ortho(e,g):i.cross(e,b,g):"H"===f?p=m.helixProfile:"E"===f?p=m.strandProfile:"A"===f&&(p=m.arrowProfile),l.buildRotation(a,g,e,b,!0),p.addTransformed(c,d,j,a,h,k,n,o)}}(),P=function(){var a=i.create(),b=i.create(),c=i.create();return function(d,e,f,g,h,j,k,l){var m=null,n=null,o=e.length();i.set(c,0,0,0);for(var p=0;o>p;++p){j.push(k.nextId({geom:d,atom:e.centralAtomAt(p)})),e.smoothPosAt(a,p,l.strength),g[3*p]=a[0],g[3*p+1]=a[1],g[3*p+2]=a[2],e.smoothNormalAt(b,p,l.strength);var q=e.centralAtomAt(p);l.color.colorFor(q,f,4*p),i.dot(b,c)<0&&i.scale(b,b,-1),"E"!==e.residueAt(p).ss()||l.forceTube||(null===m&&(m=p),n=p),"C"===e.residueAt(p).ss()&&null!==m&&(x(g,m,n,o),x(h,m,n,o),m=null,n=null),h[3*p]=g[3*p]+b[0]+c[0],h[3*p+1]=g[3*p+1]+b[1]+c[1],h[3*p+2]=g[3*p+2]+b[2]+c[2],i.copy(c,b)}}}(),Q=function(){var a=i.create(),b=i.create(),c=j.fromValues(0,0,0,1),d=i.create(),e=i.create();return function(f,k,m,n,o){var p=K([m],4*o.arcDetail,o.splineDetail),q=o.float32Allocator.request(3*m.length()),s=o.float32Allocator.request(4*m.length()),t=o.float32Allocator.request(3*m.length()),u=[],v=o.idPool.getContinuousRange(m.length());f.addIdRange(v),P(f,m,s,q,t,u,v,o);var w=f.vertArrayWithSpaceFor(p),x=l.catmullRomSpline(q,m.length(),o.splineDetail,o.strength,!1,o.float32Allocator),y=l.catmullRomSpline(t,m.length(),o.splineDetail,o.strength,!1,o.float32Allocator);k.setPerResidueColors(n,s);var z=o.radius*(m.residueAt(0).isAminoacid()?1:1.8),A=r(s,o.splineDetail);i.set(a,x[3]-x[0],x[4]-x[1],x[5]-x[2]),i.set(b,x[0],x[1],x[2]),i.set(d,y[0]-x[0],y[1]-x[0],y[2]-x[2]),i.normalize(a,a),i.normalize(d,d),j.set(c,A[0],A[1],A[2],A[3]);var B=w.numVerts();w.addVertex(b,[-a[0],-a[1],-a[2]],c,u[0]),O(w,b,d,m.residueAt(0).ss(),a,c,z,!0,o,0,u[0]),g(w,B,4*o.arcDetail);var C=w.numVerts(),D=0;k.addAssoc(n,w,D,B,C),D+=1;for(var E=Math.floor(o.splineDetail/2),F=l.catmullRomSplineNumPoints(m.length(),o.splineDetail,!1),G=4*o.arcDetail,H=1,I=F;I>H;++H){var J=3*H,L=4*H,M=3*(H+1),N=3*(H-1);i.set(b,x[J],x[J+1],x[J+2]),H===I-1?i.set(a,x[J]-x[N],x[J+1]-x[N+1],x[J+2]-x[N+2]):i.set(a,x[M]-x[N],x[M+1]-x[N+1],x[M+2]-x[N+2]),i.normalize(a,a),j.set(c,A[L],A[L+1],A[L+2],A[L+3]);var Q=0,R=Math.floor(H/o.splineDetail),S=Math.floor((H-1)/o.splineDetail),T=Math.floor((H+o.arrowSkip)/o.splineDetail),U=!1,V=m.residueAt(R).ss();if(!o.forceTube){if(R!==S){var W=m.residueAt(S).ss();if("C"===W&&("H"===V||"E"===V)){i.set(e,y[N]-x[N],y[N+1]-x[N+1],y[N+2]-x[N+2]),i.normalize(e,e);var X=2*Math.PI/(4*o.arcDetail),Y=l.signedAngle(d,e,a);Q=Math.round(Y/X),Q=(Q+4*o.arcDetail)%(4*o.arcDetail)}}if(T!==R&&Tw.maxVerts()&&(C=w.numVerts(),k.addAssoc(n,w,D,B,C),w=f.vertArrayWithSpaceFor(ab),B=0,O(w,b,d,V,a,c,z,!0,o,0,_cr)),U&&(k.addAssoc(n,w,D,B,C),O(w,b,d,"A",a,c,z,!1,o,0,_cr),H+=o.arrowSkip),C=w.numVerts(),H===I-1&&(C+=1),k.addAssoc(n,w,D,B,C),D+=1,U&&(D+=o.arrowSkip)}return w.addVertex(b,a,c,u[u.length-1]),h(w,B,4*o.arcDetail),o.float32Allocator.release(t),o.float32Allocator.release(q),n+1}}(),R=function(){var a=k.create(),b=i.create(),c=i.create(),d=i.create(),e=i.create(),f=i.create(),g=i.create(),h=j.fromValues(0,0,0,1),m=j.fromValues(0,0,0,1);return function(j,k,n,o,p){if(0!==n.length()){var q=p.idPool.getContinuousRange(n.length());j.addIdRange(q),p.color.colorFor(n.centralAtomAt(0),h,0);var r=H([n],p.protoSphere.numVerts(),p.protoCyl.numVerts()),s=r,t=j.vertArrayWithSpaceFor(r),u=t.maxVerts(),v=t.numVerts();n.posAt(f,0);var w=q.nextId({geom:j,atom:n.centralAtomAt(0)}),x=0;p.protoSphere.addTransformed(t,f,p.radius,h,w);var y=null;k.addAssoc(o,t,0,v,y);var z=p.float32Allocator.request(4*n.length());z[0]=h[0],z[1]=h[1],z[2]=h[2],z[3]=h[3];for(var A=p.protoCyl.numVerts()+p.protoSphere.numVerts(),B=1;Bu-t.numVerts()&&(t=j.vertArrayWithSpaceFor(s)),s-=A;var D=t.numVerts();p.protoCyl.addTransformed(t,e,C,p.radius,a,h,m,w,x),y=t.numVerts(),y-=(y-D)/2,p.protoSphere.addTransformed(t,g,p.radius,m,x),w=x,k.addAssoc(o,t,B,v,y),v=y,i.copy(h,m)}k.setPerResidueColors(o,z),k.addAssoc(o,t,n.length()-1,v,t.numVerts())}}}();return s}(m,t,u,v),x=function(){function a(a,b,c,d,e,f){O.call(this,a);var g=f||{};this._b={},this._b.fillStyle=g.fillStyle||"#000",this._b.backgroundAlpha=g.backgroundAlpha||0,this._b.fontSize=g.fontSize||24,this._b.font=g.font||"Verdana",this._b.fontStyle=g.fontStyle||"normal",this._b.fontColor=g.fontColor||"#000",this._bW=100,this._cH=d,this._dT=this._c.createBuffer(),this._g=new Float32Array(30),this._dF(b,c,e);var h=.5,i=.5;this._g[0]=d[0],this._g[1]=d[1],this._g[2]=d[2],this._g[3]=-h,this._g[4]=-i,this._g[5]=d[0],this._g[6]=d[1],this._g[7]=d[2],this._g[8]=h,this._g[9]=i,this._g[10]=d[0],this._g[11]=d[1],this._g[12]=d[2],this._g[13]=h,this._g[14]=-i,this._g[15]=d[0],this._g[16]=d[1],this._g[17]=d[2],this._g[18]=-h,this._g[19]=-i,this._g[20]=d[0],this._g[21]=d[1],this._g[22]=d[2],this._g[23]=-h,this._g[24]=i,this._g[25]=d[0],this._g[26]=d[1],this._g[27]=d[2],this._g[28]=h,this._g[29]=i}function b(a){for(var b=1;a>b;)b*=2;return b}return d.derive(a,O,{updateProjectionIntervals:function(){},updateSquaredSphereRadius:function(a,b){return b},_cB:function(a){a.fillStyle=this._b.fontColor,a.textAlign="left",a.textBaseline="bottom",a.font=this._b.fontStyle+" "+this._b.fontSize+"px "+this._b.font},_dF:function(a,c,d){this._cB(c);var e=c.measureText(d).width,f=24;a.width=b(e),a.height=b(f),c.fillStyle=this._b.fillStyle,c.globalAlpha=this._b.backgroundAlpha,c.fillRect(0,0,a.width,a.height),this._cB(c),c.globalAlpha=1,c.lineWidth=.5,c.lineStyle="none",c.fillText(d,0,a.height),c.strokeText(d,0,a.height),this._cx=this._c.createTexture(),this._dv(this._cx,a),this._do=e/a.width,this._dn=f/a.height,this._k=e,this._m=f},_dv:function(a,b){var c=this._c;c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,!0),c.bindTexture(c.TEXTURE_2D,a),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST),c.generateMipmap(c.TEXTURE_2D),c.bindTexture(c.TEXTURE_2D,null)},bind:function(){var a=this._c;a.bindBuffer(a.ARRAY_BUFFER,this._dT),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._cx),this._p||(a.bufferData(a.ARRAY_BUFFER,this._g,a.STATIC_DRAW),this._p=!0)},draw:function(a,b,c,d){if(this._N&&"normal"===d){var e=b.text;a.bind(e),this.bind();var f=this._c,g=a.upsamplingFactor();f.uniform1f(f.getUniformLocation(e,"xScale"),this._do),f.uniform1f(f.getUniformLocation(e,"yScale"),this._dn),f.uniform1f(f.getUniformLocation(e,"width"),2*g*this._k/a.viewportWidth()),f.uniform1f(f.getUniformLocation(e,"height"),2*g*this._m/a.viewportHeight()),f.uniform1i(f.getUniformLocation(e,"sampler"),0);var h=f.getAttribLocation(e,"attrCenter");f.enableVertexAttribArray(h),f.vertexAttribPointer(h,3,f.FLOAT,!1,20,0);var i=f.getAttribLocation(e,"attrCorner");f.vertexAttribPointer(i,2,f.FLOAT,!1,20,12),f.enableVertexAttribArray(i),f.enable(f.BLEND),f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA),f.drawArrays(f.TRIANGLES,0,6),f.disableVertexAttribArray(h),f.disableVertexAttribArray(i),f.disable(f.BLEND)}}}),a}(),y=function(c){function e(){this._d=[],this._C=[],this._P=0}function f(a,b,d,f){O.call(this,b),this._z=d,this._E=f,this._A=new e,this._dC=new c.ProtoSphere(8,8),this._dD=new c.ProtoCylinder(8),this._U=null,this._p=!1}function g(a,b,c){for(var d=0;c-1>d;++d)a.addTriangle(b,b+1+d,b+2+d);a.addTriangle(b,b+c,b+1)}function h(a,b,c){for(var d=b+c,e=0;c-1>e;++e)a.addTriangle(d,b+e+1,b+e);a.addTriangle(d,b,b+c-1)}var i=a.vec3,j=a.mat3,k=b.forceRGB;return e.prototype={numVerts:function(){return this._P},addVertex:function(a,b,c,d){this._P+=1,this._d.push(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2],c[3],d)},addTriangle:function(a,b,c){this._C.push(a,b,c)},numIndices:function(){return this._C.length},indexData:function(){return this._C},vertData:function(){return this._d}},d.derive(f,O,{updateProjectionIntervals:function(){},updateSquaredSphereRadius:function(a,b){return b},addTube:function(){var a=i.create(),b=i.create(),c=i.create(),d=i.create(),e=j.create();return function(f,j,m,n){n=n||{};var o=k(n.color||"white"),p=!0;void 0!==n.cap&&(p=n.cap),i.sub(d,j,f);var q=i.length(d);if(i.normalize(d,d),i.add(a,f,j),i.scale(a,a,.5),l.buildRotation(e,d,b,c,!1),p){var r=this._A.numVerts();this._A.addVertex(f,[-d[0],-d[1],-d[2]],o,0),g(this._A,r,8)}if(this._dD.addTransformed(this._A,a,q,m,e,o,o,0,0),p){var s=this._A.numVerts();this._A.addVertex(j,d,o,0),h(this._A,s-8,8)}this._p=!1}}(),addSphere:function(a,b,c){c=c||{};var d=k(c.color||"white");
+this._dC.addTransformed(this._A,a,b,d,0),this._p=!1},_dE:function(){this._p=!0,null!==this._U&&this._U.destroy(),this._U=new Q(this._c,this._A.numVerts(),this._A.numIndices(),this._z,this._E),this._U.setIndexData(this._A.indexData()),this._U.setVertData(this._A.vertData())},draw:function(a,b,c,d){if(this._N){this._p||this._dE();var e=this.shaderForStyleAndPass(b,c,d);if(e){a.bind(e),this._c.uniform1i(e.symId,255);var f=this._U;f.bind(e),f.draw(),f.releaseAttribs(e)}}},shaderForStyleAndPass:function(a,b,c){if("normal"===c)return a.hemilight;if("select"===c)return null;if("outline"===c)return a.outline;var d=a[c];return void 0!==d?d:null}}),f}(m),z=function(){function b(a,b,c){this._cb=a,this._bO=b,this._bc=c,this._eq=c,this._bj=Date.now(),this._cP=!1,this._cc=!1}function c(a,c,d){b.call(this,o.clone(a),o.clone(c),d),this._Q=o.clone(a)}function e(a,c,d){var e=q.create(),f=q.create();q.fromMat4(e,a),q.fromMat4(f,c);var g=p.create(),h=p.create();p.fromMat3(g,e),p.fromMat3(h,f),this._Q=q.create(),b.call(this,g,h,d)}function f(a,c){b.call(this,null,null,c),this._cq=o.clone(a),this.setLooping(!0),this._cG=0}function g(a,c){var d=1e3*(2*Math.PI/c);b.call(this,null,null,d),this._cq=o.clone(a),this.setLooping(!0),this._eo=c,this._cF=0}function h(){this._bf=[]}function i(a,b,d){return new c(a,b,d)}function j(a,b,c){return new e(a,b,c)}function k(a,c,d){return new b(a,c,d)}function m(a,b){return new g(a,b)}function n(){return new f([0,1,0],2e3)}var o=a.vec3,p=a.quat,q=a.mat3;return b.prototype={setLooping:function(a){this._cP=a},step:function(a){var b,c=Date.now(),d=c-this._bj;if(0===this._bc)b=1;else if(this._cP){var e=Math.floor(d/this._bc);b=(d-e*this._bc)/this._bc}else d=Math.min(this._bc,d),b=d/this._bc,this._cc=1===b;return this.apply(a,b),this._cc},apply:function(a,b){var c=(1-Math.cos(b*Math.PI))/2;this._Q=this._cb*(1-c)+this._bO*c,a.setZoom(this._Q)},finished:function(){return this._cc}},d.derive(c,b,{apply:function(a,b){var c=(1-Math.cos(b*Math.PI))/2;o.lerp(this._Q,this._cb,this._bO,c),a.setCenter(this._Q)}}),d.derive(e,b,{apply:function(){var a=p.create();return function(b,c){p.slerp(a,this._cb,this._bO,c),q.fromQuat(this._Q,a),b.setRotation(this._Q)}}()}),d.derive(f,b,{apply:function(){var a=q.create(),b=q.create();return function(c,d){q.fromMat4(b,c.rotation());var e=.2*Math.sin(2*d*Math.PI),f=e-this._cG;this._cG=e,l.axisRotation(a,this._cq,f),q.mul(b,a,b),c.setRotation(b)}}()}),d.derive(g,b,{apply:function(){var a=q.create(),b=q.create();return function(c,d){q.fromMat4(b,c.rotation());var e=2*Math.PI*(d-this._cF);this._cF=d,l.axisRotation(a,this._cq,e),q.mul(b,a,b),c.setRotation(b)}}()}),h.prototype={run:function(a){var b=Date.now();return this._bf=this._bf.filter(function(c){return!c.step(a,b)}),this._bf.length>0},add:function(a){this._bf.push(a)},remove:function(a){this._bf=this._bf.filter(function(b){return b!==a})}},{AnimationControl:h,move:i,rotate:j,zoom:k,rockAndRoll:n,spin:m}}(),A=function(){function a(a,b){this.near=a,this.far=b}function b(a){a=a||{},this._8=a.near||.1,this._2=a.far||400}function c(){this._2=100}return b.prototype.update=function(){return new a(this._8,this._2)},c.prototype.update=function(b,c){for(var d=c.center(),e=null,f=0;fe;++e)c[e].update(v.dot(d,b[e]))});for(var e=0;3>e;++e)c[e].extend(1.5)}this._c8(b,c)},_c8:function(a,b){if(!(b[0].empty()||b[1].empty()||b[2].empty())){var c=b[0].center(),d=b[1].center(),e=b[2].center(),f=[c*a[0][0]+d*a[1][0]+e*a[2][0],c*a[0][1]+d*a[1][1]+e*a[2][1],c*a[0][2]+d*a[1][2]+e*a[2][2]],g=this._e.fieldOfViewY(),h=this._e.aspectRatio(),i=b[0].length()/h,j=b[1].length(),k=.5*Math.max(i,j),l=k/Math.tan(.5*g),m=l+.5*b[2].length(),n=.5,o=Math.max(l-n,.1),p=2*n+l+b[2].length();this._e.setNearFar(o,p),this.setCamera(this._e.rotation(),f,m,this._b.animateTime),this.requestRedraw()}},autoZoom:function(){var a=this._e.mainAxes(),b=[new d.Range,new d.Range,new d.Range];this.forEach(function(c){c.visible()&&c.updateProjectionIntervals(a[0],a[1],a[2],b[0],b[1],b[2])}),this._c8(a,b)},slabInterval:function(){},autoSlab:function(){var a=this._b._ep.update(this._l,this._e);null!==a&&this._e.setNearFar(a.near,a.far),this.requestRedraw()},rockAndRoll:function(a){return void 0===a?null!==this._bm:a?(this._bm=o.rockAndRoll(),this._S.add(this._bm),this.requestRedraw(),!0):(this._S.remove(this._bm),this._bm=null,this.requestRedraw(),!1)},spin:function(a,b){return void 0===a?null!==this._bk:a===!1?(this._S.remove(this._bk),this._bk=null,this.requestRedraw(),!1):(a===!0&&(a=Math.PI/8),b=b||[0,1,0],this._bk=o.spin(b,a),this._S.add(this._bk),this.requestRedraw(),!0)},slabMode:function(a,b){b=b||{};var c=q(a,b),d=c.update(this._l,this._e);null!==d&&this._e.setNearFar(d.near,d.far),this._b.slabMode=c,this.requestRedraw()},label:function(a,b,c,d){var e=new m(this._.gl(),this._by,this._em,c,b,d);return this.add(a,e),e},customMesh:function(a,b){var c=this._b9(b),d=new n(a,this._.gl(),c.float32Allocator,c.uint16Allocator);return this.add(a,d),d},_d5:function(){var a=this._.gl();a.clearColor(0,0,0,0),a.disable(a.BLEND),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),a.clearColor(this._b.background[0],this._b.background[1],this._b.background[2],1),a.cullFace(a.FRONT),a.enable(a.CULL_FACE),this._cf("select")},pick:function(a){this._bV.bind(),this._d5();var b=new Uint8Array(4),c=this._.gl();c.readPixels(a.x,this._b.height-a.y,1,1,c.RGBA,c.UNSIGNED_BYTE,b),this._bV.release(),b.data&&(b=b.data);var d=b[0]|b[1]<<8|b[2]<<16,e=b[3],f=this._cJ.objectForId(d);if(void 0===f)return null;var g=null;return 255!==e&&(g=f.geom.symWithIndex(e)),new r(f,255>e?e:null,g)},add:function(a,b){return b.name(a),this._l.push(b),this._l.sort(function(a,b){return a.order()-b.order()}),this.requestRedraw(),b},_c1:function(a){var b=a.replace(".","\\.").replace("*",".*");return new RegExp("^"+b+"$")},forEach:function(){var a,b="*";2===arguments.length?(a=arguments[1],b=arguments[0]):a=arguments[0];for(var c=this._c1(b),d=0;dc;++c)a(b[c])},isConnectedTo:function(a){if(null===a)return!1;for(var b=a.full(),c=this.full(),d=this.bonds(),e=0,f=d.length;f>e;++e){var g=d[e];if(g.atom_one()===c&&g.atom_two()===b||g.atom_one()===b&&g.atom_two()===c)return!0}return!1}},d.derive(b,a,{addBond:function(a){this._co.push(a)},name:function(){return this._G},bonds:function(){return this._co},residue:function(){return this._t},structure:function(){return this._t.structure()},full:function(){return this},qualifiedName:function(){return this.residue().qualifiedName()+"."+this.name()},pos:function(){return this._cH},element:function(){return this._bb},index:function(){return this._b6},prop:function(a){return this[a]()},occupancy:function(){return this._dH},tempFactor:function(){return this._dw},isHetatm:function(){return this._dS}}),d.derive(c,a,{full:function(){return this._J},name:function(){return this._J.name()},pos:function(){return this._J.pos()},element:function(){return this._J.element()},residue:function(){return this._dA},bonds:function(){return this._J.bonds()},index:function(){return this._J.index()},occupancy:function(){return this._J.occupancy()},tempFactor:function(){return this._J.tempFactor()},qualifiedName:function(){return this._J.qualifiedName()},isHetatm:function(){return this._J.isHetatm()}}),{Atom:b,AtomView:c}}(),E=function(b){function c(){}function e(a,b,d,e){c.call(this),this._G=b,this._dJ=d,this._dU=e,this._B=[],this._cy="C",this._I=a,this._cS=!1,this._cR=!1,this._b6=a.residues().length}function f(a,b){c.call(this),this._d8=a,this._B=[],this._t=b}var g=a.vec3,h=b.Atom,i=b.AtomView;return c.prototype={prop:function(a){return this[a]()},isWater:function(){return"HOH"===this.name()||"DOD"===this.name()},eachAtom:function(a,b){b|=0;for(var c=0;c=this._B.length&&0>a?null:this._B[a]},centralAtom:function(){return this.isAminoacid()?this.atom("CA"):this.isNucleotide()?this.atom("C3'"):null},center:function(){var a=0,b=g.create();return this.eachAtom(function(c){g.add(b,b,c.pos()),a+=1}),a>0&&g.scale(b,b,1/a),b},isAminoacid:function(){return this._cS},isNucleotide:function(){return this._cR}},d.derive(e,c,{_d7:function(){this._cR=null!==this.atom("P")&&null!==this.atom("C3'"),this._cS=null!==this.atom("N")&&null!==this.atom("CA")&&null!==this.atom("C")&&null!==this.atom("O")},name:function(){return this._G},insCode:function(){return this._dU},num:function(){return this._dJ},full:function(){return this},addAtom:function(a,b,c,d,e,f){var g=new h(this,a,b,c,this.structure().nextAtomIndex(),d,e,f);return this._B.push(g),g},ss:function(){return this._cy},setSS:function(a){this._cy=a},index:function(){return this._b6},atoms:function(){return this._B},chain:function(){return this._I},structure:function(){return this._I.structure()}}),d.derive(f,c,{addAtom:function(a){var b=new i(this,a.full());this._B.push(b)},full:function(){return this._t},num:function(){return this._t.num()},insCode:function(){return this._t.insCode()},ss:function(){return this._t.ss()},index:function(){return this._t.index()},chain:function(){return this._d8},name:function(){return this._t.name()},atoms:function(){return this._B},qualifiedName:function(){return this._t.qualifiedName()},containsResidue:function(a){return this._t.full()===a.full()},isAminoacid:function(){return this._t.isAminoacid()},isNucleotide:function(){return this._t.isNucleotide()},isWater:function(){return this._t.isWater()}}),{ResidueView:f,Residue:e}}(D),F=function(){function b(){this._s=[]}function c(a,b,c){this._bJ=a,this._1=b,this._c2=c,this._b3=0===this._1,this._b4=this._bJ.length()===this._c2;var d=this._c2-this._1;this._b4||++d,this._b3||(++d,this._1-=1),this._b2=d}var d=a.vec3;return b.prototype={push:function(a){this._s.push(a)},length:function(){return this._s.length},residueAt:function(a){return this._s[a]},posAt:function(a,b){return d.copy(a,this._s[b].centralAtom().pos()),a},normalAt:function(a,b){var c=this._s[b];return c.isAminoacid()&&d.sub(a,c.atom("O").pos(),c.atom("C").pos()),d.normalize(a,a),a},centralAtomAt:function(a){return this._s[a].centralAtom()},tangentAt:function(){var a=d.create(),b=d.create();return function(c,e){e>0?this.posAt(a,e-1):this.posAt(a,e),eb&&this._s[b].index()=this._s.length)break;for(var g=this._s[b].index();a.length>d&&a[d].full().index()=a.length)break;for(var h=b;a.length>d&&this._s.length>b&&a[d].full().index()===this._s[b].index();)++d,++b;var i=b;e.push(new c(this,h,i))}return e}},b.prototype.smoothPosAt=b.prototype.posAt,b.prototype.smoothNormalAt=b.prototype.normalAt,c.prototype={length:function(){return this._b2},residueAt:function(a){return this._bJ.residueAt(this._1+a)},_cT:function(){var a=d.create(),b=d.create();return function(c,e,f,g){return this.tangentAt(a,e),this.tangentAt(b,f),d.scale(a,a,g),d.scale(b,b,g),l.cubicHermiteInterpolate(c,this.centralAtomAt(e).pos(),a,this.centralAtomAt(f).pos(),b,.5,0),c}}(),smoothPosAt:function(){return function(a,b,c){if(0===b&&!this._b3)return this._cT(a,b,b+1,c);if(b===this._b2-1&&!this._b4)return this._cT(a,b-1,b,c);var e=this.centralAtomAt(b);return d.copy(a,e.pos()),a}}(),smoothNormalAt:function(){return function(a,b){return this._bJ.normalAt(a,b+this._1),a}}(),posAt:function(a,b){var c=this.centralAtomAt(b),e=null;return d.copy(a,c.pos()),0!==b||this._b3||(e=this.centralAtomAt(b+1),d.add(a,a,e.pos()),d.scale(a,a,.5)),b!==this._b2-1||this._b4||(e=this.centralAtomAt(b-1),d.add(a,a,e.pos()),d.scale(a,a,.5)),a},centralAtomAt:function(a){return this.residueAt(a).centralAtom()},fullTraceIndex:function(a){return this._1+a},tangentAt:function(a,b){return this._bJ.tangentAt(a,b+this._1)}},{TraceSubset:c,BackboneTrace:b}}(),G=function(b,c){function e(a,b){return a<<8|b.charCodeAt(0)}function f(a,b){return a.num()1}function k(a,b){b.length()<2||a.push(b)}function l(a,b,c){if(0===a.length)return!0;if(!b)return!1;var d=e(c.num(),c.insCode()),f=a[a.length-1],g=e(f.num(),f.insCode());return d>g}function m(a,b){h.call(this),this._I=b,this._q=[],this._dQ=a,this._cC={},this._V=!0}var n=a.vec3,o=b.Residue,p=b.ResidueView;return h.prototype={eachAtom:function(a,b){b|=0;for(var c=0;c=c;++c)h.push(this._q[c])}else for(c=0,e=i.length;c!==e;++c){var l=i[c];l.num()>=a&&l.num()<=b&&h.push(l)}return h},prop:function(a){return this[a]()}},d.derive(i,h,{name:function(){return this._G},full:function(){return this},addResidue:function(a,b,c){c=c||"\x00";var d=new o(this,a,b,c);return this._V=l(this._q,this._V,d),this._q.push(d),d},assignSS:function(a,b,c){for(var d=e(a[0],a[1]),f=e(b[0],b[1]),g=1;g=i||i>=f||h.setSS(c)}},eachBackboneTrace:function(a){this._eb();for(var b=0;b0)){for(var a=new c.BackboneTrace,b=null,d=0;d=d;++d)f.push(c[d]);return f}if(b.rindices&&void 0!==b.rindices.length){for(f=[],d=0;df&&a.connect(e,d)}}function h(a,b,c){var d=b.atom("O3'"),e=c.atom("P");if(d&&e){var f=m.sqrDist(d.pos(),e.pos());1.7*1.7>f&&a.connect(d,e)}}function i(){}function j(){i.call(this),this._j=[],this._L=[],this._cK=0}function k(a){i.call(this),this._cM=a,this._j=[]
+}var m=a.vec3,n=b.Chain,o=b.ChainView,p=c.Bond,q={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69};return i.prototype={eachResidue:function(a){for(var b=0;be)){if(j||(j=h.addChain(l[o].full(),!1)),i||(i=j.addResidue(p[q].full(),f)),f){n=!0;break}i.addAtom(r[s].full());break}}}return h}}(),createEmptyView:function(){return new k(this.full())}},d.derive(j,i,{addAssembly:function(a){this._L.push(a)},setAssemblies:function(a){this._L=a},assemblies:function(){return this._L},chains:function(){return this._j},full:function(){return this},containsResidue:function(a){return a.full().structure()===this},chainByName:function(a){for(var b=0;bj;j+=1)for(var k=e[j],l=k.pos(),n=f(k.element()),o=0;j>o;o+=1){var p=e[o],q=f(p.element());d=m.sqrDist(l,p.pos());var r=n+q-.3,s=n+q+.3;s*s>d&&d>r*r&&a.connect(k,p)}c._d7(),null!==b&&(c.isAminoacid()&&b.isAminoacid()&&g(a,b,c),c.isNucleotide()&&b.isNucleotide()&&h(a,b,c)),b=c})}}),d.derive(k,i,{full:function(){return this._cM},assemblies:function(){return this._cM.assemblies()},addChain:function(a,b){var c=new o(this,a.full());if(this._j.push(c),b)for(var d=a.residues(),e=0;e=h;++h)for(var i=2;5>i;++i)if(!(h+i>=c.length())){var j=e.dist(c.posAt(a,h),c.posAt(b,h+i));if(Math.abs(j-f[i-2])>g)return!1}return!0}}(),g=function(a,b){var c=[5.45,5.18,6.37],d=2.1;return f(a,b,c,d)},h=function(a,b){var c=[6.1,10.4,13],d=1.42;return f(a,b,c,d)};return{Mol:b.Mol,assignHelixSheet:d}}(J),L=function(b){function c(){this._L={},this._Q=null}function d(a){if(" "!==a[0]){var b=a.trim();if(4===b.length)for(var c=0,d=b.charCodeAt(c);4>c&&(65>d||d>122||d>90&&97>d);)++c,d=b.charCodeAt(c);return b.substr(0,2)}return a[1]}function e(a){this._b8=[],this._bQ=[],this._cl=[],this._bR={},this._i=new S.Mol,this._cE=new c,this._bM=null,this._br=null,this._es=null,this._b={},this._b.conectRecords=!!a.conectRecords}function f(a){return a.split(/\r\n|\r|\n/g)}function g(a,b){for(var c=b||{},d=f(a),g=new e(c),h=0;ho;++o)n[o]=parseFloat(a.substr(30+8*o,8));var p=a.substr(76,2).trim();""===p&&(p=d(g));var q=parseFloat(a.substr(54,6).trim()),r=parseFloat(a.substr(60,6).trim()),s=this._br.addAtom(h,n,p,c,isNaN(q)?null:q,isNaN(r)?null:r);if(this._b.conectRecords){var t=parseInt(a.substr(6,5).trim(),10);this._bR[t]=s}return!0},parseConectRecord:function(a){for(var b=parseInt(a.substr(6,5).trim(),10),c=[],d=0;4>d;++d){var e=parseInt(a.substr(11+5*d,6).trim(),10);isNaN(e)||e>b||c.push(e)}return this._cl.push({from:b,to:c}),!0},processLine:function(a){var b=a.substr(0,6);if("ATOM "===b||"HETATM"===b)return this.parseAndAddAtom(a);if("REMARK"===b){var c=a.substr(7,3);return"350"===c&&this._cE.nextLine(a),!0}return"HELIX "===b?this.parseHelixRecord(a):"SHEET "===b?this.parseSheetRecord(a):this._b.conectRecords&&"CONECT"===b?this.parseConectRecord(a):"END "===b||"ENDMDL"===b?!1:!0},finish:function(){var a,b=null;for(a=0;ab){if(0===b){var c=a.trim();if(0===c.length)return!1;this._cw=c}return this._bS=!1,this._5++,!0}if(3===b){if(this._cd=parseInt(a.substr(0,3).trim(),10),this._da=parseInt(a.substr(3,3).trim(),10),isNaN(this._cd)||isNaN(this._da))return!1;this._5++;var d=""+(this._i.chains().length+1);this._dc=this._i.addChain(d),this._ck=this._dc.addResidue(this._cw,1)}if(4===b){for(var e=[0,0,0],f=0;3>f;++f)if(e[f]=parseFloat(a.substr(10*f,10).trim()),isNaN(e[f]))return!1;var g=a.substr(31,3).trim();this._ck.addAtom(g,e,g,!1),this._dj++,this._dj===this._cd&&this._5++}if(5===b){var h=parseInt(a.substr(0,3).trim(),10)-1,i=parseInt(a.substr(3,3).trim(),10)-1;if(isNaN(h)||isNaN(i))return!1;var j=this._ck.atoms();this._i.connect(j[h],j[i]),this._dh++,this._dh===this._da&&this._5++}return"M END"===a.substr(0,6)&&(this._bS=!0,this._5++),"$$$$"===a.substr(0,4)&&this._cD(),!0},_cD:function(){this._5=0,this._ck=null,this._dc=null,this._cd=null,this._er=null,this._dj=0,this._dh=0,this._cw=""},finish:function(){return this._bS?this._i:null}},{pdb:g,sdf:i,Remark350Reader:c,fetchPdb:k,fetchSdf:l}}(C),M=function(){var b=a.vec3,c=a.mat3,d=function(){var a=b.create(),c=b.create();return function(d,e){b.set(a,0,0,0);var f=0;d.eachCentralAtom(function(c,d){b.add(a,a,d),f+=1}),0!==f&&(b.scale(a,a,1/f),e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0,d.eachCentralAtom(function(d,f){b.sub(c,f,a);var g=c[0],h=c[1],i=c[2];e[0]+=h*h+i*i,e[1]-=g*h,e[2]-=g*i,e[5]-=h*i,e[4]+=g*g+i*i,e[8]+=g*g+h*h}),e[3]=e[1],e[6]=e[2],e[7]=e[5])}}(),e=function(){var a=c.create(),e=c.create(),f=b.create(),g=b.create(),h=b.create(),i=b.create(),j=b.create(),k=b.create(),m=b.create();return function(n){d(n,a);var o=l.diagonalizer(a);c.fromQuat(e,o);var p=!0;n.eachCentralAtom(function(a,c){b.transformMat3(h,c,e),p?(b.copy(f,h),b.copy(g,h),p=!1):(b.min(f,f,h),b.max(g,g,h))}),b.sub(i,g,f);var q=[[i[0],0],[i[1],1],[i[2],2]];q.sort(function(a,b){return b[0]-a[0]});var r=q[0][1],s=q[1][1];b.set(j,e[r+0],e[r+3],e[r+6]),b.set(k,e[s+0],e[s+3],e[s+6]),b.cross(m,j,k);var t=c.create();return t[0]=j[0],t[1]=k[0],t[2]=m[0],t[3]=j[1],t[4]=k[1],t[5]=m[1],t[6]=j[2],t[7]=k[2],t[8]=m[2],t}}();return{principalAxes:e}}(),N=function(){return{Viewer:B.Viewer,isWebGLSupported:B.isWebGLSupported,io:L,color:b,mol:S,rgb:{setColorPalette:b.setColorPalette,hex2rgb:b.hex2rgb},vec3:a.vec3,vec4:a.vec4,mat3:a.mat3,mat4:a.mat4,quat:a.quat,viewpoint:M}}()});
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/pv/formset.js b/src/main/webapp/resources/js/pv/formset.js
new file mode 100644
index 00000000000..81464ee4cea
--- /dev/null
+++ b/src/main/webapp/resources/js/pv/formset.js
@@ -0,0 +1,206 @@
+/**
+ * jQuery Formset 1.3-pre
+ * @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com)
+ * @requires jQuery 1.2.6 or later
+ *
+ * Copyright (c) 2009, Stanislaus Madueke
+ * All rights reserved.
+ *
+ * Licensed under the New BSD License
+ * See: http://www.opensource.org/licenses/bsd-license.php
+ */
+;(function($) {
+ $.fn.formset = function(opts)
+ {
+ var options = $.extend({}, $.fn.formset.defaults, opts),
+ flatExtraClasses = options.extraClasses.join(' '),
+ totalForms = $('#id_' + options.prefix + '-TOTAL_FORMS'),
+ maxForms = $('#id_' + options.prefix + '-MAX_NUM_FORMS'),
+ childElementSelector = 'input,select,textarea,label,div',
+ $$ = $(this),
+
+ applyExtraClasses = function(row, ndx) {
+ if (options.extraClasses) {
+ row.removeClass(flatExtraClasses);
+ row.addClass(options.extraClasses[ndx % options.extraClasses.length]);
+ }
+ },
+
+ updateElementIndex = function(elem, prefix, ndx) {
+ var idRegex = new RegExp(prefix + '-(\\d+|__prefix__)-'),
+ replacement = prefix + '-' + ndx + '-';
+ if (elem.attr("for")) elem.attr("for", elem.attr("for").replace(idRegex, replacement));
+ if (elem.attr('id')) elem.attr('id', elem.attr('id').replace(idRegex, replacement));
+ if (elem.attr('name')) elem.attr('name', elem.attr('name').replace(idRegex, replacement));
+ },
+
+ hasChildElements = function(row) {
+ return row.find(childElementSelector).length > 0;
+ },
+
+ showAddButton = function() {
+ return maxForms.length == 0 || // For Django versions pre 1.2
+ (maxForms.val() == '' || (maxForms.val() - totalForms.val() > 0))
+ },
+
+ insertDeleteLink = function(row) {
+ if (row.is('TR')) {
+ // If the forms are laid out in table rows, insert
+ // the remove button into the last table cell:
+ row.children(':last').append('' + options.deleteText + ' ');
+ } else if (row.is('UL') || row.is('OL')) {
+ // If they're laid out as an ordered/unordered list,
+ // insert an after the last list item:
+ row.append(' ' + options.deleteText +' ');
+ } else {
+ // Otherwise, just insert the remove button as the
+ // last child element of the form's container:
+ row.append('' + options.deleteText +' ');
+ }
+ row.find('a.' + options.deleteCssClass).click(function() {
+ var row = $(this).parents('.' + options.formCssClass),
+ del = row.find('input:hidden[id $= "-DELETE"]'),
+ buttonRow = row.siblings("a." + options.addCssClass + ', .' + options.formCssClass + '-add'),
+ forms;
+ if (del.length) {
+ // We're dealing with an inline formset.
+ // Rather than remove this form from the DOM, we'll mark it as deleted
+ // and hide it, then let Django handle the deleting:
+ del.val('on');
+ row.hide();
+ forms = $('.' + options.formCssClass).not(':hidden');
+ } else {
+ row.remove();
+ // Update the TOTAL_FORMS count:
+ forms = $('.' + options.formCssClass).not('.formset-custom-template');
+ totalForms.val(forms.length);
+ }
+ for (var i=0, formCount=forms.length; i ');
+ row.hide();
+ } else {
+ del.before(' ');
+ }
+ // Hide any labels associated with the DELETE checkbox:
+ $('label[for="' + del.attr('id') + '"]').hide();
+ del.remove();
+ }
+ if (hasChildElements(row)) {
+ row.addClass(options.formCssClass);
+ if (row.is(':visible')) {
+ insertDeleteLink(row);
+ applyExtraClasses(row, i);
+ }
+ }
+ });
+
+ if ($$.length) {
+ var hideAddButton = !showAddButton(),
+ addButton, template;
+ if (options.formTemplate) {
+ // If a form template was specified, we'll clone it to generate new form instances:
+ template = (options.formTemplate instanceof $) ? options.formTemplate : $(options.formTemplate);
+ template.removeAttr('id').addClass(options.formCssClass + ' formset-custom-template');
+ template.find(childElementSelector).each(function() {
+ updateElementIndex($(this), options.prefix, '__prefix__');
+ });
+ insertDeleteLink(template);
+ } else {
+ // Otherwise, use the last form in the formset; this works much better if you've got
+ // extra (>= 1) forms (thnaks to justhamade for pointing this out):
+ template = $('.' + options.formCssClass + ':last').clone(true).removeAttr('id');
+ template.find('input:hidden[id $= "-DELETE"]').remove();
+ // Clear all cloned fields, except those the user wants to keep (thanks to brunogola for the suggestion):
+ template.find(childElementSelector).not(options.keepFieldValues).each(function() {
+ var elem = $(this);
+ // If this is a checkbox or radiobutton, uncheck it.
+ // This fixes Issue 1, reported by Wilson.Andrew.J:
+ if (elem.is('input:checkbox') || elem.is('input:radio')) {
+ elem.attr('checked', false);
+ } else {
+ elem.val('');
+ }
+ });
+ }
+ // FIXME: Perhaps using $.data would be a better idea?
+ options.formTemplate = template;
+
+ if ($$.attr('tagName') == 'TR') {
+ // If forms are laid out as table rows, insert the
+ // "add" button in a new table row:
+ var numCols = $$.eq(0).children().length, // This is a bit of an assumption :|
+ buttonRow = $('' + options.addText + ' ')
+ .addClass(options.formCssClass + '-add');
+ $$.parent().append(buttonRow);
+ if (hideAddButton) buttonRow.hide();
+ addButton = buttonRow.find('a');
+ } else {
+ // Otherwise, insert it immediately after the last form:
+ $$.filter(':last').after('' + options.addText + ' ');
+ addButton = $$.filter(':last').next();
+ if (hideAddButton) addButton.hide();
+ }
+ addButton.click(function() {
+ var formCount = parseInt(totalForms.val()),
+ row = options.formTemplate.clone(true).removeClass('formset-custom-template'),
+ buttonRow = $($(this).parents('tr.' + options.formCssClass + '-add').get(0) || this);
+ applyExtraClasses(row, formCount);
+ row.insertBefore(buttonRow).show();
+ row.find(childElementSelector).each(function() {
+ updateElementIndex($(this), options.prefix, formCount);
+ });
+ totalForms.val(formCount + 1);
+ // Check if we've exceeded the maximum allowed number of forms:
+ if (!showAddButton()) buttonRow.hide();
+ // If a post-add callback was supplied, call it with the added form:
+ if (options.added) options.added(row);
+ return false;
+ });
+ }
+
+ return $$;
+ }
+
+ /* Setup plugin defaults */
+ $.fn.formset.defaults = {
+ prefix: 'form', // The form prefix for your django formset
+ formTemplate: null, // The jQuery selection cloned to generate new form instances
+ addText: 'add another', // Text for the add link
+ deleteText: 'remove', // Text for the delete link
+ addCssClass: 'add-row', // CSS class applied to the add link
+ deleteCssClass: 'delete-row', // CSS class applied to the delete link
+ formCssClass: 'dynamic-form', // CSS class applied to each form in a formset
+ extraClasses: [], // Additional CSS classes, which will be applied to each form in turn
+ keepFieldValues: '', // jQuery selector for fields whose values should be kept when the form is cloned
+ added: null, // Function called each time a new form is added
+ removed: null // Function called each time a form is deleted
+ };
+})(jQuery)
\ No newline at end of file
diff --git a/src/main/webapp/visualizationFragment.xhtml b/src/main/webapp/visualizationFragment.xhtml
new file mode 100644
index 00000000000..dd090c3d253
--- /dev/null
+++ b/src/main/webapp/visualizationFragment.xhtml
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Choose Style:
+
+ Preset
+ Cartoon
+ Tube
+ Lines
+ Line Trace
+ Smooth Line Trace
+ Trace
+
+
initializing...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file