From 909899bac0a71b4eeb47b1d65cdca4fd304fdb36 Mon Sep 17 00:00:00 2001 From: j0kaso Date: Tue, 8 Oct 2019 18:25:16 +0200 Subject: [PATCH] Update: NGL version to ngl-1.0.0-beta.4 (https://github.com/arose/ngl/releases/tag/v1.0.0-beta.4) including scroll bug-fix (https://github.com/arose/ngl/commit/4d6f0894c062b6bffb5aa29cdb8f6f2fdad44a33) --- mdsrv/webapp/js/ngl.js | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/mdsrv/webapp/js/ngl.js b/mdsrv/webapp/js/ngl.js index bee707f..919c31a 100644 --- a/mdsrv/webapp/js/ngl.js +++ b/mdsrv/webapp/js/ngl.js @@ -1 +1,39 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.NGL={})}(this,function(t){"use strict";function e(){}function r(t,e){return function(){t.apply(e,arguments)}}function i(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(t,this)}function n(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,ph(function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null!==r){var i;try{i=r(t._value)}catch(t){return void a(e.promise,t)}o(e.promise,i)}else(1===t._state?o:a)(e.promise,t._value)})):t._deferreds.push(e)}function o(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof i)return t._state=3,t._value=e,void s(t);if("function"==typeof n)return void u(r(n,e),t)}t._state=1,t._value=e,s(t)}catch(e){a(t,e)}}function a(t,e){t._state=2,t._value=e,s(t)}function s(t){2===t._state&&0===t._deferreds.length&&ph(function(){t._handled||dh(t._value)});for(var e=0,r=t._deferreds.length;e0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function b(t,e,r,i,n,o,a,s,c,u,h,l){p.call(this,null,o,a,s,c,u,i,n,h,l),this.image={data:t,width:e,height:r},this.magFilter=void 0!==c?c:_l,this.minFilter=void 0!==u?u:_l,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function x(t,e,r,i,n,o,a,s,c,u){t=void 0!==t?t:[],e=void 0!==e?e:ll,p.call(this,t,e,r,i,n,o,a,s,c,u),this.flipY=!1}function _(){this.seq=[],this.map={}}function w(t,e,r){var i=t[0];if(i<=0||i>0)return t;var n=e*r,o=bp[n];if(void 0===o&&(o=new Float32Array(n),bp[n]=o),0!==e){i.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function S(t,e){var r=xp[e];void 0===r&&(r=new Int32Array(e),xp[e]=r);for(var i=0;i!==e;++i)r[i]=t.allocTextureUnit();return r}function A(t,e){t.uniform1f(this.addr,e)}function M(t,e){t.uniform1i(this.addr,e)}function E(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function T(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function P(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function C(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function I(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(wp.set(e.elements),t.uniformMatrix3fv(this.addr,!1,wp))}function R(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(_p.set(e.elements),t.uniformMatrix4fv(this.addr,!1,_p))}function L(t,e,r){var i=r.allocTextureUnit();t.uniform1i(this.addr,i),r.setTexture2D(e||vp,i)}function O(t,e,r){var i=r.allocTextureUnit();t.uniform1i(this.addr,i),r.setTextureCube(e||yp,i)}function D(t,e){t.uniform2iv(this.addr,e)}function N(t,e){t.uniform3iv(this.addr,e)}function k(t,e){t.uniform4iv(this.addr,e)}function F(t){switch(t){case 5126:return A;case 35664:return E;case 35665:return T;case 35666:return P;case 35674:return C;case 35675:return I;case 35676:return R;case 35678:case 36198:return L;case 35680:return O;case 5124:case 35670:return M;case 35667:case 35671:return D;case 35668:case 35672:return N;case 35669:case 35673:return k}}function B(t,e){t.uniform1fv(this.addr,e)}function z(t,e){t.uniform1iv(this.addr,e)}function U(t,e){t.uniform2fv(this.addr,w(e,this.size,2))}function j(t,e){t.uniform3fv(this.addr,w(e,this.size,3))}function G(t,e){t.uniform4fv(this.addr,w(e,this.size,4))}function V(t,e){t.uniformMatrix2fv(this.addr,!1,w(e,this.size,4))}function $(t,e){t.uniformMatrix3fv(this.addr,!1,w(e,this.size,9))}function H(t,e){t.uniformMatrix4fv(this.addr,!1,w(e,this.size,16))}function W(t,e,r){var i=e.length,n=S(r,i);t.uniform1iv(this.addr,n);for(var o=0;o!==i;++o)r.setTexture2D(e[o]||vp,n[o])}function X(t,e,r){var i=e.length,n=S(r,i);t.uniform1iv(this.addr,n);for(var o=0;o!==i;++o)r.setTextureCube(e[o]||yp,n[o])}function q(t){switch(t){case 5126:return B;case 35664:return U;case 35665:return j;case 35666:return G;case 35674:return V;case 35675:return $;case 35676:return H;case 35678:return W;case 35680:return X;case 5124:case 35670:return z;case 35667:case 35671:return D;case 35668:case 35672:return N;case 35669:case 35673:return k}}function Y(t,e,r){this.id=t,this.addr=r,this.setValue=F(e.type)}function Z(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=q(e.type)}function K(t){this.id=t,_.call(this)}function Q(t,e){t.seq.push(e),t.map[e.id]=e}function J(t,e,r){var i=t.name,n=i.length;for(Sp.lastIndex=0;;){var o=Sp.exec(i),a=Sp.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===n){Q(r,void 0===u?new Y(s,t,e):new Z(s,t,e));break}var h=r.map[s];void 0===h&&Q(r,h=new K(s)),r=h}}function tt(t,e,r){var i=this;_.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),o=0;o.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,_=R.size*R.scale/u.w,w.x=_*y,w.y=_,e.uniform3f(d.screenPosition,S.x,S.y,S.z),e.uniform2f(d.scale,w.x,w.y),e.uniform1f(d.rotation,R.rotation),e.uniform1f(d.opacity,R.opacity),e.uniform3f(d.color,R.color.r,R.color.g,R.color.b),r.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),i.setTexture2D(R.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}r.enable(e.CULL_FACE),r.enable(e.DEPTH_TEST),r.buffers.depth.setMask(!0),r.reset()}}}function nt(t,e,r,i,n,o,a,s,c){p.call(this,t,e,r,i,n,o,a,s,c),this.needsUpdate=!0}function ot(t,e,r,i,n){function o(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),r=new Uint16Array([0,1,2,0,2,3]);c=e.createBuffer(),u=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.bufferData(e.ELEMENT_ARRAY_BUFFER,r,e.STATIC_DRAW),h=a(),l={position:e.getAttribLocation(h,"position"),uv:e.getAttribLocation(h,"uv")},p={uvOffset:e.getUniformLocation(h,"uvOffset"),uvScale:e.getUniformLocation(h,"uvScale"),rotation:e.getUniformLocation(h,"rotation"),scale:e.getUniformLocation(h,"scale"),color:e.getUniformLocation(h,"color"),map:e.getUniformLocation(h,"map"),opacity:e.getUniformLocation(h,"opacity"),modelViewMatrix:e.getUniformLocation(h,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(h,"projectionMatrix"),fogType:e.getUniformLocation(h,"fogType"),fogDensity:e.getUniformLocation(h,"fogDensity"),fogNear:e.getUniformLocation(h,"fogNear"),fogFar:e.getUniformLocation(h,"fogFar"),fogColor:e.getUniformLocation(h,"fogColor"),alphaTest:e.getUniformLocation(h,"alphaTest")};var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var n=i.getContext("2d");n.fillStyle="white",n.fillRect(0,0,8,8),d=new nt(i)}function a(){var t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),i=e.createShader(e.FRAGMENT_SHADER);return e.shaderSource(r,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(i,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(r),e.compileShader(i),e.attachShader(t,r),e.attachShader(t,i),e.linkProgram(t),t}function s(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var c,u,h,l,p,d,f=new v,m=new g,y=new v;this.render=function(n,a,g){if(0!==n.length){void 0===h&&o(),r.useProgram(h),r.initAttributes(),r.enableAttribute(l.position),r.enableAttribute(l.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,c),e.vertexAttribPointer(l.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.uniformMatrix4fv(p.projectionMatrix,!1,g.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(p.map,0);var v=0,b=0,x=a.fog;x?(e.uniform3f(p.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(p.fogNear,x.near),e.uniform1f(p.fogFar,x.far),e.uniform1i(p.fogType,1),v=1,b=1):x.isFogExp2&&(e.uniform1f(p.fogDensity,x.density),e.uniform1i(p.fogType,2),v=2,b=2)):(e.uniform1i(p.fogType,0),v=0,b=0);for(var _=0,w=n.length;_0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function dt(t,e){this.normal=void 0!==t?t:new v(1,0,0),this.constant=void 0!==e?e:0}function ft(t,e,r,i,n,o){this.planes=[void 0!==t?t:new dt,void 0!==e?e:new dt,void 0!==r?r:new dt,void 0!==i?i:new dt,void 0!==n?n:new dt,void 0!==o?o:new dt]}function mt(t,e,r){function i(e,r,i,n,o,a){var s=e.geometry,c=null,u=b,h=e.customDepthMaterial;if(i&&(u=x,h=e.customDistanceMaterial),h)c=h;else{var l=!1;r.morphTargets&&(s&&s.isBufferGeometry?l=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(l=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===r.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var d=e.isSkinnedMesh&&r.skinning,f=0;l&&(f|=p),d&&(f|=m),c=u[f]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var g=c.uuid,v=r.uuid,y=_[g];void 0===y&&(y={},_[g]=y);var w=y[v];void 0===w&&(w=c.clone(),y[v]=w),c=w}c.visible=r.visible,c.wireframe=r.wireframe;var S=r.side;return I.renderSingleSided&&S==Sh&&(S=_h),I.renderReverseSided&&(S===_h?S=wh:S===wh&&(S=_h)),c.side=S,c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,i&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(n),c.nearDistance=o,c.farDistance=a),c}function n(r,a,s,c){if(!1!==r.visible){if(r.layers.test(a.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||o.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,r.matrixWorld);var u=e.update(r),l=r.material;if(Array.isArray(l))for(var p=u.groups,d=0,f=p.length;de&&(e=t[r]);return e}function Bt(){Object.defineProperty(this,"id",{value:At()}),this.uuid=mp.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function zt(t,e,r,i,n,o){Mt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new Ut(t,e,r,i,n,o)),this.mergeVertices()}function Ut(t,e,r,i,n,o){function a(t,e,r,i,n,o,a,f,m,g,y){var b,x,_=o/m,w=a/g,S=o/2,A=a/2,M=f/2,E=m+1,T=g+1,P=0,C=0,I=new v;for(x=0;x0?1:-1,h.push(I.x,I.y,I.z),l.push(b/m),l.push(1-x/g),P+=1}}for(x=0;x1&&r.sort(Yt),i.length>1&&i.sort(Zt)}}}function Qt(){var t={};return{get:function(e,r){var i=e.id+","+r.id,n=t[i];return void 0===n&&(n=new Kt,t[i]=n),n},dispose:function(){t={}}}}function Jt(t,e){return Math.abs(e[1])-Math.abs(t[1])}function te(t){var e={},r=new Float32Array(8);return{update:function(i,n,o,a){var s=i.morphTargetInfluences,c=s.length,u=e[n.id];if(void 0===u){for(u=[],p=0;p65535?Ot:Rt)(n,1),e.update(i,t.ELEMENT_ARRAY_BUFFER),o[r.id]=i,i}}}function ne(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var r;switch(e.type){case"DirectionalLight":r={direction:new v,color:new et,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new l};break;case"SpotLight":r={position:new v,direction:new v,color:new et,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new l};break;case"PointLight":r={position:new v,color:new et,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new l,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new v,skyColor:new et,groundColor:new et};break;case"RectAreaLight":r={color:new et,position:new v,halfWidth:new v,halfHeight:new v}}return t[e.id]=r,r}}}function oe(){var t=new ne,e={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},r=new v,i=new y,n=new y;return{setup:function(o,a,s){for(var c=0,u=0,h=0,l=0,p=0,d=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v/gm;return t.replace(e,function(t,e){var r=Tp[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return ye(r)})}function be(t){var e=/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return t.replace(e,function(t,e,r,i){for(var n="",o=parseInt(e);o0?t.gammaFactor:1,v=de(i.extensions,o,e),y=fe(s),b=a.createProgram();i.isRawShaderMaterial?(f=[y,"\n"].filter(ge).join("\n"),m=[v,y,"\n"].filter(ge).join("\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+h:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ge).join("\n"),m=[v,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+g,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+l:"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+h:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==al?"#define TONE_MAPPING":"",o.toneMapping!==al?Tp.tonemapping_pars_fragment:"",o.toneMapping!==al?pe("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Tp.encodings_pars_fragment:"",o.mapEncoding?he("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?he("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?he("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?le("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ge).join("\n")),c=ve(c=ye(c),o),u=ve(u=ye(u),o),i.isShaderMaterial||(c=be(c),u=be(u));var x=f+c,_=m+u,w=ce(a,a.VERTEX_SHADER,x),S=ce(a,a.FRAGMENT_SHADER,_);a.attachShader(b,w),a.attachShader(b,S),void 0!==i.index0AttributeName?a.bindAttribLocation(b,0,i.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(b,0,"position"),a.linkProgram(b);var A=a.getProgramInfoLog(b),M=a.getShaderInfoLog(w),E=a.getShaderInfoLog(S),T=!0,P=!0;!1===a.getProgramParameter(b,a.LINK_STATUS)?(T=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(b,a.VALIDATE_STATUS),"gl.getProgramInfoLog",A,M,E)):""!==A?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",A):""!==M&&""!==E||(P=!1),P&&(this.diagnostics={runnable:T,material:i,programLog:A,vertexShader:{log:M,prefix:f},fragmentShader:{log:E,prefix:m}}),a.deleteShader(w),a.deleteShader(S);var C;this.getUniforms=function(){return void 0===C&&(C=new tt(a,b,t)),C};var I;return this.getAttributes=function(){return void 0===I&&(I=me(a,b)),I},this.destroy=function(){a.deleteProgram(b),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=Lp++,this.code=r,this.usedTimes=1,this.program=b,this.vertexShader=w,this.fragmentShader=S,this}function _e(t,e,r){function i(t){var e=t.skeleton.bones;if(r.floatVertexTextures)return 1024;var i=r.maxVertexUniforms,n=Math.floor((i-20)/4),o=Math.min(n,e.length);return o0,maxBones:d,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numClippingPlanes:u,numClipIntersection:h,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&l.receiveShadow&&s.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Sh,flipSided:e.side===wh,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,r){var i=[];if(r.shaderID?i.push(r.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(var n in e.defines)i.push(n),i.push(e.defines[n]);for(var o=0;oe||t.height>e){var r=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(t.width*r),i.height=Math.floor(t.height*r),i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function c(t){return mp.isPowerOfTwo(t.width)&&mp.isPowerOfTwo(t.height)}function u(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=mp.nearestPowerOfTwo(t.width),e.height=mp.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function h(t){return t.wrapS!==bl||t.wrapT!==bl||t.minFilter!==_l&&t.minFilter!==Al}function l(t,e){return t.generateMipmaps&&e&&t.minFilter!==_l&&t.minFilter!==Al}function p(e){return e===_l||e===wl||e===Sl?t.NEAREST:t.LINEAR}function d(t){var e=t.target;e.removeEventListener("dispose",d),m(e),a.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),g(e),a.textures--}function m(e){var r=i.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}i.remove(e)}function g(e){var r=i.get(e),n=i.get(e.texture);if(e){if(void 0!==n.__webglTexture&&t.deleteTexture(n.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);i.remove(e.texture),i.remove(e)}}function v(e,n){var o=i.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==a.complete)return void b(o,e,n);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}r.activeTexture(t.TEXTURE0+n),r.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function y(r,a,s){var c;if(s?(t.texParameteri(r,t.TEXTURE_WRAP_S,o.convert(a.wrapS)),t.texParameteri(r,t.TEXTURE_WRAP_T,o.convert(a.wrapT)),t.texParameteri(r,t.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(t.texParameteri(r,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(r,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS===bl&&a.wrapT===bl||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),t.texParameteri(r,t.TEXTURE_MAG_FILTER,p(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,p(a.minFilter)),a.minFilter!==_l&&a.minFilter!==Al&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===Ol&&null===e.get("OES_texture_float_linear"))return;if(a.type===Dl&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function b(e,i,p){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",d),e.__webglTexture=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+p),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,i.unpackAlignment);var f=s(i.image,n.maxTextureSize);h(i)&&!1===c(f)&&(f=u(f));var m=c(f),g=o.convert(i.format),v=o.convert(i.type);y(t.TEXTURE_2D,i,m);var b,x=i.mipmaps;if(i.isDepthTexture){var _=t.DEPTH_COMPONENT;if(i.type===Ol){if(!A)throw new Error("Float Depth Texture only supported in WebGL2.0");_=t.DEPTH_COMPONENT32F}else A&&(_=t.DEPTH_COMPONENT16);i.format===$l&&_===t.DEPTH_COMPONENT&&i.type!==Il&&i.type!==Ll&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=Il,v=o.convert(i.type)),i.format===Hl&&(_=t.DEPTH_STENCIL,i.type!==Bl&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=Bl,v=o.convert(i.type))),r.texImage2D(t.TEXTURE_2D,0,_,f.width,f.height,0,g,v,null)}else if(i.isDataTexture)if(x.length>0&&m){for(var w=0,S=x.length;w-1?r.compressedTexImage2D(t.TEXTURE_2D,w,g,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(t.TEXTURE_2D,w,g,b.width,b.height,0,g,v,b.data);else if(x.length>0&&m){for(var w=0,S=x.length;w0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",d),h.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var p=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,m=[],g=0;g<6;g++)m[g]=p||f?f?e.image[g].image:e.image[g]:s(e.image[g],n.maxCubemapSize);var v=c(m[0]),b=o.convert(e.format),x=o.convert(e.type);for(y(t.TEXTURE_CUBE_MAP,e,v),g=0;g<6;g++)if(p)for(var _,w=m[g].mipmaps,S=0,A=w.length;S-1?r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,S,b,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,S,b,_.width,_.height,0,b,x,_.data);else f?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,b,m[g].width,m[g].height,0,b,x,m[g].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,b,b,x,m[g]);l(e,v)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,n){r.activeTexture(t.TEXTURE0+n),r.bindTexture(t.TEXTURE_CUBE_MAP,i.get(e).__webglTexture)},this.setupRenderTarget=function(e){var n=i.get(e),o=i.get(e.texture);e.addEventListener("dispose",f),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,u=c(e);if(s)for(n.__webglFramebuffer=[],h=0;h<6;h++)n.__webglFramebuffer[h]=t.createFramebuffer();else n.__webglFramebuffer=t.createFramebuffer();if(s){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),y(t.TEXTURE_CUBE_MAP,e.texture,u);for(var h=0;h<6;h++)x(n.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);l(e.texture,u)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),y(t.TEXTURE_2D,e.texture,u),x(n.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),l(e.texture,u)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&S(e)},this.updateRenderTargetMipmap=function(e){var n=e.texture;if(l(n,c(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=i.get(n).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function Se(){var t={};return{get:function(e){var r=e.uuid,i=t[r];return void 0===i&&(i={},t[r]=i),i},remove:function(e){delete t[e.uuid]},clear:function(){t={}}}}function Ae(t,e,r){function i(e,r,i){var n=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a=1,B=null,z={},U=new d,j=new d,G={};return G[t.TEXTURE_2D]=i(t.TEXTURE_2D,t.TEXTURE_2D,1),G[t.TEXTURE_CUBE_MAP]=i(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),l.setClear(0,0,0,1),p.setClear(1),f.setClear(0),n(t.DEPTH_TEST),p.setFunc(Qh),s(!1),c(gh),n(t.CULL_FACE),n(t.BLEND),a(Ph),{buffers:{color:l,depth:p,stencil:f},initAttributes:function(){for(var t=0,e=g.length;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var n,o=void 0!==r.precision?r.precision:"highp",a=i(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_TEXTURE_SIZE),l=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),d=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=u>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var r=e.get("EXT_texture_filter_anisotropic");return n=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:l,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}function Ee(t){wt.call(this),this.cameras=t||[]}function Te(t){function e(){if(null!==i&&i.isPresenting){var e=i.getEyeParameters("left"),n=e.renderWidth,o=e.renderHeight;p=t.getPixelRatio(),l=t.getSize(),t.setDrawingBufferSize(2*n,o,1)}else r.enabled&&t.setDrawingBufferSize(l.width,l.height,p)}var r=this,i=null,n=null;"VRFrameData"in window&&(n=new window.VRFrameData);var o=new y,a=new y,s=new y,c=new wt;c.bounds=new d(0,0,.5,1),c.layers.enable(1);var u=new wt;u.bounds=new d(.5,0,.5,1),u.layers.enable(2);var h=new Ee([c,u]);h.layers.enable(1),h.layers.enable(2);var l,p;window.addEventListener("vrdisplaypresentchange",e,!1),this.enabled=!1,this.standing=!1,this.getDevice=function(){return i},this.setDevice=function(t){void 0!==t&&(i=t)},this.getCamera=function(t){if(null===i)return t;i.depthNear=t.near,i.depthFar=t.far,i.getFrameData(n);var e=n.pose;null!==e.position?t.position.fromArray(e.position):t.position.set(0,0,0),null!==e.orientation&&t.quaternion.fromArray(e.orientation),t.updateMatrixWorld();var r=i.stageParameters;if(this.standing&&r&&(a.fromArray(r.sittingToStandingTransform),s.getInverse(a),t.matrixWorld.multiply(a),t.matrixWorldInverse.multiply(s)),!1===i.isPresenting)return t;c.near=t.near,u.near=t.near,c.far=t.far,u.far=t.far,h.matrixWorld.copy(t.matrixWorld),h.matrixWorldInverse.copy(t.matrixWorldInverse),c.matrixWorldInverse.fromArray(n.leftViewMatrix),u.matrixWorldInverse.fromArray(n.rightViewMatrix),this.standing&&r&&(c.matrixWorldInverse.multiply(s),u.matrixWorldInverse.multiply(s));var l=t.parent;null!==l&&(o.getInverse(l.matrixWorld),c.matrixWorldInverse.multiply(o),u.matrixWorldInverse.multiply(o)),c.matrixWorld.getInverse(c.matrixWorldInverse),u.matrixWorld.getInverse(u.matrixWorldInverse),c.projectionMatrix.fromArray(n.leftProjectionMatrix),u.projectionMatrix.fromArray(n.rightProjectionMatrix),h.projectionMatrix.copy(c.projectionMatrix);var p=i.getLayers();if(p.length){var d=p[0];null!==d.leftBounds&&4===d.leftBounds.length&&c.bounds.fromArray(d.leftBounds),null!==d.rightBounds&&4===d.rightBounds.length&&u.bounds.fromArray(d.rightBounds)}return h},this.getStandingMatrix=function(){return a},this.submitFrame=function(){i&&i.isPresenting&&i.submitFrame()},this.dispose=function(){window.removeEventListener("vrdisplaypresentchange",e)}}function Pe(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var i;switch(r){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":i=t.getExtension("WEBGL_compressed_texture_etc1");break;default:i=t.getExtension(r)}return null===i&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),e[r]=i,i}}}function Ce(){function t(){u.value!==i&&(u.value=i,u.needsUpdate=n>0),r.numPlanes=n,r.numIntersection=0}function e(t,e,i,n){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=u.value,!0!==n||null===a){var h=i+4*o,l=e.matrixWorldInverse;c.getNormalMatrix(l),(null===a||a.length=0){var u=n[s];if(void 0!==u){var h=u.normalized,l=u.itemSize,p=Ot.get(u);if(void 0===p)continue;var d=p.buffer,f=p.type,m=p.bytesPerElement;if(u.isInterleavedBufferAttribute){var g=u.data,v=g.stride,y=u.offset;g&&g.isInstancedInterleavedBuffer?(It.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):It.enableAttribute(c),Et.bindBuffer(Et.ARRAY_BUFFER,d),Et.vertexAttribPointer(c,l,f,h,v*m,(i*v+y)*m)}else u.isInstancedBufferAttribute?(It.enableAttributeAndDivisor(c,u.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=u.meshPerAttribute*u.count)):It.enableAttribute(c),Et.bindBuffer(Et.ARRAY_BUFFER,d),Et.vertexAttribPointer(c,l,f,h,0,i*l*m)}else if(void 0!==a){var b=a[s];if(void 0!==b)switch(b.length){case 2:Et.vertexAttrib2fv(c,b);break;case 3:Et.vertexAttrib3fv(c,b);break;case 4:Et.vertexAttrib4fv(c,b);break;default:Et.vertexAttrib1fv(c,b)}}}}It.disableUnusedAttributes()}}function h(){Zt||((Xt.getDevice()||window).requestAnimationFrame(l),Zt=!0)}function l(t){null!==Kt&&Kt(t),(Xt.getDevice()||window).requestAnimationFrame(l)}function p(t,e,r){if(t.visible){if(t.layers.test(e.layers))if(t.isLight)V.push(t),t.castShadow&&$.push(t);else if(t.isSprite)t.frustumCulled&&!yt.intersectsSprite(t)||W.push(t);else if(t.isLensFlare)X.push(t);else if(t.isImmediateRenderObject)r&&St.setFromMatrixPosition(t.matrixWorld).applyMatrix4(wt),H.push(t,null,t.material,St.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||yt.intersectsObject(t))){r&&St.setFromMatrixPosition(t.matrixWorld).applyMatrix4(wt);var i=Nt.update(t),n=t.material;if(Array.isArray(n))for(var o=i.groups,a=0,s=o.length;a=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p=0&&t.numSupportedMorphNormals++}var d=i.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(i.numClippingPlanes=bt.numPlanes,i.numIntersection=bt.numIntersection,d.clippingPlanes=bt.uniform),i.fog=e,i.lightsHash=kt.state.hash,t.lights&&(d.ambientLightColor.value=kt.state.ambient,d.directionalLights.value=kt.state.directional,d.spotLights.value=kt.state.spot,d.rectAreaLights.value=kt.state.rectArea,d.pointLights.value=kt.state.point,d.hemisphereLights.value=kt.state.hemi,d.directionalShadowMap.value=kt.state.directionalShadowMap,d.directionalShadowMatrix.value=kt.state.directionalShadowMatrix,d.spotShadowMap.value=kt.state.spotShadowMap,d.spotShadowMatrix.value=kt.state.spotShadowMatrix,d.pointShadowMap.value=kt.state.pointShadowMap,d.pointShadowMatrix.value=kt.state.pointShadowMatrix);var f=i.program.getUniforms(),m=tt.seqWithValue(f.seq,d);i.uniformsList=m}function x(t,e,r,i){ct=0;var n=Rt.get(r);if(xt&&(_t||t!==et)){var o=t===et&&r.id===Q;bt.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,n,o)}!1===r.needsUpdate&&(void 0===n.program?r.needsUpdate=!0:r.fog&&n.fog!==e?r.needsUpdate=!0:r.lights&&n.lightsHash!==kt.state.hash?r.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===bt.numPlanes&&n.numIntersection===bt.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(g(r,e,i),r.needsUpdate=!1);var a=!1,s=!1,c=!1,u=n.program,h=u.getUniforms(),l=n.shader.uniforms;if(It.useProgram(u.program)&&(a=!0,s=!0,c=!0),r.id!==Q&&(Q=r.id,s=!0),a||t!==et){if(h.setValue(Et,"projectionMatrix",t.projectionMatrix),Ct.logarithmicDepthBuffer&&h.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),et!==(rt||t)&&(et=rt||t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var p=h.map.cameraPosition;void 0!==p&&p.setValue(Et,St.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&h.setValue(Et,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){h.setOptional(Et,i,"bindMatrix"),h.setOptional(Et,i,"bindMatrixInverse");var d=i.skeleton;if(d){var f=d.bones;if(Ct.floatVertexTextures){if(void 0===d.boneTexture){var m=Math.sqrt(4*f.length);m=mp.nextPowerOfTwo(Math.ceil(m)),m=Math.max(m,4);var v=new Float32Array(m*m*4);v.set(d.boneMatrices);var y=new b(v,m,m,jl,Ol);d.boneMatrices=v,d.boneTexture=y,d.boneTextureSize=m}h.setValue(Et,"boneTexture",d.boneTexture),h.setValue(Et,"boneTextureSize",d.boneTextureSize)}else h.setOptional(Et,d,"boneMatrices")}}return s&&(h.setValue(Et,"toneMappingExposure",q.toneMappingExposure),h.setValue(Et,"toneMappingWhitePoint",q.toneMappingWhitePoint),r.lights&&D(l,c),e&&r.fog&&M(l,e),r.isMeshBasicMaterial?_(l,r):r.isMeshLambertMaterial?(_(l,r),E(l,r)):r.isMeshPhongMaterial?(_(l,r),r.isMeshToonMaterial?P(l,r):T(l,r)):r.isMeshStandardMaterial?(_(l,r),r.isMeshPhysicalMaterial?I(l,r):C(l,r)):r.isMeshDepthMaterial?(_(l,r),R(l,r)):r.isMeshDistanceMaterial?(_(l,r),L(l,r)):r.isMeshNormalMaterial?(_(l,r),O(l,r)):r.isLineBasicMaterial?(w(l,r),r.isLineDashedMaterial&&S(l,r)):r.isPointsMaterial?A(l,r):r.isShadowMaterial&&(l.color.value=r.color,l.opacity.value=r.opacity),void 0!==l.ltcMat&&(l.ltcMat.value=Mp.LTC_MAT_TEXTURE),void 0!==l.ltcMag&&(l.ltcMag.value=Mp.LTC_MAG_TEXTURE),tt.upload(Et,n.uniformsList,l,q)),h.setValue(Et,"modelViewMatrix",i.modelViewMatrix),h.setValue(Et,"normalMatrix",i.normalMatrix),h.setValue(Et,"modelMatrix",i.matrixWorld),u}function _(t,e){t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var r;if(e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var i=r.offset,n=r.repeat;t.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}}function w(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function S(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function A(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*lt,t.scale.value=.5*ht,t.map.value=e.map,null!==e.map){var r=e.map.offset,i=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,i.x,i.y)}}function M(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function E(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function T(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function P(t,e){T(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function C(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function I(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,C(t,e)}function R(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function L(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}function O(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function D(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}console.log("THREE.WebGLRenderer",fh);var N=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),k=void 0!==t.context?t.context:null,F=void 0!==t.alpha&&t.alpha,B=void 0===t.depth||t.depth,z=void 0===t.stencil||t.stencil,U=void 0!==t.antialias&&t.antialias,j=void 0===t.premultipliedAlpha||t.premultipliedAlpha,G=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,V=[],$=[],H=null,W=[],X=[];this.domElement=N,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=sl,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var q=this,Y=!1,Z=null,K=null,Q=-1,J="",et=null,rt=null,nt=new d,at=new d,st=null,ct=0,ut=N.width,ht=N.height,lt=1,pt=new d(0,0,ut,ht),dt=new d(0,0,ut,ht),vt=!1,yt=new ft,bt=new Ce,xt=!1,_t=!1,wt=new y,St=new v,At={geometries:0,textures:0},Mt={frame:0,calls:0,vertices:0,faces:0,points:0};this.info={render:Mt,memory:At,programs:null};var Et;try{var Tt={alpha:F,depth:B,stencil:z,antialias:U,premultipliedAlpha:j,preserveDrawingBuffer:G};if(null===(Et=k||N.getContext("webgl",Tt)||N.getContext("experimental-webgl",Tt)))throw null!==N.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Et.getShaderPrecisionFormat&&(Et.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),N.addEventListener("webglcontextlost",i,!1),N.addEventListener("webglcontextrestored",n,!1)}catch(t){console.error("THREE.WebGLRenderer: "+t)}var Pt,Ct,It,Rt,Lt,Ot,Dt,Nt,kt,Ft,zt,Ut,jt,Gt,Vt,$t,Ht,Wt;r();var Xt=new Te(q);this.vr=Xt;var Yt=new mt(q,Nt,Ct.maxTextureSize);this.shadowMap=Yt,this.getContext=function(){return Et},this.getContextAttributes=function(){return Et.getContextAttributes()},this.forceContextLoss=function(){var t=Pt.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=Pt.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return lt},this.setPixelRatio=function(t){void 0!==t&&(lt=t,this.setSize(ut,ht,!1))},this.getSize=function(){return{width:ut,height:ht}},this.setSize=function(t,e,r){var i=Xt.getDevice();i&&i.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(ut=t,ht=e,N.width=t*lt,N.height=e*lt,!1!==r&&(N.style.width=t+"px",N.style.height=e+"px"),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(){return{width:ut*lt,height:ht*lt}},this.setDrawingBufferSize=function(t,e,r){ut=t,ht=e,lt=r,N.width=t*r,N.height=e*r,this.setViewport(0,0,t,e)},this.setViewport=function(t,e,r,i){pt.set(t,ht-e-i,r,i),It.viewport(nt.copy(pt).multiplyScalar(lt))},this.setScissor=function(t,e,r,i){dt.set(t,ht-e-i,r,i),It.scissor(at.copy(dt).multiplyScalar(lt))},this.setScissorTest=function(t){It.setScissorTest(vt=t)},this.getClearColor=Ut.getClearColor,this.setClearColor=Ut.setClearColor,this.getClearAlpha=Ut.getClearAlpha,this.setClearAlpha=Ut.setClearAlpha,this.clear=function(t,e,r){var i=0;(void 0===t||t)&&(i|=Et.COLOR_BUFFER_BIT),(void 0===e||e)&&(i|=Et.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=Et.STENCIL_BUFFER_BIT),Et.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,r,i){this.setRenderTarget(t),this.clear(e,r,i)},this.dispose=function(){N.removeEventListener("webglcontextlost",i,!1),N.removeEventListener("webglcontextrestored",n,!1),zt.dispose(),Xt.dispose()},this.renderBufferImmediate=function(t,e,r){It.initAttributes();var i=Rt.get(t);t.hasPositions&&!i.position&&(i.position=Et.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=Et.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=Et.createBuffer()),t.hasColors&&!i.color&&(i.color=Et.createBuffer());var n=e.getAttributes();if(t.hasPositions&&(Et.bindBuffer(Et.ARRAY_BUFFER,i.position),Et.bufferData(Et.ARRAY_BUFFER,t.positionArray,Et.DYNAMIC_DRAW),It.enableAttribute(n.position),Et.vertexAttribPointer(n.position,3,Et.FLOAT,!1,0,0)),t.hasNormals){if(Et.bindBuffer(Et.ARRAY_BUFFER,i.normal),!r.isMeshPhongMaterial&&!r.isMeshStandardMaterial&&!r.isMeshNormalMaterial&&!0===r.flatShading)for(var o=0,a=3*t.count;o0&&m.renderInstances(i,w,A):m.render(w,A)}},this.compile=function(t,e){V.length=0,$.length=0,t.traverse(function(t){t.isLight&&(V.push(t),t.castShadow&&$.push(t))}),kt.setup(V,$,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=Ct.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+Ct.maxTextures),ct+=1,t},this.setTexture2D=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTarget&&(t||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),Lt.setTexture2D(e,r)}}(),this.setTexture=function(){var t=!1;return function(e,r){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),Lt.setTexture2D(e,r)}}(),this.setTextureCube=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?Lt.setTextureCube(e,r):Lt.setTextureCubeDynamic(e,r)}}(),this.getRenderTarget=function(){return Z},this.setRenderTarget=function(t){Z=t,t&&void 0===Rt.get(t).__webglFramebuffer&&Lt.setupRenderTarget(t);var e=null,r=!1;if(t){var i=Rt.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(e=i[t.activeCubeFace],r=!0):e=i,nt.copy(t.viewport),at.copy(t.scissor),st=t.scissorTest}else nt.copy(pt).multiplyScalar(lt),at.copy(dt).multiplyScalar(lt),st=vt;if(K!==e&&(Et.bindFramebuffer(Et.FRAMEBUFFER,e),K=e),It.viewport(nt),It.scissor(at),It.setScissorTest(st),r){var n=Rt.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,n.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,r,i,n,o){if(t&&t.isWebGLRenderTarget){var a=Rt.get(t).__webglFramebuffer;if(a){var s=!1;a!==K&&(Et.bindFramebuffer(Et.FRAMEBUFFER,a),s=!0);try{var c=t.texture,u=c.format,h=c.type;if(u!==jl&&Wt.convert(u)!==Et.getParameter(Et.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Tl||Wt.convert(h)===Et.getParameter(Et.IMPLEMENTATION_COLOR_READ_TYPE)||h===Ol&&(Pt.get("OES_texture_float")||Pt.get("WEBGL_color_buffer_float"))||h===Dl&&Pt.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");Et.checkFramebufferStatus(Et.FRAMEBUFFER)===Et.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-i&&r>=0&&r<=t.height-n&&Et.readPixels(e,r,i,n,Wt.convert(u),Wt.convert(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&Et.bindFramebuffer(Et.FRAMEBUFFER,K)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function Le(t,e){this.name="",this.color=new et(t),this.density=void 0!==e?e:25e-5}function Oe(t,e,r){this.name="",this.color=new et(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function De(){bt.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Ne(t,e,r,i,n){bt.call(this),this.lensFlares=[],this.positionScreen=new v,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,i,n)}function ke(t){at.call(this),this.type="SpriteMaterial",this.color=new et(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Fe(t){bt.call(this),this.type="Sprite",this.material=void 0!==t?t:new ke}function Be(){bt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ze(t,e){var r=this;if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,n=this.bones.length;i=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0)}p.call(this,t,e,r,i,n,o,a,s,c),this.generateMipmaps=!1;var h=this;u()}function Ze(t,e,r,i,n,o,a,s,c,u,h,l){p.call(this,null,o,a,s,c,u,i,n,h,l),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Ke(t,e,r,i,n,o,a,s,c,u){if((u=void 0!==u?u:$l)!==$l&&u!==Hl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===$l&&(r=Il),void 0===r&&u===Hl&&(r=Bl),p.call(this,null,i,n,o,a,s,u,r,c),this.image={width:t,height:e},this.magFilter=void 0!==a?a:_l,this.minFilter=void 0!==s?s:_l,this.flipY=!1,this.generateMipmaps=!1}function Qe(t){Bt.call(this),this.type="WireframeGeometry";var e,r,i,n,o,a,s,c,u,h,l=[],p=[0,0],d={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,i=m.length;e=0?(l=t(g-1e-5,m,l),p.subVectors(h,l)):(l=t(g+1e-5,m,l),p.subVectors(l,h)),m-1e-5>=0?(l=t(g,m-1e-5,l),d.subVectors(h,l)):(l=t(g,m+1e-5,l),d.subVectors(l,h)),u.crossVectors(p,d).normalize(),s.push(u.x,u.y,u.z),c.push(g,m)}}for(i=0;i.9&&o<.1&&(e<.2&&(f[t+0]+=1),r<.2&&(f[t+2]+=1),i<.2&&(f[t+4]+=1))}}function a(t){d.push(t.x,t.y,t.z)}function s(e,r){var i=3*e;r.x=t[i+0],r.y=t[i+1],r.z=t[i+2]}function c(){for(var t=new v,e=new v,r=new v,i=new v,n=new l,o=new l,a=new l,s=0,c=0;s0)&&f.push(w,S,M),(c!==r-1||u0&&c(!0),e>0&&c(!1)),this.setIndex(h),this.addAttribute("position",new Dt(p,3)),this.addAttribute("normal",new Dt(d,3)),this.addAttribute("uv",new Dt(f,2))}function Lr(t,e,r,i,n,o,a){Ir.call(this,0,t,e,r,i,n,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:o,thetaLength:a}}function Or(t,e,r,i,n,o,a){Rr.call(this,0,t,e,r,i,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:o,thetaLength:a}}function Dr(t,e,r,i){Mt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},this.fromBufferGeometry(new Nr(t,e,r,i)),this.mergeVertices()}function Nr(t,e,r,i){Bt.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var n,o,a=[],s=[],c=[],u=[],h=new v,p=new l;for(s.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,n=3;o<=e;o++,n+=3){var d=r+o/e*i;h.x=t*Math.cos(d),h.y=t*Math.sin(d),s.push(h.x,h.y,h.z),c.push(0,0,1),p.x=(s[n]/t+1)/2,p.y=(s[n+1]/t+1)/2,u.push(p.x,p.y)}for(n=1;n<=e;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new Dt(s,3)),this.addAttribute("normal",new Dt(c,3)),this.addAttribute("uv",new Dt(u,2))}function kr(t){at.call(this),this.type="ShadowMaterial",this.color=new et(0),this.opacity=1,this.lights=!0,this.transparent=!0,this.setValues(t)}function Fr(t){st.call(this,t),this.type="RawShaderMaterial"}function Br(t){at.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new et(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new l(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zr(t){Br.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function Ur(t){at.call(this),this.type="MeshPhongMaterial",this.color=new et(16777215),this.specular=new et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new l(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=il,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function jr(t){Ur.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Gr(t){at.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new l(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Vr(t){at.call(this),this.type="MeshLambertMaterial",this.color=new et(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=il,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function $r(t){Ge.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function Hr(t,e,r){var i=this,n=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){a++,!1===n&&void 0!==i.onStart&&i.onStart(t,o,a),n=!0},this.itemEnd=function(t){o++,void 0!==i.onProgress&&i.onProgress(t,o,a),o===a&&(n=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)}}function Wr(t){this.manager=void 0!==t?t:Fp}function Xr(t){this.manager=void 0!==t?t:Fp}function qr(t){this.manager=void 0!==t?t:Fp}function Yr(t,e){bt.call(this),this.type="Light",this.color=new et(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Zr(t,e,r){Yr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(bt.DefaultUp),this.updateMatrix(),this.groundColor=new et(e)}function Kr(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new l(512,512),this.map=null,this.matrix=new y}function Qr(){Kr.call(this,new wt(50,1,.5,500))}function Jr(t,e,r,i,n,o){Yr.call(this,t,e),this.type="SpotLight",this.position.copy(bt.DefaultUp),this.updateMatrix(),this.target=new bt,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new Qr}function ti(t,e,r,i){Yr.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==i?i:1,this.shadow=new Kr(new wt(90,1,.5,500))}function ei(){Kr.call(this,new _t(-5,5,5,-5,.5,500))}function ri(t,e){Yr.call(this,t,e),this.type="DirectionalLight",this.position.copy(bt.DefaultUp),this.updateMatrix(),this.target=new bt,this.shadow=new ei}function ii(t,e){Yr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function ni(t,e,r,i){Yr.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==i?i:10}function oi(t,e,r,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function ai(t,e,r,i){oi.call(this,t,e,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function si(t,e,r,i){oi.call(this,t,e,r,i)}function ci(t,e,r,i){oi.call(this,t,e,r,i)}function ui(t,e,r,i){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=Bp.convertArray(e,this.TimeBufferType),this.values=Bp.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function hi(t,e,r,i){ui.call(this,t,e,r,i)}function li(t,e,r,i){oi.call(this,t,e,r,i)}function pi(t,e,r,i){ui.call(this,t,e,r,i)}function di(t,e,r,i){ui.call(this,t,e,r,i)}function fi(t,e,r,i){ui.call(this,t,e,r,i)}function mi(t,e,r){ui.call(this,t,e,r)}function gi(t,e,r,i){ui.call(this,t,e,r,i)}function vi(t,e,r,i){ui.apply(this,arguments)}function yi(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=mp.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function bi(t){this.manager=void 0!==t?t:Fp,this.textures={}}function xi(t){this.manager=void 0!==t?t:Fp}function _i(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function wi(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:Fp,this.withCredentials=!1}function Si(t,e,r,i,n){var o=.5*(i-e),a=.5*(n-r),s=t*t;return(2*r-2*i+o+a)*(t*s)+(-3*r+3*i-2*o-a)*s+o*t+r}function Ai(t,e){var r=1-t;return r*r*e}function Mi(t,e){return 2*(1-t)*t*e}function Ei(t,e){return t*t*e}function Ti(t,e,r,i){return Ai(t,e)+Mi(t,r)+Ei(t,i)}function Pi(t,e){var r=1-t;return r*r*r*e}function Ci(t,e){var r=1-t;return 3*r*r*t*e}function Ii(t,e){return 3*(1-t)*t*t*e}function Ri(t,e){return t*t*t*e}function Li(t,e,r,i,n){return Pi(t,e)+Ci(t,r)+Ii(t,i)+Ri(t,n)}function Oi(){this.arcLengthDivisions=200}function Di(t,e){Oi.call(this),this.v1=t,this.v2=e}function Ni(){Oi.call(this),this.curves=[],this.autoClose=!1}function ki(t,e,r,i,n,o,a,s){Oi.call(this),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function Fi(t){Oi.call(this),this.points=void 0===t?[]:t}function Bi(t,e,r,i){Oi.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=i}function zi(t,e,r){Oi.call(this),this.v0=t,this.v1=e,this.v2=r}function Ui(t){Ni.call(this),this.currentPoint=new l,t&&this.fromPoints(t)}function ji(){Ui.apply(this,arguments),this.holes=[]}function Gi(){this.subPaths=[],this.currentPath=null}function Vi(t){this.data=t}function $i(t){this.manager=void 0!==t?t:Fp}function Hi(t,e,r){bt.call(this),this.type="CubeCamera";var i=new wt(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new v(1,0,0)),this.add(i);var n=new wt(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new v(-1,0,0)),this.add(n);var o=new wt(90,1,t,e);o.up.set(0,0,1),o.lookAt(new v(0,1,0)),this.add(o);var a=new wt(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new v(0,-1,0)),this.add(a);var s=new wt(90,1,t,e);s.up.set(0,-1,0),s.lookAt(new v(0,0,1)),this.add(s);var c=new wt(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new v(0,0,-1)),this.add(c);var u={format:Ul,magFilter:Al,minFilter:Al};this.renderTarget=new m(r,r,u),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,i,r),r.activeCubeFace=1,t.render(e,n,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,s,r),r.texture.generateMipmaps=u,r.activeCubeFace=5,t.render(e,c,r),t.setRenderTarget(null)},this.clear=function(t,e,r,i){for(var n=this.renderTarget,o=0;o<6;o++)n.activeCubeFace=o,t.setRenderTarget(n),t.clear(e,r,i);t.setRenderTarget(null)}}function Wi(){bt.call(this),this.type="AudioListener",this.context=Wp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Xi(t){bt.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function qi(t){Xi.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Yi(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function Zi(t,e,r){this.binding=t,this.valueSize=r;var i,n=Float64Array;switch(e){case"quaternion":i=this._slerp;break;case"string":case"bool":n=Array,i=this._select;break;default:i=this._lerp}this.buffer=new n(4*r),this._mixBufferRegion=i,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function Ki(t,e,r){var i=r||Qi.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}function Qi(t,e,r){this.path=e,this.parsedPath=r||Qi.parseTrackName(e),this.node=Qi.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Ji(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var i=e.tracks,n=i.length,o=new Array(n),a={endingStart:rp,endingEnd:rp},s=0;s!==n;++s){var c=i[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ep,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function tn(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function en(){Bt.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function rn(t,e,r,i){this.uuid=mp.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===i}function nn(t,e){this.uuid=mp.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function on(t,e,r){nn.call(this,t,e),this.meshPerAttribute=r||1}function an(t,e,r){Et.call(this,t,e),this.meshPerAttribute=r||1}function sn(t,e){return t.distance-e.distance}function cn(t,e,r,i){if(!1!==t.visible&&(t.raycast(e,r),!0===i))for(var n=t.children,o=0,a=n.length;o1?u.pop().toLowerCase():"",l=e.match(/^(.+):\/\/(.+)$/);l&&(i=l[1].toLowerCase(),e=l[2]);var p=e.substring(0,e.lastIndexOf("/")+1);if(n.includes(h)){r=h;var d=e.length-h.length-1;h=e.substr(0,d).split(".").pop().toLowerCase();var f=c.length-h.length-1;c=c.substr(0,f)}else r=!1;return{path:e,name:s,ext:h,base:c,dir:p,compressed:r,protocol:i,src:t,query:a}}function Gn(t,e){return te?1:0}function Vn(t,e,r){void 0===r&&(r=Gn);for(var i=0,n=t.length-1;i<=n;){var o=i+n>>1,a=r(e,t[o]);if(a>0)i=o+1;else{if(!(a<0))return o;n=o-1}}return-i-1}function $n(t,e){var r=t.length-1;if(t[r]>1;t[n]>=e?r=n-1:i=n+1}return r+1}function Hn(t,e){if(t[0]>e)return-1;for(var r=0,i=t.length-1;r<=i;){var n=r+i>>1;t[n]>e?i=n-1:r=n+1}return r-1}function Wn(t,e,r){var i=$n(t,e),n=Hn(t,r);return-1===i||-1===n||i>n?0:n-i+1}function Xn(t){return t.sort().filter(function(t,e,r){return 0===e||t!==r[e-1]})}function qn(t){if(t.length>28672){for(var e=[],r=0;r65535?Uint32Array:Uint16Array)(t)}function Qn(t){return Array.isArray(t)?t:[t]}function Jn(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function to(t,e){return t instanceof e?t:new e(t)}function eo(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function ro(t){return eo(t,l)}function io(t){return eo(t,v)}function no(t){return eo(t,y)}function oo(t){return eo(t,g)}function ao(t){return to(t,Float32Array)}function so(t){return Nn(t,"").toString().toLowerCase()}function co(t){return.01745*t}function uo(t){return 57.29578*t}function ho(){for(var t,e=0,r=0;r<36;r++)8===r||13===r||18===r||23===r?Pf[r]="-":14===r?Pf[r]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Pf[r]=Tf[19===r?3&t|8:t]);return Pf.join("")}function lo(t){return t-=t>>1&1431655765,16843009*((t=(858993459&t)+(t>>2&858993459))+(t>>4)&252645135)>>24}function po(t,e,r){return(t-e)/(r-e)}function fo(t,e,r){return Math.max(e,Math.min(r,t))}function mo(t){return fo(t,0,100)}function go(t){return fo(t,0,1)}function vo(t,e,r){return t+(e-t)*r}function yo(t,e,r,i,n,o){var a=(r-t)*o,s=(i-e)*o,c=n*n;return(2*e-2*r+a+s)*(n*c)+(-3*e+3*r-2*a-s)*c+a*n+e}function bo(t,e,r){return(r=go(po(r,t,e)))*r*(3-2*r)}function xo(t,e,r){if(t>e)return t;var i=t/e;return((2*r-e)*i+(2*e-3*r))*i*i+r}function _o(t,e,r,i,n){this._listener=e,this._isOnce=r,this.context=i,this._signal=t,this._priority=n||0}function wo(t,e){if("function"!=typeof t)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}function So(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){So.prototype.dispatch.apply(t,arguments)}}function Ao(t){var e={operator:void 0,rules:[]};if(!t)return e;var r,i,n=e,o=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());for(var a,s=t.split(/\s+/),c=function(t){r={operator:t,rules:[]},void 0===n?(n=r,e=r):(n.rules.push(r),o.push(n),n=r)},u=function(t){i=n,void 0===(n=o.pop())&&(c(t),h(i))},h=function(t){n.rules.push(t)},l=0;l0)if("NOT"===d)a=1;else if(1===a)a=2;else{if(2!==a)throw new Error("something went wrong with 'not'");a=!1,u()}if("AND"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){var f=Lf[d];if(void 0===f)if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("LIGAND"!==d)if(-1===Of.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(p.length>=1&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))h({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(g.length>1&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var v=g[0].split("%");v.length>1&&m.rules.push({altloc:v[1]});var y=v[0].split(".");if(y.length>1&&y[1]){if(y[1].length>4)throw new Error("atomname must be one to four characters");m.rules.push({atomname:y[1].substring(0,4).toUpperCase()})}var b=y[0].split(":");b.length>1&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(x.length>1&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var S=x[0].split("-");if(1===S.length){if(S=parseInt(S[0]),isNaN(S))throw new Error("resi must be an integer");_&&(S*=-1),m.rules.push({resno:S})}else{if(2!==S.length)throw new Error("resi range must contain one '-'");_&&(S[0]*=-1),w&&(S[1]*=-1),m.rules.push({resno:[parseInt(S[0]),parseInt(S[1])]})}}if(1===m.rules.length)h(m.rules[0]);else{if(!(m.rules.length>1))throw new Error("empty selection chunk");h(m)}}else{var A=d.substr(1,p.length-2).split(","),M=A.length>1?A:A[0];h({resname:M})}else h({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),h({element:d.substr(1)});else{for(var E=p.substr(1).split(","),T=0,P=E.length;Tt.resno||e.resno[1]t.resno||e.resno[1]0?t:null}function Ro(t,e){return e&&(t=Io(t,function(t){return void 0!==t.keyword&&!Df.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))})),Co(t,Mo)}function Lo(t,e){return e&&(t=Io(t,function(t){return!(void 0===t.keyword||!Df.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))})),Co(t,Eo)}function Oo(t,e){return e&&(t=Io(t,function(t){return void 0!==t.keyword&&!Nf.includes(t.keyword)||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode))))))})),Co(t,To)}function Do(t,e){return e&&(t=Io(t,function(t){return void 0!==t.keyword||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode)))))))})),Co(t,Po)}function No(t){var e=t;return t.forEach(function(t){t.__deps&&Array.prototype.push.apply(e,No(t.__deps))}),e}function ko(t){return Xn(No(t)).map(function(t){return t.toString()}).join("\n\n\n")}function Fo(t){var e=t.data.__name,r=t.data.__postId;if(void 0===e)console.error("message __name undefined");else if(void 0===self.func)console.error("worker func undefined",e);else{self.func(t,function(t,e){t=t||{},void 0!==r&&(t.__postId=r);try{self.postMessage(t,e)}catch(e){console.error("self.postMessage:",e),self.postMessage(t)}})}}function Bo(t,e){var r="'use strict';\n\n"+ko(e);return r+="\n\n\nself.func = "+t.toString()+";",r+="\n\n\nself.onmessage = "+Fo.toString()+";",new window.Blob([r],{type:"application/javascript"})}function zo(t){am=t}function Uo(t){sm=t}function jo(t){var e=jn(t),r=dm.get(e.protocol);return r&&!(e=jn(r.getUrl(e.src))).ext&&r.getExt&&(e.ext=r.getExt(t)),e}function Go(t,e){var r,i=Object.assign(jo(t),e);return mm.names.includes(i.ext)?r=Em:hm.includes(i.ext)?r=Cm:"plugin"===i.ext&&(r=Im),r?new r(i.src,i).load():Promise.reject(new Error("autoLoad: ext '"+i.ext+"' unknown"))}function Vo(t){return $o(Ho(t),arguments)}function $o(t,e){var r,i,n,o,a,s,c,u,h,l=1,p=t.length,d="";for(i=0;i=0),o.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,o.width?parseInt(o.width):0);break;case"e":r=o.precision?parseFloat(r).toExponential(o.precision):parseFloat(r).toExponential();break;case"f":r=o.precision?parseFloat(r).toFixed(o.precision):parseFloat(r);break;case"g":r=o.precision?String(Number(r.toPrecision(o.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=o.precision?r.substring(0,o.precision):r;break;case"t":r=String(!!r),r=o.precision?r.substring(0,o.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=o.precision?r.substring(0,o.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=o.precision?r.substring(0,o.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}Om.json.test(o.type)?d+=r:(!Om.number.test(o.type)||u&&!o.sign?h="":(h=u?"+":"-",r=r.toString().replace(Om.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",c=o.width-(h+r).length,a=o.width&&c>0?s.repeat(c):"",d+=o.align?h+r+a:"0"===s?h+a+r:a+h+r)}return d}function Ho(t){if(Dm[t])return Dm[t];for(var e,r=t,i=[],n=0;r;){if(null!==(e=Om.text.exec(r)))i.push(e[0]);else if(null!==(e=Om.modulo.exec(r)))i.push("%");else{if(null===(e=Om.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){n|=1;var o=[],a=e[2],s=[];if(null===(s=Om.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(s[1]);""!==(a=a.substring(s[0].length));)if(null!==(s=Om.key_access.exec(a)))o.push(s[1]);else{if(null===(s=Om.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(s[1])}e[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");i.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}r=r.substring(e[0].length)}return Dm[t]=i}function Wo(){this.signals={updated:new So},this.begin(),this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0}function Xo(t){if(void 0===t)return"";var e=[];for(var r in t){var i=t[r];!1!==i&&e.push("#define "+r+" "+i)}return e.join("\n")+"\n"}function qo(t,e){e=e||{};var r=t+"|";for(var i in e)r+=i+":"+e[i];if(!Gm[r]){var n=Xo(e),o=gm.get("shader/"+t);if(!o)throw new Error("empty shader, '"+t+"'");o=o.replace(jm,function(t,e){var r="shader/chunk/"+e+".glsl";return gm.get(r)||Tp[e]||""}),Gm[r]=n+o}return Gm[r]}function Yo(t,e,r,i){function n(e){var i=e%s,n=Math.floor(e/s),o=i*d,a=n*f;r.camera.setViewOffset(d*s,f*s,o,a,d,f),r.render(),c?m.drawImage(t.domElement,Math.floor(o/2),Math.floor(a/2),Math.ceil(d/2),Math.ceil(f/2)):m.drawImage(t.domElement,Math.floor(o),Math.floor(a),Math.ceil(d),Math.ceil(f)),"function"==typeof u&&u(e+1,l,!1)}function o(){r.setSampling(g),r.camera.view=null,"function"==typeof h&&h(l+1,l,!1)}var a=i||{},s=void 0!==a.factor?a.factor:2,c=void 0!==a.antialias&&a.antialias,u=a.onProgress,h=a.onFinish;c&&(s*=2);var l=s*s,p=document.createElement("canvas"),d=r.width,f=r.height;c?(p.width=d*s/2,p.height=f*s/2):(p.width=d*s,p.height=f*s);var m=p.getContext("2d"),g=r.sampleLevel;r.setSampling(-1),this.render=function(){for(var t=0;t<=l;++t)t===l?o():n(t)},this.renderAsync=function(){for(var t=0,e=0;e<=l;++e)setTimeout(function(){t===l?o():n(t),t+=1},0)},this.canvas=p}function Zo(t,e,r,i,n){r=r||1,i=i||0;var o,a,s=n?n.length:t.length/r,c=0,u=0;if(n)for(a=0;ae?1:t=u&&e(t[o],l)>0;)t[o+1]=t[o],--o;t[o+1]=l}if(-1===c)break;h=s[c--],u=s[c--]}else{for(a=h,n(u+h>>1,o=u+1),e(t[u],t[h])>0&&n(u,h),e(t[o],t[h])>0&&n(o,h),e(t[u],t[o])>0&&n(u,o),l=t[o];;){do{o++}while(e(t[o],l)<0);do{a--}while(e(t[a],l)>0);if(a=a-u?(s[++c]=o,s[++c]=h,h=a-1):(s[++c]=u,s[++c]=a-1,u=o)}return t}function sa(t){for(var e=-1/0,r=0,i=t.length;re&&(e=t[r]);return e}function ca(t){for(var e=1/0,r=0,i=t.length;r=0;a--){for(o=h-1;o>=0;o--)if(c=4*(a*h+o),l[c]!==e||l[c+1]!==r||l[c+2]!==i||l[c+3]!==n){s=!0;break}if(s)break}var f=a;for(s=!1,o=h-1;o>=0;o--){for(a=u-1;a>=0;a--)if(c=4*(a*h+o),l[c]!==e||l[c+1]!==r||l[c+2]!==i||l[c+3]!==n){s=!0;break}if(s)break}var m=o,g=document.createElement("canvas");return g.width=m-d,g.height=f-p,g.getContext("2d").drawImage(t,d,p,g.width,g.height,0,0,g.width,g.height),g}function da(t,e){function r(e){var r=s;c&&(r*=2),e&&(r=1/r),t.scene.traverse(function(t){var e=t.material;e&&e.linewidth&&(e.linewidth*=r),e&&e.uniforms&&e.uniforms.size&&void 0===e.uniforms.size.__seen&&(e.uniforms.size.value*=r,e.uniforms.size.__seen=!0),e&&e.uniforms&&e.uniforms.linewidth&&void 0===e.uniforms.linewidth.__seen&&(e.uniforms.linewidth.value*=r,e.uniforms.linewidth.__seen=!0)}),t.scene.traverse(function(t){var e=t.material;e&&e.uniforms&&e.uniforms.size&&delete e.uniforms.size.__seen,e&&e.uniforms&&e.uniforms.linewidth&&delete e.uniforms.linewidth.__seen})}function i(t){if(a){var e=d;return pa(t,u?0:255*e.r,u?0:255*e.g,u?0:255*e.b,u?0:255)}return t}function n(t,e,r){"function"==typeof o.onProgress&&o.onProgress(t,e,r)}var o=e||{},a=Nn(o.trim,!1),s=Nn(o.factor,1),c=Nn(o.antialias,!1),u=Nn(o.transparent,!1),h=t.renderer,l=t.camera,p=h.getClearAlpha(),d=h.getClearColor();return new Promise(function(e){var o=new Yo(h,l,t,{factor:s,antialias:c,onProgress:n,onFinish:function(a,s){i(o.canvas).toBlob(function(i){h.setClearAlpha(p),r(!0),t.requestRender(),n(s,s,!0),e(i)},"image/png")}});h.setClearAlpha(u?0:1),r(),o.renderAsync()})}function fa(t,e){t.traverseVisible(function(t){if(t instanceof Xe&&t.sortParticles){var r=t.geometry.attributes,i=r.position.count;if(0!==i){Km.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),Qm.multiplyMatrices(e.projectionMatrix,Km);var n,o,a,s;t.userData.sortData?(n=t.userData.sortData,a=n.__zArray,o=n.__sortArray,s=n.__cmpFn):(a=new Float32Array(i),o=new Uint32Array(i),n={__zArray:a,__sortArray:o,__cmpFn:s=function(t,e){var r=a[t],i=a[e];return r>i?1:r500&&!L&&O<3&&-1!==O){var e=O;O=3,I=!0,S(),L=!0,O=e,t.Debug&&cm.log("rendered still frame")}window.requestAnimationFrame(l)}function p(){I||(window.performance.now()-F.startTime>22&&(F.begin(),L=!1),I=!0,window.requestAnimationFrame(function(){S(),F.update()}))}function d(){var t=co(B.fov),e=2*Math.tan(t/2)*-U.position.z;z.zoom=E/e}function m(){var t=k;(D=pt.copy(U.position).length())||(U.position.set(0,0,t.cameraZ),D=Math.abs(t.cameraZ)),N=Math.max(10,.5*lt),((N+=ct.getCenter(pt).length())===1/0||N===-1/0||isNaN(N))&&(N=50);var e=(50-t.clipNear)/50,r=-(50-t.clipFar)/50;U.near=D-N*e,U.far=D+N*r;var i=(50-t.fogNear)/50,n=-(50-t.fogFar)/50,o=j.fog;o.color.set(t.fogColor),o.near=D-N*i,o.far=D+N*n,"PerspectiveCamera"===U.type?(U.near=Math.max(.1,t.clipDist,U.near),U.far=Math.max(1,U.far),o.near=Math.max(.1,o.near),o.far=Math.max(1,o.far)):"OrthographicCamera"===U.type&&0===t.clipNear&&t.clipDist>0&&D+U.zoom>2*-t.clipDist&&(U.near+=U.zoom+t.clipDist)}function g(){U.updateMatrix(),U.updateMatrixWorld(!0),U.matrixWorldInverse.getInverse(U.matrixWorld),U.updateProjectionMatrix(),ma(j,U,Z,D,N),fa(j,U)}function y(t,e,r,i){W.visible=t,X.visible=e,q.visible=r,Y.visible=i}function b(){pt.copy(U.position).setLength(100*lt),G.position.copy(U.position).add(pt),G.color.set(k.lightColor),G.intensity=k.lightIntensity,V.color.set(k.ambientColor),V.intensity=k.ambientIntensity}function x(){Z.clearTarget(Q),y(!1,!0,!1,!1),Z.render(j,U,Q),h(),Z.setRenderTarget(null)}function _(e){e?Z.clearTarget(e):Z.clear(),y(!1,!1,!0,!1),Z.render(j,U,e),e?Z.clearTarget(e,!1,!0,!1):Z.clearDepth(),h(),y(!0,!1,!1,t.Debug),Z.render(j,U,e),h()}function w(){var t=qm[Math.max(0,Math.min(O,5))],e=1/t.length;rt.tForeground.value=J.texture;for(var r=J.width,i=J.height,n=0;n0?w():_(),R=t,C=!1,I=!1)}var A,M,E,T={ticked:new So};if((A="string"==typeof e?document.getElementById(e):e instanceof window.Element?e:document.createElement("div"))===document.body)M=window.innerWidth||1,E=window.innerHeight||1;else{var P=A.getBoundingClientRect();M=P.width||1,E=P.height||1}var C,I,R,L,O,D,N,k;k={fogColor:new et(0),fogNear:50,fogFar:100,backgroundColor:new et(0),cameraType:"perspective",cameraFov:40,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,lightColor:new et(14540253),lightIntensity:1,ambientColor:new et(14540253),ambientIntensity:.2,sampleLevel:0};var F;F=new Wo;var B,z,U;!function(){var t=new v(0,0,0);(B=new wt(k.cameraFov,M/E)).position.z=k.cameraZ,B.lookAt(t),(z=new _t(M/-2,M/2,E/2,E/-2)).position.z=k.cameraZ,z.lookAt(t),(U="orthographic"===k.cameraType?z:B).updateProjectionMatrix()}();var j,G,V,$,H,W,X,q,Y;r();var Z,K,Q,J,tt,rt,it,nt,ot;if(!1===function(){var t=window.devicePixelRatio;try{Z=new Re({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return A.innerHTML=um,!1}Z.setPixelRatio(t),Z.setSize(M,E),Z.autoClear=!1,Z.sortObjects=!0;var e=Z.getContext();Uo(Z.extensions.get("EXT_frag_depth")),Z.extensions.get("OES_element_index_uint"),zo("Safari"!==rm&&(Z.extensions.get("OES_texture_float")&&Z.extensions.get("WEBGL_color_buffer_float")||Z.extensions.get("OES_texture_float")&&ga(e,e.FLOAT))),A.appendChild(Z.domElement);var r=M*t,i=E*t;Z.extensions.get("OES_texture_float"),K=Z.extensions.get("OES_texture_half_float")&&ga(e,36193),Z.extensions.get("WEBGL_color_buffer_float"),(Q=new f(r,i,{minFilter:_l,magFilter:_l,stencilBuffer:!1,format:jl,type:am?Ol:Tl})).texture.generateMipmaps=!1,Z.clearTarget(Q),Z.setRenderTarget(null),J=new f(r,i,{minFilter:Al,magFilter:Al,format:jl}),tt=new f(r,i,{minFilter:_l,magFilter:_l,format:jl,type:K?Dl:am?Ol:Tl}),it=new st({uniforms:rt={tForeground:{type:"t",value:null},scale:{type:"f",value:1}},vertexShader:qo("Quad.vert"),fragmentShader:qo("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:Ch,depthTest:!1,depthWrite:!1}),nt=new _t(-1,1,1,-1,0,1),ot=(new De).add(new Xt(new jt(2,2),it))}())return this.container=A,void cm.error("Viewer: could not initialize renderer");var at,ct=new ht,ut=new v,lt=0;!function(){var t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),e=new Float32Array(24),r=new Bt;r.setIndex(new Et(t,1)),r.addAttribute("position",new Et(e,3));var i=new st({uniforms:{uColor:{value:new et("skyblue")}},vertexShader:qo("BasicLine.vert"),fragmentShader:qo("BasicLine.frag"),linewidth:2});at=new $e(r,i),Y.add(at)}(),c(),s();var pt=new v,dt={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};this.container=A,this.stats=F,this.signals=T,this.rotationGroup=$,this.translationGroup=H,this.add=function(e,r){r?r.forEach(function(t){n(e,t)}):n(e),e.background?(q.add(e.group),q.add(e.wireframeGroup)):(W.add(e.group),W.add(e.wireframeGroup)),e.pickable&&X.add(e.pickingGroup),t.Debug&&i()},this.remove=function(e){H.children.forEach(function(t){t.remove(e.group),t.remove(e.wireframeGroup)}),e.pickable&&X.remove(e.pickingGroup),o(),t.Debug&&i()},this.clear=function(){cm.log("scene cleared"),j.remove($),r(),Z.clear()},this.getPickingPixels=a,this.getImage=function(t){return new Promise(function(e){if(t){var r=M*E*4,i=a();if(am){for(var n=new Uint8Array(r),o=0;o0)return 1<=0)return 1<n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return[Ca([e,r,i]),Ca([n,o,a])]}function Ea(t,e){for(var r=0,i=e.length;r>>1&1431655765,16843009*((t=(858993459&t)+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function $a(t,e){this.type=t,this.scale=e||1,this.max=10}function Ha(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}function Wa(t,e){for(var r=0,i=0,n=e.rows,o=e.cols,a=0,s=0,c=0,u=e.data,h=t.data;re?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}function rs(t,e,r,i,n,o,a,s){for(var c=2*by,u=xy,h=0,l=0,p=0,d=0,f=Math.max(o,30),m=0,g=0,v=0,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,E=0,T=0,P=0,C=0,I=0,R=0,L=4660,O=0,D=0,N=0,k=new Float64Array(a<<3);h>16)?D:-D,t[h*e+p]=O;for(d=0;d<2;d++)for(l=0;l>o),f=Math.max(0,e-i-c>>o),y=Math.max(0,r-i-u>>o),x=Math.min(h,t+i-s>>o),_=Math.min(l,e+i-c>>o),w=Math.min(p,r+i-u>>o),S=[],A=d;A<=x;++A)for(var E=f;E<=_;++E)for(var P=y;P<=w;++P){var I=b[(A*l+E)*p+P];if(I>0)for(var R=I-1,L=T[R],O=L+M[R],D=L;D>o),l=1+(a.max.y-c>>o),p=1+(a.max.z-u>>o),d=h*l*p,f=t.count,m=t.x,g=t.y,v=t.z,y=0,b=new Uint32Array(d),x=new Int32Array(f);for(i=0;i>o,w=g[i]-c>>o,S=v[i]-u>>o,A=(_*l+w)*p+S;1===(b[A]+=1)&&(y+=1),x[i]=A}var M=new Uint16Array(y);for(i=0,n=0;i0&&(b[i]=n+1,M[n]=E,n+=1)}var T=new Uint32Array(y);for(i=1;i0){var R=I-1;C[T[R]+P[R]]=i,P[R]+=1}}this.within=function(t,e,i,n){var o=[];return r(t,e,i,n,function(t){return o.push(t)}),o},this.eachWithin=r}function ds(e){var r=0,i=0,n={},o={},a=window.URL.createObjectURL(lm.get(e)),s=new window.Worker(a);lm.activeWorkerCount+=1,s.onmessage=function(i){r-=1;var a=i.data.__postId;t.Debug&&cm.timeEnd("Worker.postMessage "+e+" #"+a),n[a]&&n[a].call(s,i),delete n[a],delete o[a]},s.onerror=function(t){if(r-=1,t.data){var i=t.data.__postId;o[i]?o[i].call(s,t):cm.error("Worker.onerror",i,e,t),delete n[i],delete o[i]}else cm.error("Worker.onerror",e,t)},this.name=e,this.post=function(a,c,u,h){n[i]=u,o[i]=h,(a=a||{}).__name=e,a.__postId=i,a.__debug=t.Debug,t.Debug&&cm.time("Worker.postMessage "+e+" #"+i);try{s.postMessage(a,c)}catch(t){cm.error("worker.post:",t),s.postMessage(a)}return r+=1,i+=1,this},this.terminate=function(){s?(s.terminate(),window.URL.revokeObjectURL(a),lm.activeWorkerCount-=1):cm.log("no worker to terminate")},Object.defineProperties(this,{postCount:{get:function(){return i}},pending:{get:function(){return r}}})}function fs(t,e){e=Math.min(8,e||2);var r=[],i=0;this.name=t,this.maxCount=e,this.post=function(t,e,r,i){return this.getNextWorker().post(t,e,r,i),this},this.terminate=function(){r.forEach(function(t){t.terminate()})},this.getNextWorker=function(){for(var n,o=1/0,a=0;a=i){n=new ds(t),r.push(n),i+=1;break}var s=r[a];if(0===s.pending){n=s;break}s.pending=x){N=v,L=!0;break}if(L)break}if(L)break}for(L=!1,g=o;g=x){D=g,L=!0;break}if(L)break}if(L)break}for(L=!1,m=n;m=x){O=m,L=!0;break}if(L)break}if(L)break}for(L=!1,v=h;v>=s;--v){for(g=u;g>=o;--g){for(m=c;m>=n;--m)if(p=e*r*v+e*g+m,t[p]>=x){B=v,L=!0;break}if(L)break}if(L)break}for(L=!1,g=u;g>=o;--g){for(v=B;v>=s;--v){for(m=c;m>=n;--m)if(p=e*r*v+e*g+m,t[p]>=x){F=g,L=!0;break}if(L)break}if(L)break}for(L=!1,m=c;m>=n;--m){for(g=F;g>=o;--g){for(v=B;v>=s;--v)if(p=e*r*v+e*g+m,t[p]>=x){k=m,L=!0;break}if(L)break}if(L)break}_?(n=Math.max(0,O-1),o=Math.max(0,D-1),s=Math.max(0,N-1),c=Math.min(e-1,k+1),u=Math.min(r-1,F+1),h=Math.min(i-1,B+1)):(n=Math.max(1,O-1),o=Math.max(1,D-1),s=Math.max(1,N-1),c=Math.min(e-2,k+1),u=Math.min(r-2,F+1),h=Math.min(i-2,B+1))}var z=15;for(v=s;va&&(a=e);var c=o-n;if(0===c)return-1;var p=4*h;if(h+=1,1===c)return u[p]=n,u[p+1]=-1,u[p+2]=-1,u[p+3]=i,p;var d=n+Math.floor(c/2);l=e%3;for(var f,m,g,v,y,b=n,x=o-1;x>b;){for(v=t[3*s[g=b+x>>1]+l],m=s[g],s[g]=s[x],s[x]=m,y=b,f=b;ft[3*s[u[e]]+o])throw new Error("left child is > parent!");i+=n(a,r+1)}if(-1!==c){if(t[3*s[u[c]]+o]n&&c.pop()}var p,d,f=i(h)%3,m=3*s[u[h]],g=[t[m+0],t[m+1],t[m+2]],v=e(r,g),y=u[h+1],b=u[h+2];if(-1!==b||-1!==y){a(p=-1===b?y:-1===y?b:r[f]<=t[m+f]?y:b),(c.size()0&&(e=":"+Xn(t).join(" OR :")),new qf(e)}function Rs(e,r){if(r){t.Debug&&cm.time("assignSecondaryStructure");var i=[];e.eachModel(function(t){t.eachChain(function(t){i.push(t.chainname)})});var n=i.slice().sort(),o=[];n.forEach(function(t){o.push(i.indexOf(t))});var a=r.helices;(a=a.filter(function(t){return Vn(n,t[0])>=0})).sort(function(t,e){var r=t[0],i=e[0],a=t[1],s=e[1];if(r===i)return a===s?0:a=0})).sort(function(t,e){var r=t[0],i=e[0];if(r===i)return 0;var a=Vn(n,r),s=Vn(n,i);return o[a]=e;)r=Math.floor(r/e),n+=$y[r%e],i+=1;return i>=5&&cm.warn("chainname overflow"),n}function Os(e,r){t.Debug&&cm.time("calculateChainnames");var i=!0;if(e.eachChain(function(t){t.chainname&&(i=!1)}),i){var n=e.modelStore,o=e.chainStore,a=e.residueStore,s=function(t,e,r,i){for(var s=o.count,c=0;c500)){var c,u,h=[],l=[],p=[];if(o>50){var d=new Ps(e,!0),f=e.isCg()?1.2:2.3;for(c=a;c500)return void cm.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var l=t.getBonds(),p=l.atomIndices1,d=l.atomIndices2,f=l.bondOrders,m=p.length,g=0;g1&&(c.x-=1),s.x<0&&(c.x+=1),s.y>1&&(c.y-=1),s.y<0&&(c.y+=1),s.z>1&&(c.z-=1),s.z<0&&(c.z+=1),t&&c.add(t),u.setPosition(c),u.multiplyMatrices(i.fracToCart,u),u.multiply(i.cartToFrac),e.push(u)}),e}if(e.unitcell){t.Debug&&cm.time("buildUnitcellAssembly");var i=e.unitcell,n=e.center.clone().applyMatrix4(i.cartToFrac),o=Cs(i.spacegroup),a=new v,s=new v,c=new v;n.x>1&&(a.x-=1),n.x<0&&(a.x+=1),n.y>1&&(a.y-=1),n.y<0&&(a.y+=1),n.z>1&&(a.z-=1),n.z<0&&(a.z+=1);var u,h=new zy("UNITCELL"),l=r();if(e.biomolDict.NCS){u=[new y].concat(e.biomolDict.NCS.partList[0].matrixList);var p=[];l.forEach(function(t){u.forEach(function(e){p.push(t.clone().multiply(e))})}),h.addPart(p)}else h.addPart(l);var d=new v,f=new zy("SUPERCELL"),m=Array.prototype.concat.call(r(d.set(1,0,0)),r(d.set(0,1,0)),r(d.set(0,0,1)),r(d.set(-1,0,0)),r(d.set(0,-1,0)),r(d.set(0,0,-1)),r(d.set(1,1,0)),r(d.set(1,0,1)),r(d.set(0,1,1)),r(d.set(-1,-1,0)),r(d.set(-1,0,-1)),r(d.set(0,-1,-1)),r(d.set(1,-1,-1)),r(d.set(1,1,-1)),r(d.set(1,-1,1)),r(d.set(-1,1,1)),r(d.set(-1,-1,1)),r(d.set(-1,1,-1)),r(d.set(0,1,-1)),r(d.set(0,-1,1)),r(d.set(1,0,-1)),r(d.set(-1,0,1)),r(d.set(1,-1,0)),r(d.set(-1,1,0)),r(),r(d.set(1,1,1)),r(d.set(-1,-1,-1)));if(e.biomolDict.NCS){var g=[];m.forEach(function(t){u.forEach(function(e){g.push(t.clone().multiply(e))})}),f.addPart(g)}else f.addPart(m);e.biomolDict.UNITCELL=h,e.biomolDict.SUPERCELL=f,t.Debug&&cm.timeEnd("buildUnitcellAssembly")}}function Us(t){var e=t.trim().toUpperCase();parseInt(e.charAt(0))&&(e=e.substr(1)),parseInt(e.charAt(0))&&(e=e.substr(1));var r=e.length;if(0===r)return"";if(1===r)return e;if(2===r){if(-1!==Wy.indexOf(e))return e;if(-1!==Hy.indexOf(e[0]))return e[0]}return r>=3&&-1!==Hy.indexOf(e[0])?e[0]:""}function js(t){var e=t.bondHash,r=e.countArray,i=e.offsetArray,n=e.indexArray,o=t.getBondProxy();t.eachResidue(function(t){var e=t.residueType;if(void 0===e.bonds){var a=t.atomOffset,s=[],c=[],u=[],h={};t.eachAtom(function(t){for(var e=t.index,l=i[e],p=0,d=r[e];pm){var g=m;m=f,f=g}var v=f+"|"+m;void 0===h[v]&&(h[v]=!0,s.push(f-a),c.push(m-a),u.push(o.bondOrder))}}),e.bonds={atomIndices1:s,atomIndices2:c,bondOrders:u}}})}function Gs(t,e){return t+"|"+e}function Vs(t,e,r,i){return t+"|"+e.join(",")+"|"+(r?1:0)+"|"+(i||"")}function $s(t,e,r){if(0!==r[0]&&0!==r[8]&&0!==r[4])for(var i=t.length,n=r[0],o=r[1],a=r[2],s=-e[0]+n+n/2,c=-e[1]+o+o/2,u=-e[2]+a+a/2,h=0;h.9*e[3*n+n])if(o>0)for(var a=0;a<3;++a)t[i+a]-=e[3*n+a];else for(var s=0;s<3;++s)t[i+s]+=e[3*n+s]}return t}}function Ws(t,e,r){if(0!==e[0]&&0!==e[8]&&0!==e[4]){for(var i=t.length,n=3;n.5&&(t[n+o]-=e[3*o+o]*Math.round(a))}return t}}function Xs(t,e,r){return[Zo(e,r[0],3,0,t),Zo(e,r[1],3,1,t),Zo(e,r[2],3,2,t)]}function qs(t){return[ha(t,3,0),ha(t,3,1),ha(t,3,2)]}function Ys(t,e,r,i,n){for(var o=t.length,a=new Float32Array(o),s=0;s1&&(l=1),i(e,r,n,o,h,f),i(e,r,n,o,l,m),m.sub(f).normalize(),m.toArray(a,g)}}function a(e,r,i,n,o){for(var a=r.next(),s=r.next(),c=r.next(),u=r.size,h=u-1,l=n||0,p=0;pr&&s.bondSet.clear(y)}else("OH"===u.atomname&&"TYR"===u.resname||"OH"===h.atomname&&"TYR"===h.resname)&&(function(t,e,i,n){var o,a;t.atomname===i?(o=t,a=e):(o=e,a=t),d.index=o.residueIndex;var s=d.getAtomIndexByName(n);return m.subVectors(s,o),g.subVectors(s,a),uo(m.angleTo(g))r&&s.bondSet.clear(y)))}}return{atomSet:s.atomSet,bondSet:s.bondSet,bondStore:s.bondStore}}function vc(t){var e=JSON.stringify(t);return void 0===y_[e]&&(y_[e]=new b_(t)),y_[e]}function yc(t,e){this.type=t,this.text=e||{}}function bc(t){var e=t.getAtomSet(),r=t.getBondSet(),i=t.getBondProxy();return r.forEach(function(t){i.index=t,e.clear(i.atomIndex1),e.clear(i.atomIndex2)}),e}function xc(t,e,r,i,n){function o(t,i,o){return((t*e+i)*r+o)*n}var a,s=new(i=i||Int32Array)(t*e*r*(n=n||1));this.data=s,this.index=o,this.set=function(t,e,r){var i=arguments,c=o(t,e,r);for(a=0;aa?u[h]=-1:(o=Math.sqrt(a-n),u[h]=Math.floor(o)),++h;A[l]=c,S[l]=u}}function o(r){var i,n,o,a,s,c,u,h,l,p,d,f,m,v,_,M,P,I,R=3*r,O=r;i=Math.floor(.5+g*(t[R]+w[0])),n=Math.floor(.5+g*(t[R+1]+w[1])),o=Math.floor(.5+g*(t[R+2]+w[2]));var D,N=e[O],k=S[N],F=0,B=b*x,z=A[N];for(p=0;p=y||v>=b||_>=x)){var U=m*B+v*x+_;if(E)if(T[U]&L){if(T[U]&L){var j=C[U];j!==R&&u*u+h*h+l*l<(a=i+u-Math.floor(.5+g*(t[j]+w[0])))*a+(s=n+h-Math.floor(.5+g*(t[j+1]+w[1])))*s+(c=o+l-Math.floor(.5+g*(t[j+2]+w[2])))*c&&(C[U]=r)}}else T[U]|=L,C[U]=r;else T[U]|=L}F++}}function a(e){console.time("EDTSurface fillvoxels");var r,i;for(r=0,i=T.length;r=y||d>=b||f>=x)){var B=p*F+d*x+f;if(T[B]&O){if(E){var z=C[B];u*u+h*h+l*l<(a=Math.floor(.5+g*(t[z]+w[0])))*a+(s=Math.floor(.5+g*(t[z+1]+w[1])))*s+(c=Math.floor(.5+g*(t[z+2]+w[2])))*c&&(C[B]=r)}}else T[B]|=O,E&&(C[B]=r)}N++}}function c(){var e,r;for(e=0,r=T.length;e-1&&a-1&&c-1&&s0);var f,m=v*v,g=new Uint16Array(3);for(t=0;t=m)||(T[n]|=D,E&&T[n]&O&&(o.toArray(t,e,r,g),f=g[0]*a+g[1]*x+g[2],C[n]=C[f])));console.timeEnd("EDTSurface fastdistancemap")}function l(t,e,r,i){var n,o,a,s,c,u,h,l,p,d,f,m,g=new Uint16Array(3),v=0;if(0===r)return v;var _=-1,w=-1,S=-1,A=b*x;for(h=0,p=r;h-1&&w-1&&S-1&&(T[f=_*A+x*w+S]&L&&!(T[f]&O)?(e.fromArray(_,w,S,g),d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u,P[f]=d,T[f]|=O,T[f]|=D,i[v]=_,i[v+1]=w,i[v+2]=S,v+=3):T[f]&L&&T[f]&O&&(d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u)-1&&w-1&&S-1&&(T[f=_*A+x*w+S]&L&&!(T[f]&O)?(e.fromArray(_,w,S,g),d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u,P[f]=d,T[f]|=O,T[f]|=D,i[v]=_,i[v+1]=w,i[v+2]=S,v+=3):T[f]&L&&T[f]&O&&(d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u)-1&&w-1&&S-1&&(T[f=_*A+x*w+S]&L&&!(T[f]&O)?(e.fromArray(_,w,S,g),d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u,P[f]=d,T[f]|=O,T[f]|=D,i[v]=_,i[v+1]=w,i[v+2]=S,v+=3):T[f]&L&&T[f]&O&&(d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u)T&&(T=R)}this.neighbourListLength=27*T+1,this.withinRadii=function(n,o,a,c,p){for(var d=0,f=s(n,u),y=s(o,h),x=s(a,l),_=Math.max(0,f-1),w=Math.max(0,y-1),E=Math.max(0,x-1),T=Math.min(m,f+1),P=Math.min(g,y+1),C=Math.min(v,x+1),I=_;I<=T;++I)for(var R=I*b,L=w;L<=P;++L)for(var O=L*v,D=E;D<=C;++D)for(var N=R+O+D,k=S[N],F=k+A[N],B=k;BE&&(E=A[h]);o(),a(),s(),H=-1}function n(t,e,r){for(var i=0;i=0;){if(o!==i&&o!==n&&u(o,t,e,r))return H=o,o;o=j[++a]}return H=-1,-1}function u(e,r,i,n){var o=3*e,a=M[e],s=t[o]-r,c=t[o+1]-i,u=t[o+2]-n;return s*s+c*c+u*u=0;)t0&&s0&&e(g-1),l.growIfFull(),l.resno[g]=_,void 0!==S&&(l.sstruc[g]=S.charCodeAt(0)),void 0!==A&&(l.inscode[g]=A.charCodeAt(0)),l.atomOffset[g]=m,l.atomCount[g]=0,l.count+=1,l.chainIndex[g]=v,p.residueCount[v]+=1),h.count+=1,h.residueIndex[m]=g,l.atomCount[g]+=1,n=t,o=b,a=x,s=_,c=A,u=w},this.finalize=function(){r=a,i=u,g>-1&&e(g)}}function Mc(t){switch(t=t.toLowerCase()){case"polymer":return $v;case"non-polymer":return Hv;case"macrolide":return Wv;case"water":return Xv;default:return Vv}}function Ec(t,e,r){var i=""+t;return e&&(i+=":"+e),r&&(i+="^"+r),i}function Tc(t){return!t||t[0]!==t[t.length-1]||"'"!==t[0]&&'"'!==t[0]?t:t.substring(1,t.length-1)}function Pc(t,e){Array.isArray(t[e])||Object.keys(t).forEach(function(e){t[e]=[t[e]]})}function Cc(t){return"?"!==t}function Ic(t,e){return Cc(t)?t:e}function Rc(t){switch(t.toLowerCase()){case"?":case"sing":return 1;case"doub":return 2;case"trip":return 3;case"quad":return 4}return 0}function Lc(t,e,r){var i,n,o=e.atomStore,a=e.atomMap,s=t.chem_comp,c=t.chem_comp_atom,u=t.chem_comp_bond;s&&(s.name&&(e.title=s.name.trim().replace(jw,"")),s.id&&(e.id=s.id.trim().replace(jw,"")));var h={};if(c){var l,p,d,f;for(n=c.comp_id.length,i=0;if*f)return n.growIfFull(),n.atomTypeId[m]=n.atomTypeId[t],n.x[m]=p.x,n.y[m]=p.y,n.z[m]=p.z,n.occupancy[m]=n.occupancy[t],n.serial[m]=m,n.altloc[m]="A".charCodeAt(0),r.addAtom(0,"","","HET",1,1),void(m+=1)}}})}(b)}function Dc(t,e,r){var i,n,o,a,s=[],c=[],u=t.struct_conf;if(u)for(Pc(u,"id"),i=0,n=u.beg_auth_seq_id.length;i0){o=o.split("(");var c=s(o[0]),u=s(o[1]);Object.keys(c).forEach(function(t){Object.keys(u).forEach(function(e){var r=new y;r.multiplyMatrices(c[t],u[e]),i[t+"x"+e]=r})})}else i=s(o);var h=[];for(var l in i)h.push(i[l]);var p=t;/^(0|[1-9][0-9]*)$/.test(p)&&(p="BU"+p);for(var d=a.asym_id_list[e].split(","),f=0,m=d.length;fS){var A=w;w=S,S=A;var M=m;m=x,x=M}if(0!==w&&0!==S)for(var E=0;Eo&&++s;e=new Int32Array(s)}for(r=0,i=0;r65535){for(var i=[],n=0;n6,"non valid type "+a);var s=fu(t,a,t.readUint32());cu(t),e[n]={name:o,type:hu(a),value:s}}return e}function _u(t,e,r){var i,n=t.readUint32(),o=0;if(n===DS)return su(t.readUint32()!==DS,"wrong empty tag for list of variables"),[];su(n!==kS,"wrong tag for list of variables");var a=t.readUint32();i=new Array(a);for(var s=0;s6,"non valid type "+d);var f=t.readUint32(),m=t.readUint32();2===r&&(su(m>0,"offsets larger than 4GB not supported"),m=t.readUint32()),h[0]===e&&(o+=f),i[s]={name:c,dimensions:h,attributes:p,type:hu(d),size:f,offset:m,record:h[0]===e}}return{variables:i,recordStep:o}}function wu(t){for(var e=1,r=0;t>=e&&r<32;)r++,e<<=1;return r}function Su(t,e){var r=1,i=0;VS[0]=1;for(var n=0;n>=8;for(;0!==a;)VS[o++]=255&a,a>>=8;r=o}var s=1;for(r--;VS[r]>=s;)i++,s*=2;return i+8*r}function Au(t,e,r,i){for(var n=(1<=8;)c|=(a=a<<8|e[s++])>>o<0&&(o>(o-=r)&(1<8;)$S[s++]=Au(t,e,8,a),i-=8;i>0&&($S[s++]=Au(t,e,i,a));for(var c=r-1;c>0;c--){for(var u=0,h=s-1;h>=0;h--){var l=(u=u<<8|$S[h])/n[c]|0;$S[h]=l,u-=l*n[c]}o[c]=u}o[0]=$S[0]|$S[1]<<8|$S[2]<<16|$S[3]<<24}function Eu(t){return t.trim().split(eA).map(parseFloat)}function Tu(){this.regexp={vertex_pattern:/^v\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,normal_pattern:/^vn\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,uv_pattern:/^vt\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}}function Pu(){this.propertyNameMapping={}}function Cu(t){return t.replace(lA,"")}function Iu(t){function e(){if(o(/^<\?xml\s*/)){for(var t={attributes:{}};!a()&&!s("?>");){var e=n();if(!e)return t;t.attributes[e.name]=e.value}return o(/\?>\s*/),t}}function r(){var t=o(pA);if(t){for(var e={name:t[1],attributes:{},children:[]};!(a()||s(">")||s("?>")||s("/>"));){var c=n();if(!c)return e;e.attributes[c.name]=c.value}if(o(/^\s*\/>\s*/))return e;o(/\??>\s*/),e.content=i();for(var u;u=r();)e.children.push(u);return o(/^<\/[\w-:.]+>\s*/),e}}function i(){var t=o(dA);return t?t[1]:""}function n(){var t=o(fA);if(t)return{name:t[1],value:Cu(t[2])}}function o(e){var r=t.match(e);if(r)return t=t.slice(r[0].length),r}function a(){return 0===t.length}function s(e){return 0===t.indexOf(e)}return t=t.trim().replace(//g,""),{declaration:e(),root:r()}}function Ru(t,e,r){var i=t.icode.value,n=t.chain.value,o=t.altcode.value,a=t.resnum.value;return i.trim()&&(a+="^"+i),n.trim()&&(a+=":"+n),e&&(a+="."+e),r&&o.trim()&&(a+="%"+o),a+="/"+(parseInt(t.model.value)-1)}function Lu(t,e,r){void 0===t[e]?t[e]=r:t[e]|=r}function Ou(t,e){return void 0!==t&&t.value===e}function Du(t){var e=t.inscode,r=t.chainname,i=t.atomname,n=t.altloc,o=t.resno;return e&&(o+="^"+e),r&&(o+=":"+r),i&&(o+="."+i),n&&(o+="%"+n),o+="/"+t.modelIndex}function Nu(t,e,r){for(var i=0,n=e.getElementsByTagName("clash"),o=0,a=n.length;o0&&(i+=1),e.getElementsByTagName("bond-outlier").length>0&&(i+=1),e.getElementsByTagName("plane-outlier").length>0&&(i+=1),Ou(r.rota,"OUTLIER")&&(i+=1),Ou(r.rama,"OUTLIER")&&(i+=1),Ou(r.RNApucker,"outlier")&&(i+=1),i}function ku(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])}}return t}function Fu(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)}function Bu(t,e,r,i,n){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+i),n);else for(var o=0;o>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(n=n+e[i++]|0)|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}function ju(t,e,r,i){var n=_A,o=i+r;t^=-1;for(var a=i;a>>8^n[255&(t^e[a])];return-1^t}function Gu(t,e){var r,i,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E;r=t.state,i=t.next_in,M=t.input,n=i+(t.avail_in-5),o=t.next_out,E=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),c=r.dmax,u=r.wsize,h=r.whave,l=r.wnext,p=r.window,d=r.hold,f=r.bits,m=r.lencode,g=r.distcode,v=(1<>>24,d>>>=x,f-=x,0===(x=b>>>16&255))E[o++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<>>=x,f-=x),f<15&&(d+=M[i++]<>>24,d>>>=x,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<c){t.msg="invalid distance too far back",r.mode=wA;break t}if(d>>>=x,f-=x,x=o-a,w>x){if((x=w-x)>h&&r.sane){t.msg="invalid distance too far back",r.mode=wA;break t}if(S=0,A=p,0===l){if(S+=u-x,x<_){_-=x;do{E[o++]=p[S++]}while(--x);S=o-w,A=E}}else if(l2;)E[o++]=A[S++],E[o++]=A[S++],E[o++]=A[S++],_-=3;_&&(E[o++]=A[S++],_>1&&(E[o++]=A[S++]))}else{S=o-w;do{E[o++]=E[S++],E[o++]=E[S++],E[o++]=E[S++],_-=3}while(_>2);_&&(E[o++]=E[S++],_>1&&(E[o++]=E[S++]))}break}}break}}while(i>3,d&=(1<<(f-=_<<3))-1,t.next_in=i,t.next_out=o,t.avail_in=i=1&&0===I[_];_--);if(w>_&&(w=_),0===_)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(x=1;x<_&&0===I[x];x++);for(w0&&(t===TA||1!==_))return-1;for(R[1]=0,y=1;yMA||t===CA&&E>EA)return 1;for(;;){f=y-A,a[b]d?(m=L[O+a[b]],g=P[C+a[b]]):(m=96,g=0),c=1<>A)+(u-=c)]=f<<24|m<<16|g|0}while(0!==u);for(c=1<>=1;if(0!==c?(T&=c-1,T+=c):T=0,b++,0==--I[y]){if(y===_)break;y=e[r+a[b]]}if(y>w&&(T&l)!==h){for(0===A&&(A=w),p+=x,M=1<<(S=y-A);S+A<_&&!((M-=I[S+A])<=0);)S++,M<<=1;if(E+=1<MA||t===CA&&E>EA)return 1;n[h=T&l]=w<<24|S<<16|p-o|0}}return 0!==T&&(n[p+T]=y-A<<24|64<<16|0),s.bits=w,0}function $u(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function Hu(){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 Wu(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=qA,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(EM),e.distcode=e.distdyn=new Int32Array(TM),e.sane=1,e.back=-1,UA):VA}function Xu(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,Wu(t)):VA}function qu(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?VA:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,Xu(t))):VA}function Yu(t,e){var r,i;return t?(i=new Hu,t.state=i,i.window=null,(r=qu(t,e))!==UA&&(t.state=null),r):VA}function Zu(t){if(PM){var e;for(bA=new Int32Array(512),xA=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(Vu(NA,t.lens,0,288,bA,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Vu(kA,t.lens,0,32,xA,0,t.work,{bits:5}),PM=!1}t.lencode=bA,t.lenbits=9,t.distcode=xA,t.distbits=5}function Ku(t,e,r,i){var n,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(Bu(o.window,e,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((n=o.wsize-o.wnext)>i&&(n=i),Bu(o.window,e,r-i,n,o.wnext),(i-=n)?(Bu(o.window,e,r-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,r.check=ju(r.check,T,2,0),u=0,h=0,r.mode=YA;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=SM;break}if((15&u)!==XA){t.msg="unknown compression method",r.mode=SM;break}if(u>>>=4,h-=4,w=8+(15&u),0===r.wbits)r.wbits=w;else if(w>r.wbits){t.msg="invalid window size",r.mode=SM;break}r.dmax=1<>8&1),512&r.flags&&(T[0]=255&u,T[1]=u>>>8&255,r.check=ju(r.check,T,2,0)),u=0,h=0,r.mode=ZA;case ZA:for(;h<32;){if(0===s)break t;s--,u+=i[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,r.check=ju(r.check,T,4,0)),u=0,h=0,r.mode=KA;case KA:for(;h<16;){if(0===s)break t;s--,u+=i[o++]<>8),512&r.flags&&(T[0]=255&u,T[1]=u>>>8&255,r.check=ju(r.check,T,2,0)),u=0,h=0,r.mode=QA;case QA:if(1024&r.flags){for(;h<16;){if(0===s)break t;s--,u+=i[o++]<>>8&255,r.check=ju(r.check,T,2,0)),u=0,h=0}else r.head&&(r.head.extra=null);r.mode=JA;case JA:if(1024&r.flags&&((d=r.length)>s&&(d=s),d&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Bu(r.head.extra,i,o,d,w)),512&r.flags&&(r.check=ju(r.check,i,d,o)),s-=d,o+=d,r.length-=d),r.length))break t;r.length=0,r.mode=tM;case tM:if(2048&r.flags){if(0===s)break t;d=0;do{w=i[o+d++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&d>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=oM;break;case iM:for(;h<32;){if(0===s)break t;s--,u+=i[o++]<>>=7&h,h-=7&h,r.mode=xM;break}for(;h<3;){if(0===s)break t;s--,u+=i[o++]<>>=1,h-=1,3&u){case 0:r.mode=sM;break;case 1:if(Zu(r),r.mode=dM,e===zA){u>>>=2,h-=2;break t}break;case 2:r.mode=hM;break;case 3:t.msg="invalid block type",r.mode=SM}u>>>=2,h-=2;break;case sM:for(u>>>=7&h,h-=7&h;h<32;){if(0===s)break t;s--,u+=i[o++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=SM;break}if(r.length=65535&u,u=0,h=0,r.mode=cM,e===zA)break t;case cM:r.mode=uM;case uM:if(d=r.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break t;Bu(n,i,o,d,a),s-=d,o+=d,c-=d,a+=d,r.length-=d;break}r.mode=oM;break;case hM:for(;h<14;){if(0===s)break t;s--,u+=i[o++]<>>=5,h-=5,r.ndist=1+(31&u),u>>>=5,h-=5,r.ncode=4+(15&u),u>>>=4,h-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=SM;break}r.have=0,r.mode=lM;case lM:for(;r.have>>=3,h-=3}for(;r.have<19;)r.lens[P[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},S=Vu(DA,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,S){t.msg="invalid code lengths set",r.mode=SM;break}r.have=0,r.mode=pM;case pM:for(;r.have>>24,v=E>>>16&255,y=65535&E,!(g<=h);){if(0===s)break t;s--,u+=i[o++]<>>=g,h-=g,r.lens[r.have++]=y;else{if(16===y){for(M=g+2;h>>=g,h-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=SM;break}w=r.lens[r.have-1],d=3+(3&u),u>>>=2,h-=2}else if(17===y){for(M=g+3;h>>=g)),u>>>=3,h-=3}else{for(M=g+7;h>>=g)),u>>>=7,h-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=SM;break}for(;d--;)r.lens[r.have++]=w}}if(r.mode===SM)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=SM;break}if(r.lenbits=9,A={bits:r.lenbits},S=Vu(NA,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,S){t.msg="invalid literal/lengths set",r.mode=SM;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},S=Vu(kA,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,S){t.msg="invalid distances set",r.mode=SM;break}if(r.mode=dM,e===zA)break t;case dM:r.mode=fM;case fM:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,r.hold=u,r.bits=h,Gu(t,p),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,i=t.input,s=t.avail_in,u=r.hold,h=r.bits,r.mode===oM&&(r.back=-1);break}for(r.back=0;E=r.lencode[u&(1<>>24,v=E>>>16&255,y=65535&E,!(g<=h);){if(0===s)break t;s--,u+=i[o++]<>b)],g=E>>>24,v=E>>>16&255,y=65535&E,!(b+g<=h);){if(0===s)break t;s--,u+=i[o++]<>>=b,h-=b,r.back+=b}if(u>>>=g,h-=g,r.back+=g,r.length=y,0===v){r.mode=bM;break}if(32&v){r.back=-1,r.mode=oM;break}if(64&v){t.msg="invalid literal/length code",r.mode=SM;break}r.extra=15&v,r.mode=mM;case mM:if(r.extra){for(M=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=gM;case gM:for(;E=r.distcode[u&(1<>>24,v=E>>>16&255,y=65535&E,!(g<=h);){if(0===s)break t;s--,u+=i[o++]<>b)],g=E>>>24,v=E>>>16&255,y=65535&E,!(b+g<=h);){if(0===s)break t;s--,u+=i[o++]<>>=b,h-=b,r.back+=b}if(u>>>=g,h-=g,r.back+=g,64&v){t.msg="invalid distance code",r.mode=SM;break}r.offset=y,r.extra=15&v,r.mode=vM;case vM:if(r.extra){for(M=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=SM;break}r.mode=yM;case yM:if(0===c)break t;if(d=p-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=SM;break}d>r.wnext?(d-=r.wnext,f=r.wsize-d):f=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=n,f=a-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{n[a++]=m[f++]}while(--d);0===r.length&&(r.mode=fM);break;case bM:if(0===c)break t;n[a++]=r.length,c--,r.mode=fM;break;case xM:if(r.wrap){for(;h<32;){if(0===s)break t;s--,u|=i[o++]<>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e}function ih(t,e){if(e<65537&&(t.subarray&&IM||!t.subarray&&CM))return String.fromCharCode.apply(null,Fu(t,e));for(var r="",i=0;i4)s[i++]=65533,r+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&r1?s[i++]=65533:n<65536?s[i++]=n:(n-=65536,s[i++]=55296|n>>10&1023,s[i++]=56320|1023&n)}return ih(s,i)}function ah(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+RM[t[r]]>e?r:e}function sh(){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 ch(){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}function uh(t){if(!(this instanceof uh))return new uh(t);this.options=ku({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 sh,this.strm.avail_out=0;var r=Yu(this.strm,e.windowBits);if(r!==OM)throw new Error(DM[r]);this.header=new ch,th(this.strm,this.header)}function hh(t,e){var r=new uh(e);if(r.push(t,!0),r.err)throw r.msg;return r.result}"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,r=window.console,i={},n="memory".split(","),o="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");t=n.pop();)r[t]||(r[t]=i);for(;e=o.pop();)r[e]||(r[e]=function(){})}(),void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,r){for(var i=window.atob(this.toDataURL(e,r).split(",")[1]),n=i.length,o=n>>2,a=new Uint8Array(n),s=new Uint32Array(a.buffer,0,o),c=0,u=0;c0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}),Number.isNaN||(Number.isNaN=function(t){return t!==t}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var e=arguments;if(void 0===t||null===t)throw new TypeError("Cannot convert first argument to object");for(var r,i=Object(t),n=!1,o=1;o1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),i);if(o+c>i)return!1;for(var u=-1;++ur.length)&&(e=r.length),e-=t.length;var i=r.indexOf(t,e);return-1!==i&&i===e}),String.prototype.repeat||(String.prototype.repeat=function(t){if(null===this)throw new TypeError("can't convert "+this+" to object");var e=""+this;if(t=+t,Number.isNaN(t)&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t===1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0===e.length||0===t)return"";if(e.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||(Array.prototype.includes=function(t){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),r=parseInt(e.length,10)||0;if(0===r)return!1;var i,n=parseInt(arguments[1],10)||0;n>=0?i=n:(i=r+n)<0&&(i=0);for(var o;i0?1:-1)*Math.floor(Math.abs(e)):e},i=Math.pow(2,53)-1,n=function(t){var e=r(t);return Math.min(Math.max(e,0),i)};return function(t){var r=this,i=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var o,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!e(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(o=arguments[2])}for(var s,c=n(i.length),u=e(r)?Object(new r(c)):new Array(c),h=0;h0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){var e=arguments;if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),i=1;i>=4,r[n]=e[19===n?3&t|8:t]);return r.join("")}}(),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,i,n){return i+(t-e)*(n-i)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*mp.DEG2RAD},radToDeg:function(t){return t*mp.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};Object.defineProperties(l.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(l.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t=new l,e=new l;return function(r,i){return t.set(r,r),e.set(i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),i=Math.sin(e),n=this.x-t.x,o=this.y-t.y;return this.x=n*r-o*i+t.x,this.y=n*i+o*r+t.y,this}});var gp=0;p.DEFAULT_IMAGE=void 0,p.DEFAULT_MAPPING=300,Object.defineProperty(p.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(p.prototype,h.prototype,{constructor:p,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=mp.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height;var r=e.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case yl:t.x=t.x-Math.floor(t.x);break;case bl:t.x=t.x<0?0:1;break;case xl:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case yl:t.y=t.y-Math.floor(t.y);break;case bl:t.y=t.y<0?0:1;break;case xl:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.assign(d.prototype,{isVector4:!0,set:function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,i=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*n,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*n,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*n,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*n,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,i,n,o=t.elements,a=o[0],s=o[4],c=o[8],u=o[1],h=o[5],l=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(c-p)<.01&&Math.abs(l-d)<.01){if(Math.abs(s+u)<.1&&Math.abs(c+p)<.1&&Math.abs(l+d)<.1&&Math.abs(a+h+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(h+1)/2,v=(f+1)/2,y=(s+u)/4,b=(c+p)/4,x=(l+d)/4;return m>g&&m>v?m<.01?(r=0,i=.707106781,n=.707106781):(i=y/(r=Math.sqrt(m)),n=b/r):g>v?g<.01?(r=.707106781,i=0,n=.707106781):(r=y/(i=Math.sqrt(g)),n=x/i):v<.01?(r=.707106781,i=.707106781,n=0):(r=b/(n=Math.sqrt(v)),i=x/n),this.set(r,i,n,e),this}var _=Math.sqrt((d-l)*(d-l)+(c-p)*(c-p)+(u-s)*(u-s));return Math.abs(_)<.001&&(_=1),this.x=(d-l)/_,this.y=(c-p)/_,this.z=(u-s)/_,this.w=Math.acos((a+h+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,i){return void 0===t&&(t=new d,e=new d),t.set(r,r,r,r),e.set(i,i,i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(f.prototype,h.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),m.prototype=Object.create(f.prototype),m.prototype.constructor=m,m.prototype.isWebGLRenderTargetCube=!0,Object.assign(g,{slerp:function(t,e,r,i){return r.copy(t).slerp(e,i)},slerpFlat:function(t,e,r,i,n,o,a){var s=r[i+0],c=r[i+1],u=r[i+2],h=r[i+3],l=n[o+0],p=n[o+1],d=n[o+2],f=n[o+3];if(h!==f||s!==l||c!==p||u!==d){var m=1-a,g=s*l+c*p+u*d+h*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,a=Math.sin(a*x)/b}var _=a*v;if(s=s*m+l*_,c=c*m+p*_,u=u*m+d*_,h=h*m+f*_,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+h*h);s*=w,c*=w,u*=w,h*=w}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=h}}),Object.defineProperties(g.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(g.prototype,{set:function(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,i=t._y,n=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(r/2),u=a(i/2),h=a(n/2),l=s(r/2),p=s(i/2),d=s(n/2);return"XYZ"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h-l*p*d):"YXZ"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h+l*p*d):"ZXY"===o?(this._x=l*u*h-c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h-l*p*d):"ZYX"===o?(this._x=l*u*h-c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h+l*p*d):"YZX"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h-l*p*d):"XZY"===o&&(this._x=l*u*h-c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h+l*p*d),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,i=r[0],n=r[4],o=r[8],a=r[1],s=r[5],c=r[9],u=r[2],h=r[6],l=r[10],p=i+s+l;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(h-c)*e,this._y=(o-u)*e,this._z=(a-n)*e):i>s&&i>l?(e=2*Math.sqrt(1+i-s-l),this._w=(h-c)/e,this._x=.25*e,this._y=(n+a)/e,this._z=(o+u)/e):s>l?(e=2*Math.sqrt(1+s-i-l),this._w=(o-u)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(c+h)/e):(e=2*Math.sqrt(1+l-i-s),this._w=(a-n)/e,this._x=(o+u)/e,this._y=(c+h)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new v;return function(r,i){return void 0===e&&(e=new v),(t=r.dot(i)+1)<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,i),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,i=t._y,n=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=r*u+o*a+i*c-n*s,this._y=i*u+o*s+n*a-r*c,this._z=n*u+o*c+r*s-i*a,this._w=o*u-r*a-i*s-n*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,i=this._y,n=this._z,o=this._w,a=o*t._w+r*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=n,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(i+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,a),u=Math.sin((1-e)*c)/s,h=Math.sin(e*c)/s;return this._w=o*u+this._w*h,this._x=r*u+this._x*h,this._y=i*u+this._y*h,this._z=n*u+this._z*h,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(v.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t=new g;return function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new g;return function(e,r){return this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),applyMatrix3:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6]*i,this.y=n[1]*e+n[4]*r+n[7]*i,this.z=n[2]*e+n[5]*r+n[8]*i,this},applyMatrix4:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements,o=1/(n[3]*e+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*r+n[8]*i+n[12])*o,this.y=(n[1]*e+n[5]*r+n[9]*i+n[13])*o,this.z=(n[2]*e+n[6]*r+n[10]*i+n[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,i=this.z,n=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*i-a*r,u=s*r+a*e-n*i,h=s*i+n*r-o*e,l=-n*e-o*r-a*i;return this.x=c*s+l*-n+u*-a-h*-o,this.y=u*s+l*-o+h*-n-c*-a,this.z=h*s+l*-a+c*-o-u*-n,this},project:function(){var t=new y;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new y;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*r+n[8]*i,this.y=n[1]*e+n[5]*r+n[9]*i,this.z=n[2]*e+n[6]*r+n[10]*i,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t=new v,e=new v;return function(r,i){return t.set(r,r,r),e.set(i,i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var r=this.x,i=this.y,n=this.z;return this.x=i*t.z-n*t.y,this.y=n*t.x-r*t.z,this.z=r*t.y-i*t.x,this},crossVectors:function(t,e){var r=t.x,i=t.y,n=t.z,o=e.x,a=e.y,s=e.z;return this.x=i*s-n*a,this.y=n*o-r*s,this.z=r*a-i*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new v;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new v;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(mp.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(y.prototype,{isMatrix4:!0,set:function(t,e,r,i,n,o,a,s,c,u,h,l,p,d,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=i,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=h,g[14]=l,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new y).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t=new v;return function(e){var r=this.elements,i=e.elements,n=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=i[0]*n,r[1]=i[1]*n,r[2]=i[2]*n,r[4]=i[4]*o,r[5]=i[5]*o,r[6]=i[6]*o,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,r=t.x,i=t.y,n=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(i),c=Math.sin(i),u=Math.cos(n),h=Math.sin(n);if("XYZ"===t.order){var l=o*u,p=o*h,d=a*u,f=a*h;e[0]=s*u,e[4]=-s*h,e[8]=c,e[1]=p+d*c,e[5]=l-f*c,e[9]=-a*s,e[2]=f-l*c,e[6]=d+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*u,g=s*h,v=c*u,y=c*h;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*u,g=s*h,v=c*u,y=c*h;e[0]=m-y*a,e[4]=-o*h,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*u,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var l=o*u,p=o*h,d=a*u,f=a*h;e[0]=s*u,e[4]=d*c-p,e[8]=l*c+f,e[1]=s*h,e[5]=f*c+l,e[9]=p*c-d,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=w-b*h,e[8]=_*h+x,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=x*h+_,e[10]=b-w*h}else if("XZY"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=-h,e[8]=c*u,e[1]=b*h+w,e[5]=o*u,e[9]=x*h-_,e[2]=_*h-x,e[6]=a*u,e[10]=w*h+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,i=t._y,n=t._z,o=t._w,a=r+r,s=i+i,c=n+n,u=r*a,h=r*s,l=r*c,p=i*s,d=i*c,f=n*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+f),e[4]=h-v,e[8]=l+g,e[1]=h+v,e[5]=1-(u+f),e[9]=d-m,e[2]=l-g,e[6]=d+m,e[10]=1-(u+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new v,e=new v,r=new v;return function(i,n,o){var a=this.elements;return r.subVectors(i,n),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(o,r),0===t.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(o,r)),t.normalize(),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],u=r[1],h=r[5],l=r[9],p=r[13],d=r[2],f=r[6],m=r[10],g=r[14],v=r[3],y=r[7],b=r[11],x=r[15],_=i[0],w=i[4],S=i[8],A=i[12],M=i[1],E=i[5],T=i[9],P=i[13],C=i[2],I=i[6],R=i[10],L=i[14],O=i[3],D=i[7],N=i[11],k=i[15];return n[0]=o*_+a*M+s*C+c*O,n[4]=o*w+a*E+s*I+c*D,n[8]=o*S+a*T+s*R+c*N,n[12]=o*A+a*P+s*L+c*k,n[1]=u*_+h*M+l*C+p*O,n[5]=u*w+h*E+l*I+p*D,n[9]=u*S+h*T+l*R+p*N,n[13]=u*A+h*P+l*L+p*k,n[2]=d*_+f*M+m*C+g*O,n[6]=d*w+f*E+m*I+g*D,n[10]=d*S+f*T+m*R+g*N,n[14]=d*A+f*P+m*L+g*k,n[3]=v*_+y*M+b*C+x*O,n[7]=v*w+y*E+b*I+x*D,n[11]=v*S+y*T+b*R+x*N,n[15]=v*A+y*P+b*L+x*k,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t=new v;return function(e){for(var r=this,i=0,n=e.count;i>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,i){if(e=mp.euclideanModulo(e,1),r=mp.clamp(r,0,1),i=mp.clamp(i,0,1),0===r)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+r):i+r-i*r,o=2*i-n;this.r=t(o,n,e+1/3),this.g=t(o,n,e),this.b=t(o,n,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var i,n=r[1],o=r[2];switch(n){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,e(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,e(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return e(i[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u=(h=r[1]).length;if(3===u)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(t&&t.length>0){var h=Ap[t];void 0!==h?this.setHex(h):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,i=t||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),c=Math.min(n,o,a),u=(c+s)/2;if(c===s)e=0,r=0;else{var h=s-c;switch(r=u<=.5?h/(s+c):h/(2-s-c),s){case n:e=(o-a)/h+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\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\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\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\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\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\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\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\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\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\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\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;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\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 ) ); }\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}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\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}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, 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}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\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 = value.rgb * cLogLuvM;\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}\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 = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\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\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\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\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\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\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\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#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\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#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\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\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\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}\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",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\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\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\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\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( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, 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( 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 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\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\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\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\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\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\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\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#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\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\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\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\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\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\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\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\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\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",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\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",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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\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\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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\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\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},Pp={basic:{uniforms:Ep.merge([Mp.common,Mp.specularmap,Mp.envmap,Mp.aomap,Mp.lightmap,Mp.fog]),vertexShader:Tp.meshbasic_vert,fragmentShader:Tp.meshbasic_frag},lambert:{uniforms:Ep.merge([Mp.common,Mp.specularmap,Mp.envmap,Mp.aomap,Mp.lightmap,Mp.emissivemap,Mp.fog,Mp.lights,{emissive:{value:new et(0)}}]),vertexShader:Tp.meshlambert_vert,fragmentShader:Tp.meshlambert_frag},phong:{uniforms:Ep.merge([Mp.common,Mp.specularmap,Mp.envmap,Mp.aomap,Mp.lightmap,Mp.emissivemap,Mp.bumpmap,Mp.normalmap,Mp.displacementmap,Mp.gradientmap,Mp.fog,Mp.lights,{emissive:{value:new et(0)},specular:{value:new et(1118481)},shininess:{value:30}}]),vertexShader:Tp.meshphong_vert,fragmentShader:Tp.meshphong_frag},standard:{uniforms:Ep.merge([Mp.common,Mp.envmap,Mp.aomap,Mp.lightmap,Mp.emissivemap,Mp.bumpmap,Mp.normalmap,Mp.displacementmap,Mp.roughnessmap,Mp.metalnessmap,Mp.fog,Mp.lights,{emissive:{value:new et(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Tp.meshphysical_vert,fragmentShader:Tp.meshphysical_frag},points:{uniforms:Ep.merge([Mp.points,Mp.fog]),vertexShader:Tp.points_vert,fragmentShader:Tp.points_frag},dashed:{uniforms:Ep.merge([Mp.common,Mp.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tp.linedashed_vert,fragmentShader:Tp.linedashed_frag},depth:{uniforms:Ep.merge([Mp.common,Mp.displacementmap]),vertexShader:Tp.depth_vert,fragmentShader:Tp.depth_frag},normal:{uniforms:Ep.merge([Mp.common,Mp.bumpmap,Mp.normalmap,Mp.displacementmap,{opacity:{value:1}}]),vertexShader:Tp.normal_vert,fragmentShader:Tp.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Tp.cube_vert,fragmentShader:Tp.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Tp.equirect_vert,fragmentShader:Tp.equirect_frag},distanceRGBA:{uniforms:Ep.merge([Mp.common,Mp.displacementmap,{referencePosition:{value:new v},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tp.distanceRGBA_vert,fragmentShader:Tp.distanceRGBA_frag},shadow:{uniforms:Ep.merge([Mp.lights,{color:{value:new et(0)},opacity:{value:1}}]),vertexShader:Tp.shadow_vert,fragmentShader:Tp.shadow_frag}};Pp.physical={uniforms:Ep.merge([Pp.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Tp.meshphysical_vert,fragmentShader:Tp.meshphysical_frag},Object.assign(rt.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){var e=this;this.makeEmpty();for(var r=0,i=t.length;rthis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new l).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new l).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new l;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),nt.prototype=Object.create(p.prototype),nt.prototype.constructor=nt;var Cp=0;Object.assign(at.prototype,h.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){var e=this;if(void 0!==t)for(var r in t){var i=t[r];if(void 0!==i)if("shading"!==r){var n=e[r];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):e[r]="overdraw"===r?Number(i):i:console.warn("THREE."+e.type+": '"+r+"' is not a property of this material.")}else console.warn("THREE."+e.type+": .shading has been removed. Use the boolean .flatShading instead."),e.flatShading=1===i;else console.warn("THREE.Material: '"+r+"' parameter is undefined.")}},toJSON:function(t){function e(t){var e=[];for(var r in t){var i=t[r];delete i.metadata,e.push(i)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearCoat&&(i.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(i.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ph&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),this.side!==_h&&(i.side=this.side),this.vertexColors!==Ah&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),r){var n=e(t.textures),o=e(t.images);n.length>0&&(i.textures=n),o.length>0&&(i.images=o)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var i=e.length;r=new Array(i);for(var n=0;n!==i;++n)r[n]=e[n].clone()}return this.clippingPlanes=r,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),st.prototype=Object.create(at.prototype),st.prototype.constructor=st,st.prototype.isShaderMaterial=!0,st.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ep.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},st.prototype.toJSON=function(t){var e=at.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},ct.prototype=Object.create(at.prototype),ct.prototype.constructor=ct,ct.prototype.isMeshDepthMaterial=!0,ct.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},ut.prototype=Object.create(at.prototype),ut.prototype.constructor=ut,ut.prototype.isMeshDistanceMaterial=!0,ut.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},Object.assign(ht.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,i=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;sn&&(n=u),h>o&&(o=h),l>a&&(a=l)}return this.min.set(e,r,i),this.max.set(n,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,i=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;sn&&(n=u),h>o&&(o=h),l>a&&(a=l)}return this.min.set(e,r,i),this.max.set(n,o,a),this},setFromPoints:function(t){var e=this;this.makeEmpty();for(var r=0,i=t.length;rthis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new v).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t=new v;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new v).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new v;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new v;return function(e){var r=e||new lt;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new v,new v,new v,new v,new v,new v,new v,new v];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(lt.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new ht;return function(e,r){var i=this.center;void 0!==r?i.copy(r):t.setFromPoints(e).getCenter(i);for(var n=0,o=0,a=e.length;othis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(t){var e=t||new ht;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(pt.prototype,{isMatrix3:!0,set:function(t,e,r,i,n,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=i,u[2]=a,u[3]=e,u[4]=n,u[5]=s,u[6]=r,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t=new v;return function(e){for(var r=this,i=0,n=e.count;i1))return i.copy(n).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return i.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new v).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new v,e=new pt;return function(r,i){var n=i||e.getNormalMatrix(r),o=this.coplanarPoint(t).applyMatrix4(r),a=this.normal.applyMatrix3(n).normalize();return this.constant=-o.dot(a),this}}(),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(ft.prototype,{set:function(t,e,r,i,n,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,i=r[0],n=r[1],o=r[2],a=r[3],s=r[4],c=r[5],u=r[6],h=r[7],l=r[8],p=r[9],d=r[10],f=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-i,h-s,f-l,y-m).normalize(),e[1].setComponents(a+i,h+s,f+l,y+m).normalize(),e[2].setComponents(a+n,h+c,f+p,y+g).normalize(),e[3].setComponents(a-n,h-c,f-p,y-g).normalize(),e[4].setComponents(a-o,h-u,f-d,y-v).normalize(),e[5].setComponents(a+o,h+u,f+d,y+v).normalize(),this},intersectsObject:function(){var t=new lt;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new lt;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,r=t.center,i=-t.radius,n=0;n<6;n++)if(e[n].distanceToPoint(r)0?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}}),vt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],vt.DefaultOrder="XYZ",Object.defineProperties(vt.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(vt.prototype,{isEuler:!0,set:function(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._order=i||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var i=mp.clamp,n=t.elements,o=n[0],a=n[4],s=n[8],c=n[1],u=n[5],h=n[9],l=n[2],p=n[6],d=n[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-i(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-l,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(i(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-i(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===e?(this._z=Math.asin(i(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-l,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e?(this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-h,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new y;return function(e,r,i){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,i)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new g;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new v(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(yt.prototype,{set:function(t){this.mask=1<1){for(var i=0;i1){for(var i=0;i0){a.children=[];for(c=0;c0&&(o.geometries=h),l.length>0&&(o.materials=l),p.length>0&&(o.textures=p),d.length>0&&(o.images=d)}return o.object=a,o},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){var r=this;if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var i=0;i0)for(f=0;f0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r,i=this;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,i,n,o=this;for(r=0,i=this.faces.length;r0&&(e+=r[i].distanceTo(r[i-1])),t.lineDistances[i]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ht),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new lt),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(t&&t.isGeometry){var i,n=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,u=this.faceVertexUvs[0],h=t.faceVertexUvs[0],l=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(i=(new pt).getNormalMatrix(e));for(var d=0,f=a.length;d=0;r--){var m=d[r];for(c.faces.splice(m,1),a=0,s=this.faceVertexUvs.length;a0,_=y.vertexNormals.length>0,w=1!==y.color.r||1!==y.color.g||1!==y.color.b,S=y.vertexColors.length>0,A=0;if(A=t(A,0,0),A=t(A,1,!0),A=t(A,2,!1),A=t(A,3,b),A=t(A,4,x),A=t(A,5,_),A=t(A,6,w),A=t(A,7,S),l.push(A),l.push(y.a,y.b,y.c),l.push(y.materialIndex),b){var M=n.faceVertexUvs[0][u];l.push(i(M[0]),i(M[1]),i(M[2]))}if(x&&l.push(e(y.normal)),_){var E=y.vertexNormals;l.push(e(E[0]),e(E[1]),e(E[2]))}if(w&&l.push(r(y.color)),S){var T=y.vertexColors;l.push(r(T[0]),r(T[1]),r(T[2]))}}return o.data={},o.data.vertices=c,o.data.normals=p,f.length>0&&(o.data.colors=f),g.length>0&&(o.data.uvs=[g]),o.data.faces=l,o},clone:function(){return(new Mt).copy(this)},copy:function(t){var e,r,i,n,o,a,s=this;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var c=t.vertices;for(e=0,r=c.length;e0,s=o[1]&&o[1].length>0,c=t.morphTargets,u=c.length;if(u>0){e=[];for(y=0;y0){h=[];for(y=0;y65535?Ot:Rt)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new Et(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;return void 0!==r&&((new pt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new y;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new y;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new y;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new y;return function(e,r,i){return t.makeTranslation(e,r,i),this.applyMatrix(t),this}}(),scale:function(){var t=new y;return function(e,r,i){return t.makeScale(e,r,i),this.applyMatrix(t),this}}(),lookAt:function(){var t=new bt;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new Dt(3*e.vertices.length,3),i=new Dt(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",i.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var n=new Dt(e.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var i;return!0===e.verticesNeedUpdate&&(void 0!==(i=this.attributes.position)&&(i.copyVector3sArray(e.vertices),i.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(i=this.attributes.normal)&&(i.copyVector3sArray(e.normals),i.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(i=this.attributes.color)&&(i.copyColorsArray(e.colors),i.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(i=this.attributes.uv)&&(i.copyVector2sArray(e.uvs),i.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(i=this.attributes.lineDistance)&&(i.copyArray(e.lineDistances),i.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new kt).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=this,r=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new Et(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){var i=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Et(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new Et(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var o=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Et(o,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Et(a,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var s=new(Ft(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new Et(s,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var c in t.morphTargets){for(var u=[],h=t.morphTargets[c],l=0,p=h.length;l0){var m=new Dt(4*t.skinIndices.length,4);this.addAttribute("skinIndex",m.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var g=new Dt(4*t.skinWeights.length,4);this.addAttribute("skinWeight",g.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ht);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new ht,e=new v;return function(){null===this.boundingSphere&&(this.boundingSphere=new lt);var r=this.attributes.position;if(r){var i=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(i);for(var n=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Bt).copy(this)},copy:function(t){var e,r,i,n=this;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var o=t.index;null!==o&&this.setIndex(o.clone());var a=t.attributes;for(e in a){var s=a[e];n.addAttribute(e,s.clone())}var c=t.morphAttributes;for(e in c){var u=[],h=c[e];for(r=0,i=h.length;r0)if(s=p*f-d,c=p*d-f,h=l*g,s>=0)if(c>=-h)if(c<=h){var v=1/g;u=(s*=v)*(s+p*(c*=v)+2*d)+c*(p*s+c+2*f)+m}else c=l,u=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c=-l,u=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c<=-h?u=-(s=Math.max(0,-(-p*l+d)))*s+(c=s>0?-l:Math.min(Math.max(-l,-f),l))*(c+2*f)+m:c<=h?(s=0,u=(c=Math.min(Math.max(-l,-f),l))*(c+2*f)+m):u=-(s=Math.max(0,-(p*l+d)))*s+(c=s>0?l:Math.min(Math.max(-l,-f),l))*(c+2*f)+m;else c=p>0?-l:l,u=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),u}}(),intersectSphere:function(){var t=new v;return function(e,r){t.subVectors(e.center,this.origin);var i=t.dot(this.direction),n=t.dot(t)-i*i,o=e.radius*e.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=i-a,c=i+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,i,n,o,a,s,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,l=this.origin;return c>=0?(r=(t.min.x-l.x)*c,i=(t.max.x-l.x)*c):(r=(t.max.x-l.x)*c,i=(t.min.x-l.x)*c),u>=0?(n=(t.min.y-l.y)*u,o=(t.max.y-l.y)*u):(n=(t.max.y-l.y)*u,o=(t.min.y-l.y)*u),r>o||n>i?null:((n>r||r!==r)&&(r=n),(o=0?(a=(t.min.z-l.z)*h,s=(t.max.z-l.z)*h):(a=(t.max.z-l.z)*h,s=(t.min.z-l.z)*h),r>s||a>i?null:((a>r||r!==r)&&(r=a),(s=0?r:i,e)))},intersectsBox:function(){var t=new v;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new v,e=new v,r=new v,i=new v;return function(n,o,a,s,c){e.subVectors(o,n),r.subVectors(a,n),i.crossVectors(e,r);var u,h=this.direction.dot(i);if(h>0){if(s)return null;u=1}else{if(!(h<0))return null;u=-1,h=-h}t.subVectors(this.origin,n);var l=u*this.direction.dot(r.crossVectors(t,r));if(l<0)return null;var p=u*this.direction.dot(e.cross(t));if(p<0)return null;if(l+p>h)return null;var d=-u*t.dot(i);return d<0?null:this.at(d/h,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(Ht.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new v).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new v).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new v;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new v,e=new v;return function(r,i){t.subVectors(r,this.start),e.subVectors(this.end,this.start);var n=e.dot(e),o=e.dot(t)/n;return i&&(o=mp.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,r){var i=this.closestPointToPointParameter(t,e),n=r||new v;return this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(Wt,{normal:function(){var t=new v;return function(e,r,i,n){var o=n||new v;o.subVectors(i,r),t.subVectors(e,r),o.cross(t);var a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),barycoordFromPoint:function(){var t=new v,e=new v,r=new v;return function(i,n,o,a,s){t.subVectors(a,n),e.subVectors(o,n),r.subVectors(i,n);var c=t.dot(t),u=t.dot(e),h=t.dot(r),l=e.dot(e),p=e.dot(r),d=c*l-u*u,f=s||new v;if(0===d)return f.set(-2,-1,-1);var m=1/d,g=(l*h-u*p)*m,y=(c*p-u*h)*m;return f.set(1-g-y,y,g)}}(),containsPoint:function(){var t=new v;return function(e,r,i,n){var o=Wt.barycoordFromPoint(e,r,i,n,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Wt.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new v,e=new v;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new v).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return Wt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new dt).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Wt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Wt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new dt,e=[new Ht,new Ht,new Ht],r=new v,i=new v;return function(n,o){var a=o||new v,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(n,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0){var s=o[a[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=c.length;tr.far?null:{distance:c,point:x.clone(),object:t}}function r(r,i,n,o,u,h,l,p){a.fromBufferAttribute(o,h),s.fromBufferAttribute(o,l),c.fromBufferAttribute(o,p);var g=e(r,r.material,i,n,a,s,c,b);return g&&(u&&(d.fromBufferAttribute(u,h),f.fromBufferAttribute(u,l),m.fromBufferAttribute(u,p),g.uv=t(b,a,s,c,d,f,m)),g.face=new St(h,l,p,Wt.normal(a,s,c)),g.faceIndex=h),g}var i=new y,n=new $t,o=new lt,a=new v,s=new v,c=new v,u=new v,h=new v,p=new v,d=new l,f=new l,m=new l,g=new v,b=new v,x=new v;return function(l,g){var v=this,y=this.geometry,x=this.material,_=this.matrixWorld;if(void 0!==x&&(null===y.boundingSphere&&y.computeBoundingSphere(),o.copy(y.boundingSphere),o.applyMatrix4(_),!1!==l.ray.intersectsSphere(o)&&(i.getInverse(_),n.copy(l.ray).applyMatrix4(i),null===y.boundingBox||!1!==n.intersectsBox(y.boundingBox)))){var w;if(y.isBufferGeometry){var S,A,M,E,T,P=y.index,C=y.attributes.position,I=y.attributes.uv;if(null!==P)for(E=0,T=P.count;E0&&(D=B);for(var z=0,U=F.length;zo)){var a=i.ray.origin.distanceTo(t);ai.far||n.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),Be.prototype=Object.assign(Object.create(bt.prototype),{constructor:Be,copy:function(t){var e=this;bt.prototype.copy.call(this,t,!1);for(var r=t.levels,i=0,n=r.length;i1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var n=t.distanceTo(e);i[0].object.visible=!0;for(var o=1,a=i.length;o=i[o].distance;o++)i[o-1].object.visible=!1,i[o].object.visible=!0;for(;os||(d.applyMatrix4(o.matrixWorld),(E=i.ray.origin.distanceTo(d))i.far||n.push({distance:E,point:p.clone().applyMatrix4(o.matrixWorld),index:b,face:null,faceIndex:null,object:o}))}else for(var b=0,x=g.length/3-1;bs||(d.applyMatrix4(o.matrixWorld),(E=i.ray.origin.distanceTo(d))i.far||n.push({distance:E,point:p.clone().applyMatrix4(o.matrixWorld),index:b,face:null,faceIndex:null,object:o}))}else if(c.isGeometry)for(var S=c.vertices,A=S.length,b=0;bs)){d.applyMatrix4(o.matrixWorld);var E=i.ray.origin.distanceTo(d);Ei.far||n.push({distance:E,point:p.clone().applyMatrix4(o.matrixWorld),index:b,face:null,faceIndex:null,object:o})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),$e.prototype=Object.assign(Object.create(Ve.prototype),{constructor:$e,isLineSegments:!0}),He.prototype=Object.assign(Object.create(Ve.prototype),{constructor:He,isLineLoop:!0}),We.prototype=Object.create(at.prototype),We.prototype.constructor=We,We.prototype.isPointsMaterial=!0,We.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Xe.prototype=Object.assign(Object.create(bt.prototype),{constructor:Xe,isPoints:!0,raycast:function(){var t=new y,e=new $t,r=new lt;return function(i,n){function o(t,r){var o=e.distanceSqToPoint(t);if(oi.far)return;n.push({distance:u,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=i.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),r.radius+=u,!1!==i.ray.intersectsSphere(r)){t.getInverse(c),e.copy(i.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),l=h*h,p=new v;if(s.isBufferGeometry){var d=s.index,f=s.attributes.position.array;if(null!==d)for(var m=d.array,g=0,y=m.length;g=-Number.EPSILON&&P>=-Number.EPSILON&&T>=-Number.EPSILON))return!1;return!0}return function(e,r){var i=e.length;if(i<3)return null;var n,o,a,s=[],c=[],u=[];if(Op.area(e)>0)for(o=0;o2;){if(l--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),r?u:s;if(n=o,h<=n&&(n=0),o=n+1,h<=o&&(o=0),a=o+1,h<=a&&(a=0),t(e,n,o,a,h,c)){var p,d,f,m,g;for(p=c[n],d=c[o],f=c[a],s.push([e[p],e[d],e[f]]),u.push([c[n],c[o],c[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function i(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=u*h-c*l)<0||f>p)return[]}else{if(d>0||d0||fM?[]:x===M?o?[]:[y]:_<=M?[y,b]:[y,S]}function o(t,e,r,i){var n=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,c=i.x-t.x,u=i.y-t.y,h=n*s-o*a,l=n*u-o*c;if(Math.abs(h)>Number.EPSILON){var p=c*s-u*a;return h>0?l>=0&&p>=0:l>=0||p>=0}return l>0}r(t),e.forEach(r);for(var a,s,c,u,h,l,p={},d=t.concat(),f=0,m=e.length;f0;){if(--_<0){console.log('THREE.ShapeUtils: Infinite Loop! Holes left:" + indepHoles.length + ", Probably Hole outside Shape!');break}for(a=x;ai&&(a=0);var s=o(m[t],m[n],m[a],r[e]);if(!s)return!1;var c=r.length-1,u=e-1;u<0&&(u=c);var h=e+1;return h>c&&(h=0),!!(s=o(r[e],r[u],r[h],m[t]))}(a,w)&&!function(t,e){var r,i;for(r=0;r0)return!0;return!1}(s,c)&&!function(t,r){var i,o,a,s;for(i=0;i0)return!0;return!1}(s,c)){i=w,g.splice(y,1),l=m.slice(0,a+1),p=m.slice(a),d=r.slice(i),f=r.slice(0,i+1),m=l.concat(d).concat(f).concat(p),x=a;break}if(i>=0)break;v[h]=!0}if(i>=0)break}}return m}(t,e),v=Op.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var d=Math.sqrt(h),f=Math.sqrt(c*c+u*u),m=e.x-s/d,g=e.y+a/d,v=((r.x-u/f-m)*u-(r.y+c/f-g)*c)/(a*u-s*c),y=(i=m+a*v-t.x)*i+(n=g+s*v-t.y)*n;if(y<=2)return new l(i,n);o=Math.sqrt(y/2)}else{var b=!1;a>Number.EPSILON?c>Number.EPSILON&&(b=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(b=!0):Math.sign(s)===Math.sign(u)&&(b=!0),b?(i=-s,n=a,o=Math.sqrt(h)):(i=a,n=s,o=Math.sqrt(h/2))}return new l(i/o,n/o)}function n(t,e){var r,i;for(Z=t.length;--Z>=0;){r=Z,(i=Z-1)<0&&(i=t.length-1);var n=0,o=P+2*M;for(n=0;n=0;j--){for(V=j/M,$=S*Math.cos(V*Math.PI/2),G=A*Math.sin(V*Math.PI/2),Z=0,K=U.length;Z0||0===t.search(/^data\:image\/jpeg/);o.format=r?Ul:jl,o.needsUpdate=!0,void 0!==e&&e(o)},r,i),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Yr.prototype=Object.assign(Object.create(bt.prototype),{constructor:Yr,isLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=bt.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Zr.prototype=Object.assign(Object.create(Yr.prototype),{constructor:Zr,isHemisphereLight:!0,copy:function(t){return Yr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Kr.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Qr.prototype=Object.assign(Object.create(Kr.prototype),{constructor:Qr,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*mp.RAD2DEG*t.angle,i=this.mapSize.width/this.mapSize.height,n=t.distance||e.far;r===e.fov&&i===e.aspect&&n===e.far||(e.fov=r,e.aspect=i,e.far=n,e.updateProjectionMatrix())}}),Jr.prototype=Object.assign(Object.create(Yr.prototype),{constructor:Jr,isSpotLight:!0,copy:function(t){return Yr.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ti.prototype=Object.assign(Object.create(Yr.prototype),{constructor:ti,isPointLight:!0,copy:function(t){return Yr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),ei.prototype=Object.assign(Object.create(Kr.prototype),{constructor:ei}),ri.prototype=Object.assign(Object.create(Yr.prototype),{constructor:ri,isDirectionalLight:!0,copy:function(t){return Yr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ii.prototype=Object.assign(Object.create(Yr.prototype),{constructor:ii,isAmbientLight:!0}),ni.prototype=Object.assign(Object.create(Yr.prototype),{constructor:ni,isRectAreaLight:!0,copy:function(t){return Yr.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Yr.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var Bp={arraySlice:function(t,e,r){return Bp.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),i=0;i!==e;++i)r[i]=i;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var i=t.length,n=new t.constructor(i),o=0,a=0;a!==i;++o)for(var s=r[o]*e,c=0;c!==e;++c)n[a++]=t[s+c];return n},flattenJSON:function(t,e,r,i){for(var n=1,o=t[0];void 0!==o&&void 0===o[i];)o=t[n++];if(void 0!==o){var a=o[i];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[i])&&(e.push(o.time),r.push.apply(r,a)),o=t[n++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[i])&&(e.push(o.time),a.toArray(r,r.length)),o=t[n++]}while(void 0!==o);else do{void 0!==(a=o[i])&&(e.push(o.time),r.push(a)),o=t[n++]}while(void 0!==o)}}};Object.assign(oi.prototype,{evaluate:function(t){var e=this,r=this.parameterPositions,i=this._cachedIndex,n=r[i],o=r[i-1];t:{e:{var a;r:{i:if(!(t=o)break t;var s=r[1];t=o)break e}a=i,i=0}}for(;i>>1;te;)--o;if(++o,0!==n||o!==i){n>=o&&(n=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=Bp.arraySlice(r,n,o),this.values=Bp.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var t=this,e=!0,r=this.getValueSize();r-Math.floor(r)!=0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),e=!1);var i=this.times,n=this.values,o=i.length;0===o&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),e=!1);for(var a=null,s=0;s!==o;s++){var c=i[s];if("number"==typeof c&&isNaN(c)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",t,s,c),e=!1;break}if(null!==a&&a>c){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",t,s,c,a),e=!1;break}a=c}if(void 0!==n&&Bp.isTypedArray(n))for(var s=0,u=n.length;s!==u;++s){var h=n[s];if(isNaN(h)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",t,s,h),e=!1;break}}return e},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),i=2302===this.getInterpolation(),n=1,o=t.length-1,a=1;a0){t[n]=t[o];for(var f=o*r,m=n*r,p=0;p!==r;++p)e[m+p]=e[f+p];++n}return n!==t.length&&(this.times=Bp.arraySlice(t,0,n),this.values=Bp.arraySlice(e,0,n*r)),this}},hi.prototype=Object.assign(Object.create(zp),{constructor:hi,ValueTypeName:"vector"}),li.prototype=Object.assign(Object.create(oi.prototype),{constructor:li,interpolate_:function(t,e,r,i){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(r-e)/(i-e),u=s+a;s!==u;s+=4)g.slerpFlat(n,0,o,s-a,o,s,c);return n}}),pi.prototype=Object.assign(Object.create(zp),{constructor:pi,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new li(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),di.prototype=Object.assign(Object.create(zp),{constructor:di,ValueTypeName:"number"}),fi.prototype=Object.assign(Object.create(zp),{constructor:fi,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),mi.prototype=Object.assign(Object.create(zp),{constructor:mi,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),gi.prototype=Object.assign(Object.create(zp),{constructor:gi,ValueTypeName:"color"}),vi.prototype=zp,zp.constructor=vi,Object.assign(vi,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=vi._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],i=[];Bp.flattenJSON(t.keys,r,i,"value"),t.times=r,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:Bp.convertArray(t.times,Array),values:Bp.convertArray(t.values,Array)};var i=t.getInterpolation();i!==t.DefaultInterpolation&&(e.interpolation=i)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return di;case"vector":case"vector2":case"vector3":case"vector4":return hi;case"color":return gi;case"quaternion":return pi;case"bool":case"boolean":return mi;case"string":return fi}throw new Error("Unsupported typeName: "+t)}}),Object.assign(yi,{parse:function(t){for(var e=[],r=t.tracks,i=1/(t.fps||1),n=0,o=r.length;n!==o;++n)e.push(vi.parse(r[n]).scale(i));return new yi(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,i={name:t.name,duration:t.duration,tracks:e},n=0,o=r.length;n!==o;++n)e.push(vi.toJSON(r[n]));return i},CreateFromMorphTargetSequence:function(t,e,r,i){for(var n=e.length,o=[],a=0;a1){var u=i[l=c[1]];u||(i[l]=u=[]),u.push(s)}}var h=[];for(var l in i)h.push(yi.CreateFromMorphTargetSequence(l,i[l],e,r));return h},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var r=function(t,e,r,i,n){if(0!==r.length){var o=[],a=[];Bp.flattenJSON(r,o,a,i),0!==o.length&&n.push(new t(e,o,a))}},i=[],n=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[i+1]:0,s=r>2?t.skinWeights[i+2]:0,c=r>3?t.skinWeights[i+3]:0;e.skinWeights.push(new d(o,a,s,c))}if(t.skinIndices)for(var i=0,n=t.skinIndices.length;i1?t.skinIndices[i+1]:0,l=r>2?t.skinIndices[i+2]:0,p=r>3?t.skinIndices[i+3]:0;e.skinIndices.push(new d(u,h,l,p))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}function r(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var i=0,n=t.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=e.faces,l=t.morphColors[0].colors,i=0,n=h.length;i0&&(e.animations=r)}return function(n,o){void 0!==n.data&&(n=n.data),void 0!==n.scale?n.scale=1/n.scale:n.scale=1;var a=new Mt;return t(n,a),e(n,a),r(n,a),i(n,a),a.computeFaceNormals(),a.computeBoundingSphere(),void 0===n.materials||0===n.materials.length?{geometry:a}:{geometry:a,materials:_i.prototype.initMaterials(n.materials,o,this.crossOrigin)}}}()}),Object.assign(function(t){this.manager=void 0!==t?t:Fp,this.texturePath=""}.prototype,{load:function(t,e,r,i){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var n=this;new Wr(n.manager).load(t,function(r){var o=null;try{o=JSON.parse(r)}catch(e){return void 0!==i&&i(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?n.parse(o,e):console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.")},r,i)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),i=this.parseImages(t.images,function(){void 0!==e&&e(a)}),n=this.parseTextures(t.textures,i),o=this.parseMaterials(t.materials,n),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e=this,r={};if(void 0!==t)for(var i=new wi,n=new xi,o=0,a=t.length;o0){var n=new Xr(new Hr(e));n.setCrossOrigin(this.crossOrigin);for(var o=0,a=t.length;o0?new je(c,u):new Xt(c,u);break;case"LOD":a=new Be;break;case"Line":a=new Ve(n(e.geometry),o(e.material),e.mode);break;case"LineLoop":a=new He(n(e.geometry),o(e.material));break;case"LineSegments":a=new $e(n(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new Xe(n(e.geometry),o(e.material));break;case"Sprite":a=new Fe(o(e.material));break;case"Group":a=new qe;break;default:a=new bt}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var h=e.children,l=0;l0)){c=n;break}c=n-1}if(n=c,i[n]===r)return n/(o-1);var u=i[n];return(n+(r-u)/(i[n+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var i=this.getPoint(e);return this.getPoint(r).clone().sub(i).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,i,n,o=this,a=new v,s=[],c=[],u=[],h=new v,l=new y;for(r=0;r<=t;r++)i=r/t,s[r]=o.getTangentAt(i),s[r].normalize();c[0]=new v,u[0]=new v;var p=Number.MAX_VALUE,d=Math.abs(s[0].x),f=Math.abs(s[0].y),m=Math.abs(s[0].z);for(d<=p&&(p=d,a.set(1,0,0)),f<=p&&(p=f,a.set(0,1,0)),m<=p&&a.set(0,0,1),h.crossVectors(s[0],a).normalize(),c[0].crossVectors(s[0],h),u[0].crossVectors(s[0],c[0]),r=1;r<=t;r++)c[r]=c[r-1].clone(),u[r]=u[r-1].clone(),h.crossVectors(s[r-1],s[r]),h.length()>Number.EPSILON&&(h.normalize(),n=Math.acos(mp.clamp(s[r-1].dot(s[r]),-1,1)),c[r].applyMatrix4(l.makeRotationAxis(h,n))),u[r].crossVectors(s[r],c[r]);if(!0===e)for(n=Math.acos(mp.clamp(c[0].dot(c[t]),-1,1)),n/=t,s[0].dot(h.crossVectors(c[0],c[t]))>0&&(n=-n),r=1;r<=t;r++)c[r].applyMatrix4(l.makeRotationAxis(s[r],n*r)),u[r].crossVectors(s[r],c[r]);return{tangents:s,normals:c,binormals:u}}}),(Di.prototype=Object.create(Oi.prototype)).constructor=Di,Di.prototype.isLineCurve=!0,Di.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},Di.prototype.getPointAt=function(t){return this.getPoint(t)},Di.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},Ni.prototype=Object.assign(Object.create(Oi.prototype),{constructor:Ni,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Di(e,t))},getPoint:function(t){for(var e=this,r=t*this.getLength(),i=this.getCurveLengths(),n=0;n=r){var o=i[n]-r,a=e.curves[n],s=a.getLength(),c=0===s?0:1-o/s;return a.getPointAt(c)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){var t=this;if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],r=0,i=0,n=this.curves.length;i1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Mt,r=0,i=t.length;re;)r-=e;re.length-2?e.length-1:i+1],c=e[i>e.length-3?e.length-1:i+2];return new l(Si(n,o.x,a.x,s.x,c.x),Si(n,o.y,a.y,s.y,c.y))},(Bi.prototype=Object.create(Oi.prototype)).constructor=Bi,Bi.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,n=this.v3;return new l(Li(t,e.x,r.x,i.x,n.x),Li(t,e.y,r.y,i.y,n.y))},(zi.prototype=Object.create(Oi.prototype)).constructor=zi,zi.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new l(Ti(t,e.x,r.x,i.x),Ti(t,e.y,r.y,i.y))};var $p=Object.assign(Object.create(Ni.prototype),{fromPoints:function(t){var e=this;this.moveTo(t[0].x,t[0].y);for(var r=1,i=t.length;r0){var u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)}});Ui.prototype=$p,$p.constructor=Ui,ji.prototype=Object.assign(Object.create($p),{constructor:ji,getPointsHoles:function(t){for(var e=this,r=[],i=0,n=this.holes.length;i1){for(var v=!1,y=[],b=0,x=p.length;bNumber.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[n],u=-u),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var h=u*(t.x-a.x)-c*(t.y-a.y);if(0===h)return!0;if(h<0)continue;i=!i}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return i})(S.p,p[M].p)&&(b!==M&&y.push({froms:b,tos:M,hole:w}),A?(A=!1,l[M].push(S)):v=!0);A&&l[b].push(S)}y.length>0&&(v||(d=l))}for(var E,m=0,T=p.length;m0){this.source.connect(this.filters[0]);for(var e=1,r=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,r=this.filters.length;e=.5)for(var o=0;o!==n;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,i){g.slerpFlat(t,e,t,e,t,r,i)},_lerp:function(t,e,r,i,n){for(var o=1-i,a=0;a!==n;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*i}}}),Object.assign(Ki.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,i=this._bindings[r];void 0!==i&&i.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,i=this._targetGroup.nCachedObjects_,n=r.length;i!==n;++i)r[i].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(Qi,{Composite:Ki,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new Qi.Composite(t,e,r):new Qi(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=/((?:[\w-]+[\/:])*)/,e=/([\w-\.]+)?/,r=/(?:\.([\w-]+)(?:\[(.+)\])?)?/,i=/\.([\w-]+)(?:\[(.+)\])?/,n=new RegExp("^"+t.source+e.source+r.source+i.source+"$"),o=["material","materials","bones"];return function(t){var e=n.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var a=r.nodeName.substring(i+1);-1!==o.indexOf(a)&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=a)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}}(),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r=i){var p=i++,d=r[p];n[d.uuid]=l,r[l]=d,n[h]=p,r[p]=u;for(var f=0,m=a;f!==m;++f){var g=o[f],v=g[p],y=g[l];g[l]=v,g[p]=y}}}this.nCachedObjects_=i},uncache:function(t){for(var e=arguments,r=this._objects,i=r.length,n=this.nCachedObjects_,o=this._indicesByUUID,a=this._bindings,s=a.length,c=0,u=arguments.length;c!==u;++c){var h=e[c].uuid,l=o[h];if(void 0!==l)if(delete o[h],l0)for(var c=this._interpolants,u=this._propertyBindings,h=0,l=c.length;h!==l;++h)c[h].evaluate(a),u[h].accumulate(i,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;null!==r&&(e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,i=this.loop,n=this._loopCount;if(2200===i){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===i;if(-1===n&&(t>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&n))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var i=this._interpolantSettings;r?(i.endingStart=2401,i.endingEnd=2401):(i.endingStart=t?this.zeroSlopeAtStart?2401:rp:2402,i.endingEnd=e?this.zeroSlopeAtEnd?2401:rp:2402)},_scheduleFading:function(t,e,r){var i=this._mixer,n=i.time,o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=e,a[1]=n+t,s[1]=r,this}}),Object.assign(function(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}.prototype,h.prototype,{_bindAction:function(t,e){var r=this,i=t._localRoot||this._root,n=t._clip.tracks,o=n.length,a=t._propertyBindings,s=t._interpolants,c=i.uuid,u=this._bindingsByRootAndName,h=u[c];void 0===h&&(h={},u[c]=h);for(var l=0;l!==o;++l){var p=n[l],d=p.name,f=h[d];if(void 0!==f)a[l]=f;else{if(void 0!==(f=a[l])){null===f._cacheIndex&&(++f.referenceCount,r._addInactiveBinding(f,c,d));continue}var m=e&&e._propertyBindings[l].binding.parsedPath;++(f=new Zi(Qi.create(i,d,m),p.ValueTypeName,p.getValueSize())).referenceCount,r._addInactiveBinding(f,c,d),a[l]=f}s[l].resultBuffer=f.buffer}},_activateAction:function(t){var e=this;if(!this._isActiveAction(t)){if(null===t._cacheIndex){var r=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,r)}for(var o=t._propertyBindings,a=0,s=o.length;a!==s;++a){var c=o[a];0==c.useCount++&&(e._lendBinding(c),c.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){var e=this;if(this._isActiveAction(t)){for(var r=t._propertyBindings,i=0,n=r.length;i!==n;++i){var o=r[i];0==--o.useCount&&(o.restoreOriginalState(),e._takeBackBinding(o))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),Mn.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},Mn.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},(En.prototype=Object.create($e.prototype)).constructor=En;var Yp=new v,Zp=new Tn,Kp=new Tn,Qp=new Tn;Pn.prototype=Object.create(Oi.prototype),Pn.prototype.constructor=Pn,Pn.prototype.getPoint=function(t){var e=this.points,r=e.length,i=(r-(this.closed?0:1))*t,n=Math.floor(i),o=i-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/e.length)+1)*e.length:0===o&&n===r-1&&(n=r-2,o=1);var a,s,c,u;if(this.closed||n>0?a=e[(n-1)%r]:(Yp.subVectors(e[0],e[1]).add(e[0]),a=Yp),s=e[n%r],c=e[(n+1)%r],this.closed||n+2r&&(t=r),t},Sf=function(t){return t.length>=3?[].slice.call(t):t[0]},xd=function(t){var e,r;for(t._clipped=!1,t._unclipped=t.slice(0),e=r=0;r<3;e=++r)e<3?((t[e]<0||t[e]>255)&&(t._clipped=!0),t[e]<0&&(t[e]=0),t[e]>255&&(t[e]=255)):3===e&&(t[e]<0&&(t[e]=0),t[e]>1&&(t[e]=1));return t._clipped||delete t._unclipped,t},nd=Math.PI,vf=Math.round,wd=Math.cos,Td=Math.floor,tf=Math.pow,Wd=Math.log,bf=Math.sin,xf=Math.sqrt,dd=Math.atan2,Yd=Math.max,pd=Math.abs,sd=2*nd,od=nd/3,rd=nd/180,ad=180/nd,ld=[],(bd=function(){return arguments[0]instanceof ed?arguments[0]:function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,arguments,function(){})}).version="1.3.3",hd={},cd=[],ud=!1,ed=function(){function t(){var t,e,r,i,n,o,a,s,c,u=arguments;for(o=this,e=[],s=0,i=arguments.length;s3?e[3]:1]},Ef=function(t){return 255*(t<=.00304?12.92*t:1.055*tf(t,1/2.4)-.055)},jd=function(t){return t>id.t1?t*t*t:id.t2*(t-id.t0)},id={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},uf=function(){var t,e,r,i,n,o,a,s;return i=Sf(arguments),r=i[0],e=i[1],t=i[2],n=ff(r,e,t),o=n[0],a=n[1],s=n[2],[116*a-16,500*(o-a),200*(a-s)]},mf=function(t){return(t/=255)<=.04045?t/12.92:tf((t+.055)/1.055,2.4)},Mf=function(t){return t>id.t3?tf(t,1/3):t/id.t2+id.t0},ff=function(){var t,e,r,i,n,o,a;return i=Sf(arguments),r=i[0],e=i[1],t=i[2],r=mf(r),e=mf(e),t=mf(t),n=Mf((.4124564*r+.3575761*e+.1804375*t)/id.Xn),o=Mf((.2126729*r+.7151522*e+.072175*t)/id.Yn),a=Mf((.0193339*r+.119192*e+.9503041*t)/id.Zn),[n,o,a]},bd.lab=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["lab"]),function(){})},hd.lab=Ud,ed.prototype.lab=function(){return uf(this._rgb)},fd=function(t){var e,r,i,n,o,a,s,c,u,h,l;return 2===(t=function(){var e,r,i;for(i=[],r=0,e=t.length;r=360;)r-=360;d[u]=r}return bd(d,e).alpha(i/h)},hd.rgb=function(){var t,e,r,i;e=Sf(arguments),r=[];for(t in e)i=e[t],r.push(i);return r},bd.rgb=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["rgb"]),function(){})},ed.prototype.rgb=function(t){return null==t&&(t=!0),t?this._rgb.map(Math.round).slice(0,3):this._rgb.slice(0,3)},ed.prototype.rgba=function(t){return null==t&&(t=!0),t?[Math.round(this._rgb[0]),Math.round(this._rgb[1]),Math.round(this._rgb[2]),this._rgb[3]]:this._rgb.slice(0)},cd.push({p:3,test:function(t){var e;return e=Sf(arguments),"array"===wf(e)&&3===e.length?"rgb":4===e.length&&"number"===wf(e[3])&&e[3]>=0&&e[3]<=1?"rgb":void 0}}),Cd=function(t){var e,r,i,n,o,a;if(t.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]),a=parseInt(t,16),n=a>>16,i=a>>8&255,r=255&a,[n,i,r,1];if(t.match(/^#?([A-Fa-f0-9]{8})$/))return 9===t.length&&(t=t.substr(1)),a=parseInt(t,16),n=a>>24&255,i=a>>16&255,r=a>>8&255,e=vf((255&a)/255*100)/100,[n,i,r,e];if(null!=hd.css&&(o=hd.css(t)))return o;throw"unknown color: "+t},of=function(t,e){var r,i,n,o,a,s,c;return null==e&&(e="rgb"),a=t[0],n=t[1],i=t[2],r=t[3],a=Math.round(a),n=Math.round(n),i=Math.round(i),c=a<<16|n<<8|i,s="000000"+c.toString(16),s=s.substr(s.length-6),o="0"+vf(255*r).toString(16),o=o.substr(o.length-2),"#"+function(){switch(e.toLowerCase()){case"rgba":return s+o;case"argb":return o+s;default:return s}}()},hd.hex=function(t){return Cd(t)},bd.hex=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["hex"]),function(){})},ed.prototype.hex=function(t){return null==t&&(t="rgb"),of(this._rgb,t)},cd.push({p:4,test:function(t){if(1===arguments.length&&"string"===wf(t))return"hex"}}),Ld=function(){var t,e,r,i,n,o,a,s,c,u,h,l,p,d;if(t=Sf(arguments),n=t[0],h=t[1],a=t[2],0===h)c=i=e=255*a;else{for(d=[0,0,0],r=[0,0,0],l=2*a-(p=a<.5?a*(1+h):a+h-a*h),n/=360,d[0]=n+1/3,d[1]=n,d[2]=n-1/3,o=s=0;s<=2;o=++s)d[o]<0&&(d[o]+=1),d[o]>1&&(d[o]-=1),6*d[o]<1?r[o]=l+6*(p-l)*d[o]:2*d[o]<1?r[o]=p:3*d[o]<2?r[o]=l+(p-l)*(2/3-d[o])*6:r[o]=l;c=(u=[vf(255*r[0]),vf(255*r[1]),vf(255*r[2])])[0],i=u[1],e=u[2]}return t.length>3?[c,i,e,t[3]]:[c,i,e]},sf=function(t,e,r){var i,n,o,a,s;return void 0!==t&&t.length>=3&&(t=(a=t)[0],e=a[1],r=a[2]),t/=255,e/=255,r/=255,o=Math.min(t,e,r),Yd=Math.max(t,e,r),n=(Yd+o)/2,Yd===o?(s=0,i=Number.NaN):s=n<.5?(Yd-o)/(Yd+o):(Yd-o)/(2-Yd-o),t===Yd?i=(e-r)/(Yd-o):e===Yd?i=2+(r-t)/(Yd-o):r===Yd&&(i=4+(t-e)/(Yd-o)),(i*=60)<0&&(i+=360),[i,s,n]},bd.hsl=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["hsl"]),function(){})},hd.hsl=Ld,ed.prototype.hsl=function(){return sf(this._rgb)},Od=function(){var t,e,r,i,n,o,a,s,c,u,h,l,p,d,f,m,g,v;if(t=Sf(arguments),n=t[0],m=t[1],v=t[2],v*=255,0===m)c=i=e=v;else switch(360===n&&(n=0),n>360&&(n-=360),n<0&&(n+=360),n/=60,o=Td(n),r=n-o,a=v*(1-m),s=v*(1-m*r),g=v*(1-m*(1-r)),o){case 0:c=(u=[v,g,a])[0],i=u[1],e=u[2];break;case 1:c=(h=[s,v,a])[0],i=h[1],e=h[2];break;case 2:c=(l=[a,v,g])[0],i=l[1],e=l[2];break;case 3:c=(p=[a,s,v])[0],i=p[1],e=p[2];break;case 4:c=(d=[g,a,v])[0],i=d[1],e=d[2];break;case 5:c=(f=[v,a,s])[0],i=f[1],e=f[2]}return[c,i,e,t.length>3?t[3]:1]},cf=function(){var t,e,r,i,n,o,a,s,c;return a=Sf(arguments),o=a[0],r=a[1],t=a[2],n=Math.min(o,r,t),Yd=Math.max(o,r,t),e=Yd-n,c=Yd/255,0===Yd?(i=Number.NaN,s=0):(s=e/Yd,o===Yd&&(i=(r-t)/e),r===Yd&&(i=2+(t-o)/e),t===Yd&&(i=4+(o-r)/e),(i*=60)<0&&(i+=360)),[i,s,c]},bd.hsv=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["hsv"]),function(){})},hd.hsv=Od,ed.prototype.hsv=function(){return cf(this._rgb)},Qd=function(t){var e,r,i;return"number"===wf(t)&&t>=0&&t<=16777215?(i=t>>16,r=t>>8&255,e=255&t,[i,r,e,1]):(console.warn("unknown num color: "+t),[0,0,0,1])},pf=function(){var t,e,r,i;return i=Sf(arguments),r=i[0],e=i[1],t=i[2],(r<<16)+(e<<8)+t},bd.num=function(t){return new ed(t,"num")},ed.prototype.num=function(t){return null==t&&(t="rgb"),pf(this._rgb,t)},hd.num=Qd,cd.push({p:1,test:function(t){if(1===arguments.length&&"number"===wf(t)&&t>=0&&t<=16777215)return"num"}}),Pd=function(){var t,e,r,i,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b;if(r=Sf(arguments),s=r[0],n=r[1],e=r[2],n/=100,a=a/100*255,t=255*n,0===n)l=a=i=e;else switch(360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360),s/=60,c=Td(s),o=s-c,u=e*(1-n),h=u+t*(1-o),y=u+t*o,b=u+t,c){case 0:l=(p=[b,y,u])[0],a=p[1],i=p[2];break;case 1:l=(d=[h,b,u])[0],a=d[1],i=d[2];break;case 2:l=(f=[u,b,y])[0],a=f[1],i=f[2];break;case 3:l=(m=[u,h,b])[0],a=m[1],i=m[2];break;case 4:l=(g=[y,u,b])[0],a=g[1],i=g[2];break;case 5:l=(v=[b,u,h])[0],a=v[1],i=v[2]}return[l,a,i,r.length>3?r[3]:1]},nf=function(){var t,e,r,i,n,o,a,s,c;return c=Sf(arguments),s=c[0],n=c[1],e=c[2],a=Math.min(s,n,e),Yd=Math.max(s,n,e),i=Yd-a,r=100*i/255,t=a/(255-i)*100,0===i?o=Number.NaN:(s===Yd&&(o=(n-e)/i),n===Yd&&(o=2+(e-s)/i),e===Yd&&(o=4+(s-n)/i),(o*=60)<0&&(o+=360)),[o,r,t]},bd.hcg=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["hcg"]),function(){})},hd.hcg=Pd,ed.prototype.hcg=function(){return nf(this._rgb)},Sd=function(t){var e,r,i,n,o,a,s,c;if(t=t.toLowerCase(),null!=bd.colors&&bd.colors[t])return Cd(bd.colors[t]);if(o=t.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=o.slice(1,4),n=a=0;a<=2;n=++a)s[n]=+s[n];s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(s=o.slice(1,5),n=c=0;c<=3;n=++c)s[n]=+s[n];else if(o=t.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=o.slice(1,4),n=e=0;e<=2;n=++e)s[n]=vf(2.55*s[n]);s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(s=o.slice(1,5),n=r=0;r<=2;n=++r)s[n]=vf(2.55*s[n]);s[3]=+s[3]}else(o=t.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((i=o.slice(1,4))[1]*=.01,i[2]*=.01,(s=Ld(i))[3]=1):(o=t.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((i=o.slice(1,4))[1]*=.01,i[2]*=.01,(s=Ld(i))[3]=+o[4]);return s},rf=function(t){var e;return"rgb"==(e=t[3]<1?"rgba":"rgb")?e+"("+t.slice(0,3).map(vf).join(",")+")":"rgba"===e?e+"("+t.slice(0,3).map(vf).join(",")+","+t[3]+")":void 0},gf=function(t){return vf(100*t)/100},Rd=function(t,e){var r;return r=e<1?"hsla":"hsl",t[0]=gf(t[0]||0),t[1]=gf(100*t[1])+"%",t[2]=gf(100*t[2])+"%","hsla"===r&&(t[3]=e),r+"("+t.join(",")+")"},hd.css=function(t){return Sd(t)},bd.css=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["css"]),function(){})},ed.prototype.css=function(t){return null==t&&(t="rgb"),"rgb"===t.slice(0,3)?rf(this._rgb):"hsl"===t.slice(0,3)?Rd(this.hsl(),this.alpha()):void 0},hd.named=function(t){return Cd(Af[t])},cd.push({p:5,test:function(t){if(1===arguments.length&&null!=Af[t])return"named"}}),ed.prototype.name=function(t){var e,r;arguments.length&&(Af[t]&&(this._rgb=Cd(Af[t])),this._rgb[3]=1),e=this.hex();for(r in Af)if(e===Af[r])return r;return e},Gd=function(){var t,e,r,i;return i=Sf(arguments),r=i[0],t=i[1],e=i[2],e*=rd,[r,wd(e)*t,bf(e)*t]},Vd=function(){var t,e,r,i,n,o,a,s,c,u,h;return r=Sf(arguments),s=r[0],n=r[1],a=r[2],u=Gd(s,n,a),t=u[0],e=u[1],i=u[2],h=Ud(t,e,i),c=h[0],o=h[1],i=h[2],[c,o,i,r.length>3?r[3]:1]},zd=function(){var t,e,r,i,n,o;return o=Sf(arguments),n=o[0],t=o[1],e=o[2],r=xf(t*t+e*e),i=(dd(e,t)*ad+360)%360,0===vf(1e4*r)&&(i=Number.NaN),[n,r,i]},hf=function(){var t,e,r,i,n,o,a;return o=Sf(arguments),n=o[0],r=o[1],e=o[2],a=uf(n,r,e),i=a[0],t=a[1],e=a[2],zd(i,t,e)},bd.lch=function(){var t;return t=Sf(arguments),new ed(t,"lch")},bd.hcl=function(){var t;return t=Sf(arguments),new ed(t,"hcl")},hd.lch=Vd,hd.hcl=function(){var t,e,r,i;return i=Sf(arguments),e=i[0],t=i[1],r=i[2],Vd([r,t,e])},ed.prototype.lch=function(){return hf(this._rgb)},ed.prototype.hcl=function(){return hf(this._rgb).reverse()},ef=function(t){var e,r,i,n,o,a,s,c,u;return null==t&&(t="rgb"),c=Sf(arguments),s=c[0],n=c[1],e=c[2],s/=255,n/=255,e/=255,o=1-Math.max(s,Math.max(n,e)),i=o<1?1/(1-o):0,r=(1-s-o)*i,a=(1-n-o)*i,u=(1-e-o)*i,[r,a,u,o]},_d=function(){var t,e,r,i,n,o,a,s,c;return e=Sf(arguments),i=e[0],a=e[1],c=e[2],o=e[3],t=e.length>4?e[4]:1,1===o?[0,0,0,t]:(s=i>=1?0:255*(1-i)*(1-o),n=a>=1?0:255*(1-a)*(1-o),r=c>=1?0:255*(1-c)*(1-o),[s,n,r,t])},hd.cmyk=function(){return _d(Sf(arguments))},bd.cmyk=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["cmyk"]),function(){})},ed.prototype.cmyk=function(){return ef(this._rgb)},hd.gl=function(){var t,e,r,i,n;for(i=function(){var t,r;t=Sf(arguments),r=[];for(e in t)n=t[e],r.push(n);return r}.apply(this,arguments),t=r=0;r<=2;t=++r)i[t]*=255;return i},bd.gl=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["gl"]),function(){})},ed.prototype.gl=function(){var t;return t=this._rgb,[t[0]/255,t[1]/255,t[2]/255,t[3]]},lf=function(t,e,r){var i;return i=Sf(arguments),t=i[0],e=i[1],r=i[2],t=Xd(t),e=Xd(e),r=Xd(r),.2126*t+.7152*e+.0722*r},Xd=function(t){return(t/=255)<=.03928?t/12.92:tf((t+.055)/1.055,2.4)},ld=[],Dd=function(t,e,r,i){var n,o,a,s;for(null==r&&(r=.5),null==i&&(i="rgb"),"object"!==wf(t)&&(t=bd(t)),"object"!==wf(e)&&(e=bd(e)),a=0,o=ld.length;at?o(r,c):o(c,a)},r=lf(this._rgb),this._rgb=(r>t?o(bd("black"),this):o(this,bd("white"))).rgba()),this):lf(this._rgb)},_f=function(t){var e,r,i,n;return(n=t/100)<66?(i=255,r=-155.25485562709179-.44596950469579133*(r=n-2)+104.49216199393888*Wd(r),e=n<20?0:.8274096064007395*(e=n-10)-254.76935184120902+115.67994401066147*Wd(e)):(i=351.97690566805693+.114206453784165*(i=n-55)-40.25366309332127*Wd(i),r=325.4494125711974+.07943456536662342*(r=n-50)-28.0852963507957*Wd(r),e=255),[i,r,e]},df=function(){var t,e,r,i,n,o,a;for(i=(n=Sf(arguments))[0],n[1],t=n[2],r=1e3,e=4e4,.4;e-r>.4;)(o=_f(a=.5*(e+r)))[2]/o[0]>=t/i?e=a:r=a;return vf(a)},bd.temperature=bd.kelvin=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["temperature"]),function(){})},hd.temperature=hd.kelvin=hd.K=_f,ed.prototype.temperature=function(){return df(this._rgb)},ed.prototype.kelvin=ed.prototype.temperature,bd.contrast=function(t,e){var r,i,n,o;return"string"!==(n=wf(t))&&"number"!==n||(t=new ed(t)),"string"!==(o=wf(e))&&"number"!==o||(e=new ed(e)),r=t.luminance(),i=e.luminance(),r>i?(r+.05)/(i+.05):(i+.05)/(r+.05)},bd.distance=function(t,e,r){var i,n,o,a,s,c,u;null==r&&(r="lab"),"string"!==(s=wf(t))&&"number"!==s||(t=new ed(t)),"string"!==(c=wf(e))&&"number"!==c||(e=new ed(e)),o=t.get(r),a=e.get(r),u=0;for(n in o)u+=(i=(o[n]||0)-(a[n]||0))*i;return Math.sqrt(u)},bd.deltaE=function(t,e,r,i){var n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,T,P,C,I;for(null==r&&(r=1),null==i&&(i=1),"string"!==(x=wf(t))&&"number"!==x||(t=new ed(t)),"string"!==(_=wf(e))&&"number"!==_||(e=new ed(e)),n=(w=t.lab())[0],a=w[1],c=w[2],o=(S=e.lab())[0],s=S[1],u=S[2],h=xf(a*a+c*c),l=xf(s*s+u*u),E=n<16?.511:.040975*n/(1+.01765*n),A=.0638*h/(1+.0131*h)+.638,b=h<1e-6?0:180*dd(c,a)/nd;b<0;)b+=360;for(;b>=360;)b-=360;return T=b>=164&&b<=345?.56+pd(.2*wd(nd*(b+168)/180)):.36+pd(.4*wd(nd*(b+35)/180)),p=h*h*h*h,y=xf(p/(p+1900)),M=A*(y*T+1-y),v=n-o,g=h-l,f=a-s,m=c-u,d=f*f+m*m-g*g,P=v/(r*E),C=g/(i*A),I=M,xf(P*P+C*C+d/(I*I))},ed.prototype.get=function(t){var e,r,i,n,o,a;return i=this,o=t.split("."),n=o[0],e=o[1],a=i[n](),e?(r=n.indexOf(e))>-1?a[r]:console.warn("unknown channel "+e+" in mode "+n):a},ed.prototype.set=function(t,e){var r,i,n,o,a,s;if(n=this,a=t.split("."),o=a[0],r=a[1])if(s=n[o](),(i=o.indexOf(r))>-1)if("string"===wf(e))switch(e.charAt(0)){case"+":case"-":s[i]+=+e;break;case"*":s[i]*=+e.substr(1);break;case"/":s[i]/=+e.substr(1);break;default:s[i]=+e}else s[i]=e;else console.warn("unknown channel "+r+" in mode "+o);else s=e;return bd(s,o).alpha(n.alpha())},ed.prototype.clipped=function(){return this._rgb._clipped||!1},ed.prototype.alpha=function(t){return arguments.length?bd.rgb([this._rgb[0],this._rgb[1],this._rgb[2],t]):this._rgb[3]},ed.prototype.darken=function(t){var e,r;return null==t&&(t=1),r=this,e=r.lab(),e[0]-=id.Kn*t,bd.lab(e).alpha(r.alpha())},ed.prototype.brighten=function(t){return null==t&&(t=1),this.darken(-t)},ed.prototype.darker=ed.prototype.darken,ed.prototype.brighter=ed.prototype.brighten,ed.prototype.saturate=function(t){var e,r;return null==t&&(t=1),r=this,e=r.lch(),e[1]+=t*id.Kn,e[1]<0&&(e[1]=0),bd.lch(e).alpha(r.alpha())},ed.prototype.desaturate=function(t){return null==t&&(t=1),this.saturate(-t)},ed.prototype.premultiply=function(){var t,e;return e=this.rgb(),t=this.alpha(),bd(e[0]*t,e[1]*t,e[2]*t,t)},gd=function(t){return function(e,r){var i,n;return i=bd(r).rgb(),n=bd(e).rgb(),bd(t(i,n),"rgb")}},Ed=function(t){return function(e,r){var i,n,o;for(o=[],i=n=0;n<=3;i=++n)o[i]=t(e[i],r[i]);return o}},Kd=function(t,e){return t},Zd=function(t,e){return t*e/255},Ad=function(t,e){return t>e?e:t},$d=function(t,e){return t>e?t:e},yf=function(t,e){return 255*(1-(1-t/255)*(1-e/255))},Jd=function(t,e){return e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255))},yd=function(t,e){return 255*(1-(1-e/255)/(t/255))},Md=function(t,e){return 255===t?255:(t=e/255*255/(1-t/255))>255?255:t},(md=function(t,e,r){if(!md[r])throw"unknown blend mode "+r;return md[r](t,e)}).normal=gd(Ed(Kd)),md.multiply=gd(Ed(Zd)),md.screen=gd(Ed(yf)),md.overlay=gd(Ed(Jd)),md.darken=gd(Ed(Ad)),md.lighten=gd(Ed($d)),md.dodge=gd(Ed(Md)),md.burn=gd(Ed(yd)),bd.blend=md,bd.analyze=function(t){var e,r,i,n;for(i={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},r=0,e=t.length;ri.max&&(i.max=n),i.count+=1);return i.domain=[i.min,i.max],i.limits=function(t,e){return bd.limits(i,t,e)},i},bd.scale=function(t,e){var r,i,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_;return u="rgb",h=bd("#ccc"),f=0,a=[0,1],d=[],p=[0,0],r=!1,n=[],l=!1,c=0,s=1,o=!1,i={},m=!0,x=function(t){var e,r,i,o,a,s;if(null==t&&(t=["#fff","#000"]),null!=t&&"string"===wf(t)&&null!=bd.brewer&&(t=bd.brewer[t]||bd.brewer[t.toLowerCase()]||t),"array"===wf(t)){for(e=i=0,o=(t=t.slice(0)).length-1;0<=o?i<=o:i>=o;e=0<=o?++i:--i)r=t[e],"string"===wf(r)&&(t[e]=bd(r));for(d.length=0,e=s=0,a=t.length-1;0<=a?s<=a:s>=a;e=0<=a?++s:--s)d.push(e/(t.length-1))}return b(),n=t},v=function(t){var e,i;if(null!=r){for(i=r.length-1,e=0;e=r[e];)e++;return e-1}return 0},_=function(t){return t},y=function(t,e){var o,a,l,f,g,y,b;if(null==e&&(e=!1),isNaN(t))return h;if(e?b=t:r&&r.length>2?(b=v(t)/(r.length-2),b=p[0]+b*(1-p[0]-p[1])):s!==c?(b=(t-c)/(s-c),b=p[0]+b*(1-p[0]-p[1]),b=Math.min(1,Math.max(0,b))):b=1,e||(b=_(b)),l=Math.floor(1e4*b),m&&i[l])o=i[l];else{if("array"===wf(n))for(a=f=0,y=d.length-1;0<=y?f<=y:f>=y;a=0<=y?++f:--f){if(g=d[a],b<=g){o=n[a];break}if(b>=g&&a===d.length-1){o=n[a];break}if(b>g&&b=h;e=0<=h?++l:--l)d.push(e/(i-1));return a=[c,s],g},g.mode=function(t){return arguments.length?(u=t,b(),g):u},g.range=function(t,e){return x(t),g},g.out=function(t){return l=t,g},g.spread=function(t){return arguments.length?(f=t,g):f},g.correctLightness=function(t){return null==t&&(t=!0),o=t,b(),_=o?function(t){var e,r,i,n,o,a,s,c,u;for(e=y(0,!0).lab()[0],r=y(1,!0).lab()[0],s=e>r,i=y(t,!0).lab()[0],n=i-(o=e+(r-e)*t),c=0,u=1,a=20;Math.abs(n)>.01&&a-- >0;)s&&(n*=-1),n<0?(c=t,t+=.5*(u-t)):(u=t,t+=.5*(c-t)),i=y(t,!0).lab()[0],n=i-o;return t}:function(t){return t},g},g.padding=function(t){return null!=t?("number"===wf(t)&&(t=[t,t]),p=t,g):p},g.colors=function(e,i){var o,s,c,u,h,l,p;if(null==i&&(i="hex"),0===arguments.length)return n.map(function(t){return t[i]()});if(e)return 1===e?g(.5)[i]():(s=a[0],o=a[1]-s,function(){h=[];for(var t=0;0<=e?te;0<=e?t++:t--)h.push(t);return h}.apply(this).map(function(t){return g(s+t/(e-1)*o)[i]()}));if(t=[],l=[],r&&r.length>2)for(c=p=1,u=r.length;1<=u?pu;c=1<=u?++p:--p)l.push(.5*(r[c-1]+r[c]));else l=a;return l.map(function(t){return g(t)[i]()})},g.cache=function(t){return null!=t?m=t:m},g},null==bd.scales&&(bd.scales={}),bd.scales.cool=function(){return bd.scale([bd.hsl(180,1,.9),bd.hsl(250,.7,.4)])},bd.scales.hot=function(){return bd.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},bd.analyze=function(t,e,r){var i,n,o,a,s,c;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==r&&(r=function(){return!0}),i=function(t){null==t||isNaN(t)||(s.values.push(t),s.sum+=t,ts.max&&(s.max=t),s.count+=1)},c=function(t,n){if(r(t,n))return i(null!=e&&"function"===wf(e)?e(t):null!=e&&"string"===wf(e)||"number"===wf(e)?t[e]:t)},"array"===wf(t))for(a=0,o=t.length;a=F;w=1<=F?++O:--O)M.push(T+w/r*(Yd-T));M.push(Yd)}else if("l"===e.substr(0,1)){if(T<=0)throw"Logarithmic scales are only possible for values > 0";for(P=Math.LOG10E*Wd(T),E=Math.LOG10E*Wd(Yd),M.push(T),w=it=1,B=r-1;1<=B?it<=B:it>=B;w=1<=B?++it:--it)M.push(tf(10,P+w/r*(E-P)));M.push(Yd)}else if("q"===e.substr(0,1)){for(M.push(T),w=i=1,$=r-1;1<=$?i<=$:i>=$;w=1<=$?++i:--i)D=(rt.length-1)*w/r,(N=Td(D))===D?M.push(rt[N]):(k=D-N,M.push(rt[N]*(1-k)+rt[N+1]*k));M.push(Yd)}else if("k"===e.substr(0,1)){for(I=rt.length,g=new Array(I),x=new Array(r),Q=!0,R=0,y=null,(y=[]).push(T),w=n=1,H=r-1;1<=H?n<=H:n>=H;w=1<=H?++n:--n)y.push(T+w/r*(Yd-T));for(y.push(Yd);Q;){for(S=o=0,W=r-1;0<=W?o<=W:o>=W;S=0<=W?++o:--o)x[S]=0;for(w=a=0,X=I-1;0<=X?a<=X:a>=X;w=0<=X?++a:--a){for(et=rt[w],C=Number.MAX_VALUE,S=s=0,q=r-1;0<=q?s<=q:s>=q;S=0<=q?++s:--s)(_=pd(y[S]-et))=Y;S=0<=Y?++c:--c)L[S]=null;for(w=u=0,Z=I-1;0<=Z?u<=Z:u>=Z;w=0<=Z?++u:--u)null===L[b=g[w]]?L[b]=rt[w]:L[b]+=rt[w];for(S=h=0,K=r-1;0<=K?h<=K:h>=K;S=0<=K?++h:--h)L[S]*=1/x[S];for(Q=!1,S=l=0,z=r-1;0<=z?l<=z:l>=z;S=0<=z?++l:--l)if(L[S]!==y[w]){Q=!0;break}y=L,++R>200&&(Q=!1)}for(A={},S=p=0,U=r-1;0<=U?p<=U:p>=U;S=0<=U?++p:--p)A[S]=[];for(w=d=0,j=I-1;0<=j?d<=j:d>=j;w=0<=j?++d:--d)A[b=g[w]].push(rt[w]);for(J=[],S=f=0,G=r-1;0<=G?f<=G:f>=G;S=0<=G?++f:--f)J.push(A[S][0]),J.push(A[S][A[S].length-1]);for(J=J.sort(function(t,e){return t-e}),M.push(J[0]),w=m=1,V=J.length-1;m<=V;w=m+=2)tt=J[w],isNaN(tt)||-1!==M.indexOf(tt)||M.push(tt)}return M},Id=function(t,e,r){var i,n,o,a;return i=Sf(arguments),t=i[0],e=i[1],r=i[2],isNaN(t)&&(t=0),(t/=360)<1/3?o=1-((n=(1-e)/3)+(a=(1+e*wd(sd*t)/wd(od-sd*t))/3)):t<2/3?n=1-((a=(1-e)/3)+(o=(1+e*wd(sd*(t-=1/3))/wd(od-sd*t))/3)):a=1-((o=(1-e)/3)+(n=(1+e*wd(sd*(t-=2/3))/wd(od-sd*t))/3)),a=Hd(r*a*3),o=Hd(r*o*3),n=Hd(r*n*3),[255*a,255*o,255*n,i.length>3?i[3]:1]},af=function(){var t,e,r,i,n,o,a,s;return a=Sf(arguments),o=a[0],e=a[1],t=a[2],sd=2*Math.PI,o/=255,e/=255,t/=255,n=Math.min(o,e,t),i=(o+e+t)/3,0===(s=1-n/i)?r=0:(r=(o-e+(o-t))/2,r/=Math.sqrt((o-e)*(o-e)+(o-t)*(e-t)),r=Math.acos(r),t>e&&(r=sd-r),r/=sd),[360*r,s,i]},bd.hsi=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(ed,Cf.call(arguments).concat(["hsi"]),function(){})},hd.hsi=Id,ed.prototype.hsi=function(){return af(this._rgb)},Nd=function(t,e,r,i){var n,o,a,s,c,u,h,l,p,d,f;return"hsl"===i?(d=t.hsl(),f=e.hsl()):"hsv"===i?(d=t.hsv(),f=e.hsv()):"hcg"===i?(d=t.hcg(),f=e.hcg()):"hsi"===i?(d=t.hsi(),f=e.hsi()):"lch"!==i&&"hcl"!==i||(i="hcl",d=t.hcl(),f=e.hcl()),"h"===i.substr(0,1)&&(o=d[0],l=d[1],c=d[2],a=f[0],p=f[1],u=f[2]),isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?n=Number.NaN:(n=a,1!==c&&0!==c||"hsv"===i||(h=p)):(n=o,1!==u&&0!==u||"hsv"===i||(h=l)):n=o+r*(a>o&&a-o>180?a-(o+360):a180?a+360-o:a-o),null==h&&(h=l+r*(p-l)),s=c+r*(u-c),bd[i](n,h,s)},Fd=function(t,e,r,i){var n,o;return n=t.num(),o=e.num(),bd.num(n+(o-n)*r,"num")},(ld=ld.concat(function(){var t,e,r,i;for(i=[],e=0,t=(r=["hsv","hsl","hsi","hcl","lch","hcg"]).length;e>16&255)/255,e[r+1]=(t>>8&255)/255,e[r+2]=(255&t)/255,e},Rf.prototype.atomColorToArray=function(t,e,r){return this.colorToArray(this.atomColor(t),e,r)},Rf.prototype.bondColor=function(t,e){return this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)},Rf.prototype.bondColorToArray=function(t,e,r,i){return this.colorToArray(this.bondColor(t,e),r,i)},Rf.prototype.volumeColorToArray=function(t,e,r){return this.colorToArray(this.volumeColor(t),e,r)},Rf.prototype.positionColorToArray=function(t,e,r){return this.colorToArray(this.positionColor(t),e,r)},_o.prototype={active:!0,params:null,execute:function(t){var e,r;return this.active&&this._listener&&(r=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,r),this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},So.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,e,r,i){var n,o=this._indexOfListener(t,r);if(-1!==o){if((n=this._bindings[o]).isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else n=new _o(this,t,e,r,i),this._addBinding(n);return this.memorize&&this._prevParams&&n.execute(this._prevParams),n},_addBinding:function(t){var e=this._bindings.length;do{--e}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var r,i=this,n=this._bindings.length;n--;)if((r=i._bindings[n])._listener===t&&r.context===e)return n;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,r){return wo(t,"add"),this._registerListener(t,!1,e,r)},addOnce:function(t,e,r){return wo(t,"addOnce"),this._registerListener(t,!0,e,r)},remove:function(t,e){wo(t,"remove");var r=this._indexOfListener(t,e);return-1!==r&&(this._bindings[r]._destroy(),this._bindings.splice(r,1)),t},removeAll:function(){for(var t=this,e=this._bindings.length;e--;)t._bindings[e]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(t){if(this.active){var e,r=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=r),i){e=this._bindings.slice(),this._shouldPropagate=!0;do{i--}while(e[i]&&this._shouldPropagate&&!1!==e[i].execute(r))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var Lf={PROTEIN:1,NUCLEIC:2,RNA:3,DNA:4,POLYMER:5,WATER:6,HELIX:7,SHEET:8,TURN:9,BACKBONE:10,SIDECHAIN:11,ALL:12,HETERO:13,ION:14,SACCHARIDE:15,SUGAR:15,BONDED:16,RING:17},Of=["*","","ALL"],Df=[Lf.BACKBONE,Lf.SIDECHAIN,Lf.BONDED,Lf.RING],Nf=[Lf.POLYMER,Lf.WATER],kf=["ALA","GLY","SER"],Ff=["CYS","SER","THR"],Bf=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],zf=["PHE","TRP","TYR","HIS"],Uf=["ASN","GLN"],jf=["ASP","GLU"],Gf=["ARG","HIS","LYS"],Vf=["ARG","ASP","GLU","HIS","LYS"],$f=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],Hf=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Wf=["HIS","PHE","PRO","TRP","TYR"],Xf=["ALA","GLY","ILE","LEU","VAL"],qf=function(t){this.signals={stringChanged:new So},this.setString(t)},Yf={type:{}};Yf.type.get=function(){return"selection"},qf.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.selection=Ao(t)}catch(t){this.selection={error:t.message}}var r=this.selection;this.string=t,this.test=Ro(r),this.residueTest=Lo(r),this.chainTest=Oo(r),this.modelTest=Do(r),this.atomOnlyTest=Ro(r,!0),this.residueOnlyTest=Lo(r,!0),this.chainOnlyTest=Oo(r,!0),this.modelOnlyTest=Do(r,!0),e||this.signals.stringChanged.dispatch(this.string)}},Object.defineProperties(qf.prototype,Yf);var Zf=function(t){function e(e){var r=this;t.call(this,e);var i=e.dataList||[];this.colormakerList=[],this.selectionList=[],i.forEach(function(t){var e=t[0],i=t[1],n=t[2];void 0===n&&(n={}),pm.hasScheme(e)?Object.assign(n,{scheme:e,structure:r.structure}):Object.assign(n,{scheme:"uniform",value:new et(e).getHex()}),r.colormakerList.push(pm.getScheme(n)),r.selectionList.push(new qf(i))})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){for(var e=this,r=0,i=this.selectionList.length;ri).lines},_m.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},_m.prototype.asText=function(){return this.isBinary()?qn(this.data):this.data},_m.prototype.chunkToLines=function(t,e,r){var i=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(i),partialLine:""};var n=[],o=this.isBinary()?qn(t):t,a=o.lastIndexOf(i);if(-1===a)e+=o;else{var s=e+o.substr(0,a);n=n.concat(s.split(i)),e=a===o.length-i.length?"":o.substr(a+i.length)}return r&&""!==e&&n.push(e),{lines:n,partialLine:e}},_m.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},_m.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,r=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=r.partialLine,r.lines}},_m.prototype.eachChunk=function(t){for(var e=this,r=this.chunkSize,i=this.data.length,n=this.chunkCount(),o=0;o>>0:0,o=t.byteLength-n,a=n;t.buffer&&(t.byteLength!==t.buffer.byteLength&&(a=t.byteOffset+n),t=t.buffer),this._lastWrittenByte=i?o:0,this.buffer=t,this.length=o,this.byteLength=o,this.byteOffset=a,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,a,o),this._mark=0,this._marks=[]};Bm.prototype.available=function(t){return void 0===t&&(t=1),this.offset+t<=this.length},Bm.prototype.isLittleEndian=function(){return this.littleEndian},Bm.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},Bm.prototype.isBigEndian=function(){return!this.littleEndian},Bm.prototype.setBigEndian=function(){return this.littleEndian=!1,this},Bm.prototype.skip=function(t){return void 0===t&&(t=1),this.offset+=t,this},Bm.prototype.seek=function(t){return this.offset=t,this},Bm.prototype.mark=function(){return this._mark=this.offset,this},Bm.prototype.reset=function(){return this.offset=this._mark,this},Bm.prototype.pushMark=function(){return this._marks.push(this.offset),this},Bm.prototype.popMark=function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this},Bm.prototype.rewind=function(){return this.offset=0,this},Bm.prototype.ensureAvailable=function(t){if(void 0===t&&(t=1),!this.available(t)){var e=2*(this.offset+t),r=new Uint8Array(e);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this},Bm.prototype.readBoolean=function(){return 0!==this.readUint8()},Bm.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},Bm.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},Bm.prototype.readByte=function(){return this.readUint8()},Bm.prototype.readBytes=function(t){var e=this;void 0===t&&(t=1);for(var r=new Uint8Array(t),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)};var zm=function(t){function e(e){t.call(this),this.surface=e,this._records=[]}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={mimeType:{},defaultName:{},defaultExt:{}};return r.mimeType.get=function(){return"application/vnd.ms-pki.stl"},r.defaultName.get=function(){return"surface"},r.defaultExt.get=function(){return"stl"},e.prototype.getData=function(){var t=this,e=this.surface.index.length/3,r=new Bm(2*e+3*e*4*4+80+4);r.skip(80),r.writeUint32(e);for(var i=new v,n=new v,o=new v,a=new v,s=0;sthis.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t}},gm.add("shader/chunk/dull_interior_fragment.glsl","#ifdef DULL_INTERIOR\nif( gl_FrontFacing == false ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#endif"),gm.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),gm.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),gm.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),gm.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip )\ndiscard;\n#endif"),gm.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),gm.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),gm.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),gm.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");var jm=/^(?!\/\/)\s*#include\s+(\S+)/gim,Gm={};if("undefined"!=typeof window&&window.WebGLRenderingContext){var Vm=window.WebGLRenderingContext.prototype,$m=Vm.getShaderParameter;Vm.getShaderParameter=function(){return!t.Debug||$m.apply(this,arguments)};var Hm=Vm.getShaderInfoLog;Vm.getShaderInfoLog=function(){return t.Debug?Hm.apply(this,arguments):""};var Wm=Vm.getProgramParameter;Vm.getProgramParameter=function(e,r){return!t.Debug&&r===Vm.LINK_STATUS||Wm.apply(this,arguments)};var Xm=Vm.getProgramInfoLog;Vm.getProgramInfoLog=function(){return t.Debug?Xm.apply(this,arguments):""}}var qm=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];qm.forEach(function(t){t.forEach(function(t){t[0]*=.0625,t[1]*=.0625})}),Yo.prototype.constructor=Yo;var Ym=2*Math.PI,Zm=new v,Km=new y,Qm=new y,Jm=new l,tg=new y,eg=new y,rg=new Float32Array(4),ig=new Uint8Array(4),ng=new y;ya.prototype.constructor=ya;var og=function(t,e){this.signals={moved:new So,scrolled:new So,dragged:new So,dropped:new So,clicked:new So,hovered:new So,doubleClicked:new So};var r=Object.assign({},e);this.hoverTimeout=Nn(r.hoverTimeout,50),this.handleScroll=Nn(r.handleScroll,!0),this.doubleClickSpeed=Nn(r.doubleClickSpeed,500),this.domElement=t,this.domElement.style.touchAction="none",this.position=new l,this.prevPosition=new l,this.down=new l,this.canvasPosition=new l,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=void 0,this.buttons=void 0,this.pressed=void 0,this.altKey=void 0,this.ctrlKey=void 0,this.metaKey=void 0,this.shiftKey=void 0,this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen(),document.addEventListener("mousewheel",this._onMousewheel),document.addEventListener("wheel",this._onMousewheel),document.addEventListener("MozMousePixelScroll",this._onMousewheel),document.addEventListener("mousemove",this._onMousemove),document.addEventListener("mousedown",this._onMousedown),document.addEventListener("mouseup",this._onMouseup),document.addEventListener("contextmenu",this._onContextmenu),document.addEventListener("touchstart",this._onTouchstart),document.addEventListener("touchend",this._onTouchend),document.addEventListener("touchmove",this._onTouchmove),this.prevClickCP=new l},ag={key:{}};ag.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},og.prototype.setParameters=function(t){var e=Object.assign({},t);this.hoverTimeout=Nn(e.hoverTimeout,this.hoverTimeout)},og.prototype._listen=function(){var t=window.performance.now(),e=this.canvasPosition;this.doubleClickPending&&t-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),t-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(e.x,e.y))),window.requestAnimationFrame(this._listen)},og.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var r=0;r=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail/3:-t.deltaY/(t.deltaMode?.33:30),this.signals.scrolled.dispatch(r),setTimeout(function(){e.scrolled=!0},this.hoverTimeout)}},og.prototype._onMousemove=function(t){t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(t),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.clientX,t.clientY),this._setCanvasPosition(t);var e=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,r),this.pressed&&this.signals.dragged.dispatch(e,r)},og.prototype._onMousedown=function(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=xa(t),this.pressed=!0,this._setCanvasPosition(t))},og.prototype._onMouseup=function(t){t.target===this.domElement&&t.preventDefault(),this._setKeys(t);var e=this.canvasPosition;this._distance()<4&&(this.lastClicked=window.performance.now(),this.doubleClickPending&&this.prevClickCP.distanceTo(e)<4?(this.signals.doubleClicked.dispatch(e.x,e.y),this.doubleClickPending=!1):(this.signals.clicked.dispatch(e.x,e.y),this.doubleClickPending=!0),this.prevClickCP.copy(e)),this.which=void 0,this.buttons=void 0,this.pressed=void 0},og.prototype._onContextmenu=function(t){t.target===this.domElement&&t.preventDefault()},og.prototype._onTouchstart=function(t){if(t.target===this.domElement)switch(t.preventDefault(),this.pressed=!0,t.touches.length){case 1:this.moving=!1,this.hovering=!1,this.down.set(t.touches[0].pageX,t.touches[0].pageY),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);break;case 2:this.down.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.lastTouchDistance=ba(t)}},og.prototype._onTouchend=function(t){t.target===this.domElement&&t.preventDefault(),this.which=void 0,this.buttons=void 0,this.pressed=void 0},og.prototype._onTouchmove=function(t){switch(t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,t.touches.length){case 1:this._setKeys(t),this.which=1,this.buttons=1,this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);var e=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,r),this.pressed&&this.signals.dragged.dispatch(e,r);break;case 2:var i=ba(t),n=i-this.lastTouchDistance;if(this.lastTouchDistance=i,this.prevPosition.copy(this.position),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),Math.abs(n)>2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(n/2);else{this.which=3,this.buttons=2;var o=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(o,a),this.pressed&&this.signals.dragged.dispatch(o,a)}}},og.prototype._distance=function(){return this.position.distanceTo(this.down)},og.prototype._setCanvasPosition=function(t){var e,r,i=this.domElement.getBoundingClientRect();"offsetX"in t&&"offsetY"in t?(e=t.offsetX,r=t.offsetY):(e=t.clientX-i.left,r=t.clientY-i.top),this.canvasPosition.set(e,i.height-r)},og.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},og.prototype.dispose=function(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove)},Object.defineProperties(og.prototype,ag);var sg=new y,cg=new y,ug=new y,hg=new v,lg=new g,pg=new y,dg=new v,fg=new v,mg=function(t,e){var r=e||{};this.rotateSpeed=Nn(r.rotateSpeed,2),this.zoomSpeed=Nn(r.zoomSpeed,1.2),this.panSpeed=Nn(r.panSpeed,1),this.stage=t,this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},gg={component:{},atom:{}};gg.component.get=function(){return this.stage.transformComponent},gg.atom.get=function(){return this.stage.transformAtom},mg.prototype._setPanVector=function(t,e,r){var i,n=this.viewer.camera;if(r=-r||0,r+=n.position.z,"OrthographicCamera"===n.type)i=1/n.zoom;else{var o=co(n.fov);i=-2*r*Math.tan(o/2)/this.viewer.height}dg.set(t,e,0),dg.multiplyScalar(this.panSpeed*i)},mg.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},mg.prototype._transformPanVector=function(){pg.extractRotation(this.component.transform),pg.premultiply(this.viewer.rotationGroup.matrix),pg.getInverse(pg),dg.applyMatrix4(pg)},mg.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},mg.prototype.pan=function(t,e){this._setPanVector(t,e),pg.getInverse(this.viewer.rotationGroup.matrix),dg.applyMatrix4(pg),this.controls.translate(dg)},mg.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(dg),this.component.updateMatrix())},mg.prototype.panAtom=function(t,e){this.atom&&this.component&&(this.atom.positionToVector3(fg),fg.add(this.viewer.translationGroup.position),fg.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,fg.z),this._transformPanVector(),this.atom.positionAdd(dg),this.component.updateRepresentations({position:!0}))},mg.prototype.rotate=function(t,e){var r=this._getRotateXY(t,e),i=r[0],n=r[1];sg.makeRotationX(n),cg.makeRotationY(i),sg.multiply(cg),this.controls.applyMatrix(sg)},mg.prototype.rotateComponent=function(t,e){if(this.component){var r=this._getRotateXY(t,e),i=r[0],n=r[1];ug.extractRotation(this.component.transform),ug.premultiply(this.viewer.rotationGroup.matrix),ug.getInverse(ug),hg.set(1,0,0),hg.applyMatrix4(ug),sg.makeRotationAxis(hg,n),hg.set(0,1,0),hg.applyMatrix4(ug),cg.makeRotationAxis(hg,i),sg.multiply(cg),lg.setFromRotationMatrix(sg),this.component.quaternion.premultiply(lg),this.component.updateMatrix()}},Object.defineProperties(mg.prototype,gg);var vg=function(t,e){this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver},yg={type:{},altKey:{},ctrlKey:{},metaKey:{},shiftKey:{},canvasPosition:{},component:{},object:{},position:{},closestBondAtom:{},arrow:{},atom:{},axes:{},bond:{},box:{},cone:{},clash:{},contact:{},cylinder:{},distance:{},ellipsoid:{},octahedron:{},mesh:{},slice:{},sphere:{},tetrahedron:{},torus:{},surface:{},unitcell:{},unknown:{},volume:{}};yg.type.get=function(){return this.picker.type},yg.altKey.get=function(){return this.mouse.altKey},yg.ctrlKey.get=function(){return this.mouse.ctrlKey},yg.metaKey.get=function(){return this.mouse.metaKey},yg.shiftKey.get=function(){return this.mouse.shiftKey},yg.canvasPosition.get=function(){return this.mouse.canvasPosition},yg.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},yg.object.get=function(){return this.picker.getObject(this.pid)},yg.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},yg.closestBondAtom.get=function(){if("bond"===this.type){var t=this.bond,e=this.controls;return _a(this.canvasPosition,e.getPositionOnCanvas(t.atom1),e.getPositionOnCanvas(t.atom2))?t.atom1:t.atom2}},yg.arrow.get=function(){return this._objectIfType("arrow")},yg.atom.get=function(){return this._objectIfType("atom")},yg.axes.get=function(){return this._objectIfType("axes")},yg.bond.get=function(){return this._objectIfType("bond")},yg.box.get=function(){return this._objectIfType("box")},yg.cone.get=function(){return this._objectIfType("cone")},yg.clash.get=function(){return this._objectIfType("clash")},yg.contact.get=function(){return this._objectIfType("contact")},yg.cylinder.get=function(){return this._objectIfType("cylinder")},yg.distance.get=function(){return this._objectIfType("distance")},yg.ellipsoid.get=function(){return this._objectIfType("ellipsoid")},yg.octahedron.get=function(){return this._objectIfType("octahedron")},yg.mesh.get=function(){return this._objectIfType("mesh")},yg.slice.get=function(){return this._objectIfType("slice")},yg.sphere.get=function(){return this._objectIfType("sphere")},yg.tetrahedron.get=function(){return this._objectIfType("tetrahedron")},yg.torus.get=function(){return this._objectIfType("torus")},yg.surface.get=function(){return this._objectIfType("surface")},yg.unitcell.get=function(){return this._objectIfType("unitcell")},yg.unknown.get=function(){return this._objectIfType("unknown")},yg.volume.get=function(){return this._objectIfType("volume")},vg.prototype._objectIfType=function(t){return this.type===t?this.object:void 0},vg.prototype.getLabel=function(){var t="nothing";return this.arrow?t="arrow: "+(this.arrow.name||this.pid)+" ("+this.arrow.shape.name+")":this.atom?t="atom: "+this.atom.qualifiedName()+" ("+this.atom.structure.name+")":this.axes?t="axes":this.bond?t="bond: "+this.bond.atom1.qualifiedName()+" - "+this.bond.atom2.qualifiedName()+" ("+this.bond.structure.name+")":this.box?t="box: "+(this.box.name||this.pid)+" ("+this.box.shape.name+")":this.cone?t="cone: "+(this.cone.name||this.pid)+" ("+this.cone.shape.name+")":this.clash?t="clash: "+this.clash.clash.sele1+" - "+this.clash.clash.sele2:this.contact?t="contact: "+this.contact.atom1.qualifiedName()+" - "+this.contact.atom2.qualifiedName()+" ("+this.contact.structure.name+")":this.cylinder?t="cylinder: "+(this.cylinder.name||this.pid)+" ("+this.cylinder.shape.name+")":this.distance?t="distance: "+this.distance.atom1.qualifiedName()+" - "+this.distance.atom2.qualifiedName()+" ("+this.distance.structure.name+")":this.ellipsoid?t="ellipsoid: "+(this.ellipsoid.name||this.pid)+" ("+this.ellipsoid.shape.name+")":this.octahedron?t="octahedron: "+(this.octahedron.name||this.pid)+" ("+this.octahedron.shape.name+")":this.mesh?t="mesh: "+(this.mesh.name||this.mesh.serial)+" ("+this.mesh.shape.name+")":this.slice?t="slice: "+this.slice.value.toPrecision(3)+" ("+this.slice.volume.name+")":this.sphere?t="sphere: "+(this.sphere.name||this.pid)+" ("+this.sphere.shape.name+")":this.surface?t="surface: "+this.surface.surface.name:this.tetrahedron?t="tetrahedron: "+(this.tetrahedron.name||this.pid)+" ("+this.tetrahedron.shape.name+")":this.torus?t="torus: "+(this.torus.name||this.pid)+" ("+this.torus.shape.name+")":this.unitcell?t="unitcell: "+this.unitcell.unitcell.spacegroup+" ("+this.unitcell.structure.name+")":this.unknown?t="unknown":this.volume&&(t="volume: "+this.volume.value.toPrecision(3)+" ("+this.volume.volume.name+")"),t},Object.defineProperties(vg.prototype,yg);var bg=function(t){this.stage=t,this.viewer=t.viewer};bg.prototype.pick=function(t,e){var r=this.viewer.pick(t,e);if(r.picker&&"ignore"!==r.picker.type&&void 0!==r.pid){var i=r.picker.array;if(!(i&&r.pid>=i.length))return new vg(r,this.stage);console.error("pid >= picker.array.length")}};var xg=new g,_g=new v,wg=new v,Sg=new v,Ag=new v,Mg=new y,Eg=new v,Tg=new y,Pg=function(t){this.stage=t,this.viewer=t.viewer,this.signals={changed:new So}},Cg={position:{},rotation:{}};Cg.position.get=function(){return this.viewer.translationGroup.position},Cg.rotation.get=function(){return this.viewer.rotationGroup.quaternion},Pg.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},Pg.prototype.getPositionOnCanvas=function(t,e){var r=ro(e),i=this.viewer;return Sg.copy(t).add(i.translationGroup.position).applyMatrix4(i.rotationGroup.matrix).project(i.camera),r.set((Sg.x+1)*i.width/2,(Sg.y+1)*i.height/2)},Pg.prototype.getOrientation=function(t){var e=no(t);e.copy(this.viewer.rotationGroup.matrix);var r=-this.viewer.camera.position.z;return e.scale(Ag.set(r,r,r)),e.setPosition(this.viewer.translationGroup.position),e},Pg.prototype.orient=function(t){no(t).decompose(_g,xg,wg);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(xg),e.translationGroup.position.copy(_g),e.camera.position.z=-wg.z,e.updateZoom(),this.changed()},Pg.prototype.translate=function(t){this.viewer.translationGroup.position.add(io(t)),this.changed()},Pg.prototype.center=function(t){this.viewer.translationGroup.position.copy(io(t)).negate(),this.changed()},Pg.prototype.zoom=function(t){this.distance(this.viewer.camera.position.z*(1-t))},Pg.prototype.distance=function(t){this.viewer.camera.position.z=t,this.viewer.updateZoom(),this.changed()},Pg.prototype.spin=function(t,e){Mg.getInverse(this.viewer.rotationGroup.matrix),Eg.copy(io(t)).applyMatrix4(Mg),this.viewer.rotationGroup.rotateOnAxis(Eg,e),this.changed()},Pg.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(oo(t)),this.changed()},Pg.prototype.align=function(t){Tg.getInverse(no(t)),this.viewer.rotationGroup.setRotationFromMatrix(Tg),this.changed()},Pg.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix(no(t)),this.changed()},Object.defineProperties(Pg.prototype,Cg);var Ig=function(t,e){for(var r=[],i=arguments.length-2;i-- >0;)r[i]=arguments[i+2];this.duration=Nn(t,1e3),this.controls=e,this.startTime=window.performance.now(),this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],(n=this)._init.apply(n,r);var n},Rg={done:{},paused:{}};Rg.done.get=function(){return 1===this.alpha},Rg.paused.get=function(){return this._paused},Ig.prototype._init=function(){},Ig.prototype._tick=function(){},Ig.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=bo(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach(function(t){return t()}),this.done},Ig.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},Ig.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},Ig.prototype.toggle=function(){this._paused?this.resume():this.pause()},Ig.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise(function(t){return e._resolveList.push(t)})).then(t)},Object.defineProperties(Ig.prototype,Rg);var Lg=function(t){function e(e){for(var r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];t.apply(this,[Nn(e,1/0)].concat(r))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){Array.isArray(t)?this.axis=(new v).fromArray(t):this.axis=Nn(t,new v(0,1,0)),this.angle=Nn(e,.01)},e.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},e}(Ig),Og=function(t){function e(e){for(var r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];t.apply(this,[Nn(e,1/0)].concat(r))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,r){Array.isArray(t)?this.axis=(new v).fromArray(t):this.axis=Nn(t,new v(0,1,0)),this.angleStep=Nn(e,.01),this.angleEnd=Nn(r,.2),this.angleSum=0,this.direction=1},e.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=bo(0,1,Math.abs(this.angleSum)/this.angleEnd),r=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,r*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},e}(Ig),Dg=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.moveFrom=io(Nn(t,new v)),this.moveTo=io(Nn(e,new v))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(Ig),Ng=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.zoomFrom=t,this.zoomTo=e},e.prototype._tick=function(){this.controls.distance(vo(this.zoomFrom,this.zoomTo,this.alpha))},e}(Ig),kg=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.rotateFrom=oo(t),this.rotateTo=oo(e),this._currentRotation=new g},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(Ig),Fg=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,r){this.valueFrom=t,this.valueTo=e,this.callback=r},e.prototype._tick=function(){this.callback(vo(this.valueFrom,this.valueTo,this.alpha))},e}(Ig),Bg=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(Ig),zg=function(t){this._list=t||[],this._resolveList=[]},Ug={done:{}};Ug.done.get=function(){return this._list.every(function(t){return t.done})},zg.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise(function(t){e._resolveList.push(t),e._list.forEach(function(t){t.then(function(){e._resolveList.forEach(function(t){t()}),e._resolveList.length=0})})})).then(t)},Object.defineProperties(zg.prototype,Ug);var jg=function(t){this.stage=t,this.viewer=t.viewer,this.controls=t.viewerControls,this.animationList=[],this.finishedList=[]},Gg={paused:{}};Gg.paused.get=function(){return this.animationList.every(function(t){return t.paused})},jg.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},jg.prototype.remove=function(t){var e=this.animationList,r=e.indexOf(t);r>-1&&e.splice(r,1)},jg.prototype.run=function(t){for(var e=this,r=this.finishedList,i=this.animationList,n=i.length,o=0;o0;)r[i]=arguments[i+1];if(!this.disabled){var n=this.mouse.key||0,o=this.mouse.buttons||0;this.actionList.forEach(function(i){i.type===t&&i.key===n&&i.button===o&&i.callback.apply(i,[e.stage].concat(r))})}},Hg.prototype.add=function(t,e){var r=wa(t),i=r[0],n=r[1],o=r[2];this.actionList.push({type:i,key:n,button:o,callback:e})},Hg.prototype.remove=function(t,e){var r=t.includes("*"),i=wa(t),n=i[0],o=i[1],a=i[2],s=this.actionList.filter(function(t){return!((t.type===n||r&&""===n)&&(t.key===o||r&&0===o)&&(t.button===a||r&&0===a)&&(t.callback===e||void 0===e))});this.actionList=s},Hg.prototype.preset=function(t){var e=this;this.clear(),($g[t]||[]).forEach(function(t){return(r=e).add.apply(r,t);var r})},Hg.prototype.clear=function(){this.actionList.length=0};var Wg=function(){};Wg.autoView=function(t){t.autoView(1e3)},Wg.toggleAnimations=function(t){t.animationControls.toggle()},Wg.toggleRock=function(t){t.toggleRock()};var Xg={default:[["i",Wg.toggleSpin=function(t){t.toggleSpin()}],["k",Wg.toggleRock],["p",Wg.toggleAnimations],["r",Wg.autoView]]},qg=function(t,e){var r=e||{};this.stage=t,this.actionList=[],this.disabled=r.disabled||!1,this.preset(r.preset||"default")};qg.prototype.run=function(t){var e=this;this.disabled||this.actionList.forEach(function(r){r.keyCode===t&&r.callback(e.stage)})},qg.prototype.add=function(t,e){var r=t.charCodeAt(0);this.actionList.push({keyCode:r,callback:e})},qg.prototype.remove=function(t,e){var r=t.charCodeAt(0),i=this.actionList.filter(function(t){return!(t.keyCode===r&&(t.callback===e||void 0===e))});this.actionList=i},qg.prototype.preset=function(t){var e=this;this.clear(),(Xg[t]||[]).forEach(function(t){return(r=e).add.apply(r,t);var r})},qg.prototype.clear=function(){this.actionList.length=0};var Yg=function(t){this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)};Yg.prototype._onClick=function(t,e){var r=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(r),this.controls.run("clickPick",r)},Yg.prototype._onHover=function(t,e){var r=this.stage.pickingControls.pick(t,e);r&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=r.component,this.stage.transformAtom=r.atom),this.stage.signals.hovered.dispatch(r),this.controls.run("hoverPick",r)},Yg.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Zg=function(t){this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)};Zg.prototype._onMove=function(){this.stage.tooltip.style.display="none"},Zg.prototype._onScroll=function(t){this.controls.run("scroll",t)},Zg.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},Zg.prototype._onClick=function(t,e){this.controls.run("click",t,e)},Zg.prototype._onDblclick=function(t,e){this.controls.run("doubleClick",t,e)},Zg.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},Zg.prototype.dispose=function(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Kg=function(t){this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};Kg.prototype._onTick=function(t){this.animationControls.run(t)},Kg.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var Qg=!!im&&{passive:!0},Jg=function(t){this.stage=t,this.controls=t.keyControls,this.domElement=t.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this.domElement.autofocus=!0,this.domElement.focus(),this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,Qg),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)};Jg.prototype._onKeydown=function(){},Jg.prototype._onKeyup=function(){},Jg.prototype._onKeypress=function(t){this.controls.run(t.keyCode)},Jg.prototype._focusDomElement=function(){this.domElement.focus()},Jg.prototype.dispose=function(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,Qg),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)};var tv=function(t,e,r,i){var n=i||{};this.offsetX=Nn(n.offsetX,0),this.offsetY=Nn(n.offsetY,0),this.visible=Nn(n.visible,!0),this.component=t,this.stage=t.stage,this.viewer=this.stage.viewer,this.position=e,this._viewerPosition=new v,this._updateViewerPosition(),this._canvasPosition=new v,this._cameraPosition=new v,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"fixed",zIndex:1+(parseInt(this.viewer.container.style.zIndex)||0),pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif",left:"-10000px"}),this.viewer.container.appendChild(this.element),this.setContent(r),this.updateVisibility(),this.viewer.signals.ticked.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};tv.prototype.setContent=function(t){var e=this.element.style.display;"none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof window.Element?(this.element.innerHTML="",this.element.appendChild(t)):this.element.innerHTML=t,this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)},tv.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},tv.prototype.getVisibility=function(){return this.visible&&this.component.visible},tv.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},tv.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},tv.prototype._update=function(){if(this.getVisibility()){var t=this.element.style,e=this._canvasPosition,r=this._viewerPosition,i=this._clientRect;this._cameraPosition.copy(r).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0?t.display="none":(t.display="block",t.opacity=1-bo(this.viewer.scene.fog.near,this.viewer.scene.fog.far,this._cameraPosition.length()),this.stage.viewerControls.getPositionOnCanvas(r,e),t.bottom=this.offsetX+e.y+i.height/2+"px",t.left=this.offsetY+e.x-i.width/2+"px")}},tv.prototype.dispose=function(){this.viewer.container.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var ev=new y,rv=new v,iv=new g,nv=function(t){this.component=t,this.stage=t.stage,this.viewer=t.stage.viewer,this.signals={changed:new So}},ov={position:{},rotation:{}};ov.position.get=function(){return this.component.position},ov.rotation.get=function(){return this.component.quaternion},nv.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},nv.prototype.spin=function(t,e){ev.getInverse(this.viewer.rotationGroup.matrix),rv.copy(io(t)).applyMatrix4(ev),ev.extractRotation(this.component.transform),ev.premultiply(this.viewer.rotationGroup.matrix),ev.getInverse(ev),rv.copy(io(t)),rv.applyMatrix4(ev),ev.makeRotationAxis(rv,e),iv.setFromRotationMatrix(ev),this.component.quaternion.premultiply(iv),this.changed()},Object.defineProperties(nv.prototype,ov),Da.__deps=[Na],ka.__deps=[Na,Oa];var av=new v,sv=function(){},cv={Picker:{},Buffer:{}};cv.Picker.get=function(){return xm.get(this.type)},cv.Buffer.get=function(){return bm.get(this.type)},sv.getShapeKey=function(t){return this.type+t[0].toUpperCase()+t.substr(1)},sv.valueToShape=function(t,e,r){var i=t[this.getShapeKey(e)];switch(this.fields[e]){case"v3":case"c":Ga(r,i);break;default:i.push(r)}},sv.objectToShape=function(t,e){var r=this;Object.keys(this.fields).forEach(function(i){r.valueToShape(t,i,e[i])}),this.valueToShape(t,"name",e.name),this.expandBoundingBox(t.boundingBox,e)},sv.valueFromShape=function(t,e,r){var i=t[this.getShapeKey(r)];switch(this.fields[r]){case"v3":return(new v).fromArray(i,3*e);case"c":return(new et).fromArray(i,3*e);default:return i[e]}},sv.objectFromShape=function(t,e){var r=this,i={shape:t,name:this.valueFromShape(t,e,"name")};return Object.keys(this.fields).forEach(function(n){i[n]=r.valueFromShape(t,e,n)}),i},sv.arrayFromShape=function(t,e){var r=t[this.getShapeKey(e)];switch(this.fields[e]){case"s":return r;default:return new Float32Array(r)}},sv.dataFromShape=function(t){var e=this,r={};return this.Picker&&(r.picking=new this.Picker(t)),Object.keys(this.fields).forEach(function(i){r[i]=e.arrayFromShape(t,i)}),r},sv.bufferFromShape=function(t,e){return new this.Buffer(this.dataFromShape(t),e)},Object.defineProperties(sv,cv);var uv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},fields:{}};return r.type.get=function(){return"sphere"},r.fields.get=function(){return{position:"v3",color:"c",radius:"f"}},e.positionFromShape=function(t,e){return this.valueFromShape(t,e,"position")},e.expandBoundingBox=function(t,e){t.expandByPoint(av.fromArray(e.position))},Object.defineProperties(e,r),e}(sv),hv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},fields:{}};return r.type.get=function(){return"box"},r.fields.get=function(){return{position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"}},Object.defineProperties(e,r),e}(uv),lv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"octahedron"},Object.defineProperties(e,r),e}(hv),pv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"tetrahedron"},Object.defineProperties(e,r),e}(hv),dv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},fields:{}};return r.type.get=function(){return"cylinder"},r.fields.get=function(){return{position1:"v3",position2:"v3",color:"c",radius:"f"}},e.positionFromShape=function(t,e){var r=this.valueFromShape(t,e,"position1"),i=this.valueFromShape(t,e,"position2");return r.add(i).multiplyScalar(.5)},e.expandBoundingBox=function(t,e){t.expandByPoint(av.fromArray(e.position1)),t.expandByPoint(av.fromArray(e.position2))},Object.defineProperties(e,r),e}(sv),fv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"arrow"},Object.defineProperties(e,r),e}(dv),mv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"cone"},Object.defineProperties(e,r),e}(dv),gv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},fields:{}};return r.type.get=function(){return"ellipsoid"},r.fields.get=function(){return{position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"}},Object.defineProperties(e,r),e}(uv),vv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"torus"},Object.defineProperties(e,r),e}(gv),yv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},fields:{}};return r.type.get=function(){return"text"},r.fields.get=function(){return{position:"v3",color:"c",size:"f",text:"s"}},Object.defineProperties(e,r),e}(uv),bv=function(t){this.array=t};bv.prototype.getIndex=function(t){return this.array?this.array[t]:t},bv.prototype.getObject=function(){return{}},bv.prototype._applyTransformations=function(t,e,r){return e&&t.applyMatrix4(e.matrix),r&&t.applyMatrix4(r.matrix),t},bv.prototype._getPosition=function(){return new v},bv.prototype.getPosition=function(t,e,r){return this._applyTransformations(this._getPosition(t),e,r)};var xv=function(t){function e(e){t.call(this),this.shape=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{},data:{},type:{}};return r.primitive.get=function(){},r.data.get=function(){return this.shape},r.type.get=function(){return this.primitive.type},e.prototype.getObject=function(t){return this.primitive.objectFromShape(this.shape,t)},e.prototype._getPosition=function(t){return this.primitive.positionFromShape(this.shape,t)},Object.defineProperties(e.prototype,r),e}(bv),_v=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return dv},Object.defineProperties(e.prototype,r),e}(xv),wv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return fv},Object.defineProperties(e.prototype,r),e}(xv),Sv=function(t){function e(e,r){t.call(this,e),this.structure=r}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"atom"},r.data.get=function(){return this.structure},e.prototype.getObject=function(t){return this.structure.getAtomProxy(this.getIndex(t))},e.prototype._getPosition=function(t){return(new v).copy(this.getObject(t))},Object.defineProperties(e.prototype,r),e}(bv),Av=function(t){function e(e){t.call(this),this.axes=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"axes"},r.data.get=function(){return this.axes},e.prototype.getObject=function(){return{axes:this.axes}},e.prototype._getPosition=function(){return this.axes.center.clone()},Object.defineProperties(e.prototype,r),e}(bv),Mv=function(t){function e(e,r,i){t.call(this,e),this.structure=r,this.bondStore=i||r.bondStore}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"bond"},r.data.get=function(){return this.structure},e.prototype.getObject=function(t){var e=this.structure.getBondProxy(this.getIndex(t));return e.bondStore=this.bondStore,e},e.prototype._getPosition=function(t){var e=this.getObject(t);return(new v).copy(e.atom1).add(e.atom2).multiplyScalar(.5)},Object.defineProperties(e.prototype,r),e}(bv),Ev=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"contact"},Object.defineProperties(e.prototype,r),e}(Mv),Tv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return mv},Object.defineProperties(e.prototype,r),e}(xv),Pv=function(t){function e(e,r,i){t.call(this,e),this.validation=r,this.structure=i}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"clash"},r.data.get=function(){return this.validation},e.prototype.getObject=function(t){var e=this.validation,r=this.getIndex(t);return{validation:e,index:r,clash:e.clashArray[r]}},e.prototype._getAtomProxyFromSele=function(t){var e=new qf(t),r=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(r)},e.prototype._getPosition=function(t){var e=this.getObject(t).clash,r=this._getAtomProxyFromSele(e.sele1),i=this._getAtomProxyFromSele(e.sele2);return(new v).copy(r).add(i).multiplyScalar(.5)},Object.defineProperties(e.prototype,r),e}(bv),Cv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"distance"},Object.defineProperties(e.prototype,r),e}(Mv),Iv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return gv},Object.defineProperties(e.prototype,r),e}(xv),Rv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return lv},Object.defineProperties(e.prototype,r),e}(xv),Lv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return hv},Object.defineProperties(e.prototype,r),e}(xv),Ov=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"ignore"},Object.defineProperties(e.prototype,r),e}(bv),Dv=function(t){function e(e,r){t.call(this,e),this.mesh=r}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"mesh"},e.prototype.getObject=function(){var t=this.mesh;return{shape:this.shape,name:t.name,serial:t.serial}},e.prototype._getPosition=function(){return this.__position||(this.__position=Sa(this.mesh.position)),this.__position},Object.defineProperties(e.prototype,r),e}(xv),Nv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return uv},Object.defineProperties(e.prototype,r),e}(xv),kv=function(t){function e(e,r){t.call(this,e),this.surface=r}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"surface"},r.data.get=function(){return this.surface},e.prototype.getObject=function(t){return{surface:this.surface,index:this.getIndex(t)}},e.prototype._getPosition=function(){return this.surface.center.clone()},Object.defineProperties(e.prototype,r),e}(bv),Fv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return pv},Object.defineProperties(e.prototype,r),e}(xv),Bv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={primitive:{}};return r.primitive.get=function(){return vv},Object.defineProperties(e.prototype,r),e}(xv),zv=function(t){function e(e,r){t.call(this),this.unitcell=e,this.structure=r}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"unitcell"},r.data.get=function(){return this.unitcell},e.prototype.getObject=function(){return{unitcell:this.unitcell,structure:this.structure}},e.prototype._getPosition=function(){return this.unitcell.getCenter(this.structure)},Object.defineProperties(e.prototype,r),e}(bv),Uv=(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};r.type.get=function(){return"unknown"},Object.defineProperties(e.prototype,r)}(bv),function(t){function e(e,r){t.call(this,e),this.volume=r}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},data:{}};return r.type.get=function(){return"volume"},r.data.get=function(){return this.volume},e.prototype.getObject=function(t){var e=this.volume,r=this.getIndex(t);return{volume:e,index:r,value:e.data[r]}},e.prototype._getPosition=function(t){var e=this.volume.position,r=this.getIndex(t);return new v(e[3*r],e[3*r+1],e[3*r+2])},Object.defineProperties(e.prototype,r),e}(bv)),jv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"slice"},Object.defineProperties(e.prototype,r),e}(Uv);xm.add("arrow",wv),xm.add("box",Lv),xm.add("cone",Tv),xm.add("cylinder",_v),xm.add("ellipsoid",Iv),xm.add("octahedron",Rv),xm.add("sphere",Nv),xm.add("tetrahedron",Fv),xm.add("torus",Bv);var Gv=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};Gv.prototype.get=function(t){return 0!=(this._words[t>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,a=e>>>5,s=o;s>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>r,this},Gv.prototype._isRangeValue=function(t,e,r){for(var i=this._words,n=!0===r?4294967295:0,o=t>>>5,a=e>>>5,s=o;s>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0?f>e&&(e=f):f>r&&(r=f),Aa(s.copy(t),l,u);var m=c.subVectors(s,u).normalize().dot(l),g=s.distanceTo(u);m>0?g>i&&(i=g):g>n&&(n=g),Aa(s.copy(t),p,u);var v=c.subVectors(s,u).normalize().dot(p),y=s.distanceTo(u);v>0?y>o&&(o=y):y>a&&(a=y)}),{d1a:e,d2a:i,d3a:o,d1b:-r,d2b:-n,d3b:-a}},ds.prototype.constructor=ds,fs.prototype.constructor=fs,ys.__deps=[ms,gs,vs,Kn],bs.__deps=[xs],xs.__deps=[Ra,Ia,La,Pa],ws.__deps=[co,Fa,Ba,Da,Na,za,Ua,Ra,ja,ns,as,cs,ss,us];var Ay=function(t,e,r){this.name=t||"",this.path=e||"",this.info={},this.center=new v,this.boundingBox=new ht,r instanceof Mt||r instanceof Bt||r instanceof qe?this.fromGeometry(r):r&&(this.set(r.position,r.index,r.normal,r.color,r.atomindex,r.contour),this.boundingBox.setFromArray(r.position),this.boundingBox.getCenter(this.center))},My={type:{}};My.type.get=function(){return"Surface"},Ay.prototype.set=function(t,e,r,i,n,o){this.position=t,this.index=e,this.normal=r,this.color=i,this.atomindex=n,this.size=t.length/3,this.contour=o},Ay.prototype.fromGeometry=function(e){t.Debug&&cm.time("GeometrySurface.fromGeometry");var r;e instanceof Mt?(e.computeVertexNormals(!0),r=(new Bt).fromGeometry(e)):r=e instanceof Bt?e:e[0],r.boundingBox||r.computeBoundingBox(),this.boundingBox.copy(r.boundingBox),this.boundingBox.getCenter(this.center);var i,n,o;if(r instanceof Bt){var a=r.attributes,s=!!a.normal&&a.normal.array;(!s||0===s[0]&&0===s[1]&&0===s[2])&&r.computeVertexNormals(),i=a.position.array,n=a.index?a.index.array:null,o=a.normal.array}this.set(i,n,o,void 0,void 0),t.Debug&&cm.timeEnd("GeometrySurface.setGeometry")},Ay.prototype.getPosition=function(){return this.position},Ay.prototype.getColor=function(t){var e=t||{};e.surface=this;var r=this.size,i=new Float32Array(3*r),n=pm.getScheme(e);if(n.volumeColor||"random"===e.scheme)for(var o=0;o=t&&f<=e||r&&(fe)){var m=3*l;u[l]=f,h[m+0]=n[d+0],h[m+1]=n[d+1],h[m+2]=n[d+2],o&&(c[l]=o[p]),l+=1}}this.data=new Float32Array(this._dataBuffer,0,l),this.position=new Float32Array(this._positionBuffer,0,3*l),o&&(this.atomindex=new Float32Array(this._atomindexBuffer,0,l))}this._filterHash=a}},Object.defineProperties(Py.prototype,Cy),Py.prototype.getValueForSigma=Ey.prototype.getValueForSigma,Py.prototype.getSigmaForValue=Ey.prototype.getSigmaForValue,Py.prototype.getDataAtomindex=Ey.prototype.getDataAtomindex,Py.prototype.getDataPosition=Ey.prototype.getDataPosition,Py.prototype.getDataColor=Ey.prototype.getDataColor,Py.prototype.getDataPicking=Ey.prototype.getDataPicking,Py.prototype.getDataSize=Ey.prototype.getDataSize;var Iy=function(e,r){t.Debug&&cm.time("BondHash init");for(var i=e.count,n=e.atomIndex1,o=e.atomIndex2,a=new Uint8Array(r),s=new Int32Array(r),c=0;ca?s.set(e[n].subarray(0,a)):s.set(e[n]),e[n]=s}},Ry.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},Ry.prototype.copyFrom=function(t,e,r,i){for(var n=this,o=0,a=this._fields.length;o0;)s-=1;a<=s&&(a===o?o=s:s===o&&(o=a),e(a,s),a+=1,s-=1)}while(a<=s);r(i,s),r(a,n)}}cm.time("Store.sort");var i=this,n=new this.constructor(1);r(0,this.count-1),cm.timeEnd("Store.sort")},Ry.prototype.clear=function(){this.count=0},Ry.prototype.dispose=function(){var t=this;delete this.length,delete this.count;for(var e=0,r=this._fields.length;e0&&(l[r]=M.angleTo(E)),t=Math.cos(x.angleTo(_)),f[r]=180/Math.PI*Math.acos(t),i=x.length(),n=_.length(),p[r]=Math.sqrt(n*i)/Math.max(2,2*(1-t)),d[r]=Math.abs(y.dot(M)),w.copy(x).multiplyScalar(p[r]/i),S.copy(_).multiplyScalar(p[r]/n),w.subVectors(R,w),S.subVectors(L,S),w.toArray(u,e+3),S.toArray(u,e+6),T.subVectors(I,P),T.toArray(m,e),E.copy(M),P.copy(w);for(w.fromArray(u,3),S.fromArray(u,6),M.subVectors(w,S).normalize(),I.index=o.getAtomIndexByType(0,C),P.copy(I),A.copy(I),Aa(A,M,w),A.toArray(u,0),T.subVectors(P,w),T.toArray(m,0),w.fromArray(u,3*s-6),S.fromArray(u,3*s-9),M.subVectors(w,S).normalize(),I.index=o.getAtomIndexByType(s-1,C),P.copy(I),A.copy(I),Aa(A,M,w),A.toArray(u,3*s-3),r=s-3;re?F=!0:h.bending[B]>t&&(F=!0)),F){if(B-g<4){g=B,F=!1;continue}D.index=L.traceAtomIndex,P=h.axis.subarray(3*g+3,3*B),C=h.center.subarray(3*g,3*B+3),p=Sa(P).normalize(),d=Sa(C),I.fromArray(C),Aa(I,p,d),R.fromArray(C,C.length-3),Aa(R,p,d),p.subVectors(R,I),p.toArray(b,y),d.toArray(x,y),I.toArray(_,y),R.toArray(w,y),f.atomColorToArray(D,S,y),A.push(D.index),M.push(m.atomRadius(D)),E.push(u+g),T.push(u+B+1-g),y+=3,g=B,F=!1}var z=new Float32Array(A);return{axis:new Float32Array(b),center:new Float32Array(x),begin:new Float32Array(_),end:new Float32Array(w),color:new Float32Array(S),picking:new Sv(z,s),size:new Float32Array(M),residueOffset:E,residueCount:T}}},Es.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},peek:function(){return this.content[0]},remove:function(t){for(var e=this,r=this.content.length,i=0;i0;){var i=Math.floor((t+1)/2)-1,n=e.content[i];if(!(e.scoreFunction(r)":"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"},By={"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":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},zy=function(t){this.name=t||"",this.partList=[]},Uy={type:{}};Uy.type.get=function(){return"Assembly"},zy.prototype.addPart=function(t,e){var r=new jy(t,e);return this.partList.push(r),r},zy.prototype._getCount=function(t,e){var r=0;return this.partList.forEach(function(i){r+=i[e](t)}),r},zy.prototype.getAtomCount=function(t){return this._getCount(t,"getAtomCount")},zy.prototype.getResidueCount=function(t){return this._getCount(t,"getResidueCount")},zy.prototype.getInstanceCount=function(){var t=0;return this.partList.forEach(function(e){t+=e.matrixList.length}),t},zy.prototype.isIdentity=function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new y).equals(e.matrixList[0]))return!1;var r=[];return t.eachChain(function(t){r.push(t.chainname)}),r=Xn(r),e.chainList.length===r.length},zy.prototype.getBoundingBox=function(t){var e=new ht;return this.partList.forEach(function(r){var i=r.getBoundingBox(t);e.expandByPoint(i.min),e.expandByPoint(i.max)}),e},zy.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter()},zy.prototype.getSelection=function(){var t=[];return this.partList.forEach(function(e){t=t.concat(e.chainList)}),Is(t)},Object.defineProperties(zy.prototype,Uy);var jy=function(t,e){this.matrixList=t||[],this.chainList=e||[]},Gy={type:{}};Gy.type.get=function(){return"AssemblyPart"},jy.prototype._getCount=function(t,e){var r=0,i=this.chainList;return t.eachChain(function(t){(0===i.length||i.includes(t.chainname))&&(r+=t[e])}),this.matrixList.length*r},jy.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},jy.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},jy.prototype.getBoundingBox=function(t){var e=new ht,r=new ht,i=this.getSelection(),n=t.getBoundingBox(i);return this.matrixList.forEach(function(t){r.copy(n).applyMatrix4(t),e.expandByPoint(r.min),e.expandByPoint(r.max)}),e},jy.prototype.getSelection=function(){return Is(this.chainList)},jy.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},jy.prototype.getInstanceList=function(){for(var t=this,e=[],r=0,i=this.matrixList.length;r=t.residueCount)){a.index=o+h,s.index=o+h+l,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-r[l-2])>i)return!1}return!0},r=function(t,r){return e(t,r,[5.45,5.18,6.37],2.1)},i=function(t,r){return e(t,r,[6.1,10.4,13],1.42)},n=function(t){for(var e=t.residueStore,n=t.residueIndexStart,o=0,a=t.residueCount;o1&&i.bending[a]<20&&(e.sstruc[r+a]="h".charCodeAt(0),e.sstruc[r+a+1]="h".charCodeAt(0))}};return function(e){t.Debug&&cm.time("calculateSecondaryStructure"),e.eachPolymer(function(t){if(!(t.residueCount<4)){if(t.isCg())o(t);else{if(!t.isProtein())return;n(t)}var e,r=0;t.eachResidue(function(t){t.sstruc===e?r+=1:(1===r&&(t.index-=1,t.sstruc="c"),r=1,e=t.sstruc)})}}),t.Debug&&cm.timeEnd("calculateSecondaryStructure")}}(),$y="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Hy=["H","C","O","N","S","P"],Wy=["NA","CL","FE"],Xy=function(t,e,r){this.structure=t,r=r||Us(e),this.atomname=e,this.element=r,this.vdw=ny[r],this.covalent=oy[r]},qy=function(t){this.structure=t,this.dict={},this.list=[]};qy.prototype.add=function(t,e){var r=Gs(t=t.toUpperCase(),e=e?e.toUpperCase():Us(t)),i=this.dict[r];if(void 0===i){var n=new Xy(this.structure,t,e);i=this.list.length,this.dict[r]=i,this.list.push(n)}return i},qy.prototype.get=function(t){return this.list[t]};var Yy=function(t,e,r,i,n,o){this.structure=t,this.resname=e,this.atomTypeIdList=r,this.hetero=i?1:0,this.chemCompType=n,this.bonds=o,this.rings=void 0,this.atomCount=r.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();var a=yy[this.backboneType],s=yy[this.backboneStartType],c=yy[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=void 0!==u?u:-1;var h=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=void 0!==h?h:-1;var l=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=void 0!==l?l:-1;var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=void 0!==p?p:-1;var d=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=void 0!==d?d:-1;var f;f=py.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=void 0!==f?f:-1,this.bondReferenceAtomIndices=[]};Yy.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=gy;break;case 4:case 5:t=vy;break;default:return e}for(var r=this.structure.atomMap,i=this.atomTypeIdList,n=0,o=this.atomCount;n=2?t(l,e[l],a):r[l]=2;else if(1===r[l]&&c&&c!==l){var p=[l];i[l]=1,n.push(p);for(var d=o.length-1;d>=0;--d){var f=o[d];if(f===l)break;p.push(f),i[f]=1}}}r[a]=2,o.pop()}for(var e=this.getBondGraph(),r=new Int8Array(this.atomCount),i=new Int8Array(this.atomCount),n=[],o=[],a=0;a1)for(var y=0;y1)for(var x=0;x0){var e=this.residueStore.atomOffset[this.residueIndex];return t.includes(this.index-e)}return!1},Jy.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},Jy.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},Jy.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},Jy.prototype.isHetero=function(){return 1===this.residueType.hetero},Jy.prototype.isProtein=function(){return 3===this.residueType.moleculeType},Jy.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},Jy.prototype.isRna=function(){return 4===this.residueType.moleculeType},Jy.prototype.isDna=function(){return 5===this.residueType.moleculeType},Jy.prototype.isWater=function(){return 1===this.residueType.moleculeType},Jy.prototype.isIon=function(){return 2===this.residueType.moleculeType},Jy.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},Jy.prototype.isHelix=function(){return ey.includes(this.sstruc)},Jy.prototype.isSheet=function(){return ry.includes(this.sstruc)},Jy.prototype.isTurn=function(){return iy.includes(this.sstruc)&&this.isProtein()},Jy.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},Jy.prototype.isRing=function(){return 1===this.residueType.getRings().flags[this.index-this.residueAtomOffset]},Jy.prototype.distanceTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,n=t.index,o=e.x[i]-r.x[n],a=e.y[i]-r.y[n],s=e.z[i]-r.z[n],c=o*o+a*a+s*s;return Math.sqrt(c)},Jy.prototype.connectedTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,n=t.index;if(e.altloc&&r.altloc){var o=e.altloc[i],a=r.altloc[n];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=e.x[i]-r.x[n],c=e.y[i]-r.y[n],u=e.z[i]-r.z[n],h=s*s+c*c+u*u;if(h<64&&this.isCg())return!0;if(isNaN(h))return!1;var l=this.covalent+t.covalent,p=l+.3,d=l-.5;return hd*d},Jy.prototype.positionFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this},Jy.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var r=this.index,i=this.atomStore;return t[e+0]=i.x[r],t[e+1]=i.y[r],t[e+2]=i.z[r],t},Jy.prototype.positionToVector3=function(t){return void 0===t&&(t=new v),t.x=this.x,t.y=this.y,t.z=this.z,t},Jy.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},Jy.prototype.positionAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},Jy.prototype.positionSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},Jy.prototype.getResidueBonds=function(t){var e,r,i,n,o=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(t||(n=[]),e=c.indexOf(a);-1!==e;){if(i=u[e]+o,t)return i;n.push(i),e=c.indexOf(a,e+1)}for(r=u.indexOf(a);-1!==r;){if(i=c[r]+o,t)return i;n.push(i),r=u.indexOf(a,r+1)}return n},Jy.prototype.qualifiedName=function(t){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},Jy.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Jy.prototype.toObject=function(){return{index:this.index,residueIndex:this.residueIndex,atomno:this.atomno,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelindex:this.modelindex}},Object.defineProperties(Jy.prototype,tb);var eb=function(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap,this.index=e},rb={entity:{},entityIndex:{},chain:{},chainIndex:{},atomOffset:{},atomCount:{},atomEnd:{},modelIndex:{},chainname:{},chainid:{},resno:{},sstruc:{},inscode:{},residueType:{},resname:{},hetero:{},moleculeType:{},backboneType:{},backboneStartType:{},backboneEndType:{},traceAtomIndex:{},direction1AtomIndex:{},direction2AtomIndex:{},backboneStartAtomIndex:{},backboneEndAtomIndex:{},rungEndAtomIndex:{}};rb.entity.get=function(){return this.structure.entityList[this.entityIndex]},rb.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},rb.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},rb.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},rb.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},rb.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},rb.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},rb.atomCount.get=function(){return this.residueStore.atomCount[this.index]},rb.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},rb.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},rb.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},rb.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},rb.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},rb.resno.get=function(){return this.residueStore.resno[this.index]},rb.resno.set=function(t){this.residueStore.resno[this.index]=t},rb.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},rb.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},rb.inscode.get=function(){return this.residueStore.getInscode(this.index)},rb.inscode.set=function(t){this.residueStore.getInscode(this.index,t)},rb.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},rb.resname.get=function(){return this.residueType.resname},rb.hetero.get=function(){return this.residueType.hetero},rb.moleculeType.get=function(){return this.residueType.moleculeType},rb.backboneType.get=function(){return this.residueType.backboneType},rb.backboneStartType.get=function(){return this.residueType.backboneStartType},rb.backboneEndType.get=function(){return this.residueType.backboneEndType},rb.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},rb.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},rb.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},rb.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},rb.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},rb.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},eb.prototype.eachAtom=function(t,e){var r,i=this.atomCount,n=this.atomOffset,o=this.structure._ap,a=n+i;if(e&&e.atomOnlyTest){var s=e.atomOnlyTest;for(r=n;r0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},eb.prototype.isHetero=function(){return 1===this.residueType.hetero},eb.prototype.isWater=function(){return 1===this.residueType.moleculeType},eb.prototype.isIon=function(){return 2===this.residueType.moleculeType},eb.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},eb.prototype.isHelix=function(){return ey.includes(this.sstruc)},eb.prototype.isSheet=function(){return ry.includes(this.sstruc)},eb.prototype.isTurn=function(){return iy.includes(this.sstruc)&&this.isProtein()},eb.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},eb.prototype.getResname1=function(){return cy[this.resname.toUpperCase()]||"X"},eb.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},eb.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},eb.prototype.getAtomByName=function(t){return this.residueType.getAtomByName(t)},eb.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},eb.prototype.getAtomnameList=function(){var t=this;console.warn("getAtomnameList - might be expensive");for(var e=this.atomCount,r=this.atomOffset,i=new Array(e),n=0;n=t){var r=this.structure.getResidueProxy(e);if(r.connectedTo(this))return r}else if(e===t-1){var i=this.chainStore.residueCount[this.chainIndex],n=this.structure.getResidueProxy(t+i-1);if(n.connectedTo(this))return n}},eb.prototype.getBonds=function(){return this.residueType.getBonds(this)},eb.prototype.getRings=function(){return this.residueType.getRings()},eb.prototype.qualifiedName=function(t){var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex},eb.prototype.clone=function(){return new this.constructor(this.structure,this.index)},eb.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(eb.prototype,rb);var ib=function(t,e,r){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueIndexStart=e,this.residueIndexEnd=r,this.residueCount=r-e+1;var i=this.structure.getResidueProxy(this.residueIndexStart),n=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==i.getPreviousConnectedResidue();var o=n.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=this.isNextConnected&&void 0!==o.getNextConnectedResidue(),this.isCyclic=n.connectedTo(i),this.__residueProxy=this.structure.getResidueProxy()},nb={chainIndex:{},modelIndex:{},chainname:{}};nb.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},nb.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},nb.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},ib.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},ib.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},ib.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},ib.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},ib.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},ib.prototype.getAtomIndexByType=function(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));var r=this.__residueProxy;r.index=this.residueIndexStart+t;var i;switch(e){case"trace":i=r.traceAtomIndex;break;case"direction1":i=r.direction1AtomIndex;break;case"direction2":i=r.direction2AtomIndex;break;default:var n=r.getAtomByName(e);i=n?n.index:void 0}return i},ib.prototype.eachAtom=function(t,e){this.eachResidue(function(r){r.eachAtom(t,e)},e)},ib.prototype.eachAtomN=function(t,e,r){var i,n=this,o=this.residueCount,a=new Array(t);for(i=0;i=n&&r=t&&e.apply(this,s)}})}},ib.prototype.eachResidue=function(t){for(var e=this.structure.getResidueProxy(),r=this.residueCount,i=this.residueIndexStart,n=0;n1&&t(new ib(o,r,u.index)),r=i)):(m!==qv&&u.index-r>1&&t(new ib(o,r,u.index)),r=i)}i-r>1&&this.structure.getResidueProxy(r).backboneEndType&&t(new ib(o,r,i))},ob.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},ob.prototype.clone=function(){return new this.constructor(this.structure,this.index)},ob.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(ob.prototype,ab);var sb=function(t,e){this.structure=t,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e},cb={chainOffset:{},chainCount:{},residueOffset:{},atomOffset:{},chainEnd:{},residueEnd:{},atomEnd:{},residueCount:{},atomCount:{}};cb.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},cb.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},cb.chainCount.get=function(){return this.modelStore.chainCount[this.index]},cb.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},cb.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},cb.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},cb.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},cb.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},cb.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},cb.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},cb.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},sb.prototype.eachAtom=function(t,e){this.eachChain(function(r){r.eachAtom(t,e)},e)},sb.prototype.eachResidue=function(t,e){this.eachChain(function(r){r.eachResidue(t,e)},e)},sb.prototype.eachPolymer=function(t,e){if(e&&e.chainOnlyTest){var r=e.chainOnlyTest;this.eachChain(function(i){r(i)&&i.eachPolymer(t,e)})}else this.eachChain(function(r){r.eachPolymer(t,e)})},sb.prototype.eachChain=function(t,e){var r,i=this.chainCount,n=this.chainOffset,o=this.structure._cp,a=n+i;if(e&&e.test){var s=e.chainOnlyTest;if(s)for(r=n;r1?(C=r.atomRadius(w),I=C*g/(.5*P),x.calculateShiftDir(N),m?(R=2*y*C,N.multiplyScalar(R),N.negate(),D.subVectors(S,w).multiplyScalar(Math.max(.1,R/1.88)),w.positionToArray(n,E),S.positionToArray(o,E),P>=2&&(O.addVectors(w,N).add(D).toArray(n,E+3),O.addVectors(S,N).sub(D).toArray(o,E+3),P>=3&&(O.subVectors(w,N).add(D).toArray(n,E+6),O.subVectors(S,N).sub(D).toArray(o,E+6)))):(R=(y-g)*C,N.multiplyScalar(R),2===P?(O.addVectors(w,N).toArray(n,E),O.subVectors(w,N).toArray(n,E+3),O.addVectors(S,N).toArray(o,E),O.subVectors(S,N).toArray(o,E+3)):3===P?(w.positionToArray(n,E),O.addVectors(w,N).toArray(n,E+3),O.subVectors(w,N).toArray(n,E+6),S.positionToArray(o,E),O.addVectors(S,N).toArray(o,E+3),O.subVectors(S,N).toArray(o,E+6)):(w.positionToArray(n,E),S.positionToArray(o,E)))):(w.positionToArray(n,E),S.positionToArray(o,E))),a&&(i.bondColorToArray(x,1,a,E),i.bondColorToArray(x,0,s,E),f&&P>1))for(M=1;M1))for(M=1;M1))for(I=u[L]*g/(m?1:.5*P),M=m?1:0;M1))for(I=h[L]*g/(m?1:.5*P),M=m?1:0;Ma&&(a=e),r>s&&(s=r),u>c&&(c=u)},e),r.min.set(i,n,o),r.max.set(a,s,c),t.Debug&&cm.timeEnd("getBoundingBox"),r},ub.prototype.getPrincipalAxes=function(e){t.Debug&&cm.time("getPrincipalAxes");var r=0,i=new Ha(3,this.atomCount),n=i.data;return this.eachAtom(function(t){n[r+0]=t.x,n[r+1]=t.y,n[r+2]=t.z,r+=3},e),t.Debug&&cm.timeEnd("getPrincipalAxes"),new Sy(i)},ub.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter():this.center.clone()},ub.prototype.hasCoords=function(){var t=this.atomStore;return 0!==ca(t.x)||0!==sa(t.x)||0!==ca(t.y)||0!==sa(t.y)||0!==ca(t.z)||0!==sa(t.z)},ub.prototype.getSequence=function(t){var e=[],r=this.getResidueProxy();return this.eachAtom(function(t){r.index=t.residueIndex,t.index===r.traceAtomIndex&&e.push(r.getResname1())},t),e},ub.prototype.getAtomIndices=function(t){var e;if(t&&t.string)e=[],this.eachAtom(function(t){e.push(t.index)},t);else{var r={what:{index:!0}};e=this.getAtomData(r).index}return e},ub.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain(function(t){t.residueCount&&e.add(t.chainname)},t),e.size},ub.prototype.updatePosition=function(t){var e=0;this.eachAtom(function(r){r.positionFromArray(t,e),e+=3})},ub.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new ps(this.atomStore,this.boundingBox)},ub.prototype.dispose=function(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondStore,delete this.atomStore,delete this.residueStore,delete this.chainStore,delete this.modelStore,delete this.frames,delete this.boxes,delete this.cif,delete this.bondSet,delete this.atomSet},Object.defineProperties(ub.prototype,hb);var lb=function(t,e){var r;"function"==typeof t.eachAtom?r=t.atomCount:t instanceof Float32Array&&(r=t.length/3);var i;"function"==typeof e.eachAtom?i=e.atomCount:t instanceof Float32Array&&(i=e.length/3);var n=Math.min(r,i),o=new Ha(3,n),a=new Ha(3,n);this.coords1t=new Ha(n,3),this.coords2t=new Ha(n,3),this.A=new Ha(3,3),this.W=new Ha(1,3),this.U=new Ha(3,3),this.V=new Ha(3,3),this.VH=new Ha(3,3),this.R=new Ha(3,3),this.tmp=new Ha(3,3),this.c=new Ha(3,3),this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,o,n),this.prepCoords(e,a,n),this._superpose(o,a)};lb.prototype._superpose=function(e,r){this.mean1=Ka(e),this.mean2=Ka(r),Qa(e,this.mean1),Qa(r,this.mean2),Wa(this.coords1t,e),Wa(this.coords2t,r),Xa(this.A,this.coords2t,this.coords1t),is(this.A,this.W,this.U,this.V),qa(this.V,this.VH),Za(this.R,this.U,this.VH),Ya(this.R)<0&&(t.Debug&&cm.log("R not a right handed system"),Za(this.tmp,this.c,this.VH),Za(this.R,this.U,this.tmp))},lb.prototype.prepCoords=function(t,e,r){var i=0,n=3*r,o=e.data;"function"==typeof t.eachAtom?t.eachAtom(function(t){i=r)if(this.interpolateType)if(this._currentStep>this.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),i.hasFrame(this._currentFrame)){this._currentStep+=1;var n=this._currentStep/(this.interpolateStep+1);i.setFrameInterpolated.apply(i,this._currentFrame.concat([n],[this.interpolateType])),this._previousTime=this._currentTime}else i.loadFrame(this._currentFrame);else{var o=this._next();i.hasFrame(o)?(i.setFrame(o),this._previousTime=this._currentTime):i.loadFrame(o)}window.requestAnimationFrame(this._animate)}},pb.prototype._next=function(){var t;return((t="forward"===this._direction?this.traj.currentFrame+this.step:this.traj.currentFrame-this.step)>this.end||t=this.end?e=this.start:"backward"===this.direction&&t<=this.start&&(e=this.end),this.traj.setFrame(e),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}},pb.prototype.pause=function(){this._run=!1,this.signals.haltedRunning.dispatch()},pb.prototype.stop=function(){this.pause(),this.traj.setFrame(this.start)},Object.defineProperties(pb.prototype,db);var fb=function(t,e,r){this.signals={countChanged:new So,frameChanged:new So,playerChanged:new So};var i=r||{};this.deltaTime=Nn(i.deltaTime,0),this.timeOffset=Nn(i.timeOffset,0),this.centerPbc=Nn(i.centerPbc,!1),this.removePbc=Nn(i.removePbc,!1),this.removePeriodicity=Nn(i.removePeriodicity,!1),this.superpose=Nn(i.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.initialCoords=null,this.structureCoords=null,this.selection=new qf(Nn(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add(function(){this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},this),this._frameCount=0,this._currentFrame=-1},mb={frameCount:{},currentFrame:{}};mb.frameCount.get=function(){return this._frameCount},mb.currentFrame.get=function(){return this._currentFrame},fb.prototype._init=function(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new pb(this))},fb.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new qf("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},fb.prototype._saveInitialCoords=function(){var t=this;this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,function(){return t._saveInitialCoords()})},fb.prototype._saveStructureCoords=function(){var t={what:{position:!0}};this.structureCoords=this.structure.getAtomData(t).position},fb.prototype.setSelection=function(t){return this.selection.setString(t),this},fb.prototype._getIndices=function(t){var e=0,r=t.test,i=[];return this.structure.eachAtom(function(t){r(t)&&i.push(e),e+=1}),i},fb.prototype._makeSuperposeCoords=function(){var t=this,e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);for(var r=this.initialCoords,i=this.coords2,n=0;n0&&this.centerPbc){var n=[e[0],e[4],e[8]];$s(r,Xs(this.backboneIndices,r,n),n)}this.removePeriodicity&&Ws(r,e,qs(r)),this.removePbc&&Hs(r,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(r),this.frameCache[t]=r,this.boxCache[t]=e,this.frameCacheSize+=1},fb.prototype._setFrameCount=function(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))},fb.prototype.dispose=function(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()},fb.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},fb.prototype.getPath=function(t,e){cm.error("Trajectory.getPath not implemented",t,e)},fb.prototype.getFrameTime=function(t){return this.timeOffset+t*this.deltaTime},Object.defineProperties(fb.prototype,mb),gm.add("shader/Mesh.vert","#define STANDARD\nuniform float nearClip;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#elif defined( NOLIGHT )\nvarying vec3 vColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#elif defined( NOLIGHT )\nvColor = color;\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\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),gm.add("shader/Mesh.frag","#define STANDARD\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\nuniform float clipRadius;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\n#elif defined( NOLIGHT )\nvarying vec3 vColor;\n#else\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars\n#include lights_physical_pars_fragment\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.7 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#elif defined( NOLIGHT )\ngl_FragColor = vec4( vColor, opacity );\n#else\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_flip\n#include normal_fragment\n#include dull_interior_fragment\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#include opaque_back_fragment\n#endif\n}");var gb={f:1,v2:2,v3:3,c:3},vb=function(t,e){var r=t||{},i=e||{};this.opaqueBack=Nn(i.opaqueBack,!1),this.dullInterior=Nn(i.dullInterior,!1),this.side=Nn(i.side,"double"),this.opacity=Nn(i.opacity,1),this.depthWrite=Nn(i.depthWrite,!0),this.clipNear=Nn(i.clipNear,0),this.clipRadius=Nn(i.clipRadius,0),this.clipCenter=Nn(i.clipCenter,new v),this.flatShaded=Nn(i.flatShaded,!1),this.background=Nn(i.background,!1),this.wireframe=Nn(i.wireframe,!1),this.roughness=Nn(i.roughness,.4),this.metalness=Nn(i.metalness,0),this.diffuse=Nn(i.diffuse,16777215),this.forceTransparent=Nn(i.forceTransparent,!1),this.disablePicking=Nn(i.disablePicking,!1),this.geometry=new Bt,this.indexVersion=0,this.wireframeIndexVersion=-1,this.uniforms=Ep.merge([Mp.common,{fogColor:{value:null},fogNear:{value:0},fogFar:{value:0},opacity:{value:this.opacity},nearClip:{value:0},clipRadius:{value:this.clipRadius},clipCenter:{value:this.clipCenter}},{emissive:{value:new et(0)},roughness:{value:this.roughness},metalness:{value:this.metalness}},Mp.ambient,Mp.lights]),this.uniforms.diffuse.value.set(this.diffuse),this.pickingUniforms={nearClip:{value:0},objectId:{value:0},opacity:{value:this.opacity}},this.group=new qe,this.wireframeGroup=new qe,this.pickingGroup=new qe,this.matrix=Nn(i.matrix,new y);var n=r.position||r.position1;this._positionDataSize=n?n.length/3:0,this.addAttributes({position:{type:"v3",value:r.position},color:{type:"c",value:r.color},primitiveId:{type:"f",value:r.primitiveId}}),r.index&&this.initIndex(r.index),this.picking=r.picking,this.makeWireframeGeometry()},yb={parameters:{},matrix:{},transparent:{},size:{},attributeSize:{},pickable:{},dynamic:{},vertexShader:{},fragmentShader:{}};yb.parameters.get=function(){return{opaqueBack:{updateShader:!0},dullInterior:{updateShader:!0},side:{updateShader:!0,property:!0},opacity:{uniform:!0},depthWrite:{property:!0},clipNear:{updateShader:!0,property:!0},clipRadius:{updateShader:!0,property:!0,uniform:!0},clipCenter:{uniform:!0},flatShaded:{updateShader:!0},background:{updateShader:!0},wireframe:{updateVisibility:!0},roughness:{uniform:!0},metalness:{uniform:!0},diffuse:{uniform:!0},matrix:{}}},yb.matrix.set=function(t){this.setMatrix(t)},yb.matrix.get=function(){return this.group.matrix.clone()},yb.transparent.get=function(){return this.opacity<1||this.forceTransparent},yb.size.get=function(){return this._positionDataSize},yb.attributeSize.get=function(){return this.size},yb.pickable.get=function(){return!!this.picking&&!this.disablePicking},yb.dynamic.get=function(){return!0},yb.vertexShader.get=function(){},yb.fragmentShader.get=function(){},vb.prototype.setMatrix=function(t){Qs(this.group,t),Qs(this.wireframeGroup,t),Qs(this.pickingGroup,t)},vb.prototype.initIndex=function(t){this.geometry.setIndex(new Et(t,1)),this.geometry.getIndex().setDynamic(this.dynamic)},vb.prototype.makeMaterial=function(){var t=Ks(this.side),e=new st({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!0,fog:!0,side:t});e.vertexColors=Eh,e.extensions.derivatives=this.flatShaded,e.extensions.fragDepth=this.isImpostor,e.clipNear=this.clipNear;var r=new st({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!1,fog:!0,side:t});r.vertexColors=Eh,r.clipNear=this.clipNear;var i=new st({uniforms:this.pickingUniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:!1,depthWrite:this.depthWrite,lights:!1,fog:!1,side:t,blending:Th});i.vertexColors=Eh,i.extensions.fragDepth=this.isImpostor,i.clipNear=this.clipNear,this.material=e,this.wireframeMaterial=r,this.pickingMaterial=i,this.updateShader()},vb.prototype.makeWireframeGeometry=function(){this.makeWireframeIndex();var t=this.geometry,e=this.wireframeIndex,r=new Bt;r.attributes=t.attributes,e&&(r.setIndex(new Et(e,1).setDynamic(this.dynamic)),r.setDrawRange(0,this.wireframeIndexCount)),this.wireframeGeometry=r},vb.prototype.makeWireframeIndex=function(){function t(t,r){if(t>r){var i=t;t=r,r=i}var n=e[t];return void 0===n?(e[t]=[r],!0):!n.includes(r)&&(n.push(r),!0)}var e=[],r=this.geometry,i=r.index;if(this.wireframe)if(i){var n=i.array,o=n.length;r.drawRange.count!==1/0&&(o=r.drawRange.count);var a;a=this.wireframeIndex&&this.wireframeIndex.length>2*o?this.wireframeIndex:Kn(2*o,r.attributes.position.count);var s=0;e.length=0;for(var c=0;c2*d?this.wireframeIndex:Kn(2*d,d);for(var f=0,m=0;fthis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new Et(this.wireframeIndex,1).setDynamic(this.dynamic));else{var t=this.wireframeGeometry.getIndex();t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)},vb.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},vb.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,r=this.geometry,i=this[t];return this.isLine?e=new $e(r,i):this.isPoint?(e=new Xe(r,i),this.sortParticles&&(e.sortParticles=!0)):e=new Xt(r,i),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},vb.prototype.getMesh=function(){return this._getMesh("material")},vb.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),t=new $e(this.wireframeGeometry,this.wireframeMaterial),t.frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},vb.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},vb.prototype.getShader=function(t,e){return qo(t,this.getDefines(e))},vb.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},vb.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},vb.prototype.getDefines=function(t){var e={};return this.clipNear&&(e.NEAR_CLIP=1),this.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.background)&&(e.NOLIGHT=1),this.flatShaded&&(e.FLAT_SHADED=1),this.opaqueBack&&(e.OPAQUE_BACK=1),this.dullInterior&&(e.DULL_INTERIOR=1)),e},vb.prototype.getParameters=function(){var t=this,e={};for(var r in t.parameters)e[r]=t[r];return e},vb.prototype.addUniforms=function(t){this.uniforms=Ep.merge([this.uniforms,t]),this.pickingUniforms=Ep.merge([this.pickingUniforms,t])},vb.prototype.addAttributes=function(t){var e=this;for(var r in t){var i=void 0,n=t[r],o=e.attributeSize*gb[n.type];n.value?(o!==n.value.length&&cm.error("attribute value has wrong length",r),i=n.value):i=Zn("float32",o),e.geometry.addAttribute(r,new Et(i,gb[n.type]).setDynamic(e.dynamic))}},vb.prototype.updateRenderOrder=function(){function t(t){t.renderOrder=e}var e=this.getRenderOrder();this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)},vb.prototype.updateShader=function(){var t=this.material,e=this.wireframeMaterial,r=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,r.vertexShader=this.getVertexShader("picking"),r.fragmentShader=this.getFragmentShader("picking"),r.needsUpdate=!0},vb.prototype.setParameters=function(t){var e=this;if(t){var r=t,i=this.parameters,n={},o={},a=!1,s=!1;for(var c in r){var u=r[c];void 0!==u&&(void 0!==i[c]&&(e[c]=u,i[c].property&&(!0!==i[c].property?n[i[c].property]=u:n[c]=u),i[c].uniform&&(!0!==i[c].uniform?o[i[c].uniform]=u:o[c]=u),i[c].updateShader&&(a=!0),i[c].updateVisibility&&(s=!0),e.dynamic&&"wireframe"===c&&!0===u&&e.updateWireframeIndex(),"flatShaded"===c&&(e.material.extensions.derivatives=e.flatShaded),"forceTransparent"===c&&(n.transparent=e.transparent)))}this.setProperties(n),this.setUniforms(o),a&&this.updateShader(),s&&this.setVisibility(this.visible)}},vb.prototype.setAttributes=function(t){var e=this,r=this.geometry,i=r.attributes;for(var n in t)if("picking"!==n){var o=t[n],a=o.length;if("index"===n){var s=r.getIndex();r.setDrawRange(0,1/0),a>s.array.length?r.setIndex(new Et(o,1).setDynamic(e.dynamic)):(s.set(o),s.needsUpdate=a>0,s.updateRange.count=a,r.setDrawRange(0,a)),e.indexVersion++,e.wireframe&&e.updateWireframeIndex()}else{var c=i[n];a>c.array.length?r.addAttribute(n,new Et(o,c.itemSize).setDynamic(e.dynamic)):(i[n].set(o),i[n].needsUpdate=a>0,i[n].updateRange.count=a)}}},vb.prototype.setUniforms=function(t){var e=this;if(t){var r=this.material.uniforms,i=this.wireframeMaterial.uniforms,n=this.pickingMaterial.uniforms;for(var o in t)"opacity"===o&&e.setProperties({transparent:e.transparent}),void 0!==r[o]&&(r[o].value.isVector3?r[o].value.copy(t[o]):r[o].value.set?r[o].value.set(t[o]):r[o].value=t[o]),void 0!==i[o]&&(i[o].value.isVector3?i[o].value.copy(t[o]):i[o].value.set?i[o].value.set(t[o]):i[o].value=t[o]),void 0!==n[o]&&(n[o].value.isVector3?n[o].value.copy(t[o]):n[o].value.set?n[o].value.set(t[o]):n[o].value=t[o])}},vb.prototype.setProperties=function(t){var e=this;if(t){var r=this.material,i=this.wireframeMaterial,n=this.pickingMaterial;for(var o in t){var a=t[o];"transparent"===o?e.updateRenderOrder():"side"===o&&(a=Ks(a)),void 0!==r[o]&&(r[o]=a),void 0!==i[o]&&(i[o]=a),void 0!==n[o]&&(n[o]=a)}r.needsUpdate=!0,i.needsUpdate=!0,n.needsUpdate=!0}},vb.prototype.setVisibility=function(t){this.visible=t,this.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))},vb.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},Object.defineProperties(vb.prototype,yb);var bb=function(t){function e(e,r){var i=e||{};!i.primitiveId&&i.position&&(i.primitiveId=ea(i.position.length/3)),t.call(this,i,r),this.addAttributes({normal:{type:"v3",value:i.normal}}),void 0===i.normal&&this.geometry.computeVertexNormals()}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={vertexShader:{},fragmentShader:{}};return r.vertexShader.get=function(){return"Mesh.vert"},r.fragmentShader.get=function(){return"Mesh.frag"},Object.defineProperties(e.prototype,r),e}(vb),xb=new ht,_b=[fv,hv,mv,dv,gv,lv,uv,pv,yv,vv],wb=function(t,e){var r=this;this.name=Nn(t,"shape");var i=e||{};this.aspectRatio=Nn(i.aspectRatio,1.5),this.sphereDetail=Nn(i.sphereDetail,2),this.radialSegments=Nn(i.radialSegments,50),this.disableImpostor=Nn(i.disableImpostor,!1),this.openEnded=Nn(i.openEnded,!1),this.labelParams=Nn(i.labelParams,{}),this.boundingBox=new ht,this.bufferList=[],this.meshCount=0,_b.forEach(function(t){Object.keys(t.fields).forEach(function(e){r[t.getShapeKey(e)]=[]}),r[t.getShapeKey("name")]=[]})},Sb={center:{},type:{}};wb.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},wb.prototype.addMesh=function(t,e,r,i,n){t=ao(t),e=ao(e),Array.isArray(r)&&(r=Kn(r,t.length)),i&&(i=ao(i));var o={position:t,color:e,index:r,normal:i},a=new Dv(this,Object.assign({serial:this.meshCount,name:n},o)),s=new bb(Object.assign({picking:a},o));return this.bufferList.push(s),xb.setFromArray(t),this.boundingBox.union(xb),this.meshCount+=1,this},wb.prototype.addSphere=function(t,e,r,i){return uv.objectToShape(this,{position:t,color:e,radius:r,name:i}),this},wb.prototype.addEllipsoid=function(t,e,r,i,n,o){return gv.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:n,name:o}),this},wb.prototype.addTorus=function(t,e,r,i,n,o){return vv.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:n,name:o}),this},wb.prototype.addCylinder=function(t,e,r,i,n){return dv.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:n}),this},wb.prototype.addCone=function(t,e,r,i,n){return mv.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:n}),this},wb.prototype.addArrow=function(t,e,r,i,n){return fv.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:n}),this},wb.prototype.addBox=function(t,e,r,i,n,o){return hv.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:n,name:o}),this},wb.prototype.addOctahedron=function(t,e,r,i,n,o){return lv.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:n,name:o}),this},wb.prototype.addTetrahedron=function(t,e,r,i,n,o){return pv.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:n,name:o}),this},wb.prototype.addText=function(t,e,r,i){return yv.objectToShape(this,{position:t,color:e,size:r,text:i}),this},wb.prototype.addLabel=function(t,e,r,i){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,r,i)},wb.prototype.getBufferList=function(){var t=this,e=[],r={aspectRatio:this.aspectRatio,sphereDetail:this.sphereDetail,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded,labelParams:this.labelParams};return _b.forEach(function(i){t[i.getShapeKey("color")].length&&e.push(i.bufferFromShape(t,r))}),this.bufferList.concat(e)},wb.prototype.dispose=function(){var t=this;this.bufferList.forEach(function(t){t.dispose()}),this.bufferList.length=0,_b.forEach(function(e){Object.keys(e.fields).forEach(function(r){t[e.getShapeKey(r)].length=0}),t[e.getShapeKey("name")].length=0})},Sb.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter()),this._center},Sb.type.get=function(){return"Shape"},Object.defineProperties(wb.prototype,Sb);var Ab=function(t,e,r){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:pm.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:pm.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=e,this.tasks=new Um,this.queue=new Js(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=pm.getSchemes())};Ab.prototype.init=function(t){var e=t||{};this.clipNear=Nn(e.clipNear,0),this.clipRadius=Nn(e.clipRadius,0),this.clipCenter=Nn(e.clipCenter,new v),this.flatShaded=Nn(e.flatShaded,!1),this.side=Nn(e.side,"double"),this.opacity=Nn(e.opacity,1),this.depthWrite=Nn(e.depthWrite,!0),this.wireframe=Nn(e.wireframe,!1),this.setColor(e.color,e),this.colorScheme=Nn(e.colorScheme,"uniform"),this.colorScale=Nn(e.colorScale,""),this.colorReverse=Nn(e.colorReverse,!1),this.colorValue=Nn(e.colorValue,9474192),this.colorDomain=Nn(e.colorDomain,void 0),this.colorMode=Nn(e.colorMode,"hcl"),this.visible=Nn(e.visible,!0),this.quality=Nn(e.quality,void 0),this.roughness=Nn(e.roughness,.4),this.metalness=Nn(e.metalness,0),this.diffuse=Nn(e.diffuse,16777215),this.lazy=Nn(e.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=Nn(e.matrix,new y),this.disablePicking=Nn(e.disablePicking,!1);var r=this.parameters;!0===r.sphereDetail&&(r.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===r.radialSegments&&(r.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===r.openEnded&&(r.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===r.disableImpostor&&(r.disableImpostor={type:"boolean",rebuild:!0}),"low"===e.quality?(r.sphereDetail&&(this.sphereDetail=0),r.radialSegments&&(this.radialSegments=5)):"medium"===e.quality?(r.sphereDetail&&(this.sphereDetail=1),r.radialSegments&&(this.radialSegments=10)):"high"===e.quality?(r.sphereDetail&&(this.sphereDetail=2),r.radialSegments&&(this.radialSegments=20)):(r.sphereDetail&&(this.sphereDetail=Nn(e.sphereDetail,1)),r.radialSegments&&(this.radialSegments=Nn(e.radialSegments,10))),r.openEnded&&(this.openEnded=Nn(e.openEnded,!0)),r.disableImpostor&&(this.disableImpostor=Nn(e.disableImpostor,!1))},Ab.prototype.getColorParams=function(t){return Object.assign({scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode},t)},Ab.prototype.getBufferParams=function(t){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,matrix:this.matrix,disablePicking:this.disablePicking},t)},Ab.prototype.setColor=function(t,e){var r=Object.keys(pm.getSchemes());return"string"==typeof t&&r.includes(t.toLowerCase())?e?e.colorScheme=t:this.setParameters({colorScheme:t}):void 0!==t&&(t=new et(t).getHex(),e?(e.colorScheme="uniform",e.colorValue=t):this.setParameters({colorScheme:"uniform",colorValue:t})),this},Ab.prototype.create=function(){},Ab.prototype.update=function(){this.build()},Ab.prototype.build=function(t){if(!this.lazy||this.visible){if(!this.prepare)return this.tasks.increment(),void this.make();this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(t||!1)}else this.lazyProps.build=!0},Ab.prototype.make=function(e,r){t.Debug&&cm.time("Representation.make "+this.type);var i=function(){e?(this.update(e),this.viewer.requestRender(),this.tasks.decrement(),r&&r()):(this.clear(),this.create(),this.manualAttach||this.disposed||(t.Debug&&cm.time("Representation.attach "+this.type),this.attach(function(){t.Debug&&cm.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),r&&r()}.bind(this)))),t.Debug&&cm.timeEnd("Representation.make "+this.type)}.bind(this);this.prepare?this.prepare(i):i()},Ab.prototype.attach=function(t){this.setVisibility(this.visible),t()},Ab.prototype.setVisibility=function(t,e){if(this.visible=t,this.visible){var r=this.lazyProps,i=r.bufferParams,n=r.what;if(r.build)return r.build=!1,void this.build();(Object.keys(i).length||Object.keys(n).length)&&(r.bufferParams={},r.what={},this.updateParameters(i,n))}return this.bufferList.forEach(function(e){e.setVisibility(t)}),e||this.viewer.requestRender(),this},Ab.prototype.setParameters=function(t,e,r){var i=this,n=t||{},o=this.parameters;this.setColor(n.color,n),e=e||{},r=r||!1;var a={};for(var s in n)void 0!==n[s]&&void 0!==o[s]&&(o[s].int&&(n[s]=parseInt(n[s])),o[s].float&&(n[s]=parseFloat(n[s])),(n[s]!==i[s]||n[s].equals&&!n[s].equals(i[s]))&&(i[s]&&i[s].set?i[s].set(n[s]):i[s]=n[s],o[s].buffer&&(!0===o[s].buffer?a[s]=n[s]:a[o[s].buffer]=n[s]),o[s].update&&(e[o[s].update]=!0),!o[s].rebuild||"impostor"===o[s].rebuild&&sm&&!i.disableImpostor||(r=!0)));return r?this.build():this.updateParameters(a,e),this},Ab.prototype.updateParameters=function(t,e){if(this.lazy&&!this.visible)return Object.assign(this.lazyProps.bufferParams,t),void Object.assign(this.lazyProps.what,e);this.bufferList.forEach(function(e){e.setParameters(t)}),Object.keys(e).length&&this.update(e),this.viewer.requestRender()},Ab.prototype.getParameters=function(){var t=this,e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(function(r){null!==t.parameters[r]&&(e[r]=t[r])}),e},Ab.prototype.clear=function(){var t=this;this.bufferList.forEach(function(e){t.viewer.remove(e),e.dispose()}),this.bufferList.length=0,this.viewer.requestRender()},Ab.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var Mb=function(t){function e(e,r,i){Array.isArray(e)||(e=[e]),t.call(this,e,r,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){t.prototype.init.call(this,e),this.build()},e.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t),t.setParameters(e.getBufferParams())}),this.setVisibility(this.visible),t()},e}(Ab),Eb=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={isSurface:{}};return r.isSurface.get=function(){return!0},Object.defineProperties(e.prototype,r),e}(bb),Tb=function(t){this.size=t.size,this.side=t.side,this.wireframe=t.wireframe,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.background=t.background,this.disablePicking=t.disablePicking,this.group=new qe,this.wireframeGroup=new qe,this.pickingGroup=new qe,this.matrix=t.matrix,this.frontMeshes=[],this.backMeshes=[];var e=t,r=new t.constructor;e.makeMaterial(),r.makeMaterial(),r.picking=t.picking,r.geometry=t.geometry,r.wireframeGeometry=t.wireframeGeometry,r.setParameters(t.getParameters()),r.updateShader(),e.setParameters({side:"front"}),r.setParameters({side:"back",opacity:r.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=r},Pb={matrix:{},pickable:{}};Pb.matrix.set=function(t){vb.prototype.setMatrix.call(this,t)},Pb.matrix.get=function(){return this.group.matrix.clone()},Pb.pickable.get=function(){return!!this.picking&&!this.disablePicking},Tb.prototype.getMesh=function(t){var e,r;return t?(r=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(r=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(r),this.setParameters({side:this.side}),(new qe).add(r,e)},Tb.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},Tb.prototype.getPickingMesh=function(){return this.getMesh(!0)},Tb.prototype.setAttributes=function(t){this.buffer.setAttributes(t)},Tb.prototype.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(tc),this.backMeshes.forEach(ec)):"back"===t.side?(this.frontMeshes.forEach(ec),this.backMeshes.forEach(tc)):"double"===t.side&&(this.frontMeshes.forEach(tc),this.backMeshes.forEach(tc)),void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,void 0!==t.side&&(this.side=t.side),delete t.side,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)},Tb.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},Object.defineProperties(Tb.prototype,Pb),Tb.prototype.setVisibility=vb.prototype.setVisibility,gm.add("shader/Line.vert","uniform float nearClip;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),gm.add("shader/Line.frag","uniform float opacity;\nuniform float nearClip;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");var Cb=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={isLine:{},vertexShader:{},fragmentShader:{}};return r.isLine.get=function(){return!0},r.vertexShader.get=function(){return"Line.vert"},r.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,r),e}(vb),Ib=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof Ey?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new v,this.__boxCenter=new v,this.box=new ht,this.__box=new ht,this._position=new v,this.setBox=function(){this._position.copy(r.translationGroup.position).negate(),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.viewer.signals.ticked.add(this.setBox,this),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=Nn(r.colorScheme,"uniform"),r.colorValue=Nn(r.colorValue,14540253),this.isolevelType=Nn(r.isolevelType,"sigma"),this.isolevel=Nn(r.isolevel,2),this.negateIsolevel=Nn(r.negateIsolevel,!1),this.smooth=Nn(r.smooth,0),this.background=Nn(r.background,!1),this.opaqueBack=Nn(r.opaqueBack,!0),this.boxSize=Nn(r.boxSize,0),this.colorVolume=Nn(r.colorVolume,void 0),this.contour=Nn(r.contour,!1),this.useWorker=Nn(r.useWorker,!0),this.wrap=Nn(r.wrap,!1),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.prepare=function(t){var e=this;if(this.volume){var r;if(r="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(r*=-1),!this.surface||this.__isolevel!==r||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=r,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var i=function(r){e.surface=r,t()};this.useWorker?this.volume.getSurfaceWorker(r,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(r,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t()}else t()},e.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new Cb(e,this.getBufferParams({wireframe:!1}));else{e.normal=this.surface.getNormal(),e.picking=this.surface.getPicking();var r=new Eb(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new Tb(r)}this.bufferList.push(t)},e.prototype.update=function(t){if(0!==this.bufferList.length){var e={};(t=t||{}).position&&(e.position=this.surface.getPosition()),t.color&&(e.color=this.surface.getColor(this.getColorParams())),t.index&&(e.index=this.surface.getIndex()),t.normal&&(e.normal=this.surface.getNormal()),this.bufferList.forEach(function(t){t.setAttributes(e)})}},e.prototype.setParameters=function(e,r,i){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,r,i),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&(r.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),t.prototype.dispose.call(this)},e}(Ab),Rb=new y,Lb=new pt,Ob=function(t){function e(e,r,i){var n,o=e||{},a=r||{},s=i.attributes.position.array,c=i.attributes.normal.array,u=i.index?i.index.array:void 0,h=o.position.length/3,l=s.length/3,p=h*l,d=new Float32Array(3*p),f=new Float32Array(3*p),m=new Float32Array(3*p);u&&(n=Kn(h*u.length,p)),t.call(this,{position:d,color:m,index:n,normal:f,primitiveId:o.primitiveId||ra(h,l),picking:o.picking},a),this.setAttributes(o),this.geoPosition=s,this.geoNormal=c,this.geoIndex=u,this.positionCount=h,this.geoPositionCount=l,this.transformedGeoPosition=new Float32Array(3*l),this.transformedGeoNormal=new Float32Array(3*l),this.meshPosition=d,this.meshColor=m,this.meshIndex=n,this.meshNormal=f,this.meshIndex=n,this.makeIndex()}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={updateNormals:{}};return e.prototype.applyPositionTransform=function(){},e.prototype.setAttributes=function(t,e){var r,i,n,o,a,s,c,u,h,l=this,p=this.geometry.attributes,d=this.updateNormals;t.position&&(r=t.position,n=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,p.position.needsUpdate=!0,(d||e)&&(o=this.geoNormal,h=this.meshNormal,s=this.transformedGeoNormal,p.normal.needsUpdate=!0)),t.color&&(i=t.color,u=this.meshColor,p.color.needsUpdate=!0);for(var f=this.positionCount,m=this.geoPositionCount,g=0;g 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\nreturn false;\n}else{\ncameraNormal = normalize( cameraPos - cameraSpherePos );\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nreturn false;\n}else{\ncameraNormal = normalize( cameraPos - cameraSpherePos );\n}\n#endif\nreturn true;\n}\nreturn false;\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( - ( nearClip - 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\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_flip\n#include normal_fragment\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var kb=function(t){function e(e,r){t.call(this,e,r),this.index=Kn(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index,1),this.addAttributes({mapping:{type:this.mappingType,value:null}}),this.setAttributes({primitiveId:ea(this.size)})}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={attributeSize:{},indexSize:{},mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return r.attributeSize.get=function(){return this.size*this.mappingSize},r.indexSize.get=function(){return this.size*this.mappingIndicesSize},r.mapping.get=function(){},r.mappingIndices.get=function(){},r.mappingIndicesSize.get=function(){},r.mappingType.get=function(){},r.mappingSize.get=function(){},r.mappingItemSize.get=function(){},e.prototype.addAttributes=function(e){var r={};for(var i in e){var n=e[i];r[i]={type:n.type,value:null}}t.prototype.addAttributes.call(this,r)},e.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},e.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Ko(t.position1,t.position2));var e,r,i,n,o,a,s,c=this.size,u=this.mappingSize,h=this.geometry.attributes;for(var l in t)if("index"!==l&&"picking"!==l){r=t[l],i=(e=h[l]).itemSize,n=e.array;for(var p=0;p0&&this.alphaTest<=1&&(r.ALPHATEST=this.alphaTest.toPrecision(2)),r},e.prototype.setUniforms=function(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.tex&&this.tex.dispose()},r.isPoint.get=function(){return!0},r.vertexShader.get=function(){return"Point.vert"},r.fragmentShader.get=function(){return"Point.frag"},Object.defineProperties(e.prototype,r),e}(vb),Vb=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Ey?(this.surface=void 0,this.volume=new Py(e)):(this.surface=e,this.volume=void 0),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=Nn(r.colorScheme,"uniform"),r.colorValue=Nn(r.colorValue,14540253),this.thresholdType=Nn(r.thresholdType,"sigma"),this.thresholdMin=Nn(r.thresholdMin,2),this.thresholdMax=Nn(r.thresholdMax,1/0),this.thresholdOut=Nn(r.thresholdOut,!1),this.dotType=Nn(r.dotType,"point"),this.radius=Nn(r.radius,.1),this.scale=Nn(r.scale,1),this.pointSize=Nn(r.pointSize,1),this.sizeAttenuation=Nn(r.sizeAttenuation,!0),this.sortParticles=Nn(r.sortParticles,!1),this.useTexture=Nn(r.useTexture,!1),this.alphaTest=Nn(r.alphaTest,.5),this.forceTransparent=Nn(r.forceTransparent,!1),this.edgeBleach=Nn(r.edgeBleach,0),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.create=function(){var t={};if(this.volume){var e,r,i=this.volume;"sigma"===this.thresholdType?(e=i.getValueForSigma(this.thresholdMin),r=i.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,r=this.thresholdMax),i.setFilter(e,r,this.thresholdOut),t.position=i.getDataPosition(),t.color=i.getDataColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=i.getDataSize(this.radius,this.scale),t.picking=i.getDataPicking())}else{var n=this.surface;t.position=n.getPosition(),t.color=n.getColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=n.getSize(this.radius,this.scale),t.picking=n.getPicking())}"sphere"===this.dotType?this.dotBuffer=new jb(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Gb(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)},e.prototype.update=function(t){if(0!==this.bufferList.length){var e={};(t=t||{}).color&&(this.volume?e.color=this.volume.getDataColor(this.getColorParams()):e.color=this.surface.getColor(this.getColorParams())),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?e.radius=this.volume.getDataSize(this.radius,this.scale):e.radius=this.surface.getSize(this.radius,this.scale)),this.dotBuffer.setAttributes(e)}},e.prototype.setParameters=function(e,r,i){return r=r||{},e&&void 0!==e.thresholdType&&this.volume instanceof Ey&&("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=e.radiusType,r.radius=!0,"sphere"!==this.dotType||sm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(r.radius=!0,"sphere"!==this.dotType||sm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(r.scale=!0,"sphere"!==this.dotType||sm&&!this.disableImpostor||(i=!0)),t.prototype.setParameters.call(this,e,r,i),this},e}(Ab);gm.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}"),gm.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float nearClip;\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.7 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");var $b=new Uint16Array([0,1,2,1,3,2]),Hb=new Float32Array([0,1,0,0,1,1,1,0]),Wb=function(t){function e(e,r){var i=e||{},n=r||{};t.call(this,{position:i.position,index:$b,picking:i.picking},n),this.forceTransparent=!0,this.filter=Nn(n.filter,"nearest");var o=new b(i.imageData,i.width,i.height);o.flipY=!0,this.tex=o;for(var a=i.imageData.length,s=new Uint8Array(a),c=0;c>16&255,s[c+1]=u>>8&255,s[c+2]=255&u}var h=new b(s,i.width,i.height);h.flipY=!0,h.minFilter=_l,h.magFilter=_l,this.pickingTex=h,this.addUniforms({map:{value:o},pickingMap:{value:h},mapSize:{value:new l(i.width,i.height)}}),this.geometry.addAttribute("uv",new Et(Hb,2))}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={parameters:{},vertexShader:{},fragmentShader:{}};return r.parameters.get=function(){return Object.assign.call(this,{filter:{updateShader:!0,uniform:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e);return this.filter.startsWith("cubic")&&(r.CUBIC_INTERPOLATION=1,this.filter.endsWith("bspline")?r.BSPLINE_FILTER=1:this.filter.endsWith("catmulrom")?r.CATMULROM_FILTER=1:this.filter.endsWith("mitchell")&&(r.MITCHELL_FILTER=1)),r},e.prototype.updateTexture=function(){var t=this.tex;this.filter.startsWith("cubic")?(t.minFilter=_l,t.magFilter=_l):"linear"===this.filter?(t.minFilter=Al,t.magFilter=Al):(t.minFilter=_l,t.magFilter=_l),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.updateTexture();var e=this.material;e.uniforms.map.value=this.tex,e.blending=Ph,e.needsUpdate=!0;var r=this.wireframeMaterial;r.uniforms.map.value=this.tex,r.blending=Ph,r.needsUpdate=!0;var i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=Ph,i.needsUpdate=!0},e.prototype.setUniforms=function(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},r.vertexShader.get=function(){return"Image.vert"},r.fragmentShader.get=function(){return"Image.frag"},Object.defineProperties(e.prototype,r),e}(vb),Xb=function(t,e){var r=e||{};this.dimension=Nn(r.dimension,"x"),this.positionType=Nn(r.positionType,"percent"),this.position=Nn(r.position,30),this.thresholdType=Nn(r.thresholdType,"sigma"),this.thresholdMin=Nn(r.thresholdMin,-1/0),this.thresholdMax=Nn(r.thresholdMax,1/0),this.normalize=Nn(r.normalize,!1),this.volume=t};Xb.prototype.getPositionFromCoordinate=function(t){var e,r=this.dimension,i=this.volume,n=i.matrix,o=(new v).setFromMatrixPosition(n)[r],a=(new v).setFromMatrixScale(n)[r];return e="x"===r?i.nx:"y"===r?i.ny:i.nz,Math.round(((t-o)/(e/100)+1)/a)},Xb.prototype.getData=function(t){function e(t){return Math.round(t/100*(o-1))}function r(t,e,r,i){return 3*(r*a.ny*a.nx+e*a.nx+t)+i}function i(t,e,r,i){m.set(t,e,r).applyMatrix4(c).toArray(f,i)}var n=this;t=t||{};var o,a=this.volume,s=a.data,c=a.matrix;o="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var u,h,l,p,d,f=new Float32Array(12),m=new v,g=0,y=0,b=0,x=a.nx,_=a.ny,w=a.nz;"x"===this.dimension?(l=e(a.nx),p=a.ny-1,d=a.nz-1,u=a.nz,h=a.ny,x=(g=l)+1,i(l,0,0,0),i(l,p,0,3),i(l,0,d,6),i(l,p,d,9)):"y"===this.dimension?(l=a.nx-1,p=e(a.ny),d=a.nz-1,u=a.nz,h=a.nx,_=(y=p)+1,i(0,p,0,0),i(l,p,0,3),i(0,p,d,6),i(l,p,d,9)):"z"===this.dimension&&(l=a.nx-1,p=a.ny-1,d=e(a.nz),u=a.nx,h=a.ny,w=(b=d)+1,i(0,0,d,0),i(0,p,d,3),i(l,0,d,6),i(l,p,d,9));var S,A,M=0,E=0,T=new Uint8Array(u*h*4),P=new Float32Array(u*h);"sigma"===this.thresholdType?(S=a.getValueForSigma(this.thresholdMin),A=a.getValueForSigma(this.thresholdMax)):(S=this.thresholdMin,A=this.thresholdMax);var C=Object.assign({},t.colorParams,{volume:a});this.normalize&&(C.domain=[0,1]);var I,R,L,O=pm.getScheme(C),D=new Float32Array(3),N=O.getScale();if(this.normalize){I=1/0,R=-1/0;for(var k=y;k<_;++k)for(var F=g;FR&&(R=z)}L=R-I}for(var U=y;U<_;++U)for(var j=g;jS&&$0&&this.updateData(t,e)},this):Object.assign(this.lazyProps.what,t)},e.prototype.updateData=function(){this.build()},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.structure=this.structure,e},e.prototype.getAtomParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},e.prototype.getBondParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},e.prototype.setSelection=function(t,e){return this.selection.setString(t,e),this},e.prototype.setParameters=function(e,r,i){return r=r||{},e&&void 0!==e.radiusType&&("size"===e.radiusType?this.radius=1:this.radius=e.radiusType,delete e.radiusType,r.radius=!0,sm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(r.radius=!0,sm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(r.radius=!0,sm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.defaultAssembly&&(i=!0),t.prototype.setParameters.call(this,e,r,i),this},e.prototype.getParameters=function(){return Object.assign(t.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},e.prototype.attach=function(t){var e=this.viewer,r=this.bufferList;this.dataList.forEach(function(t){t.bufferList.forEach(function(i){r.push(i),e.add(i,t.instanceList)})}),this.setVisibility(this.visible),t()},e.prototype.clear=function(){this.dataList.length=0,t.prototype.clear.call(this)},e.prototype.dispose=function(){this.structureView.dispose(),delete this.structure,delete this.structureView,t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Ab),Zb=new v,Kb=new v,Qb=new v,Jb=new v(0,1,0),tx=function(t){function e(e,r){var i=e||{},n=r||{},o=Nn(n.radialSegments,10),a=Nn(n.openEnded,!0),s=(new y).makeRotationX(Math.PI/2),c=new Rr(1,1,1,o,1,a);c.applyMatrix(s);var u=i.position1.length,h=i.radius.length,l=c.attributes.position.array.length/3,p=u/3,d=new Float32Array(2*p*l);ra(p,l,0,d),ra(p,l,p*l,d);var f=new Float32Array(2*u),m=new Float32Array(2*u);t.call(this,{position:f,color:m,primitiveId:d,picking:i.picking},n,c),this.__center=new Float32Array(u),this._position=f,this._color=m,this._from=new Float32Array(2*u),this._to=new Float32Array(2*u),this._radius=new Float32Array(2*h),this.setAttributes(i,!0)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,r){Kb.fromArray(this._from,r),Qb.fromArray(this._to,r),t.lookAt(Kb,Qb,Jb);var i=this._radius[e];Zb.set(i,i,Kb.distanceTo(Qb)),t.scale(Zb)},e.prototype.setAttributes=function(e,r){var i={};e.position1&&e.position2&&(Ko(e.position1,e.position2,this.__center),Ko(e.position1,this.__center,this._position),Ko(this.__center,e.position2,this._position,e.position1.length),this._from.set(e.position1),this._from.set(this.__center,e.position1.length),this._to.set(this.__center),this._to.set(e.position2,this.__center.length),i.position=this._position),e.color&&e.color2&&(this._color.set(e.color),this._color.set(e.color2,e.color.length),i.color=this._color),e.radius&&(this._radius.set(e.radius),this._radius.set(e.radius,e.radius.length),i.radius=this._radius),t.prototype.setAttributes.call(this,i,r)},r.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,r),e}(Ob);gm.add("shader/CylinderImpostor.vert","\nattribute vec3 mapping;\nattribute vec3 position1;\nattribute vec3 position2;\nattribute float radius;\nvarying vec3 axis;\nvarying vec4 base_radius;\nvarying vec4 end_b;\nvarying vec3 U;\nvarying vec3 V;\nvarying vec4 w;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\nattribute vec3 color2;\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#endif\nuniform mat4 modelViewMatrixInverse;\nuniform float ortho;\n#include matrix_scale\nvoid main(){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\nvColor1 = color;\nvColor2 = color2;\n#endif\nbase_radius.w = radius * matrixScale( modelViewMatrix );\nvec3 center = position;\nvec3 dir = normalize( position2 - position1 );\nfloat ext = length( position2 - position1 ) / 2.0;\nvec3 cam_dir;\nif( ortho == 0.0 ){\ncam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;\n}else{\ncam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;\n}\ncam_dir = normalize( cam_dir );\nvec3 ldir;\nfloat b = dot( cam_dir, dir );\nend_b.w = b;\nif( b < 0.0 )\nldir = -ext * dir;\nelse\nldir = ext * dir;\nvec3 left = normalize( cross( cam_dir, ldir ) );\nleft = radius * left;\nvec3 up = radius * normalize( cross( left, ldir ) );\naxis = normalize( normalMatrix * ldir );\nU = normalize( normalMatrix * up );\nV = normalize( normalMatrix * left );\nvec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );\nbase_radius.xyz = base4.xyz / base4.w;\nvec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );\nvec4 end4 = top_position;\nend_b.xyz = end4.xyz / end4.w;\nw = modelViewMatrix * vec4(\ncenter + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0\n);\ngl_Position = projectionMatrix * w;\ngl_Position.z = 0.99;\n}"),gm.add("shader/CylinderImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\nuniform mat4 projectionMatrix;\nuniform float ortho;\nvarying vec3 axis;\nvarying vec4 base_radius;\nvarying vec4 end_b;\nvarying vec3 U;\nvarying vec3 V;\nvarying vec4 w;\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\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat distSq3( vec3 v3a, vec3 v3b ){\nreturn (\n( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +\n( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +\n( v3a.z - v3b.z ) * ( v3a.z - v3b.z )\n);\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}\nfloat calcClip( vec3 cameraPos ){\nreturn dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );\n}\nvoid main(){\nvec3 point = w.xyz / w.w;\nvec3 base = base_radius.xyz;\nfloat vRadius = base_radius.w;\nvec3 end = end_b.xyz;\nfloat b = end_b.w;\nvec3 end_cyl = end;\nvec3 surface_point = point;\nvec3 ray_target = surface_point;\nvec3 ray_origin = vec3(0.0);\nvec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);\nmat3 basis = mat3( U, V, axis );\nvec3 diff = ray_target - 0.5 * (base + end_cyl);\nvec3 P = diff * basis;\nfloat dz = dot( axis, ray_direction );\nfloat radius2 = vRadius*vRadius;\nvec3 D = vec3(dot(U, ray_direction),\ndot(V, ray_direction),\ndz);\nfloat a0 = P.x*P.x + P.y*P.y - radius2;\nfloat a1 = P.x*D.x + P.y*D.y;\nfloat a2 = D.x*D.x + D.y*D.y;\nfloat d = a1*a1 - a0*a2;\nif (d < 0.0)\ndiscard;\nfloat dist = (-a1 + sqrt(d)) / a2;\nvec3 new_point = ray_target + dist * ray_direction;\nvec3 tmp_point = new_point - base;\nvec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );\nray_origin = mix( ray_origin, surface_point, ortho );\nfloat front_cap_test = dot( tmp_point, axis );\nfloat end_cap_test = dot((new_point - end_cyl), axis);\n#ifndef CAP\nvec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\nvec3 tmp_point2 = new_point2 - base;\n#endif\nif (front_cap_test < 0.0)\n{\nfloat dNV = dot(-axis, ray_direction);\nif (dNV < 0.0)\ndiscard;\nfloat near = dot(-axis, (base)) / dNV;\nvec3 front_point = ray_direction * near + ray_origin;\nif (dot(front_point - base, front_point-base) > radius2)\ndiscard;\n#ifdef CAP\nnew_point = front_point;\n_normal = axis;\n#else\nnew_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end_cyl) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end_cyl, new_point2-base) < radius2)\ndiscard;\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV = dot(axis, ray_direction);\nif (dNV < 0.0)\ndiscard;\nfloat near = dot(axis, end_cyl) / dNV;\nvec3 end_point = ray_direction * near + ray_origin;\nif( dot(end_point - end_cyl, end_point-base) > radius2 )\ndiscard;\n#ifdef CAP\nnew_point = end_point;\n_normal = axis;\n#else\nnew_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;\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( new_point );\n#ifdef NEAR_CLIP\nif( calcClip( new_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\nif( calcClip( new_point ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_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;\nnew_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -new_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( new_point, end_cyl ) < distSq3( new_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 );\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var ex=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),rx=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),ix=function(t){function e(e,r){t.call(this,e,r);var i=r||{};this.openEnded=Nn(i.openEnded,!1),this.addUniforms({modelViewMatrixInverse:{value:new y},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={parameters:{},isImpostor:{},vertexShader:{},fragmentShader:{}};return r.parameters.get=function(){return Object.assign.call(this,{openEnded:{updateShader:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e);return this.openEnded||(r.CAP=1),r},r.isImpostor.get=function(){return!0},r.vertexShader.get=function(){return"CylinderImpostor.vert"},r.fragmentShader.get=function(){return"CylinderImpostor.frag"},Object.defineProperties(e.prototype,r),e}(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return r.mapping.get=function(){return ex},r.mappingIndices.get=function(){return rx},r.mappingIndicesSize.get=function(){return 12},r.mappingType.get=function(){return"v3"},r.mappingSize.get=function(){return 6},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(kb)),nx=function(t,e){return t.color2||(t.color2=t.color),!sm||e&&e.disableImpostor?new tx(t,e):new ix(t,e)};bm.add("cylinder",nx);var ox=function(t){function e(e,r){var i=4*(e.position1.length/3);t.call(this,{position:new Float32Array(3*i),color:new Float32Array(3*i)},r),this.setAttributes(e)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,r,i,n,o,a,s=this.geometry.attributes;t.position1&&t.position2&&(e=t.position1,r=t.position2,o=s.position.array,s.position.needsUpdate=!0),t.color&&t.color2&&(i=t.color,n=t.color2,a=s.color.array,s.color.needsUpdate=!0);for(var c,u,h,l,p,d,f,m,g,v,y,b=this.size,x=0;x5&&s>15e3||s>7e5){var p=Math.min(1.5,Math.max(.1,2e3/(s/n)));c&&(p=Math.min(p,.15)),e.addRepresentation("surface",{sele:"polymer",surfaceType:"sas",probeRadius:1.4,scaleFactor:p,colorScheme:u,colorScale:h,colorReverse:l,useWorker:!1})}else s>25e4?e.addRepresentation("backbone",{lineOnly:!0,colorScheme:u,colorScale:h,colorReverse:l}):s>1e5?e.addRepresentation("backbone",{quality:"low",disableImpostor:!0,colorScheme:u,colorScale:h,colorReverse:l,scale:2}):s>8e4?e.addRepresentation("backbone",{colorScheme:u,colorScale:h,colorReverse:l,scale:2}):(e.addRepresentation("cartoon",{colorScheme:u,colorScale:h,colorReverse:l,scale:.7,aspectRatio:5,quality:"auto"}),s<5e4&&e.addRepresentation("base",{colorScheme:u,colorScale:h,colorReverse:l,quality:"auto"}),e.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));e.structure.frames.length&&e.addTrajectory()}else"surface"!==e.type&&"volume"!==e.type||e.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},vx.prototype.loadFile=function(t,e){var r=Object.assign({},this.defaultFileParams,e),i=new hx(this,r);i.name=jn(t).name,this.addComponent(i);var n=this.tasks;n.increment();var o=function(t){return this.removeComponent(i),"script"===(i=this.addComponentFromObject(t,r)).type?i.run():r.defaultRepresentation&&this.defaultFileRepresentation(i),n.decrement(),i}.bind(this),a=Nn(r.ext,jn(t).ext);return(mm.isTrajectory(a)?Promise.reject(new Error('loadFile: ext "'+a+'" is a trajectory and must be loaded into a structure component')):Go(t,r)).then(o,function(t){throw i.setStatus(t),n.decrement(),t})},vx.prototype.addComponent=function(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):cm.warn("Stage.addComponent: no component given")},vx.prototype.addComponentFromObject=function(t,e){var r=ym.get(t.type);if(r){var i=new r(this,t,e);return this.addComponent(i),i}cm.warn("no component for object type",t.type)},vx.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},vx.prototype.removeAllComponents=function(t){this.compList.slice().forEach(function(e){t&&e.type!==t||this.removeComponent(e)},this)},vx.prototype.handleResize=function(){this.viewer.handleResize()},vx.prototype.setSize=function(t,e){var r=this.viewer.container;r!==document.body&&(void 0!==t&&(r.style.width=t),void 0!==e&&(r.style.height=e),this.handleResize())},vx.prototype.toggleFullscreen=function(t){function e(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!e()&&i.lastFullscreenElement){var t=i.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),i.handleResize(),i.signals.fullscreenChanged.dispatch(!1)}}if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var i=this;t=t||this.viewer.container,this.lastFullscreenElement=t,e()?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(){i.handleResize()},100))}else cm.log("fullscreen mode (currently) not possible")},vx.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},vx.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},vx.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},vx.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},vx.prototype.setFocus=function(t){var e=fo(t/2,0,49.9),r=100-e,i=(r-e)/2;this.setParameters({clipNear:e,clipFar:r,fogNear:mo(r-i),fogFar:mo(r+i)})},vx.prototype.getZoomForBox=function(t){var e=t.getSize(gx),r=Math.max(e.x,e.y,e.z),i=Math.min(e.x,e.y,e.z),n=r+Math.sqrt(i),o=co(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=a/s,u=s=this.V[n][o]?(r="S",this.score=this.S[n][o]):this.V[n][o]>=this.H[n][o]?(r="V",this.score=this.V[n][o]):(r="H",this.score=this.H[n][o]),t.Debug&&cm.log("Alignment: SCORE",this.score),t.Debug&&cm.log("Alignment: S, V, H",this.S[n][o],this.V[n][o],this.H[n][o]);n>0&&o>0;)"S"===r?e.S[n][o]===e.S[n-1][o-1]+i(n-1,o-1)?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--n,--o,r="S"):e.S[n][o]===e.V[n][o]?r="V":e.S[n][o]===e.H[n][o]?r="H":(--n,--o):"V"===r?e.V[n][o]===e.V[n-1][o]+e.gapExtensionPenalty?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n,r="V"):e.V[n][o]===e.S[n-1][o]+e.gap(0)?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n,r="S"):--n:"H"===r?e.H[n][o]===e.H[n][o-1]+e.gapExtensionPenalty?(e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o,r="H"):e.H[n][o]===e.S[n][o-1]+e.gap(0)?(e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o,r="S"):--o:cm.error("Alignment: no matrix");for(;n>0;)e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n;for(;o>0;)e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o;t.Debug&&cm.timeEnd("Alignment.trace"),t.Debug&&cm.log([this.ali1,this.ali2])};var _x=function(t){function e(e){var r=this;t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=Nn(e.reverse,!0)),this.scalePerModel={},this.structure.eachModel(function(t){r.domain=[t.atomOffset,t.atomEnd],r.scalePerModel[t.index]=r.getScale()})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.index)},e}(Rf);pm.add("atomindex",_x);var wx=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="OrRd"),!e.domain){var r,i=1/0,n=-1/0;e.sele&&(r=new qf(e.sele)),this.structure.eachAtom(function(t){var e=t.bfactor;i=Math.min(i,e),n=Math.max(n,e)},r),this.domain=[i,n]}this.bfactorScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.bfactorScale(t.bfactor)},e}(Rf);pm.add("bfactor",wx);var Sx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var r={},i={};this.structure.eachModel(function(t){var e=0,n={};t.eachChain(function(t){void 0===n[t.chainid]&&(n[t.chainid]=e,e+=1)}),this.domain=[0,e-1],r[t.index]=n,i[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=r[t.modelIndex];return i[t.modelIndex](e[t.chainid])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("chainid",Sx);var Ax=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="Spectral"),e.domain){var r=this.getScale();this.atomColor=function(t){return r(t.chainIndex)}}else{var i={};this.structure.eachModel(function(t){this.domain=[t.chainOffset,t.chainEnd],i[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){return i[t.modelIndex](t.chainIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("chainindex",Ax);var Mx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var r={},i={};this.structure.eachModel(function(t){var e=0,n={};t.eachChain(function(t){void 0===n[t.chainname]&&(n[t.chainname]=e,e+=1)}),this.domain=[0,e-1],r[t.index]=n,i[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=r[t.modelIndex];return i[t.modelIndex](e[t.chainname])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("chainname",Mx);var Ex=function(t){function e(e){t.call(this,e),e.scale||(this.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});var r=e.structure.validation||{};this.rsrzDict=r.rsrzDict||{},this.rsccDict=r.rsccDict||{}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.resno;t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var r=this.rsrzDict[e];if(void 0!==r)return this.rsrzScale(r);var i=this.rsccDict[e];return void 0!==i?this.rsccScale(i):9474192},e}(Rf);pm.add("densityfit",Ex);var Tx={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}},Px=12,Cx=1.04,Ix=.25,Rx=function(t){function e(e){function r(t){return t.isProtein()?Tx[t.resname]&&Tx[t.resname][t.atomname]||Tx.backbone[t.atomname]||0:0}t.call(this,e),e.scale||(this.scale="rwb"),e.domain||(this.domain=[-.5,0,.5]);var i=this.getScale(),n=this.structure,o=new Float32Array(n.atomCount),a=[],s=[];n.eachAtom(function(t){if(o[t.index]=r(t)*t.occupancy,"N"===t.atomname){var e=uc(t);void 0!==e&&(a.push(e),s.push(Ix*t.occupancy))}});var c=this.structure.getBoundingBox();c.expandByScalar(Cx);var u=hc(a),h=new ps(u,c),l=new ps(this.structure.atomStore,c),p=this.atomProxy,d=new v,f=Px*Px;this.positionColor=function(t){for(var e=0,r=l.within(t.x,t.y,t.z,Px),n=0;n=3?10813478:9474192},e}(Rf);pm.add("geoquality",kx);var Fx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="RdYlGn");var r,i={};for(r in ay)i[r]=ay[r][0];if(!e.domain){var n,o=1/0,a=-1/0;for(r in i)n=i[r],o=Math.min(o,n),a=Math.max(a,n);this.domain=[o,0,a]}var s=this.getScale();this.atomColor=function(t){return s(i[t.resname]||sy)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("hydrophobicity",Fx);var Bx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rainbow"),e.domain||(this.domain=[0,this.structure.modelStore.count]);var r=this.getScale();this.atomColor=function(t){return r(t.modelIndex)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("modelindex",Bx);var zx=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}},e}(Rf);pm.add("moleculetype",zx);var Ux=function(t){function e(e){t.call(this,e),e.scale||(this.scale="PuBu"),e.domain||(this.domain=[0,1]);var r=this.getScale();this.atomColor=function(t){return r(t.occupancy)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("occupancy",Ux);var jx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rwb"),e.domain||(this.domain=[-1,1]),this.partialchargeScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.partialchargeScale(t.partialCharge)},e}(Rf);pm.add("partialcharge",jx);var Gx=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return lc()},e.prototype.volumeColor=function(){return lc()},e.prototype.positionColor=function(){return lc()},e}(Rf);pm.add("random",Gx);var Vx=function(t){function e(e){var r=this;if(t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=Nn(e.reverse,!0)),e.domain){var i=this.getScale();this.atomColor=function(t){return i(t.residueIndex)}}else{var n={};this.structure.eachChain(function(t){r.domain=[t.residueOffset,t.residueEnd],n[t.index]=r.getScale()}),this.atomColor=function(t){return n[t.chainIndex](t.residueIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Rf);pm.add("residueindex",Vx);var $x={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:10526975,G:16740464,I:8454143,C:16747595,T:10551200,U:16744576,DA:10526975,DG:16740464,DI:8454143,DC:16747595,DT:10551200,DU:16744576},Hx=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return $x[t.resname]||16711935},e}(Rf);pm.add("resname",Hx);var Wx={alphaHelix:16711808,threeTenHelix:10485888,piHelix:6291584,betaStrand:16762880,betaTurn:6324479,coil:16777215,dna:11403518,rna:16580962,carbohydrate:10921722},Xx=function(t){function e(e){t.call(this,e),this.rp=this.structure.getResidueProxy()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.sstruc,r=this.rp;return"h"===e?Wx.alphaHelix:"g"===e?Wx.threeTenHelix:"i"===e?Wx.piHelix:"e"===e||"b"===e?Wx.betaStrand:"t"===e?Wx.betaTurn:(r.index=t.residueIndex,r.isDna()?Wx.dna:r.isRna()?Wx.rna:r.isSaccharide()?Wx.carbohydrate:r.isProtein()||"s"===e||"l"===e?Wx.coil:8421504)},e}(Rf);pm.add("sstruc",Xx);var qx=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return this.value},e.prototype.bondColor=function(){return this.value},e.prototype.valueColor=function(){return this.value},e.prototype.volumeColor=function(){return this.value},e}(Rf);pm.add("uniform",qx);var Yx=function(t){function e(e){t.call(this,e),this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.volumeColor=function(t){return this.valueScale(this.volume.data[t])},e}(Rf);pm.add("value",Yx);var Zx=function(t){function e(e){t.call(this,e);var r=this.volume;if(r&&r.inverseMatrix){var i=this.getScale(),n=r.inverseMatrix,o=r.data,a=r.nx,s=r.ny,c=a*s,u=new v;this.positionColor=function(t){u.copy(t),u.applyMatrix4(n);var e=Math.floor(u.x),r=Math.floor(u.y),h=Math.floor(u.z),l=(h*s+r)*a+e,p=l+1,d=l+a,f=l+c,m=d+1,g=f+1,v=d+c,y=v+1,b=o[l],x=o[p],_=o[d],w=o[f],S=o[m],A=o[g],M=o[v],E=o[y],T=u.x-e,P=u.y-r,C=u.z-h,I=vo(b,x,T),R=vo(w,A,T),L=vo(_,S,T),O=vo(M,E,T),D=vo(vo(I,L,P),vo(R,O,P),C);return i(D)}}else{var h=this.value;this.positionColor=function(){return h}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.positionColor=function(){},e}(Rf);pm.add("volume",Zx);var Kx=function(t){function e(e,r,i){var n=this,o=i||{};o.name=Nn(o.name,r.name),t.call(this,e,o),this.script=r,this.status="loaded",this.script.signals.nameChanged.add(function(t){n.setName(t)})}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"script"},e.prototype.addRepresentation=function(){},e.prototype.removeRepresentation=function(){},e.prototype.run=function(){var t=this;this.setStatus("running"),this.script.call(this.stage).then(function(){t.setStatus("finished")}),this.setStatus("called")},e.prototype.dispose=function(){this.signals.disposed.dispatch()},e.prototype.setVisibility=function(){},e.prototype.getCenter=function(){},e.prototype.getZoom=function(){},e.prototype.getBox=function(){},Object.defineProperties(e.prototype,r),e}(hx);ym.add("script",Kx);var Qx=function(t){function e(e,r,i){var n=i||{};n.name=Nn(n.name,r.name),t.call(this,e,n),this.shape=r}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"shape"},e.prototype.addRepresentation=function(e,r){return t.prototype.addRepresentation.call(this,e,this.shape,r)},e.prototype.getBoxUntransformed=function(){return this.shape.boundingBox},e.prototype.getCenterUntransformed=function(){return this.shape.center},e.prototype.dispose=function(){this.shape.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(hx);ym.add("shape",Qx);var Jx=function(t){function e(e,r,i,n){var o=this,a=i||{};a.name=Nn(a.name,r.name),t.call(this,e,a),this.signals=Object.assign(this.signals,{frameChanged:new So,playerChanged:new So,countChanged:new So,parametersChanged:new So}),this.trajectory=r,this.parent=n,this.status="loaded",this.defaultStep=Nn(a.defaultStep,void 0),this.defaultTimeout=Nn(a.defaultTimeout,50),this.defaultInterpolateType=Nn(a.defaultInterpolateType,""),this.defaultInterpolateStep=Nn(a.defaultInterpolateStep,5),this.defaultMode=Nn(a.defaultMode,"loop"),this.defaultDirection=Nn(a.defaultDirection,"forward"),r.signals.frameChanged.add(function(t){o.signals.frameChanged.dispatch(t)}),r.signals.playerChanged.add(function(t){o.signals.playerChanged.dispatch(t)}),r.signals.countChanged.add(function(t){o.signals.countChanged.dispatch(t)}),void 0!==a.initialFrame&&this.setFrame(a.initialFrame)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"trajectory"},e.prototype.addRepresentation=function(e,r){return t.prototype.addRepresentation.call(this,e,this.trajectory,r)},e.prototype.setFrame=function(t){this.trajectory.setFrame(t)},e.prototype.setParameters=function(t){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)},e.prototype.dispose=function(){this.trajectory.dispose(),t.prototype.dispose.call(this)},e.prototype.getCenter=function(){},Object.defineProperties(e.prototype,r),e}(hx),t_=function(t){function e(e,r,i){var n=i||{};n.timeOffset=Nn(n.timeOffset,e.timeOffset),n.deltaTime=Nn(n.deltaTime,e.deltaTime),t.call(this,"",r,n),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(r)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"frames"},e.prototype._makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=null},e.prototype._loadFrame=function(t,e){var r,i=this.frames[t];if(this.atomIndices){var n=this.atomIndices,o=n.length;r=new Float32Array(3*o);for(var a=0;a0&&(i="( "+e.join(" ) AND ( ")+" )"),new qf(i)},r.prototype.getStructure=function(){return this.structure.getStructure()},r.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},r.prototype.eachAtom=function(t,e){var r=this.getAtomProxy(),i=this.getAtomSet(e),n=this.atomStore.count;if(i.getSize()= 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}"),gm.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float nearClip;\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.7 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var c_=function(t){function e(e,r){t.call(this,e,r);var i=r||{};this.linewidth=Nn(i.linewidth,2),this.addUniforms({linewidth:{value:this.linewidth},resolution:{value:new l},projectionMatrixInverse:{value:new y}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={parameters:{},vertexShader:{},fragmentShader:{}};return r.parameters.get=function(){return Object.assign.call(this,{linewidth:{uniform:!0}},t.prototype.parameters)},r.vertexShader.get=function(){return"WideLine.vert"},r.fragmentShader.get=function(){return"WideLine.frag"},Object.defineProperties(e.prototype,r),e}(zb),u_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radius=Nn(r.radius,.15),this.aspectRatio=Nn(r.aspectRatio,2),this.lineOnly=Nn(r.lineOnly,!1),this.cylinderOnly=Nn(r.cylinderOnly,!1),this.multipleBond=Nn(r.multipleBond,"off"),this.bondSpacing=Nn(r.bondSpacing,1),this.bondScale=Nn(r.bondScale,.4),this.linewidth=Nn(r.linewidth,2),t.prototype.init.call(this,r)},e.prototype.getAtomParams=function(e,r){return r=Object.assign({radiusParams:{radius:this.radius,scale:this.scale*this.aspectRatio}},r),t.prototype.getAtomParams.call(this,e,r)},e.prototype.getAtomData=function(t,e,r){return t.getAtomData(this.getAtomParams(e,r))},e.prototype.getBondParams=function(e,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},r),t.prototype.getBondParams.call(this,e,r)},e.prototype.getBondData=function(t,e,r){return t.getBondData(this.getBondParams(e,r))},e.prototype.createData=function(t){var e=[];if(this.lineOnly)this.lineBuffer=new c_(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{var r=new nx(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(r),!this.cylinderOnly){var i=new jb(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}},e.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var r=this.getBondData(e.sview,t);if(this.lineOnly){var i={};t&&!t.position||(i.position1=r.position1,i.position2=r.position2),t&&!t.color||(i.color=r.color,i.color2=r.color2),e.bufferList[0].setAttributes(i)}else{var n={};if(t&&!t.position||(n.position1=r.position1,n.position2=r.position2),t&&!t.color||(n.color=r.color,n.color2=r.color2),t&&!t.radius||(n.radius=r.radius),e.bufferList[0].setAttributes(n),!this.cylinderOnly){var o=this.getAtomData(e.sview,t),a={};t&&!t.position||(a.position=o.position),t&&!t.color||(a.color=o.color),t&&!t.radius||(a.radius=o.radius),e.bufferList[1].setAttributes(a)}}},e.prototype.setParameters=function(e){var r=!1,i={};return e&&(e.aspectRatio||e.bondSpacing||e.bondScale)&&(i.radius=!0,sm&&!this.disableImpostor||(r=!0)),t.prototype.setParameters.call(this,e,i,r),this},e}(Yb);fm.add("ball+stick",u_);var h_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=Nn(r.aspectRatio,1),r.radius=Nn(r.radius,.25),t.prototype.init.call(this,r)},e.prototype.getAtomData=function(t,e,r){return t.getBackboneAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){return t.getBackboneBondData(this.getBondParams(e,r))},e}(u_);fm.add("backbone",h_);var l_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=Nn(r.aspectRatio,1),r.radius=Nn(r.radius,.3),t.prototype.init.call(this,r)},e.prototype.getAtomData=function(t,e,r){return t.getRungAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){var i=this.getBondParams(e,r);return i.colorParams.rung=!0,t.getRungBondData(i)},e}(u_);fm.add("base",l_),fc.prototype={constructor:fc,getAtomIterator:function(t,e){var r=this.polymer,i=r.structure,n=r.residueCount,o=0,a=-1,s=[i.getAtomProxy(),i.getAtomProxy(),i.getAtomProxy(),i.getAtomProxy()],c=[new v,new v,new v,new v],u=i.getAtomProxy(),h=i.getAtomProxy();return{size:n,next:function(){var t=this.get(a);return a+=1,t},get:function(i){var a=s[o%4];if(a.index=r.getAtomIndexByType(i,t),e&&i>0&&ie)&&(s=!0,n.set(i.index),o.addBond(a,i,1))}s&&n.set(a.index)});var a=new Gv(o.count,!0);return cm.timeEnd("Contact within"),{atomSet:n,bondSet:a,bondStore:o}};var v_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="contact",this.parameters=Object.assign({contactType:{type:"select",rebuild:!0,options:{polar:"polar",polarBackbone:"polar backbone"}},maxDistance:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxAngle:{type:"integer",max:180,min:0,rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radius=Nn(r.radius,.25),this.contactType=Nn(r.contactType,"polarBackbone"),this.maxDistance=Nn(r.maxDistance,3.5),this.maxAngle=Nn(r.maxAngle,40),t.prototype.init.call(this,r)},e.prototype.getContactData=function(t){return{polar:mc,polarBackbone:gc}[this.contactType](t,this.maxDistance,this.maxAngle)},e.prototype.getBondData=function(t,e,r){var i=t.getBondData(this.getBondParams(e,r));return i.picking&&(i.picking=new Ev(i.picking.array,i.picking.structure,r.bondStore)),i},e.prototype.createData=function(t){var e=this.getContactData(t);return{bufferList:[new nx(this.getBondData(t,void 0,{bondSet:e.bondSet,bondStore:e.bondStore}),this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],bondSet:e.bondSet,bondStore:e.bondStore}},e.prototype.updateData=function(t,e){if(!t||t.position){var r=this.getContactData(e.sview);e.bondSet=r.bondSet,e.bondStore=r.bondStore}var i={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(e.sview,t,i),o={};t&&!t.position||(o.position=Ko(n.position1,n.position2),o.position1=n.position1,o.position2=n.position2),t&&!t.color||(o.color=n.color,o.color2=n.color2),t&&!t.radius||(o.radius=n.radius),e.bufferList[0].setAttributes(o)},e}(Yb);fm.add("contact",v_),gm.add("shader/SDFFont.vert","uniform float nearClip;\nuniform float clipRadius;\nuniform vec3 clipCenter;\nuniform float xOffset;\nuniform float yOffset;\nuniform float zOffset;\nuniform bool ortho;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\nvarying vec2 texCoord;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#endif\nattribute vec2 mapping;\nattribute vec2 inputTexCoord;\nattribute float inputSize;\n#include matrix_scale\n#include common\nvoid main(void){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#endif\ntexCoord = inputTexCoord;\nfloat scale = matrixScale( modelViewMatrix );\nfloat _zOffset = zOffset * scale;\nif( texCoord.x == 10.0 ){\n_zOffset -= 0.001;\n}\nvec3 pos = position;\nif( ortho ){\npos += normalize( cameraPosition ) * _zOffset;\n}\nvec4 cameraPos = modelViewMatrix * vec4( pos, 1.0 );\nvec4 cameraCornerPos = vec4( cameraPos.xyz, 1.0 );\ncameraCornerPos.xy += mapping * inputSize * 0.01 * scale;\ncameraCornerPos.x += xOffset * scale;\ncameraCornerPos.y += yOffset * scale;\nif( !ortho ){\ncameraCornerPos.xyz += normalize( -cameraCornerPos.xyz ) * _zOffset;\n}\ngl_Position = projectionMatrix * cameraCornerPos;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvViewPosition = -cameraCornerPos.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n#include radiusclip_vertex\n}"),gm.add("shader/SDFFont.frag","uniform sampler2D fontTexture;\nuniform float opacity;\nuniform bool showBorder;\nuniform vec3 borderColor;\nuniform float borderWidth;\nuniform vec3 backgroundColor;\nuniform float backgroundOpacity;\nuniform float nearClip;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\nvarying vec2 texCoord;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\nconst vec3 vColor = vec3( 0.0 );\n#else\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#endif\n#ifdef SDF\nconst float smoothness = 16.0;\n#else\nconst float smoothness = 256.0;\n#endif\nconst float gamma = 2.2;\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\nif( texCoord.x > 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat w = clamp(\nsmoothness * ( abs( dFdx( texCoord.x ) ) + abs( dFdy( texCoord.y ) ) ),\n0.0,\n0.5\n);\nfloat a = smoothstep( 0.5 - w, 0.5 + w, sdf );\na = pow( a, 1.0 / gamma );\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( 0.5 + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var y_={},b_=function(t){var e=Object.assign({},t);if(this.font=Nn(e.font,["sans-serif"]),this.size=Nn(e.size,36),this.style=Nn(e.style,"normal"),this.variant=Nn(e.variant,"normal"),this.weight=Nn(e.weight,"normal"),this.outline=Nn(e.outline,0),this.width=Nn(e.width,2048),this.height=Nn(e.height,2048),this.gamma=1,"undefined"!=typeof navigator){var r=navigator.userAgent;r.match(/Chrome/)&&r.match(/OS X/)&&(this.gamma=.5)}this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.build(),this.populate(),this.texture=new nt(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};b_.prototype.build=function(){var t=this.size+2*this.outline+Math.round(this.size/4),e=this.width/4,r=document.createElement("canvas");r.width=e,r.height=t;var i=r.getContext("2d");i.font=this.style+" "+this.variant+" "+this.weight+" "+this.size+"px "+this.font,i.fillStyle="#FF0000",i.textAlign="left",i.textBaseline="bottom",i.lineJoin="round";for(var n=[],o=3*this.outline,a=0;athis.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>this.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]},b_.prototype.get=function(t){return this.mapped[t]||this.placeholder},b_.prototype.draw=function(t){var e=this.lineHeight,r=this.outline,i=this.context,n=this.scratch,o=this.maxWidth,a=this.colors,s=r,c=e-this.outline,u=i.measureText(t),h=Math.min(o,Math.ceil(u.width+2*s+1));i.clearRect(0,0,h,e);var l,p,d,f,m;if(0===this.outline)for(i.fillText(t,s,c),d=3,l=0,p=(m=(f=i.getImageData(0,0,h,e)).data).length/4;l0;--l)d=l>1?2*l-2:l,i.strokeStyle=a[d-1],i.lineWidth=d,i.strokeText(t,s,c);i.globalCompositeOperation="multiply",i.fillStyle="#FF00FF",i.fillText(t,s,c),m=(f=i.getImageData(0,0,h,e)).data,d=0;var g=this.gamma;for(l=0,p=m.length/4;l0&&(r-=h,n=n.subarray(0,3*r));var l=new Gv(s.count,!0);return{text:i,position:n,bondSet:l,bondStore:s}},e.prototype.getBondData=function(t,e,r){var i=t.getBondData(this.getBondParams(e,r));return i.picking&&(i.picking=new Cv(i.picking.array,i.picking.structure,r.bondStore)),i},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=this.atomPair.length;if(0!==t){var e=this.getDistanceData(this.structureView,this.atomPair),r=new et(this.labelColor);this.textBuffer=new x_({position:e.position,size:Qo(t,this.labelSize),color:Jo(t,r.r,r.g,r.b),text:e.text},this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,sdf:this.sdf,zOffset:this.labelZOffset,opacity:1,visible:this.labelVisible}));var i={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(this.structureView,void 0,i);this.cylinderBuffer=new nx(n,this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bondSet:e.bondSet,bondStore:e.bondStore,position:e.position,bufferList:[this.textBuffer,this.cylinderBuffer]})}}},e.prototype.update=function(e){e.position?this.build():t.prototype.update.call(this,e)},e.prototype.updateData=function(t,e){var r={bondSet:e.bondSet,bondStore:e.bondStore},i=this.getBondData(e.sview,t,r),n={},o={},a=this.atomPair.length;if(t.labelSize&&(o.size=Qo(a,this.labelSize)),t.labelColor){var s=new et(this.labelColor);o.color=Jo(a,s.r,s.g,s.b)}t.color&&(n.color=i.color,n.color2=i.color2),(t.radius||t.scale)&&(n.radius=i.radius),this.textBuffer.setAttributes(o),this.cylinderBuffer.setAttributes(n)},e.prototype.setVisibility=function(e,r){return t.prototype.setVisibility.call(this,e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),r||this.viewer.requestRender(),this},e.prototype.setParameters=function(e){var r={};return e&&e.labelSize&&(r.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(r.labelColor=!0),t.prototype.setParameters.call(this,e,r,!1),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this},e}(Yb);fm.add("distance",__);var w_=function(t){function e(e,r){var i=r||{},n=2*(e.position.length/3),o=new et(Nn(i.color,"grey")),a=new Float32Array(3*n),s=Jo(n,o.r,o.g,o.b);t.call(this,{position:a,color:s},i),this.scale=Nn(i.scale,1),this.setAttributes(e)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,r,i,n=this.geometry.attributes;t.position&&t.vector&&(e=t.position,r=t.vector,i=n.position.array,n.position.needsUpdate=!0);var o,a,s=this.size/2,c=this.scale;if(t.position&&t.vector)for(var u=0;u 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}"),gm.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\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\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, nearClip - 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( - ( nearClip - 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\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 );\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var M_=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]),E_=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]),T_=function(t){function e(e,r){t.call(this,e,r);var i=e||{},n=Nn((r||{}).shrink,.14);this.addUniforms({modelViewProjectionMatrix:{value:new y},modelViewProjectionMatrixInverse:{value:new y},modelViewMatrixInverseTranspose:{value:new y},shrink:{value:n}}),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(i),this.makeMapping()}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={parameters:{},isImpostor:{},vertexShader:{},fragmentShader:{}};return r.parameters.get=function(){return Object.assign.call(this,{shrink:{uniform:!0}},t.prototype.parameters)},r.isImpostor.get=function(){return!0},r.vertexShader.get=function(){return"HyperballStickImpostor.vert"},r.fragmentShader.get=function(){return"HyperballStickImpostor.frag"},Object.defineProperties(e.prototype,r),e}(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return r.mapping.get=function(){return M_},r.mappingIndices.get=function(){return E_},r.mappingIndicesSize.get=function(){return 36},r.mappingType.get=function(){return"v3"},r.mappingSize.get=function(){return 8},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(kb)),P_=function(t,e){return!sm||e&&e.disableImpostor?(t.radius=ia(t.radius,t.radius2),new tx(t,e)):new T_(t,e)},C_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="hyperball",this.parameters=Object.assign({shrink:{type:"number",precision:3,max:1,min:.001,buffer:!0}},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.scale=Nn(r.scale,.2),r.radius=Nn(r.radius,"vdw"),this.shrink=Nn(r.shrink,.12),t.prototype.init.call(this,r)},e.prototype.getBondParams=function(e,r){return e&&!e.radius||(r=Object.assign({radius2:!0},r)),t.prototype.getBondParams.call(this,e,r)},e.prototype.createData=function(t){var e=new jb(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));return this.__center=new Float32Array(3*t.bondCount),{bufferList:[e,new P_(t.getBondData(this.getBondParams()),this.getBufferParams({shrink:this.shrink,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))]}},e.prototype.updateData=function(t,e){var r=e.sview.getAtomData(this.getAtomParams()),i=e.sview.getBondData(this.getBondParams()),n={},o={};if(!t||t.position){n.position=r.position;var a=i.position1,s=i.position2;o.position=Ko(a,s,this.__center),o.position1=a,o.position2=s}t&&!t.color||(n.color=r.color,o.color=i.color,o.color2=i.color2),t&&!t.radius||(n.radius=r.radius,o.radius=i.radius,o.radius2=i.radius2),e.bufferList[0].setAttributes(n),e.bufferList[1].setAttributes(o)},e}(A_);fm.add("hyperball",C_),yc.prototype={constructor:yc,atomLabel:function(t){var e;switch(this.type){case"atomname":e=t.atomname;break;case"atomindex":e=""+t.index;break;case"occupancy":e=t.occupancy.toFixed(2);break;case"bfactor":e=t.bfactor.toFixed(2);break;case"serial":e=""+t.serial;break;case"element":e=t.element;break;case"atom":e=t.atomname+"|"+t.index;break;case"resname":e=t.resname;break;case"resno":e=""+t.resno;break;case"res":var r=t.resname.toUpperCase();e=(cy[r]||r)+t.resno;break;case"text":e=this.text[t.index];break;default:e=t.qualifiedName()}return void 0===e?"":e}},yc.types={"":"",atomname:"atom name",atomindex:"atom index",occupancy:"occupancy",bfactor:"b-factor",serial:"serial",element:"element",atom:"atom name + index",resname:"residue name",resno:"residue no",res:"residue name + no",text:"text",qualified:"qualified name"};var I_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="label",this.parameters=Object.assign({labelType:{type:"select",options:yc.types,rebuild:!0},labelText:{type:"hidden",rebuild:!0},fontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:!0},fontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:!0},fontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:!0},sdf:{type:"boolean",buffer:!0},xOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},yOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},zOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},attachment:{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},showBorder:{type:"boolean",buffer:!0},borderColor:{type:"color",buffer:!0},borderWidth:{type:"number",precision:2,max:.3,min:0,buffer:!0},showBackground:{type:"boolean",rebuild:!0},backgroundColor:{type:"color",buffer:!0},backgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},backgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:!0}},this.parameters,{side:null,flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null,diffuse:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};this.labelType=Nn(r.labelType,"res"),this.labelText=Nn(r.labelText,{}),this.fontFamily=Nn(r.fontFamily,"sans-serif"),this.fontStyle=Nn(r.fontStyle,"normal"),this.fontWeight=Nn(r.fontWeight,"bold"),this.sdf=Nn(r.sdf,"Chrome"===rm),this.xOffset=Nn(r.xOffset,0),this.yOffset=Nn(r.yOffset,0),this.zOffset=Nn(r.zOffset,.5),this.attachment=Nn(r.attachment,"bottom-left"),this.showBorder=Nn(r.showBorder,!1),this.borderColor=Nn(r.borderColor,"lightgrey"),this.borderWidth=Nn(r.borderWidth,.15),this.showBackground=Nn(r.showBackground,!1),this.backgroundColor=Nn(r.backgroundColor,"lightgrey"),this.backgroundMargin=Nn(r.backgroundMargin,.5),this.backgroundOpacity=Nn(r.backgroundOpacity,1),t.prototype.init.call(this,r)},e.prototype.createData=function(t){var e={position:!0,color:!0,radius:!0},r=t.getAtomData(this.getAtomParams(e)),i=[],n=new yc(this.labelType,this.labelText);return t.eachAtom(function(t){i.push(n.atomLabel(t))}),{bufferList:[new x_({position:r.position,size:r.radius,color:r.color,text:i},this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,sdf:this.sdf,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}))]}},e.prototype.updateData=function(t,e){var r=e.sview.getAtomData(this.getAtomParams(t)),i={};t&&!t.position||(i.position=r.position),t&&!t.radius||(i.size=r.radius),t&&!t.color||(i.color=r.color),e.bufferList[0].setAttributes(i)},e}(Yb);fm.add("label",I_);var R_=function(t){function e(e,r,i){t.call(this,e,r,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)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};this.multipleBond=Nn(r.multipleBond,"off"),this.bondSpacing=Nn(r.bondSpacing,1),this.linewidth=Nn(r.linewidth,2),this.lines=Nn(r.lines,!0),this.crosses=Nn(r.crosses,"lone"),this.crossSize=Nn(r.crossSize,.4),t.prototype.init.call(this,r)},e.prototype.getBondParams=function(e,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{radius:.1,scale:1}},r),t.prototype.getBondParams.call(this,e,r)},e.prototype._crossData=function(t,e){if(!t||t.position||t.color){var r={};"lone"===this.crosses&&(r.atomSet=bc(e));var i,n,o,a,s,c,u=e.getAtomData(this.getAtomParams(t,r)),h={},l=u.position,p=u.color,d=u.picking,f=(l||p).length,m=3*f;t&&!t.position||(i=h.position1=new Float32Array(m),n=h.position2=new Float32Array(m),s=this.crossSize/2),t&&!t.color||(o=h.color=new Float32Array(m),a=h.color2=new Float32Array(m)),t&&!t.picking||(c=new Float32Array(3*u.picking.array.length));for(var g=0;g0)continue;var o=void 0,st=void 0,vt=void 0,yt=void 0,bt=void 0;if(U){if(yt=l.split(kw),bt=10===yt.length?1:0,x=yt[2],q&&"CA"!==x)continue;o=parseFloat(yt[6-bt]),st=parseFloat(yt[7-bt]),vt=parseFloat(yt[8-bt])}else{if(x=l.substr(12,4).trim(),q&&"CA"!==x)continue;o=parseFloat(l.substr(30,8)),st=parseFloat(l.substr(38,8)),vt=parseFloat(l.substr(46,8))}if(X){var xt=3*s;if(a[xt+0]=o,a[xt+1]=st,a[xt+2]=vt,s+=1,K)continue}var _t=void 0;U?(d=parseInt(yt[1]),_t="",_="H"===l[0]?1:0,f=bt?"":yt[4],m=parseInt(yt[5-bt]),b="",g=yt[3],S="",v=0):(d=parseInt(l.substr(6,5),$),V&&99999===d&&($=16),_="H"===l[0]?1:0,f=l[21].trim(),m=parseInt(l.substr(22,4),H)||1,V&&9999===m&&(H=16),b=l[26].trim(),g=l.substr(17,4).trim()||"MOL",w=parseFloat(l.substr(60,6)),S=l[16].trim(),v=parseFloat(l.substr(54,6)),r||(_t=l.substr(76,2).trim(),f||(f=l.substr(72,4).trim()))),lt.growIfFull(),lt.atomTypeId[ft]=ht.add(x,_t),lt.x[ft]=o,lt.y[ft]=st,lt.z[ft]=vt,lt.serial[ft]=d,lt.altloc[ft]=S.charCodeAt(0),lt.occupancy[ft]=isNaN(v)?0:v,U?(lt.partialCharge[ft]=parseFloat(yt[9-bt]),lt.radius[ft]=parseFloat(yt[10-bt])):lt.bfactor[ft]=isNaN(w)?0:w;var wt=Ec(m,f,b);!_||nt[wt]||Dw.includes(g)?D||N===f||(O=(L+=1).toString()):N===f&&F===g&&(dy.includes(g)||k===m&&B===b)||(O=(L+=1).toString(),k=m,F=g,B=b),G.addAtom(mt,f,O,g,m,_,void 0,b),J[d]=ft,ft+=1,D=!1,N=f}else if("CONECT"===p){var St=J[parseInt(l.substr(6,5))],At=[11,16,21,26],Mt={};if(void 0===St)continue;for(var Et=0;Et<4;++Et){var Tt=parseInt(l.substr(At[Et],5));if(!Number.isNaN(Tt)&&void 0!==(Tt=J[Tt]))if(St0)continue;var ot=it[c].replace(Uw,"");if(T&&"CA"!==ot)continue;var at=parseFloat(it[y]),st=parseFloat(it[b]),ct=parseFloat(it[x]);if(E){var ut=3*i;if(r[ut+0]=at,r[ut+1]=st,r[ut+2]=ct,i+=1,X>0)continue}var ht=it[u],lt=parseInt(it[s]),pt=it[v];pt="?"===pt?"":pt;var dt=it[a],ft=it[h],mt="H"===it[d][0]?1:0,gt=it[m],vt=parseFloat(it[_]),yt=parseFloat(it[w]),bt=it[p];if(bt="."===bt?"":bt,$.growIfFull(),$.atomTypeId[W]=V.add(ot,gt),$.x[W]=at,$.y[W]=st,$.z[W]=ct,$.serial[W]=parseInt(it[f]),$.bfactor[W]=isNaN(vt)?0:vt,$.occupancy[W]=isNaN(yt)?0:yt,$.altloc[W]=bt.charCodeAt(0),A.addAtom(X,dt,ft,ht,lt,mt,void 0,pt),t.Debug){var xt=I[ft];void 0!==xt&&xt!==dt&&t.Debug&&cm.warn(xt,dt)}I[ft]=dt;var _t=it[l];R[_t]||(R[_t]=new Set),R[_t].add(S.chainStore.count-1),W+=1}else{var wt=o.match(zw),St=wt.length;B===F.length&&(B=0);for(var At=0;At_)continue}d=P.substr(5,5).trim(),f=parseInt(P.substr(0,5)),m=parseInt(P.substr(15,5)),S.growIfFull(),S.atomTypeId[A]=w.add(p),S.x[A]=R,S.y[A]=L,S.z[A]=O,S.serial[A]=m,o.addAtom(M,"","",d,f,0,"l"),A+=1}}}t.Debug&&cm.time("GroParser._parse "+this.name);var r,i,n=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=this.cAlphaOnly,u=n.frames,h=n.boxes,l=this.streamer.peekLines(3);n.title=l[0].trim();var p,d,f,m,g=5+(l[2].length-l[2].lastIndexOf(".")-1),v=20,y=20+g,b=20+2*g,x=parseInt(l[1]),_=x+3,w=n.atomMap,S=n.atomStore;S.resize(x);var A=0,M=0,E=0;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),o.finalize(),n.finalizeAtoms(),Os(n),Ds(n),n.finalizeBonds(),Vy(n),t.Debug&&cm.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Cw);mm.add("gro",Vw);var $w=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],Hw=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat($w),Ww={0:"i".charCodeAt(0),1:"s".charCodeAt(0),2:"h".charCodeAt(0),3:"e".charCodeAt(0),4:"g".charCodeAt(0),5:"b".charCodeAt(0),6:"t".charCodeAt(0),7:"l".charCodeAt(0),"-1":"".charCodeAt(0)},Xw=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{},isBinary:{}};return i.type.get=function(){return"mmtf"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&cm.time("MmtfParser._parse "+this.name);var e,r,i,n,o,a=this.structure,s=ou(iu(this.streamer.data));["depositionDate","releaseDate","resolution","rFree","rWork","experimentalMethods"].forEach(function(t){void 0!==s[t]&&(a.header[t]=s[t])});var c,u,h,l,p,d;if(a.id=s.structureId,a.title=s.title,this.firstModelOnly||this.asTrajectory){for(p=1,h=0,e=0,r=l=s.chainsPerModel[0];e0&&(a.biomolDict.NCS=at)}var ct=s.unitCell;ct&&Array.isArray(ct)&&ct[0]?a.unitcell=new Lw({a:ct[0],b:ct[1],c:ct[2],alpha:ct[3],beta:ct[4],gamma:ct[5],spacegroup:s.spaceGroup}):a.unitcell=void 0,Bs(a,!0),Fs(a,!0),a.finalizeAtoms(),a.finalizeBonds(),zs(a),t.Debug&&cm.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Cw);mm.add("mmtf",Xw);var qw=/\s+/,Yw={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0},Zw=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{}};return i.type.get=function(){return"mol2"},r.prototype._parse=function(){function e(t,e,S){for(var A=t;AMOLECULE"===M?(v=y,d=0,++m):"@ATOM"===M?(v=b,f=l.count,s&&(i=0,r=new Float32Array(3*g),c.push(r),m>0&&(u=!0))):v="@BOND"===M?x:0;else if(v===y){if(0===d)n.title=M,n.id=M;else if(1===d){var E=M.split(qw);g=parseInt(E[0])}++d}else if(v===b){var T=M.split(qw);if(a&&m>0)continue;var P=parseFloat(T[2]),C=parseFloat(T[3]),I=parseFloat(T[4]);if(s){var R=3*i;if(r[R+0]=P,r[R+1]=C,r[R+2]=I,i+=1,u)continue}var L=T[0],O=T[1],D=T[5].split(".")[0],N=T[6]?parseInt(T[6]):1,k=T[7]?T[7]:"",F=T[8]?parseFloat(T[8]):0;l.growIfFull(),l.atomTypeId[p]=h.add(O,D),l.x[p]=P,l.y[p]=C,l.z[p]=I,l.serial[p]=L,l.partialCharge[p]=F,o.addAtom(m,"","",k,N,1),p+=1}else if(v===x){if(a&&m>0)continue;if(s&&m>0)continue;var B=M.split(qw);_.index=parseInt(B[1])-1+f,w.index=parseInt(B[2])-1+f;var z=Yw[B[3]];n.bondStore.addBond(_,w,z)}}}t.Debug&&cm.time("Mol2Parser._parse "+this.name);var r,i,n=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=n.frames,u=!1,h=n.atomMap,l=n.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");var p=0,d=0,f=0,m=-1,g=0,v=0,y=1,b=2,x=3,_=n.getAtomProxy(),w=n.getAtomProxy();this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),o.finalize(),n.finalizeAtoms(),Os(n),Fs(n,!0),Bs(n,!0),n.finalizeBonds(),js(n),Vy(n),t.Debug&&cm.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(Cw);mm.add("mol2",Zw);var Kw=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,r),e}(Fw);mm.add("pqr",Kw);var Qw=/> <(.+)>/,Jw=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{}};return i.type.get=function(){return"sdf"},r.prototype._parse=function(){function e(t,e,a){for(var C=t;C0&&(h=!0));else if(v>=M&&v0)continue;var R=parseFloat(I.substr(0,10)),L=parseFloat(I.substr(10,10)),O=parseFloat(I.substr(20,10));if(o){var D=3*c;if(s[D+0]=R,s[D+1]=L,s[D+2]=O,c+=1,h)continue}var N=I.substr(31,3).trim(),k=N+(g+1);p.growIfFull(),p.atomTypeId[g]=l.add(k,N),p.x[g]=R,p.y[g]=L,p.z[g]=O,p.serial[g]=g,p.formalCharge[g]=0,i.addAtom(y,"","","HET",1,1),g+=1}else if(v>=T&&v0)continue;if(o&&y>0)continue;f.index=parseInt(I.substr(0,3))-1+b,m.index=parseInt(I.substr(3,3))-1+b;var F=parseInt(I.substr(6,3));r.bondStore.addBond(f,m,F)}else if(I.match(/M {2}CHG/))for(var B=parseInt(I.substr(6,3)),z=0,U=10;z0)cm.error("dcd format with fixed atoms unsupported, aborting");else{for(var v=a.NATOM,y=4*v,b=0,x=a.NSET;b=1&&(i.timeOffset=(a.ISTART-1)*i.deltaTime),t.Debug&&cm.timeEnd("DcdParser._parse "+this.name)}},Object.defineProperties(r.prototype,i),r}(RS);mm.add("dcd",LS);var OS={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6},DS=0,NS=10,kS=11,FS=12,BS=function(t){var e=new Bm(t);e.setBigEndian(),su("CDF"!==e.readChars(3),"should start with CDF");var r=e.readByte();su(r>2,"unknown version"),this.header=yu(e,r),this.buffer=e},zS={version:{},recordDimension:{},dimensions:{},globalAttributes:{},variables:{}};zS.version.get=function(){return 1===this.header.version?"classic format":"64-bit offset format"},zS.recordDimension.get=function(){return this.header.recordDimension},zS.dimensions.get=function(){return this.header.dimensions},zS.globalAttributes.get=function(){return this.header.globalAttributes},zS.variables.get=function(){return this.header.variables},BS.prototype.hasDataVariable=function(t){return-1!==this.header.variables.findIndex(function(e){return e.name===t})},BS.prototype.getDataVariable=function(t){var e;return e="string"==typeof t?this.header.variables.find(function(e){return e.name===t}):t,su(void 0===e,"variable not found"),this.buffer.seek(e.offset),e.record?vu(this.buffer,e,this.header.recordDimension):gu(this.buffer,e)},Object.defineProperties(BS.prototype,zS);var US=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{},isBinary:{}};return i.type.get=function(){return"nctraj"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&cm.time("NctrajParser._parse "+this.name);var e=new BS(this.streamer.data),r=this.frames,i=r.coordinates,n=r.boxes,o=r.times;e.getDataVariable("coordinates").forEach(function(t){i.push(new Float32Array(t))}),e.hasDataVariable("cell_lengths")&&e.getDataVariable("cell_lengths").forEach(function(t){n.push(new Float32Array(t))}),e.hasDataVariable("time")&&e.getDataVariable("time").forEach(function(t){o.push(t)}),o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),t.Debug&&cm.timeEnd("NctrajParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(RS);mm.add("nctraj",US),mm.add("ncdf",US),mm.add("nc",US);var jS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{},isBinary:{}};return i.type.get=function(){return"trr"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&cm.time("TrrParser._parse "+this.name);for(var e=Jn(this.streamer.data),r=new DataView(e),i=this.frames,n=i.coordinates,o=i.boxes,a=i.times,s=0;;){s+=8;var c=r.getInt32(s);s+=4,s+=c;var u=r.getInt32(s+8),h=r.getInt32(s+12),l=r.getInt32(s+16),p=r.getInt32(s+28),d=r.getInt32(s+32),f=r.getInt32(s+36),m=r.getInt32(s+40);s+=52;var g=u/9,v=3*m;if(8===g?a.push(r.getFloat64(s)):a.push(r.getFloat32(s)),s+=2*g,u){var y=new Float32Array(9);if(8===g)for(var b=0;b<9;++b)y[b]=10*r.getFloat64(s),s+=8;else for(var x=0;x<9;++x)y[x]=10*r.getFloat32(s),s+=4;o.push(y)}if(s+=h,s+=l,p){var _=void 0;if(8===g){_=new Float32Array(v);for(var w=0;w>8&65280|M>>24&255}_=new Float32Array(e,s,v);for(var E=0;E=e.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),t.Debug&&cm.timeEnd("TrrParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(RS);mm.add("trr",jS);var GS=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]),VS=new Uint8Array(32),$S=new Int32Array(32),HS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{},isBinary:{}};return i.type.get=function(){return"xtc"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&cm.time("XtcParser._parse "+this.name);for(var e=Jn(this.streamer.data),r=new DataView(e),i=this.frames,n=i.coordinates,o=i.boxes,a=i.times,s=new Int32Array(6),c=new Int32Array(3),u=new Int32Array(3),h=new Uint32Array(3),l=new Float32Array(3),p=new Float32Array(3),d=0,f=new Int32Array(3),m=new Uint32Array(f.buffer);;){var g=void 0,v=r.getInt32(d+4);d+=12;var y=3*v;a.push(r.getFloat32(d)),d+=4;for(var b=new Float32Array(9),x=0;x<9;++x)b[x]=10*r.getFloat32(d),d+=4;if(o.push(b),v<=9)for(var _=0;_16777215?(u[0]=wu(c[0]),u[1]=wu(c[1]),u[2]=wu(c[2]),M=0):M=Su(3,c);var E=r.getInt32(d);d+=4;var T=E-1,P=GS[T=9>T?9:T]/2|0,C=GS[E]/2|0;h[0]=h[1]=h[2]=GS[E];var I=4*Math.ceil(r.getInt32(d)/4);d+=4;var R=1/A,L=0,O=0,D=new Uint8Array(e,d);for(l[0]=l[1]=l[2]=0;O0){l[0]=l[1]=l[2]=0;for(var k=0;k9?GS[E-1]/2|0:0):N>0&&(P=C,C=GS[E]/2|0),h[0]=h[1]=h[2]=GS[E],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}d+=I}for(var B=0;B=e.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),t.Debug&&cm.timeEnd("XtcParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(RS);mm.add("xtc",HS);var WS=function(t){function e(e,r){var i=r||{};t.call(this,e,i),this.volume=new Ey(this.name,this.path),this.voxelSize=Nn(i.voxelSize,1)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{},__objName:{}};return r.type.get=function(){return"volume"},r.__objName.get=function(){return"volume"},e.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix()),t.prototype._afterParse.call(this)},e.prototype.getMatrix=function(){return new y},Object.defineProperties(e.prototype,r),e}(Tw),XS=/\s+/,qS=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,YS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{}};return i.type.get=function(){return"cube"},r.prototype._parse=function(){function e(t,e){var r=n[t].trim().split(XS)[e];return parseFloat(r)}function r(t,e,r){for(var i=t;i=o.atomCount+6+h)for(var a=n.match(qS),l=0,p=a.length;l0?0:1;this.streamer.eachChunkOfLines(function(t){r(0,t.length,t)}),i.header=o,i.setData(s,o.NVZ,o.NVY,o.NVX),t.Debug&&cm.timeEnd("CubeParser._parse "+this.name)},r.prototype.getMatrix=function(){var t=this.volume.header,e=new y;return e.multiply((new y).makeTranslation(t.originX,t.originY,t.originZ)),e.multiply((new y).makeBasis(t.basisZ,t.basisY,t.basisX)),e},Object.defineProperties(r.prototype,i),r}(WS);mm.add("cub",YS),mm.add("cube",YS);var ZS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r;var i={type:{},isBinary:{}};return i.type.get=function(){return"dsn6"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&cm.time("Dsn6Parser._parse "+this.name);var e,r,i=this.volume,n={},o=Jn(this.streamer.data),a=new Int16Array(o),s=new Uint8Array(o),c=String.fromCharCode.apply(null,s.subarray(0,512));if(c.startsWith(":-)"))n.xStart=parseInt(c.substr(10,5)),n.yStart=parseInt(c.substr(15,5)),n.zStart=parseInt(c.substr(20,5)),n.xExtent=parseInt(c.substr(32,5)),n.yExtent=parseInt(c.substr(38,5)),n.zExtent=parseInt(c.substr(42,5)),n.xRate=parseInt(c.substr(52,5)),n.yRate=parseInt(c.substr(58,5)),n.zRate=parseInt(c.substr(62,5)),n.xlen=parseFloat(c.substr(73,10))*this.voxelSize,n.ylen=parseFloat(c.substr(83,10))*this.voxelSize,n.zlen=parseFloat(c.substr(93,10))*this.voxelSize,n.alpha=parseFloat(c.substr(103,10)),n.beta=parseFloat(c.substr(113,10)),n.gamma=parseFloat(c.substr(123,10)),e=parseFloat(c.substr(138,12))/100,r=parseInt(c.substr(155,8)),n.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(var u=0,h=a.length;u>8&255}n.xStart=a[0],n.yStart=a[1],n.zStart=a[2],n.xExtent=a[3],n.yExtent=a[4],n.zExtent=a[5],n.xRate=a[6],n.yRate=a[7],n.zRate=a[8];var p=1/a[17],d=p*this.voxelSize;n.xlen=a[9]*d,n.ylen=a[10]*d,n.zlen=a[11]*d,n.alpha=a[12]*p,n.beta=a[13]*p,n.gamma=a[14]*p,e=a[15]/100,r=a[16],n.gamma=a[14]*p}i.header=n,t.Debug&&cm.log(n,e,r);for(var f=new Float32Array(n.xExtent*n.yExtent*n.zExtent),m=512,g=Math.ceil(n.xExtent/8),v=Math.ceil(n.yExtent/8),y=Math.ceil(n.zExtent/8),b=0;ba){var n=r[i].trim();if(""!==n)for(var o=n.split(KS),l=0,p=o.length;l=a&&(g-a)%f!=0&&m=0?r-1:r+e/3)},parseNormalIndex:function(t,e){var r=parseInt(t,10);return 3*(r>=0?r-1:r+e/3)},addVertex:function(t,e,r){var i=this.vertices,n=this.object.geometry.vertices;n.push(i[t+0]),n.push(i[t+1]),n.push(i[t+2]),n.push(i[e+0]),n.push(i[e+1]),n.push(i[e+2]),n.push(i[r+0]),n.push(i[r+1]),n.push(i[r+2])},addVertexLine:function(t){var e=this.vertices,r=this.object.geometry.vertices;r.push(e[t+0]),r.push(e[t+1]),r.push(e[t+2])},addNormal:function(t,e,r){var i=this.normals,n=this.object.geometry.normals;n.push(i[t+0]),n.push(i[t+1]),n.push(i[t+2]),n.push(i[e+0]),n.push(i[e+1]),n.push(i[e+2]),n.push(i[r+0]),n.push(i[r+1]),n.push(i[r+2])},addFace:function(t,e,r,i,n,o,a,s){var c,u=this.vertices.length,h=this.parseVertexIndex(t,u),l=this.parseVertexIndex(e,u),p=this.parseVertexIndex(r,u);if(void 0===i?this.addVertex(h,l,p):(c=this.parseVertexIndex(i,u),this.addVertex(h,l,c),this.addVertex(l,p,c)),void 0!==n){var d=this.normals.length;h=this.parseNormalIndex(n,d),l=n===o?h:this.parseNormalIndex(o,d),p=n===a?h:this.parseNormalIndex(a,d),void 0===i?this.addNormal(h,l,p):(c=this.parseNormalIndex(s,d),this.addNormal(h,l,c),this.addNormal(l,p,c))}},addLineGeometry:function(t){var e=this;this.object.geometry.type="Line";for(var r=this.vertices.length,i=0,n=t.length;i0?x.addAttribute("normal",new Et(new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};var nA=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={type:{}};return r.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new Tu},Object.defineProperties(e.prototype,r),e}(iA);mm.add("obj",nA),Pu.prototype={constructor:Pu,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),r="",i=0;i=n.elements[s].count&&(s++,c=0);var l=r.parseASCIIElement(n.elements[s].properties,h);r.handleElement(i,n.elements[s].name,l),c++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e0&&(a[C]=I)}else{var R=T.getElementsByTagName("clash"),L=T.getElementsByTagName("mog-bond-outlier"),O=T.getElementsByTagName("mog-angle-outlier");if(L.length>0||O.length>0||R.length>0){var D={};s[C]=D;for(var N=0,k=R.length;N>>1:t>>>1;e[r]=t}return e}(),wA=30,SA=12,AA=15,MA=852,EA=592,TA=0,PA=1,CA=2,IA=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],RA=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],LA=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],OA=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],DA=0,NA=1,kA=2,FA=4,BA=5,zA=6,UA=0,jA=1,GA=2,VA=-2,$A=-3,HA=-4,WA=-5,XA=8,qA=1,YA=2,ZA=3,KA=4,QA=5,JA=6,tM=7,eM=8,rM=9,iM=10,nM=11,oM=12,aM=13,sM=14,cM=15,uM=16,hM=17,lM=18,pM=19,dM=20,fM=21,mM=22,gM=23,vM=24,yM=25,bM=26,xM=27,_M=28,wM=29,SM=30,AM=31,MM=32,EM=852,TM=592,PM=!0,CM=!0,IM=!0;try{String.fromCharCode.apply(null,[0])}catch(t){CM=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){IM=!1}for(var RM=new Uint8Array(256),LM=0;LM<256;LM++)RM[LM]=LM>=252?6:LM>=248?5:LM>=240?4:LM>=224?3:LM>=192?2:1;RM[254]=RM[254]=1;var OM=0,DM={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"},NM=Object.prototype.toString;uh.prototype.push=function(t,e){var r,i,n,o,a,s,c=this,u=this.strm,h=this.options.chunkSize,l=this.options.dictionary,p=!1;if(this.ended)return!1;i=e===~~e?e:!0===e?4:0,"string"==typeof t?u.input=nh(t):"[object ArrayBuffer]"===NM.call(t)?u.input=new Uint8Array(t):u.input=t,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new Uint8Array(h),u.next_out=0,u.avail_out=h),2===(r=Qu(u,0))&&l&&(s="string"==typeof l?rh(l):"[object ArrayBuffer]"===NM.call(l)?new Uint8Array(l):l,r=eh(c.strm,s)),-5===r&&!0===p&&(r=OM,p=!1),1!==r&&r!==OM)return c.onEnd(r),c.ended=!0,!1;u.next_out&&(0!==u.avail_out&&1!==r&&(0!==u.avail_in||4!==i&&2!==i)||("string"===c.options.to?(n=ah(u.output,u.next_out),o=u.next_out-n,a=oh(u.output,n),u.next_out=o,u.avail_out=h-o,o&&Bu(u.output,u.output,n,o,0),c.onData(a)):c.onData(Fu(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(p=!0)}while((u.avail_in>0||0===u.avail_out)&&1!==r);return 1===r&&(i=4),4===i?(r=Ju(this.strm),this.onEnd(r),this.ended=!0,r===OM):2!==i||(this.onEnd(OM),u.avail_out=0,!0)},uh.prototype.onData=function(t){this.chunks.push(t)},uh.prototype.onEnd=function(t){t===OM&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=zu(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},vm.add("gz",function(t){var e;t instanceof ArrayBuffer&&(t=new Uint8Array(t));try{e=hh(t)}catch(r){e=t}return e});var kM=function(){};kM.prototype.getUrl=function(t){},kM.prototype.getExt=function(t){};var FM="//mmtf.rcsb.org/v1.0/full/",BM=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){var e,r=jn(t),i=r.name.substr(0,4);return!["pdb","cif"].includes(r.ext)||!1!==r.compressed&&"gz"!==r.compressed?"mmtf"===r.ext?e=r.base.endsWith(".bb")?"//mmtf.rcsb.org/v1.0/reduced/"+i:FM+i:r.ext?(cm.warn("unsupported ext",r.ext),e=FM+i):e=FM+i:e="//files.rcsb.org/download/"+r.path,Fn()+e},e.prototype.getExt=function(t){var e=jn(t);if("mmtf"===e.ext||!e.ext)return"mmtf"},e}(kM);dm.add("rcsb",new BM);var zM="//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/",UM=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){var e,r=jn(t),i=r.name;return r.ext&&"sdf"!==r.ext?(cm.warn("unsupported ext",r.ext),e=zM+i+"/SDF?record_type=3d"):e=zM+i+"/SDF?record_type=3d",Fn()+e},e.prototype.getExt=function(t){var e=jn(t);if(!e.ext||"sdf"===e.ext)return"sdf"},e}(kM);dm.add("pubchem",new UM);var jM=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){return t},e}(kM);dm.add("ftp",new jM),dm.add("http",new jM),dm.add("https",new jM);var GM=/^((http|https|ftp):)*\/\//,VM=function(t){function e(e){t.call(this),this.baseUrl=e||""}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){var e=jn(t),r=this.baseUrl+e.path;return GM.test(this.baseUrl)||(r=zn(r)),r},e}(kM),$M=function(t){function e(e){t.call(this),this.baseUrl=e||""}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getListing=function(t){t=t||"";var e=this.baseUrl+"dir/"+t;return"/"!==e[e.length-1]&&(e+="/"),Go(e,{ext:"json"}).then(function(e){return{path:t,data:e.data}})},e.prototype.getUrl=function(t){var e=jn(t);return this.baseUrl+"file/"+e.path+e.query},e.prototype.getCountUrl=function(t){var e=jn(t);return this.baseUrl+"traj/numframes/"+e.path+e.query},e.prototype.getFrameUrl=function(t,e){var r=jn(t);return this.baseUrl+"traj/frame/"+e+"/"+r.path+r.query},e.prototype.getFrameParams=function(t,e){return"atomIndices="+e.join(";")},e.prototype.getPathUrl=function(t,e){var r=jn(t);return this.baseUrl+"traj/path/"+e+"/"+r.path+r.query},e}(kM);"undefined"==typeof window||window.Promise||(window.Promise=i),t.Version="1.0.0-beta.3",t.setDebug=function(e){t.Debug=e},t.ScriptExtensions=hm,t.DatasourceRegistry=dm,t.DecompressorRegistry=vm,t.StaticDatasource=VM,t.MdsrvDatasource=$M,t.ParserRegistry=mm,t.autoLoad=Go,t.RepresentationRegistry=fm,t.ColormakerRegistry=pm,t.Colormaker=Rf,t.Selection=qf,t.PdbWriter=Nm,t.SdfWriter=km,t.StlWriter=zm,t.Stage=vx,t.Collection=dx,t.ComponentCollection=fx,t.RepresentationCollection=mx,t.Assembly=zy,t.TrajectoryPlayer=pb,t.superpose=cc,t.Superposition=lb,t.guessElement=Us,t.flatten=kn,t.Queue=Js,t.Counter=Um,t.throttle=function(t,e,r){var i,n,o,a=null,s=0;r||(r={});var c=function(){s=!1===r.leading?0:Date.now(),a=null,o=t.apply(i,n),a||(i=n=null)};return function(){var u=Date.now();s||!1!==r.leading||(s=u);var h=e-(u-s);return i=this,n=arguments,h<=0||h>e?(a&&(clearTimeout(a),a=null),s=u,o=t.apply(i,n),a||(i=n=null)):a||!1===r.trailing||(a=setTimeout(c,h)),o}},t.download=Un,t.getQuery=Dn,t.getDataInfo=jo,t.getFileInfo=jn,t.uniqueArray=Xn,t.BufferRepresentation=Mb,t.ArrowBuffer=J_,t.BoxBuffer=ow,t.ConeBuffer=K_,t.CylinderBuffer=nx,t.EllipsoidBuffer=lw,t.OctahedronBuffer=gw,t.SphereBuffer=jb,t.TetrahedronBuffer=_w,t.TextBuffer=x_,t.TorusBuffer=Ew,t.Shape=wb,t.Structure=ub,t.Kdtree=Ps,t.SpatialHash=ps,t.MolecularSurface=L_,t.Volume=Ey,t.LeftMouseButton=1,t.MiddleMouseButton=2,t.RightMouseButton=3,t.MouseActions=Vg,t.KeyActions=Wg,t.Signal=So,t.Matrix3=pt,t.Matrix4=y,t.Vector2=l,t.Vector3=v,t.Box3=ht,t.Quaternion=g,t.Euler=vt,t.Plane=dt,t.Color=et,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.NGL={})}(this,function(t){"use strict";function e(){}function r(t,e){return function(){t.apply(e,arguments)}}function i(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(t,this)}function n(t,e){for(;3===t._state;)t=t._value;if(0===t._state)return void t._deferreds.push(e);t._handled=!0,kl(function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null===r)return void(1===t._state?o:a)(e.promise,t._value);var i;try{i=r(t._value)}catch(t){return void a(e.promise,t)}o(e.promise,i)})}function o(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof i)return t._state=3,t._value=e,void s(t);if("function"==typeof n)return void u(r(n,e),t)}t._state=1,t._value=e,s(t)}catch(e){a(t,e)}}function a(t,e){t._state=2,t._value=e,s(t)}function s(t){2===t._state&&0===t._deferreds.length&&kl(function(){t._handled||Bl(t._value)});for(var e=0,r=t._deferreds.length;e0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function b(t,e,r,i,n,o,a,s,c,u,l,h){p.call(this,null,o,a,s,c,u,i,n,l,h),this.image={data:t,width:e,height:r},this.magFilter=void 0!==c?c:Hh,this.minFilter=void 0!==u?u:Hh,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function x(t,e,r,i,n,o,a,s,c,u){t=void 0!==t?t:[],e=void 0!==e?e:Nh,p.call(this,t,e,r,i,n,o,a,s,c,u),this.flipY=!1}function _(){this.seq=[],this.map={}}function w(t,e,r){var i=t[0];if(i<=0||i>0)return t;var n=e*r,o=Gp[n];if(void 0===o&&(o=new Float32Array(n),Gp[n]=o),0!==e){i.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function S(t,e){var r=$p[e];void 0===r&&(r=new Int32Array(e),$p[e]=r);for(var i=0;i!==e;++i)r[i]=t.allocTextureUnit();return r}function A(t,e){t.uniform1f(this.addr,e)}function M(t,e){t.uniform1i(this.addr,e)}function P(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function E(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function T(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function C(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function I(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Wp.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Wp))}function R(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Hp.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Hp))}function L(t,e,r){var i=r.allocTextureUnit();t.uniform1i(this.addr,i),r.setTexture2D(e||jp,i)}function O(t,e,r){var i=r.allocTextureUnit();t.uniform1i(this.addr,i),r.setTextureCube(e||Vp,i)}function D(t,e){t.uniform2iv(this.addr,e)}function N(t,e){t.uniform3iv(this.addr,e)}function k(t,e){t.uniform4iv(this.addr,e)}function B(t){switch(t){case 5126:return A;case 35664:return P;case 35665:return E;case 35666:return T;case 35674:return C;case 35675:return I;case 35676:return R;case 35678:case 36198:return L;case 35680:return O;case 5124:case 35670:return M;case 35667:case 35671:return D;case 35668:case 35672:return N;case 35669:case 35673:return k}}function F(t,e){t.uniform1fv(this.addr,e)}function z(t,e){t.uniform1iv(this.addr,e)}function U(t,e){t.uniform2fv(this.addr,w(e,this.size,2))}function j(t,e){t.uniform3fv(this.addr,w(e,this.size,3))}function V(t,e){t.uniform4fv(this.addr,w(e,this.size,4))}function G(t,e){t.uniformMatrix2fv(this.addr,!1,w(e,this.size,4))}function $(t,e){t.uniformMatrix3fv(this.addr,!1,w(e,this.size,9))}function H(t,e){t.uniformMatrix4fv(this.addr,!1,w(e,this.size,16))}function W(t,e,r){var i=e.length,n=S(r,i);t.uniform1iv(this.addr,n);for(var o=0;o!==i;++o)r.setTexture2D(e[o]||jp,n[o])}function X(t,e,r){var i=e.length,n=S(r,i);t.uniform1iv(this.addr,n);for(var o=0;o!==i;++o)r.setTextureCube(e[o]||Vp,n[o])}function q(t){switch(t){case 5126:return F;case 35664:return U;case 35665:return j;case 35666:return V;case 35674:return G;case 35675:return $;case 35676:return H;case 35678:return W;case 35680:return X;case 5124:case 35670:return z;case 35667:case 35671:return D;case 35668:case 35672:return N;case 35669:case 35673:return k}}function Y(t,e,r){this.id=t,this.addr=r,this.setValue=B(e.type)}function Z(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=q(e.type)}function K(t){this.id=t,_.call(this)}function Q(t,e){t.seq.push(e),t.map[e.id]=e}function J(t,e,r){var i=t.name,n=i.length;for(Xp.lastIndex=0;;){var o=Xp.exec(i),a=Xp.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===n){Q(r,void 0===u?new Y(s,t,e):new Z(s,t,e));break}var l=r.map,h=l[s];void 0===h&&(h=new K(s),Q(r,h)),r=h}}function tt(t,e,r){var i=this;_.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),o=0;o.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,_=R.size*R.scale/u.w,w.x=_*y,w.y=_,e.uniform3f(d.screenPosition,S.x,S.y,S.z),e.uniform2f(d.scale,w.x,w.y),e.uniform1f(d.rotation,R.rotation),e.uniform1f(d.opacity,R.opacity),e.uniform3f(d.color,R.color.r,R.color.g,R.color.b),r.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),i.setTexture2D(R.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}r.enable(e.CULL_FACE),r.enable(e.DEPTH_TEST),r.buffers.depth.setMask(!0),r.reset()}}}function nt(t,e,r,i,n,o,a,s,c){p.call(this,t,e,r,i,n,o,a,s,c),this.needsUpdate=!0}function ot(t,e,r,i,n){function o(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),r=new Uint16Array([0,1,2,0,2,3]);c=e.createBuffer(),u=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.bufferData(e.ELEMENT_ARRAY_BUFFER,r,e.STATIC_DRAW),l=a(),h={position:e.getAttribLocation(l,"position"),uv:e.getAttribLocation(l,"uv")},p={uvOffset:e.getUniformLocation(l,"uvOffset"),uvScale:e.getUniformLocation(l,"uvScale"),rotation:e.getUniformLocation(l,"rotation"),scale:e.getUniformLocation(l,"scale"),color:e.getUniformLocation(l,"color"),map:e.getUniformLocation(l,"map"),opacity:e.getUniformLocation(l,"opacity"),modelViewMatrix:e.getUniformLocation(l,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(l,"projectionMatrix"),fogType:e.getUniformLocation(l,"fogType"),fogDensity:e.getUniformLocation(l,"fogDensity"),fogNear:e.getUniformLocation(l,"fogNear"),fogFar:e.getUniformLocation(l,"fogFar"),fogColor:e.getUniformLocation(l,"fogColor"),alphaTest:e.getUniformLocation(l,"alphaTest")};var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var n=i.getContext("2d");n.fillStyle="white",n.fillRect(0,0,8,8),d=new nt(i)}function a(){var t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),i=e.createShader(e.FRAGMENT_SHADER);return e.shaderSource(r,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(i,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(r),e.compileShader(i),e.attachShader(t,r),e.attachShader(t,i),e.linkProgram(t),t}function s(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var c,u,l,h,p,d,f=new v,m=new g,y=new v;this.render=function(n,a,g){if(0!==n.length){void 0===l&&o(),r.useProgram(l),r.initAttributes(),r.enableAttribute(h.position),r.enableAttribute(h.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,c),e.vertexAttribPointer(h.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(h.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.uniformMatrix4fv(p.projectionMatrix,!1,g.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(p.map,0);var v=0,b=0,x=a.fog;x?(e.uniform3f(p.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(p.fogNear,x.near),e.uniform1f(p.fogFar,x.far),e.uniform1i(p.fogType,1),v=1,b=1):x.isFogExp2&&(e.uniform1f(p.fogDensity,x.density),e.uniform1i(p.fogType,2),v=2,b=2)):(e.uniform1i(p.fogType,0),v=0,b=0);for(var _=0,w=n.length;_0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function dt(t,e){this.normal=void 0!==t?t:new v(1,0,0),this.constant=void 0!==e?e:0}function ft(t,e,r,i,n,o){this.planes=[void 0!==t?t:new dt,void 0!==e?e:new dt,void 0!==r?r:new dt,void 0!==i?i:new dt,void 0!==n?n:new dt,void 0!==o?o:new dt]}function mt(t,e,r){function i(e,r,i,n,o,a){var s=e.geometry,c=null,u=b,l=e.customDepthMaterial;if(i&&(u=x,l=e.customDistanceMaterial),l)c=l;else{var h=!1;r.morphTargets&&(s&&s.isBufferGeometry?h=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===r.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var d=e.isSkinnedMesh&&r.skinning,f=0;h&&(f|=p),d&&(f|=m),c=u[f]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var g=c.uuid,v=r.uuid,y=_[g];void 0===y&&(y={},_[g]=y);var w=y[v];void 0===w&&(w=c.clone(),y[v]=w),c=w}c.visible=r.visible,c.wireframe=r.wireframe;var S=r.side;return I.renderSingleSided&&S==Xl&&(S=Hl),I.renderReverseSided&&(S===Hl?S=Wl:S===Wl&&(S=Hl)),c.side=S,c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,i&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(n),c.nearDistance=o,c.farDistance=a),c}function n(r,a,s,c){if(!1!==r.visible){if(r.layers.test(a.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||o.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,r.matrixWorld);var u=e.update(r),h=r.material;if(Array.isArray(h))for(var p=u.groups,d=0,f=p.length;de&&(e=t[r]);return e}function Ft(){Object.defineProperty(this,"id",{value:At()}),this.uuid=zp.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function zt(t,e,r,i,n,o){Mt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new Ut(t,e,r,i,n,o)),this.mergeVertices()}function Ut(t,e,r,i,n,o){function a(t,e,r,i,n,o,a,f,m,g,y){var b,x,_=o/m,w=a/g,S=o/2,A=a/2,M=f/2,P=m+1,E=g+1,T=0,C=0,I=new v;for(x=0;x0?1:-1,l.push(I.x,I.y,I.z),h.push(b/m),h.push(1-x/g),T+=1}}for(x=0;x1&&o.sort(Yt),a.length>1&&a.sort(Zt)}var i=[],n=0,o=[],a=[];return{opaque:o,transparent:a,init:t,push:e,sort:r}}function Qt(){function t(t,e){var i=t.id+","+e.id,n=r[i];return void 0===n&&(n=new Kt,r[i]=n),n}function e(){r={}}var r={};return{get:t,dispose:e}}function Jt(t,e){return Math.abs(e[1])-Math.abs(t[1])}function te(t){function e(e,n,o,a){var s=e.morphTargetInfluences,c=s.length,u=r[n.id];if(void 0===u){u=[];for(var l=0;l65535?Ot:Rt)(n,1),e.update(i,t.ELEMENT_ARRAY_BUFFER),c[r.id]=i,i}var s={},c={};return{get:n,update:o,getWireframeAttribute:a}}function ne(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var r;switch(e.type){case"DirectionalLight":r={direction:new v,color:new et,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new h};break;case"SpotLight":r={position:new v,direction:new v,color:new et,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new h};break;case"PointLight":r={position:new v,color:new et,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new h,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new v,skyColor:new et,groundColor:new et};break;case"RectAreaLight":r={color:new et,position:new v,halfWidth:new v,halfHeight:new v}}return t[e.id]=r,r}}}function oe(){function t(t,a,s){for(var c=0,u=0,l=0,h=0,p=0,d=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=t.length;v");return ye(r)}var r=/^[ \t]*#include +<([\w\d.]+)>/gm;return t.replace(r,e)}function be(t){function e(t,e,r,i){for(var n="",o=parseInt(e);o0?t.gammaFactor:1,v=de(i.extensions,o,e),y=fe(s),b=a.createProgram();i.isRawShaderMaterial?(f=[y,"\n"].filter(ge).join("\n"),m=[v,y,"\n"].filter(ge).join("\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ge).join("\n"),m=[v,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+g,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==Ih?"#define TONE_MAPPING":"",o.toneMapping!==Ih?Kp.tonemapping_pars_fragment:"",o.toneMapping!==Ih?pe("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Kp.encodings_pars_fragment:"",o.mapEncoding?le("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?le("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?le("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?he("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ge).join("\n")),c=ye(c),c=ve(c,o),u=ye(u),u=ve(u,o),i.isShaderMaterial||(c=be(c),u=be(u));var x=f+c,_=m+u,w=ce(a,a.VERTEX_SHADER,x),S=ce(a,a.FRAGMENT_SHADER,_);a.attachShader(b,w),a.attachShader(b,S),void 0!==i.index0AttributeName?a.bindAttribLocation(b,0,i.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(b,0,"position"),a.linkProgram(b);var A=a.getProgramInfoLog(b),M=a.getShaderInfoLog(w),P=a.getShaderInfoLog(S),E=!0,T=!0;!1===a.getProgramParameter(b,a.LINK_STATUS)?(E=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(b,a.VALIDATE_STATUS),"gl.getProgramInfoLog",A,M,P)):""!==A?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",A):""!==M&&""!==P||(T=!1),T&&(this.diagnostics={runnable:E,material:i,programLog:A,vertexShader:{log:M,prefix:f},fragmentShader:{log:P,prefix:m}}),a.deleteShader(w),a.deleteShader(S);var C;this.getUniforms=function(){return void 0===C&&(C=new tt(a,b,t)),C};var I;return this.getAttributes=function(){return void 0===I&&(I=me(a,b)),I},this.destroy=function(){a.deleteProgram(b),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=rd++,this.code=r,this.usedTimes=1,this.program=b,this.vertexShader=w,this.fragmentShader=S,this}function _e(t,e,r){function i(t){var e=t.skeleton,i=e.bones;if(r.floatVertexTextures)return 1024;var n=r.maxVertexUniforms,o=Math.floor((n-20)/4),a=Math.min(o,i.length);return a0,maxBones:d,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numClippingPlanes:u,numClipIntersection:l,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.receiveShadow&&s.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Xl,flipSided:e.side===Wl,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,r){var i=[];if(r.shaderID?i.push(r.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(var n in e.defines)i.push(n),i.push(e.defines[n]);for(var o=0;oe||t.height>e){var r=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=Math.floor(t.width*r),i.height=Math.floor(t.height*r);return i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function c(t){return zp.isPowerOfTwo(t.width)&&zp.isPowerOfTwo(t.height)}function u(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");e.width=zp.nearestPowerOfTwo(t.width),e.height=zp.nearestPowerOfTwo(t.height);return e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function l(t){return t.wrapS!==Gh||t.wrapT!==Gh||t.minFilter!==Hh&&t.minFilter!==qh}function h(t,e){return t.generateMipmaps&&e&&t.minFilter!==Hh&&t.minFilter!==qh}function p(e){return e===Hh||e===Wh||e===Xh?t.NEAREST:t.LINEAR}function d(t){var e=t.target;e.removeEventListener("dispose",d),m(e),a.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),g(e),a.textures--}function m(e){var r=i.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}i.remove(e)}function g(e){var r=i.get(e),n=i.get(e.texture);if(e){if(void 0!==n.__webglTexture&&t.deleteTexture(n.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);i.remove(e.texture),i.remove(e)}}function v(e,n){var o=i.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==a.complete)return void _(o,e,n);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}r.activeTexture(t.TEXTURE0+n),r.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function y(e,u){var l=i.get(e);if(6===e.image.length)if(e.version>0&&l.__version!==e.version){l.__image__webglTextureCube||(e.addEventListener("dispose",d),l.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var p=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,m=[],g=0;g<6;g++)m[g]=p||f?f?e.image[g].image:e.image[g]:s(e.image[g],n.maxCubemapSize);var v=m[0],y=c(v),b=o.convert(e.format),_=o.convert(e.type);x(t.TEXTURE_CUBE_MAP,e,y);for(var g=0;g<6;g++)if(p)for(var w,S=m[g].mipmaps,A=0,M=S.length;A-1?r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,A,b,w.width,w.height,0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,A,b,w.width,w.height,0,b,_,w.data);else f?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,b,m[g].width,m[g].height,0,b,_,m[g].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,b,b,_,m[g]);h(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),l.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube)}function b(e,n){r.activeTexture(t.TEXTURE0+n),r.bindTexture(t.TEXTURE_CUBE_MAP,i.get(e).__webglTexture)}function x(r,a,s){var c;if(s?(t.texParameteri(r,t.TEXTURE_WRAP_S,o.convert(a.wrapS)),t.texParameteri(r,t.TEXTURE_WRAP_T,o.convert(a.wrapT)),t.texParameteri(r,t.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(t.texParameteri(r,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(r,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS===Gh&&a.wrapT===Gh||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),t.texParameteri(r,t.TEXTURE_MAG_FILTER,p(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,p(a.minFilter)),a.minFilter!==Hh&&a.minFilter!==qh&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===ip&&null===e.get("OES_texture_float_linear"))return;if(a.type===np&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function _(e,i,p){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",d),e.__webglTexture=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+p),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,i.unpackAlignment);var f=s(i.image,n.maxTextureSize);l(i)&&!1===c(f)&&(f=u(f));var m=c(f),g=o.convert(i.format),v=o.convert(i.type);x(t.TEXTURE_2D,i,m);var y,b=i.mipmaps;if(i.isDepthTexture){var _=t.DEPTH_COMPONENT;if(i.type===ip){if(!T)throw new Error("Float Depth Texture only supported in WebGL2.0");_=t.DEPTH_COMPONENT32F}else T&&(_=t.DEPTH_COMPONENT16);i.format===fp&&_===t.DEPTH_COMPONENT&&i.type!==tp&&i.type!==rp&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=tp,v=o.convert(i.type)),i.format===mp&&(_=t.DEPTH_STENCIL,i.type!==cp&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=cp,v=o.convert(i.type))),r.texImage2D(t.TEXTURE_2D,0,_,f.width,f.height,0,g,v,null)}else if(i.isDataTexture)if(b.length>0&&m){for(var w=0,S=b.length;w-1?r.compressedTexImage2D(t.TEXTURE_2D,w,g,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(t.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);else if(b.length>0&&m){for(var w=0,S=b.length;w=1,rt=null,it={},nt=new d,ot=new d,at={};return at[t.TEXTURE_2D]=a(t.TEXTURE_2D,t.TEXTURE_2D,1),at[t.TEXTURE_CUBE_MAP]=a(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),I.setClear(0,0,0,1),R.setClear(1),L.setClear(0),h(t.DEPTH_TEST),R.setFunc(wh),y(!1),b(Ul),h(t.CULL_FACE),h(t.BLEND),g(Ql),{buffers:{color:I,depth:R,stencil:L},initAttributes:s,enableAttribute:c,enableAttributeAndDivisor:u,disableUnusedAttributes:l,enable:h,disable:p,getCompressedTextureFormats:f,useProgram:m,setBlending:g,setMaterial:v,setFlipSided:y,setCullFace:b,setLineWidth:x,setPolygonOffset:_,setScissorTest:w,activeTexture:S,bindTexture:A,compressedTexImage2D:M,texImage2D:P,scissor:E,viewport:T,reset:C}}function Me(t,e,r){function i(){if(void 0!==o)return o;var r=e.get("EXT_texture_filter_anisotropic");return o=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}function n(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o,a=void 0!==r.precision?r.precision:"highp",s=n(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);var c=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),d=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),m=t.getParameter(t.MAX_VARYING_VECTORS),g=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=l>0,y=!!e.get("OES_texture_float");return{getMaxAnisotropy:i,getMaxPrecision:n,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:l,maxTextureSize:h,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y}}function Pe(t){wt.call(this),this.cameras=t||[]}function Ee(t){function e(){if(null!==i&&i.isPresenting){var e=i.getEyeParameters("left"),n=e.renderWidth,o=e.renderHeight;p=t.getPixelRatio(),h=t.getSize(),t.setDrawingBufferSize(2*n,o,1)}else r.enabled&&t.setDrawingBufferSize(h.width,h.height,p)}var r=this,i=null,n=null;"VRFrameData"in window&&(n=new window.VRFrameData);var o=new y,a=new y,s=new y,c=new wt;c.bounds=new d(0,0,.5,1),c.layers.enable(1);var u=new wt;u.bounds=new d(.5,0,.5,1),u.layers.enable(2);var l=new Pe([c,u]);l.layers.enable(1),l.layers.enable(2);var h,p;window.addEventListener("vrdisplaypresentchange",e,!1),this.enabled=!1,this.standing=!1,this.getDevice=function(){return i},this.setDevice=function(t){void 0!==t&&(i=t)},this.getCamera=function(t){if(null===i)return t;i.depthNear=t.near,i.depthFar=t.far,i.getFrameData(n);var e=n.pose;null!==e.position?t.position.fromArray(e.position):t.position.set(0,0,0),null!==e.orientation&&t.quaternion.fromArray(e.orientation),t.updateMatrixWorld();var r=i.stageParameters;if(this.standing&&r&&(a.fromArray(r.sittingToStandingTransform),s.getInverse(a),t.matrixWorld.multiply(a),t.matrixWorldInverse.multiply(s)),!1===i.isPresenting)return t;c.near=t.near,u.near=t.near,c.far=t.far,u.far=t.far,l.matrixWorld.copy(t.matrixWorld),l.matrixWorldInverse.copy(t.matrixWorldInverse),c.matrixWorldInverse.fromArray(n.leftViewMatrix),u.matrixWorldInverse.fromArray(n.rightViewMatrix),this.standing&&r&&(c.matrixWorldInverse.multiply(s),u.matrixWorldInverse.multiply(s));var h=t.parent;null!==h&&(o.getInverse(h.matrixWorld),c.matrixWorldInverse.multiply(o),u.matrixWorldInverse.multiply(o)),c.matrixWorld.getInverse(c.matrixWorldInverse),u.matrixWorld.getInverse(u.matrixWorldInverse),c.projectionMatrix.fromArray(n.leftProjectionMatrix),u.projectionMatrix.fromArray(n.rightProjectionMatrix),l.projectionMatrix.copy(c.projectionMatrix);var p=i.getLayers();if(p.length){var d=p[0];null!==d.leftBounds&&4===d.leftBounds.length&&c.bounds.fromArray(d.leftBounds),null!==d.rightBounds&&4===d.rightBounds.length&&u.bounds.fromArray(d.rightBounds)}return l},this.getStandingMatrix=function(){return a},this.submitFrame=function(){i&&i.isPresenting&&i.submitFrame()},this.dispose=function(){window.removeEventListener("vrdisplaypresentchange",e)}}function Te(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var i;switch(r){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":i=t.getExtension("WEBGL_compressed_texture_etc1");break;default:i=t.getExtension(r)}return null===i&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),e[r]=i,i}}}function Ce(){function t(){u.value!==i&&(u.value=i,u.needsUpdate=n>0),r.numPlanes=n,r.numIntersection=0}function e(t,e,i,n){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=u.value,!0!==n||null===a){var l=i+4*o,h=e.matrixWorldInverse;c.getNormalMatrix(h),(null===a||a.length=0){var u=n[s];if(void 0!==u){var l=u.normalized,h=u.itemSize,p=Dt.get(u);if(void 0===p)continue;var d=p.buffer,f=p.type,m=p.bytesPerElement;if(u.isInterleavedBufferAttribute){var g=u.data,v=g.stride,y=u.offset;g&&g.isInstancedInterleavedBuffer?(Rt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):Rt.enableAttribute(c),Et.bindBuffer(Et.ARRAY_BUFFER,d),Et.vertexAttribPointer(c,h,f,l,v*m,(i*v+y)*m)}else u.isInstancedBufferAttribute?(Rt.enableAttributeAndDivisor(c,u.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=u.meshPerAttribute*u.count)):Rt.enableAttribute(c),Et.bindBuffer(Et.ARRAY_BUFFER,d),Et.vertexAttribPointer(c,h,f,l,0,i*h*m)}else if(void 0!==a){var b=a[s];if(void 0!==b)switch(b.length){case 2:Et.vertexAttrib2fv(c,b);break;case 3:Et.vertexAttrib3fv(c,b);break;case 4:Et.vertexAttrib4fv(c,b);break;default:Et.vertexAttrib1fv(c,b)}}}}Rt.disableUnusedAttributes()}function l(){Kt||((Yt.getDevice()||window).requestAnimationFrame(h),Kt=!0)}function h(t){null!==Jt&&Jt(t),(Yt.getDevice()||window).requestAnimationFrame(h)}function p(t,e,r){if(t.visible){if(t.layers.test(e.layers))if(t.isLight)$.push(t),t.castShadow&&H.push(t);else if(t.isSprite)t.frustumCulled&&!bt.intersectsSprite(t)||X.push(t);else if(t.isLensFlare)q.push(t);else if(t.isImmediateRenderObject)r&&At.setFromMatrixPosition(t.matrixWorld).applyMatrix4(St),W.push(t,null,t.material,At.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||bt.intersectsObject(t))){r&&At.setFromMatrixPosition(t.matrixWorld).applyMatrix4(St);var i=kt.update(t),n=t.material;if(Array.isArray(n))for(var o=i.groups,a=0,s=o.length;a=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p=0&&t.numSupportedMorphNormals++}var d=i.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(i.numClippingPlanes=xt.numPlanes,i.numIntersection=xt.numIntersection,d.clippingPlanes=xt.uniform),i.fog=e,i.lightsHash=Bt.state.hash,t.lights&&(d.ambientLightColor.value=Bt.state.ambient,d.directionalLights.value=Bt.state.directional,d.spotLights.value=Bt.state.spot,d.rectAreaLights.value=Bt.state.rectArea,d.pointLights.value=Bt.state.point,d.hemisphereLights.value=Bt.state.hemi,d.directionalShadowMap.value=Bt.state.directionalShadowMap,d.directionalShadowMatrix.value=Bt.state.directionalShadowMatrix,d.spotShadowMap.value=Bt.state.spotShadowMap,d.spotShadowMatrix.value=Bt.state.spotShadowMatrix,d.pointShadowMap.value=Bt.state.pointShadowMap,d.pointShadowMatrix.value=Bt.state.pointShadowMatrix);var f=i.program.getUniforms(),m=tt.seqWithValue(f.seq,d);i.uniformsList=m}function x(t,e,r,i){ut=0;var n=Lt.get(r);if(_t&&(wt||t!==rt)){var o=t===rt&&r.id===J;xt.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,n,o)}!1===r.needsUpdate&&(void 0===n.program?r.needsUpdate=!0:r.fog&&n.fog!==e?r.needsUpdate=!0:r.lights&&n.lightsHash!==Bt.state.hash?r.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===xt.numPlanes&&n.numIntersection===xt.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(g(r,e,i),r.needsUpdate=!1);var a=!1,s=!1,c=!1,u=n.program,l=u.getUniforms(),h=n.shader.uniforms;if(Rt.useProgram(u.program)&&(a=!0,s=!0,c=!0),r.id!==J&&(J=r.id,s=!0),a||t!==rt){if(l.setValue(Et,"projectionMatrix",t.projectionMatrix),It.logarithmicDepthBuffer&&l.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),rt!==(nt||t)&&(rt=nt||t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var p=l.map.cameraPosition;void 0!==p&&p.setValue(Et,At.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&l.setValue(Et,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){l.setOptional(Et,i,"bindMatrix"),l.setOptional(Et,i,"bindMatrixInverse");var d=i.skeleton;if(d){var f=d.bones;if(It.floatVertexTextures){if(void 0===d.boneTexture){var m=Math.sqrt(4*f.length);m=zp.nextPowerOfTwo(Math.ceil(m)),m=Math.max(m,4);var v=new Float32Array(m*m*4);v.set(d.boneMatrices);var y=new b(v,m,m,hp,ip);d.boneMatrices=v,d.boneTexture=y,d.boneTextureSize=m}l.setValue(Et,"boneTexture",d.boneTexture),l.setValue(Et,"boneTextureSize",d.boneTextureSize)}else l.setOptional(Et,d,"boneMatrices")}}return s&&(l.setValue(Et,"toneMappingExposure",Y.toneMappingExposure),l.setValue(Et,"toneMappingWhitePoint",Y.toneMappingWhitePoint),r.lights&&D(h,c),e&&r.fog&&M(h,e),r.isMeshBasicMaterial?_(h,r):r.isMeshLambertMaterial?(_(h,r),P(h,r)):r.isMeshPhongMaterial?(_(h,r),r.isMeshToonMaterial?T(h,r):E(h,r)):r.isMeshStandardMaterial?(_(h,r),r.isMeshPhysicalMaterial?I(h,r):C(h,r)):r.isMeshDepthMaterial?(_(h,r),R(h,r)):r.isMeshDistanceMaterial?(_(h,r),L(h,r)):r.isMeshNormalMaterial?(_(h,r),O(h,r)):r.isLineBasicMaterial?(w(h,r),r.isLineDashedMaterial&&S(h,r)):r.isPointsMaterial?A(h,r):r.isShadowMaterial&&(h.color.value=r.color,h.opacity.value=r.opacity),void 0!==h.ltcMat&&(h.ltcMat.value=Yp.LTC_MAT_TEXTURE),void 0!==h.ltcMag&&(h.ltcMag.value=Yp.LTC_MAG_TEXTURE),tt.upload(Et,n.uniformsList,h,Y)),l.setValue(Et,"modelViewMatrix",i.modelViewMatrix),l.setValue(Et,"normalMatrix",i.normalMatrix),l.setValue(Et,"modelMatrix",i.matrixWorld),u}function _(t,e){t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var r;if(e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var i=r.offset,n=r.repeat;t.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}}function w(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function S(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function A(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*pt,t.scale.value=.5*ht,t.map.value=e.map,null!==e.map){var r=e.map.offset,i=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,i.x,i.y)}}function M(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function P(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function E(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function T(t,e){E(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function C(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function I(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,C(t,e)}function R(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function L(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}function O(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function D(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}function N(){var t=ut;return t>=It.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+It.maxTextures),ut+=1,t}console.log("THREE.WebGLRenderer",Fl),t=t||{};var k=void 0!==t.canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),B=void 0!==t.context?t.context:null,F=void 0!==t.alpha&&t.alpha,z=void 0===t.depth||t.depth,U=void 0===t.stencil||t.stencil,j=void 0!==t.antialias&&t.antialias,V=void 0===t.premultipliedAlpha||t.premultipliedAlpha,G=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,$=[],H=[],W=null,X=[],q=[];this.domElement=k,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=Rh,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var Y=this,Z=!1,K=null,Q=null,J=-1,et="",rt=null,nt=null,at=new d,st=new d,ct=null,ut=0,lt=k.width,ht=k.height,pt=1,dt=new d(0,0,lt,ht),vt=new d(0,0,lt,ht),yt=!1,bt=new ft,xt=new Ce,_t=!1,wt=!1,St=new y,At=new v,Mt={geometries:0,textures:0},Pt={frame:0,calls:0,vertices:0,faces:0,points:0};this.info={render:Pt,memory:Mt,programs:null};var Et +;try{var Tt={alpha:F,depth:z,stencil:U,antialias:j,premultipliedAlpha:V,preserveDrawingBuffer:G};if(null===(Et=B||k.getContext("webgl",Tt)||k.getContext("experimental-webgl",Tt)))throw null!==k.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Et.getShaderPrecisionFormat&&(Et.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),k.addEventListener("webglcontextlost",i,!1),k.addEventListener("webglcontextrestored",n,!1)}catch(t){console.error("THREE.WebGLRenderer: "+t)}var Ct,It,Rt,Lt,Ot,Dt,Nt,kt,Bt,zt,Ut,jt,Vt,Gt,$t,Ht,Wt,Xt;r();var Yt=new Ee(Y);this.vr=Yt;var Zt=new mt(Y,kt,It.maxTextureSize);this.shadowMap=Zt,this.getContext=function(){return Et},this.getContextAttributes=function(){return Et.getContextAttributes()},this.forceContextLoss=function(){var t=Ct.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=Ct.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return pt},this.setPixelRatio=function(t){void 0!==t&&(pt=t,this.setSize(lt,ht,!1))},this.getSize=function(){return{width:lt,height:ht}},this.setSize=function(t,e,r){var i=Yt.getDevice();if(i&&i.isPresenting)return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");lt=t,ht=e,k.width=t*pt,k.height=e*pt,!1!==r&&(k.style.width=t+"px",k.style.height=e+"px"),this.setViewport(0,0,t,e)},this.getDrawingBufferSize=function(){return{width:lt*pt,height:ht*pt}},this.setDrawingBufferSize=function(t,e,r){lt=t,ht=e,pt=r,k.width=t*r,k.height=e*r,this.setViewport(0,0,t,e)},this.setViewport=function(t,e,r,i){dt.set(t,ht-e-i,r,i),Rt.viewport(at.copy(dt).multiplyScalar(pt))},this.setScissor=function(t,e,r,i){vt.set(t,ht-e-i,r,i),Rt.scissor(st.copy(vt).multiplyScalar(pt))},this.setScissorTest=function(t){Rt.setScissorTest(yt=t)},this.getClearColor=jt.getClearColor,this.setClearColor=jt.setClearColor,this.getClearAlpha=jt.getClearAlpha,this.setClearAlpha=jt.setClearAlpha,this.clear=function(t,e,r){var i=0;(void 0===t||t)&&(i|=Et.COLOR_BUFFER_BIT),(void 0===e||e)&&(i|=Et.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=Et.STENCIL_BUFFER_BIT),Et.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,r,i){this.setRenderTarget(t),this.clear(e,r,i)},this.dispose=function(){k.removeEventListener("webglcontextlost",i,!1),k.removeEventListener("webglcontextrestored",n,!1),Ut.dispose(),Yt.dispose()},this.renderBufferImmediate=function(t,e,r){Rt.initAttributes();var i=Lt.get(t);t.hasPositions&&!i.position&&(i.position=Et.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=Et.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=Et.createBuffer()),t.hasColors&&!i.color&&(i.color=Et.createBuffer());var n=e.getAttributes();if(t.hasPositions&&(Et.bindBuffer(Et.ARRAY_BUFFER,i.position),Et.bufferData(Et.ARRAY_BUFFER,t.positionArray,Et.DYNAMIC_DRAW),Rt.enableAttribute(n.position),Et.vertexAttribPointer(n.position,3,Et.FLOAT,!1,0,0)),t.hasNormals){if(Et.bindBuffer(Et.ARRAY_BUFFER,i.normal),!r.isMeshPhongMaterial&&!r.isMeshStandardMaterial&&!r.isMeshNormalMaterial&&!0===r.flatShading)for(var o=0,a=3*t.count;o0&&m.renderInstances(i,w,A):m.render(w,A)}},this.compile=function(t,e){$.length=0,H.length=0,t.traverse(function(t){t.isLight&&($.push(t),t.castShadow&&H.push(t))}),Bt.setup($,H,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&e<=t.width-i&&r>=0&&r<=t.height-n&&Et.readPixels(e,r,i,n,Xt.convert(u),Xt.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&Et.bindFramebuffer(Et.FRAMEBUFFER,Q)}}}}function Le(t,e){this.name="",this.color=new et(t),this.density=void 0!==e?e:25e-5}function Oe(t,e,r){this.name="",this.color=new et(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function De(){bt.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Ne(t,e,r,i,n){bt.call(this),this.lensFlares=[],this.positionScreen=new v,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,i,n)}function ke(t){at.call(this),this.type="SpriteMaterial",this.color=new et(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Be(t){bt.call(this),this.type="Sprite",this.material=void 0!==t?t:new ke}function Fe(){bt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ze(t,e){var r=this;if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,n=this.bones.length;i=t.HAVE_CURRENT_DATA&&(l.needsUpdate=!0)}p.call(this,t,e,r,i,n,o,a,s,c),this.generateMipmaps=!1;var l=this;u()}function Ze(t,e,r,i,n,o,a,s,c,u,l,h){p.call(this,null,o,a,s,c,u,i,n,l,h),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Ke(t,e,r,i,n,o,a,s,c,u){if((u=void 0!==u?u:fp)!==fp&&u!==mp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===fp&&(r=tp),void 0===r&&u===mp&&(r=cp),p.call(this,null,i,n,o,a,s,u,r,c),this.image={width:t,height:e},this.magFilter=void 0!==a?a:Hh,this.minFilter=void 0!==s?s:Hh,this.flipY=!1,this.generateMipmaps=!1}function Qe(t){Ft.call(this),this.type="WireframeGeometry";var e,r,i,n,o,a,s,c,u,l,h=[],p=[0,0],d={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,i=m.length;e=0?(h=t(g-1e-5,m,h),p.subVectors(l,h)):(h=t(g+1e-5,m,h),p.subVectors(h,l)),m-1e-5>=0?(h=t(g,m-1e-5,h),d.subVectors(l,h)):(h=t(g,m+1e-5,h),d.subVectors(h,l)),u.crossVectors(p,d).normalize(),s.push(u.x,u.y,u.z),c.push(g,m)}}for(i=0;i.9&&o<.1&&(e<.2&&(f[t+0]+=1),r<.2&&(f[t+2]+=1),i<.2&&(f[t+4]+=1))}}function a(t){d.push(t.x,t.y,t.z)}function s(e,r){var i=3*e;r.x=t[i+0],r.y=t[i+1],r.z=t[i+2]}function c(){for(var t=new v,e=new v,r=new v,i=new v,n=new h,o=new h,a=new h,s=0,c=0;s0)&&f.push(w,S,M),(c!==r-1||u0&&c(!0),e>0&&c(!1)),this.setIndex(l),this.addAttribute("position",new Dt(p,3)),this.addAttribute("normal",new Dt(d,3)),this.addAttribute("uv",new Dt(f,2))}function Lr(t,e,r,i,n,o,a){Ir.call(this,0,t,e,r,i,n,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:o,thetaLength:a}}function Or(t,e,r,i,n,o,a){Rr.call(this,0,t,e,r,i,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:o,thetaLength:a}}function Dr(t,e,r,i){Mt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},this.fromBufferGeometry(new Nr(t,e,r,i)),this.mergeVertices()}function Nr(t,e,r,i){Ft.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var n,o,a=[],s=[],c=[],u=[],l=new v,p=new h;for(s.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,n=3;o<=e;o++,n+=3){var d=r+o/e*i;l.x=t*Math.cos(d),l.y=t*Math.sin(d),s.push(l.x,l.y,l.z),c.push(0,0,1),p.x=(s[n]/t+1)/2,p.y=(s[n+1]/t+1)/2,u.push(p.x,p.y)}for(n=1;n<=e;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new Dt(s,3)),this.addAttribute("normal",new Dt(c,3)),this.addAttribute("uv",new Dt(u,2))}function kr(t){at.call(this),this.type="ShadowMaterial",this.color=new et(0),this.opacity=1,this.lights=!0,this.transparent=!0,this.setValues(t)}function Br(t){st.call(this,t),this.type="RawShaderMaterial"}function Fr(t){at.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial", +this.color=new et(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new h(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zr(t){Fr.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function Ur(t){at.call(this),this.type="MeshPhongMaterial",this.color=new et(16777215),this.specular=new et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new h(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Eh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function jr(t){Ur.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Vr(t){at.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new h(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gr(t){at.call(this),this.type="MeshLambertMaterial",this.color=new et(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Eh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function $r(t){Ve.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function Hr(t,e,r){var i=this,n=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){a++,!1===n&&void 0!==i.onStart&&i.onStart(t,o,a),n=!0},this.itemEnd=function(t){o++,void 0!==i.onProgress&&i.onProgress(t,o,a),o===a&&(n=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)}}function Wr(t){this.manager=void 0!==t?t:sd}function Xr(t){this.manager=void 0!==t?t:sd,this._parser=null}function qr(t){this.manager=void 0!==t?t:sd,this._parser=null}function Yr(t){this.manager=void 0!==t?t:sd}function Zr(t){this.manager=void 0!==t?t:sd}function Kr(t){this.manager=void 0!==t?t:sd}function Qr(t,e){bt.call(this),this.type="Light",this.color=new et(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Jr(t,e,r){Qr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(bt.DefaultUp),this.updateMatrix(),this.groundColor=new et(e)}function ti(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new h(512,512),this.map=null,this.matrix=new y}function ei(){ti.call(this,new wt(50,1,.5,500))}function ri(t,e,r,i,n,o){Qr.call(this,t,e),this.type="SpotLight",this.position.copy(bt.DefaultUp),this.updateMatrix(),this.target=new bt,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new ei}function ii(t,e,r,i){Qr.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==i?i:1,this.shadow=new ti(new wt(90,1,.5,500))}function ni(){ti.call(this,new _t(-5,5,5,-5,.5,500))}function oi(t,e){Qr.call(this,t,e),this.type="DirectionalLight",this.position.copy(bt.DefaultUp),this.updateMatrix(),this.target=new bt,this.shadow=new ni}function ai(t,e){Qr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function si(t,e,r,i){Qr.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==i?i:10}function ci(t,e,r,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function ui(t,e,r,i){ci.call(this,t,e,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function li(t,e,r,i){ci.call(this,t,e,r,i)}function hi(t,e,r,i){ci.call(this,t,e,r,i)}function pi(t,e,r,i){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=cd.convertArray(e,this.TimeBufferType),this.values=cd.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function di(t,e,r,i){pi.call(this,t,e,r,i)}function fi(t,e,r,i){ci.call(this,t,e,r,i)}function mi(t,e,r,i){pi.call(this,t,e,r,i)}function gi(t,e,r,i){pi.call(this,t,e,r,i)}function vi(t,e,r,i){pi.call(this,t,e,r,i)}function yi(t,e,r){pi.call(this,t,e,r)}function bi(t,e,r,i){pi.call(this,t,e,r,i)}function xi(t,e,r,i){pi.apply(this,arguments)}function _i(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=zp.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function wi(t){this.manager=void 0!==t?t:sd,this.textures={}}function Si(t){this.manager=void 0!==t?t:sd}function Ai(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function Mi(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:sd,this.withCredentials=!1}function Pi(t){this.manager=void 0!==t?t:sd,this.texturePath=""}function Ei(t,e,r,i,n){var o=.5*(i-e),a=.5*(n-r),s=t*t;return(2*r-2*i+o+a)*(t*s)+(-3*r+3*i-2*o-a)*s+o*t+r}function Ti(t,e){var r=1-t;return r*r*e}function Ci(t,e){return 2*(1-t)*t*e}function Ii(t,e){return t*t*e}function Ri(t,e,r,i){return Ti(t,e)+Ci(t,r)+Ii(t,i)}function Li(t,e){var r=1-t;return r*r*r*e}function Oi(t,e){var r=1-t;return 3*r*r*t*e}function Di(t,e){return 3*(1-t)*t*t*e}function Ni(t,e){return t*t*t*e}function ki(t,e,r,i,n){return Li(t,e)+Oi(t,r)+Di(t,i)+Ni(t,n)}function Bi(){this.arcLengthDivisions=200}function Fi(t,e){Bi.call(this),this.v1=t,this.v2=e}function zi(){Bi.call(this),this.curves=[],this.autoClose=!1}function Ui(t,e,r,i,n,o,a,s){Bi.call(this),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function ji(t){Bi.call(this),this.points=void 0===t?[]:t}function Vi(t,e,r,i){Bi.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=i}function Gi(t,e,r){Bi.call(this),this.v0=t,this.v1=e,this.v2=r}function $i(t){zi.call(this),this.currentPoint=new h,t&&this.fromPoints(t)}function Hi(){$i.apply(this,arguments),this.holes=[]}function Wi(){this.subPaths=[],this.currentPath=null}function Xi(t){this.data=t}function qi(t){this.manager=void 0!==t?t:sd}function Yi(t){this.manager=void 0!==t?t:sd}function Zi(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new wt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new wt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Ki(t,e,r){bt.call(this),this.type="CubeCamera";var i=new wt(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new v(1,0,0)),this.add(i);var n=new wt(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new v(-1,0,0)),this.add(n);var o=new wt(90,1,t,e);o.up.set(0,0,1),o.lookAt(new v(0,1,0)),this.add(o);var a=new wt(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new v(0,-1,0)),this.add(a);var s=new wt(90,1,t,e);s.up.set(0,-1,0),s.lookAt(new v(0,0,1)),this.add(s);var c=new wt(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new v(0,0,-1)),this.add(c);var u={format:lp,magFilter:qh,minFilter:qh};this.renderTarget=new m(r,r,u),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,i,r),r.activeCubeFace=1,t.render(e,n,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,s,r),r.texture.generateMipmaps=u,r.activeCubeFace=5,t.render(e,c,r),t.setRenderTarget(null)},this.clear=function(t,e,r,i){for(var n=this.renderTarget,o=0;o<6;o++)n.activeCubeFace=o,t.setRenderTarget(n),t.clear(e,r,i);t.setRenderTarget(null)}}function Qi(){bt.call(this),this.type="AudioListener",this.context=gd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Ji(t){bt.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function tn(t){Ji.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function en(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function rn(t,e,r){this.binding=t,this.valueSize=r;var i,n=Float64Array;switch(e){case"quaternion":i=this._slerp;break;case"string":case"bool":n=Array,i=this._select;break;default:i=this._lerp}this.buffer=new n(4*r),this._mixBufferRegion=i,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function nn(t,e,r){var i=r||on.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}function on(t,e,r){this.path=e,this.parsedPath=r||on.parseTrackName(e),this.node=on.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function an(t){var e=arguments;this.uuid=zp.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var r={};this._indicesByUUID=r;for(var i=0,n=arguments.length;i!==n;++i)r[e[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var o=this;this.stats={objects:{get total(){return o._objects.length},get inUse(){return this.total-o.nCachedObjects_}},get bindingsPerObject(){return o._bindings.length}}}function sn(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var i=e.tracks,n=i.length,o=new Array(n),a={endingStart:Pp,endingEnd:Pp},s=0;s!==n;++s){var c=i[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Mp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function cn(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function un(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function ln(){Ft.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function hn(t,e,r,i){this.uuid=zp.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===i}function pn(t,e){this.uuid=zp.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function dn(t,e,r){pn.call(this,t,e),this.meshPerAttribute=r||1}function fn(t,e,r){Pt.call(this,t,e),this.meshPerAttribute=r||1}function mn(t,e,r,i){this.ray=new $t(t,e),this.near=r||0,this.far=i||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function gn(t,e){return t.distance-e.distance}function vn(t,e,r,i){if(!1!==t.visible&&(t.raycast(e,r),!0===i))for(var n=t.children,o=0,a=n.length;o1?u.pop().toLowerCase():"",h=e.match(/^(.+):\/\/(.+)$/);h&&(i=h[1].toLowerCase(),e=h[2]);var p=e.substring(0,e.lastIndexOf("/")+1);if(n.includes(l)){r=l;var d=e.length-l.length-1;l=e.substr(0,d).split(".").pop().toLowerCase();var f=c.length-l.length-1;c=c.substr(0,f)}else r=!1;return{path:e,name:s,ext:l,base:c,dir:p,compressed:r,protocol:i,src:t,query:a}}function to(t,e,r){var i,n,o,a=null,s=0;r||(r={});var c=function(){s=!1===r.leading?0:Date.now(),a=null,o=t.apply(i,n),a||(i=n=null)};return function(){var u=Date.now();s||!1!==r.leading||(s=u);var l=e-(u-s);return i=this,n=arguments,l<=0||l>e?(a&&(clearTimeout(a),a=null),s=u,o=t.apply(i,n),a||(i=n=null)):a||!1===r.trailing||(a=setTimeout(c,l)),o}}function eo(t,e){return te?1:0}function ro(t,e,r){void 0===r&&(r=eo);for(var i=0,n=t.length-1;i<=n;){var o=i+n>>1,a=r(e,t[o]);if(a>0)i=o+1;else{if(!(a<0))return o;n=o-1}}return-i-1}function io(t,e){var r=t.length-1;if(t[r]>1;t[n]>=e?r=n-1:i=n+1}return r+1}function no(t,e){if(t[0]>e)return-1;for(var r=0,i=t.length-1;r<=i;){var n=r+i>>1;t[n]>e?i=n-1:r=n+1}return r-1}function oo(t,e,r){var i=io(t,e),n=no(t,r);return-1===i||-1===n||i>n?0:n-i+1}function ao(t){return t.sort().filter(function(t,e,r){return 0===e||t!==r[e-1]})}function so(t){if(t.length>28672){for(var e=[],r=0;r65535?Uint32Array:Uint16Array)(t)}function ho(t){return Array.isArray(t)?t:[t]}function po(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function fo(t,e){return t instanceof e?t:new e(t)}function mo(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function go(t){return mo(t,h)}function vo(t){return mo(t,v)}function yo(t){return mo(t,y)}function bo(t){return mo(t,g)}function xo(t){return fo(t,Float32Array)}function _o(t){return Xn(t,"").toString().toLowerCase()}function wo(t){return.01745*t}function So(t){return 57.29578*t}function Ao(){for(var t,e=0,r=0;r<36;r++)8===r||13===r||18===r||23===r?Qf[r]="-":14===r?Qf[r]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Qf[r]=Kf[19===r?3&t|8:t]);return Qf.join("")}function Mo(t){return t-=t>>1&1431655765,16843009*((t=(858993459&t)+(t>>2&858993459))+(t>>4)&252645135)>>24}function Po(t,e,r){return(t-e)/(r-e)}function Eo(t,e,r){return Math.max(e,Math.min(r,t))}function To(t){return Eo(t,0,100)}function Co(t){return Eo(t,0,1)}function Io(t,e,r){return t+(e-t)*r}function Ro(t,e,r,i,n,o){var a=(r-t)*o,s=(i-e)*o,c=n*n;return(2*e-2*r+a+s)*(n*c)+(-3*e+3*r-2*a-s)*c+a*n+e}function Lo(t,e,r){return(r=Co(Po(r,t,e)))*r*(3-2*r)}function Oo(t,e,r){if(t>e)return t;var i=2*r-e,n=2*e-3*r,o=t/e;return(i*o+n)*o*o+r}function Do(t,e,r,i,n){this._listener=e,this._isOnce=r,this.context=i,this._signal=t,this._priority=n||0}function No(t,e){if("function"!=typeof t)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}function ko(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){ko.prototype.dispatch.apply(t,arguments)}}function Bo(t){var e={operator:void 0,rules:[]};if(!t)return e;var r,i,n=e,o=[];t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim(),"("===t.charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());for(var a,s=t.split(/\s+/),c=function(t){r={operator:t,rules:[]},void 0===n?(n=r,e=r):(n.rules.push(r),o.push(n),n=r)},u=function(t){i=n,void 0===(n=o.pop())&&(c(t),l(i))},l=function(t){n.rules.push(t)},h=0;h0)if("NOT"===d)a=1;else if(1===a)a=2;else{if(2!==a)throw new Error("something went wrong with 'not'");a=!1,u()}if("AND"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){var f=rm[d];if(void 0===f)if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("LIGAND"!==d)if(-1===im.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(p.length>=1&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))l({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(g.length>1&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var v=g[0].split("%");v.length>1&&m.rules.push({altloc:v[1]});var y=v[0].split(".");if(y.length>1&&y[1]){if(y[1].length>4)throw new Error("atomname must be one to four characters");m.rules.push({atomname:y[1].substring(0,4).toUpperCase()})}var b=y[0].split(":");b.length>1&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(x.length>1&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var S=x[0].split("-");if(1===S.length){if(S=parseInt(S[0]),isNaN(S))throw new Error("resi must be an integer");_&&(S*=-1),m.rules.push({resno:S})}else{if(2!==S.length)throw new Error("resi range must contain one '-'");_&&(S[0]*=-1),w&&(S[1]*=-1),m.rules.push({resno:[parseInt(S[0]),parseInt(S[1])]})}}if(1===m.rules.length)l(m.rules[0]);else{if(!(m.rules.length>1))throw new Error("empty selection chunk");l(m)}}else{var A=d.substr(1,p.length-2).split(","),M=A.length>1?A:A[0];l({resname:M})}else l({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),l({element:d.substr(1)});else{for(var P=p.substr(1).split(","),E=0,T=P.length;Et.resno||e.resno[1]t.resno||e.resno[1]0?t:null}function $o(t,e){return e&&(t=Go(t,function(t){return void 0!==t.keyword&&!nm.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))})),Vo(t,Fo)}function Ho(t,e){return e&&(t=Go(t,function(t){return!(void 0===t.keyword||!nm.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))})),Vo(t,zo)}function Wo(t,e){return e&&(t=Go(t,function(t){return void 0!==t.keyword&&!om.includes(t.keyword)||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode))))))})),Vo(t,Uo)}function Xo(t,e){return e&&(t=Go(t,function(t){return void 0!==t.keyword||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode)))))))})),Vo(t,jo)}function qo(t){var e=t;return t.forEach(function(t){t.__deps&&Array.prototype.push.apply(e,qo(t.__deps))}),e}function Yo(t){return ao(qo(t)).map(function(t){return t.toString()}).join("\n\n\n")}function Zo(t){var e=t.data.__name,r=t.data.__postId;if(void 0===e)console.error("message __name undefined");else if(void 0===self.func)console.error("worker func undefined",e);else{var i=function(t,e){t=t||{},void 0!==r&&(t.__postId=r);try{self.postMessage(t,e)}catch(e){console.error("self.postMessage:",e),self.postMessage(t)}};self.func(t,i)}}function Ko(t,e){var r="'use strict';\n\n"+Yo(e);return r+="\n\n\nself.func = "+t.toString()+";",r+="\n\n\nself.onmessage = "+Zo.toString()+";",new window.Blob([r],{type:"application/javascript"})}function Qo(t){Im=t}function Jo(t){Rm=t}function ta(e){t.Debug=e}function ea(t){var e=Jn(t),r=Bm.get(e.protocol);return r&&(e=Jn(r.getUrl(e.src)),!e.ext&&r.getExt&&(e.ext=r.getExt(t))),e}function ra(t,e){var r,i=Object.assign(ea(t),e);if(zm.names.includes(i.ext)?r=Zm:Dm.includes(i.ext)?r=Jm:"plugin"===i.ext&&(r=tg),r){return new r(i.src,i).load()}return Promise.reject(new Error("autoLoad: ext '"+i.ext+"' unknown"))}function ia(t){return na(oa(t),arguments)}function na(t,e){var r,i,n,o,a,s,c,u,l,h=1,p=t.length,d="";for(i=0;i=0),o.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,o.width?parseInt(o.width):0);break;case"e":r=o.precision?parseFloat(r).toExponential(o.precision):parseFloat(r).toExponential();break;case"f":r=o.precision?parseFloat(r).toFixed(o.precision):parseFloat(r);break;case"g":r=o.precision?String(Number(r.toPrecision(o.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=o.precision?r.substring(0,o.precision):r;break;case"t":r=String(!!r),r=o.precision?r.substring(0,o.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=o.precision?r.substring(0,o.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=o.precision?r.substring(0,o.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}ig.json.test(o.type)?d+=r:(!ig.number.test(o.type)||u&&!o.sign?l="":(l=u?"+":"-",r=r.toString().replace(ig.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",c=o.width-(l+r).length,a=o.width&&c>0?s.repeat(c):"",d+=o.align?l+r+a:"0"===s?l+a+r:a+l+r)}return d}function oa(t){if(ng[t])return ng[t];for(var e,r=t,i=[],n=0;r;){if(null!==(e=ig.text.exec(r)))i.push(e[0]);else if(null!==(e=ig.modulo.exec(r)))i.push("%");else{if(null===(e=ig.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){n|=1;var o=[],a=e[2],s=[];if(null===(s=ig.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(s[1]);""!==(a=a.substring(s[0].length));)if(null!==(s=ig.key_access.exec(a)))o.push(s[1]);else{if(null===(s=ig.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(s[1])}e[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");i.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}r=r.substring(e[0].length)}return ng[t]=i}function aa(){this.signals={updated:new ko},this.begin(),this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0}function sa(t){if(void 0===t)return"";var e=[];for(var r in t){var i=t[r];!1!==i&&e.push("#define "+r+" "+i)}return e.join("\n")+"\n"}function ca(t,e){e=e||{};var r=t+"|";for(var i in e)r+=i+":"+e[i];if(!pg[r]){var n=sa(e),o=Um.get("shader/"+t);if(!o)throw new Error("empty shader, '"+t+"'");o=o.replace(hg,function(t,e){var r="shader/chunk/"+e+".glsl";return Um.get(r)||Kp[e]||""}),pg[r]=n+o}return pg[r]}function ua(t,e,r,i){function n(e){var i=e%u,n=Math.floor(e/u),o=i*m,a=n*g;r.camera.setViewOffset(m*u,g*u,o,a,m,g),r.render(),l?v.drawImage(t.domElement,Math.floor(o/2),Math.floor(a/2),Math.ceil(m/2),Math.ceil(g/2)):v.drawImage(t.domElement,Math.floor(o),Math.floor(a),Math.ceil(m),Math.ceil(g)),"function"==typeof h&&h(e+1,d,!1)}function o(){r.setSampling(y),r.camera.view=null,"function"==typeof p&&p(d+1,d,!1)}function a(){for(var t=0;t<=d;++t)t===d?o():n(t)}function s(){function t(){e===d?o():n(e),e+=1}for(var e=0,r=0;r<=d;++r)setTimeout(t,0)}var c=i||{},u=void 0!==c.factor?c.factor:2,l=void 0!==c.antialias&&c.antialias,h=c.onProgress,p=c.onFinish;l&&(u*=2);var d=u*u,f=document.createElement("canvas"),m=r.width,g=r.height;l?(f.width=m*u/2,f.height=g*u/2):(f.width=m*u,f.height=g*u);var v=f.getContext("2d"),y=r.sampleLevel;r.setSampling(-1),this.render=a,this.renderAsync=s,this.canvas=f}function la(t,e,r,i,n){r=r||1,i=i||0;var o,a,s,c=n?n.length:t.length/r,u=0,l=0;if(n)for(a=0;ae?1:t=u&&e(t[o],h)>0;)t[o+1]=t[o],--o;t[o+1]=h}if(-1===c)break;l=s[c--],u=s[c--]}else{var d=u+l>>1;for(o=u+1,a=l,n(d,o),e(t[u],t[l])>0&&n(u,l),e(t[o],t[l])>0&&n(o,l),e(t[u],t[o])>0&&n(u,o),h=t[o];;){do{o++}while(e(t[o],h)<0);do{a--}while(e(t[a],h)>0);if(a=a-u?(s[++c]=o,s[++c]=l,l=a-1):(s[++c]=u,s[++c]=a-1,u=o)}return t}function _a(t){for(var e=-1/0,r=0,i=t.length;re&&(e=t[r]);return e}function wa(t){for(var e=1/0,r=0,i=t.length;r=0;a--){for(o=l-1;o>=0;o--)if(c=4*(a*l+o),p[c]!==e||p[c+1]!==r||p[c+2]!==i||p[c+3]!==n){s=!0;break}if(s)break}var m=a;for(s=!1,o=l-1;o>=0;o--){for(a=u-1;a>=0;a--)if(c=4*(a*l+o),p[c]!==e||p[c+1]!==r||p[c+2]!==i||p[c+3]!==n){s=!0;break}if(s)break}var g=o,v=document.createElement("canvas");return v.width=g-f,v.height=m-d,v.getContext("2d").drawImage(t,f,d,v.width,v.height,0,0,v.width,v.height),v}function Ea(t,e){function r(e){var r=s;c&&(r*=2),e&&(r=1/r),t.scene.traverse(function(t){var e=t.material;e&&e.linewidth&&(e.linewidth*=r),e&&e.uniforms&&e.uniforms.size&&void 0===e.uniforms.size.__seen&&(e.uniforms.size.value*=r,e.uniforms.size.__seen=!0),e&&e.uniforms&&e.uniforms.linewidth&&void 0===e.uniforms.linewidth.__seen&&(e.uniforms.linewidth.value*=r,e.uniforms.linewidth.__seen=!0)}),t.scene.traverse(function(t){var e=t.material;e&&e.uniforms&&e.uniforms.size&&delete e.uniforms.size.__seen,e&&e.uniforms&&e.uniforms.linewidth&&delete e.uniforms.linewidth.__seen})}function i(t){if(a){var e=d;return Pa(t,u?0:255*e.r,u?0:255*e.g,u?0:255*e.b,u?0:255)}return t}function n(t,e,r){"function"==typeof o.onProgress&&o.onProgress(t,e,r)}var o=e||{},a=Xn(o.trim,!1),s=Xn(o.factor,1),c=Xn(o.antialias,!1),u=Xn(o.transparent,!1),l=t.renderer,h=t.camera,p=l.getClearAlpha(),d=l.getClearColor();return new Promise(function(e){function o(o,s){i(a.canvas).toBlob(function(i){l.setClearAlpha(p),r(!0),t.requestRender(),n(s,s,!0),e(i)},"image/png")}var a=new ua(l,h,t,{factor:s,antialias:c,onProgress:n,onFinish:o});l.setClearAlpha(u?0:1),r(),a.renderAsync()})}function Ta(t,e){t.traverseVisible(function(t){if(t instanceof Xe&&t.sortParticles){var r=t.geometry.attributes,i=r.position.count;if(0!==i){wg.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),Sg.multiplyMatrices(e.projectionMatrix,wg);var n,o,a,s;t.userData.sortData?(n=t.userData.sortData,a=n.__zArray,o=n.__sortArray,s=n.__cmpFn):(a=new Float32Array(i),o=new Uint32Array(i),s=function(t,e){var r=a[t],i=a[e];return r>i?1:r500&&!G&&$<3&&-1!==$){var e=$;$=3,j=!0,O(),G=!0,$=e,t.Debug&&Lm.log("rendered still frame")}window.requestAnimationFrame(w)}function S(t,e){t*=window.devicePixelRatio,e*=window.devicePixelRatio;var r,i,n,o=Im?Eg:Tg;O(!0),ut.readRenderTargetPixels(pt,t,e,1,1,o),r=Im?Math.round(255*o[0])<<16&16711680|Math.round(255*o[1])<<8&65280|255&Math.round(255*o[2]):o[0]<<16|o[1]<<8|o[2];var a=Math.round(o[3]),s=ot.getObjectById(a);return s&&(i=s.userData.instance,n=s.userData.buffer.picking),{pid:r,instance:i,picker:n}}function A(){j||(window.performance.now()-q.startTime>22&&(q.begin(),G=!1),j=!0,window.requestAnimationFrame(function(){O(),q.update()}))}function M(){var t=wo(Y.fov),e=2*Math.tan(t/2)*-K.position.z;Z.zoom=F/e}function P(){var t=X;H=Mt.copy(K.position).length(),H||(K.position.set(0,0,t.cameraZ),H=Math.abs(t.cameraZ)),W=Math.max(10,.5*At),((W+=xt.getCenter(Mt).length())===1/0||W===-1/0||isNaN(W))&&(W=50);var e=(50-t.clipNear)/50,r=-(50-t.clipFar)/50;K.near=H-W*e,K.far=H+W*r;var i=(50-t.fogNear)/50,n=-(50-t.fogFar)/50,o=Q.fog;o.color.set(t.fogColor),o.near=H-W*i,o.far=H+W*n,"PerspectiveCamera"===K.type?(K.near=Math.max(.1,t.clipDist,K.near),K.far=Math.max(1,K.far),o.near=Math.max(.1,o.near),o.far=Math.max(1,o.far)):"OrthographicCamera"===K.type&&0===t.clipNear&&t.clipDist>0&&H+K.zoom>2*-t.clipDist&&(K.near+=K.zoom+t.clipDist)}function E(){K.updateMatrix(),K.updateMatrixWorld(!0),K.matrixWorldInverse.getInverse(K.matrixWorld),K.updateProjectionMatrix(),Ca(Q,K,ut,H,W),Ta(Q,K)}function T(t,e,r,i){nt.visible=t,ot.visible=e,at.visible=r,ct.visible=i}function C(){Mt.copy(K.position).setLength(100*At),J.position.copy(K.position).add(Mt),J.color.set(X.lightColor),J.intensity=X.lightIntensity,tt.color.set(X.ambientColor),tt.intensity=X.ambientIntensity}function I(){ut.clearTarget(pt),T(!1,!0,!1,!1),ut.render(Q,K,pt),_(),ut.setRenderTarget(null)}function R(e){e?ut.clearTarget(e):ut.clear(),T(!1,!1,!0,!1),ut.render(Q,K,e),e?ut.clearTarget(e,!1,!0,!1):ut.clearDepth(),_(),T(!0,!1,!1,t.Debug),ut.render(Q,K,e),_()}function L(){var t=yg[Math.max(0,Math.min($,5))],e=1/t.length;mt.tForeground.value=dt.texture;for(var r=dt.width,i=dt.height,n=0;n0?L():R(),V=t,U=!1,j=!1}function D(){Lm.log("scene cleared"),Q.remove(rt),r(),ut.clear()}var N,k={ticked:new ko};N="string"==typeof e?document.getElementById(e):e instanceof window.Element?e:document.createElement("div");var B,F;if(N===document.body)B=window.innerWidth||1,F=window.innerHeight||1;else{var z=N.getBoundingClientRect();B=z.width||1,F=z.height||1}var U,j,V,G,$,H,W,X;!function(){X={fogColor:new et(0),fogNear:50,fogFar:100,backgroundColor:new et(0),cameraType:"perspective",cameraFov:40,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,lightColor:new et(14540253),lightIntensity:1,ambientColor:new et(14540253),ambientIntensity:.2,sampleLevel:0}}();var q;!function(){q=new aa}();var Y,Z,K;!function(){var t=new v(0,0,0);Y=new wt(X.cameraFov,B/F),Y.position.z=X.cameraZ,Y.lookAt(t),Z=new _t(B/-2,B/2,F/2,F/-2),Z.position.z=X.cameraZ,Z.lookAt(t),K="orthographic"===X.cameraType?Z:Y,K.updateProjectionMatrix()}();var Q,J,tt,rt,it,nt,ot,at,ct;r();var ut,ht,pt,dt,ft,mt,gt,vt,yt;if(!1===function(){var t=window.devicePixelRatio;try{ut=new Re({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return N.innerHTML=Om,!1}ut.setPixelRatio(t),ut.setSize(B,F),ut.autoClear=!1,ut.sortObjects=!0;var e=ut.getContext();Jo(ut.extensions.get("EXT_frag_depth")),ut.extensions.get("OES_element_index_uint"),Qo("Safari"!==Pm&&(ut.extensions.get("OES_texture_float")&&ut.extensions.get("WEBGL_color_buffer_float")||ut.extensions.get("OES_texture_float")&&Ia(e,e.FLOAT))),N.appendChild(ut.domElement);var r=B*t,i=F*t;ut.extensions.get("OES_texture_float"),ht=ut.extensions.get("OES_texture_half_float")&&Ia(e,36193),ut.extensions.get("WEBGL_color_buffer_float"),pt=new f(r,i,{minFilter:Hh,magFilter:Hh,stencilBuffer:!1,format:hp,type:Im?ip:Kh}),pt.texture.generateMipmaps=!1,ut.clearTarget(pt),ut.setRenderTarget(null),dt=new f(r,i,{minFilter:qh,magFilter:qh,format:hp}),ft=new f(r,i,{minFilter:Hh,magFilter:Hh,format:hp,type:ht?np:Im?ip:Kh}),mt={tForeground:{type:"t",value:null},scale:{type:"f",value:1}},gt=new st({uniforms:mt,vertexShader:ca("Quad.vert"),fragmentShader:ca("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:Jl,depthTest:!1,depthWrite:!1}),vt=new _t(-1,1,1,-1,0,1),yt=(new De).add(new Xt(new jt(2,2),gt))}())return this.container=N,void Lm.error("Viewer: could not initialize renderer");var bt,xt=new lt,St=new v,At=0;!function(){var t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),e=new Float32Array(24),r=new Ft;r.setIndex(new Pt(t,1)),r.addAttribute("position",new Pt(e,3));var i=new st({uniforms:{uColor:{value:new et("skyblue")}},vertexShader:ca("BasicLine.vert"),fragmentShader:ca("BasicLine.frag"),linewidth:2});bt=new $e(r,i),ct.add(bt)}(),d(),p();var Mt=new v,Et={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};this.container=N,this.stats=q,this.signals=k,this.rotationGroup=rt,this.translationGroup=it,this.add=n,this.remove=a,this.clear=D,this.getPickingPixels=c,this.getImage=u,this.makeImage=l,this.setLight=h,this.setFog=p,this.setBackground=d,this.setSampling=m,this.setCamera=g,this.setClip=y,this.setSize=b,this.handleResize=x,this.pick=S,this.requestRender=A,this.render=O,this.animate=w,this.updateZoom=M,this.updateHelper=i,this.renderer=ut,this.scene=Q,this.perspectiveCamera=Y,this.boundingBox=xt,this.updateBoundingBox=function(){s(),t.Debug&&i()},Object.defineProperties(this,{camera:{get:function(){return K}},width:{get:function(){return B}},height:{get:function(){return F}},sampleLevel:{get:function(){return $}}})}function Oa(t){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;return Math.sqrt(e*e+r*r)}function Da(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<n&&(n=u),l>o&&(o=l),h>a&&(a=h)}return[Ga([e,r,i]),Ga([n,o,a])]}function Ua(t,e){for(var r=0,i=e.length;r>>1&1431655765,16843009*((t=(858993459&t)+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function ss(t,e){this.type=t,this.scale=e||1,this.max=10}function cs(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}function us(t,e){for(var r=0,i=0,n=e.rows,o=e.cols,a=0,s=0,c=0,u=e.data,l=t.data;re?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}function bs(t,e,r,i,n,o,a,s){for(var c=2*Hy,u=Wy,l=0,h=0,p=0,d=0,f=Math.max(o,30),m=0,g=0,v=0,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,P=0,E=0,T=0,C=0,I=0,R=0,L=4660,O=0,D=0,N=0,k=new Float64Array(a<<3);l>16)?D:-D,t[l*e+p]=O;for(d=0;d<2;d++)for(h=0;h>a),f=Math.max(0,e-i-u>>a),m=Math.max(0,r-i-l>>a),b=Math.min(h,t+i-c>>a),_=Math.min(p,e+i-u>>a),w=Math.min(d,r+i-l>>a),S=[],A=s;A<=b;++A)for(var M=f;M<=_;++M)for(var E=m;E<=w;++E){var C=(A*p+M)*d+E,R=x[C];if(R>0)for(var L=R-1,O=T[L],D=P[L],N=O+D,k=O;k>a),p=1+(s.max.y-u>>a),d=1+(s.max.z-l>>a),f=h*p*d,m=t.count,g=t.x,v=t.y,y=t.z,b=0,x=new Uint32Array(f),_=new Int32Array(m);for(n=0;n>a,S=v[n]-u>>a,A=y[n]-l>>a,M=(w*p+S)*d+A;1===(x[M]+=1)&&(b+=1),_[n]=M}var P=new Uint16Array(b);for(n=0,o=0;n0&&(x[n]=o+1,P[o]=E,o+=1)}var T=new Uint32Array(b);for(n=1;n0){var L=R-1;I[T[L]+C[L]]=n,C[L]+=1}}this.within=r,this.eachWithin=i}function Is(e){var r=0,i=0,n={},o={},a=window.URL.createObjectURL(Nm.get(e)),s=new window.Worker(a);Nm.activeWorkerCount+=1,s.onmessage=function(i){r-=1;var a=i.data.__postId;t.Debug&&Lm.timeEnd("Worker.postMessage "+e+" #"+a),n[a]&&n[a].call(s,i),delete n[a],delete o[a]},s.onerror=function(t){if(r-=1,t.data){var i=t.data.__postId;o[i]?o[i].call(s,t):Lm.error("Worker.onerror",i,e,t),delete n[i],delete o[i]}else Lm.error("Worker.onerror",e,t)},this.name=e,this.post=function(a,c,u,l){n[i]=u,o[i]=l,a=a||{},a.__name=e,a.__postId=i,a.__debug=t.Debug,t.Debug&&Lm.time("Worker.postMessage "+e+" #"+i);try{s.postMessage(a,c)}catch(t){Lm.error("worker.post:",t),s.postMessage(a)}return r+=1,i+=1,this},this.terminate=function(){s?(s.terminate(),window.URL.revokeObjectURL(a),Nm.activeWorkerCount-=1):Lm.log("no worker to terminate")},Object.defineProperties(this,{postCount:{get:function(){return i}},pending:{get:function(){return r}}})}function Rs(t,e){e=Math.min(8,e||2);var r=[],i=0;this.name=t,this.maxCount=e,this.post=function(t,e,r,i){return this.getNextWorker().post(t,e,r,i),this},this.terminate=function(){r.forEach(function(t){t.terminate()})},this.getNextWorker=function(){for(var n,o=1/0,a=0;a=i){n=new Is(t),r.push(n),i+=1;break}var s=r[a];if(0===s.pending){n=s;break}s.pending=x){N=v,L=!0;break}if(L)break}if(L)break}for(L=!1,g=o;g=x){D=g,L=!0;break}if(L)break}if(L)break}for(L=!1,m=n;m=x){O=m,L=!0;break}if(L)break}if(L)break}for(L=!1,v=l;v>=s;--v){for(g=u;g>=o;--g){for(m=c;m>=n;--m)if(p=e*r*v+e*g+m,t[p]>=x){F=v,L=!0;break}if(L)break}if(L)break}for(L=!1,g=u;g>=o;--g){for(v=F;v>=s;--v){for(m=c;m>=n;--m)if(p=e*r*v+e*g+m,t[p]>=x){B=g,L=!0;break}if(L)break}if(L)break}for(L=!1,m=c;m>=n;--m){for(g=B;g>=o;--g){for(v=F;v>=s;--v)if(p=e*r*v+e*g+m,t[p]>=x){k=m,L=!0;break}if(L)break}if(L)break}_?(n=Math.max(0,O-1),o=Math.max(0,D-1),s=Math.max(0,N-1),c=Math.min(e-1,k+1),u=Math.min(r-1,B+1),l=Math.min(i-1,F+1)):(n=Math.max(1,O-1),o=Math.max(1,D-1),s=Math.max(1,N-1),c=Math.min(e-2,k+1),u=Math.min(r-2,B+1),l=Math.min(i-2,F+1))}var z=15;for(v=s;vs&&(s=e);var a=o-n;if(0===a)return-1;var u=4*h;if(h+=1,1===a)return l[u]=n,l[u+1]=-1,l[u+2]=-1,l[u+3]=i,u;var d=n+Math.floor(a/2);p=e%3;for(var f,m,g,v,y,b=n,x=o-1;x>b;){for(g=b+x>>1,v=t[3*c[g]+p],m=c[g],c[g]=c[x],c[x]=m,y=b,f=b;fn&&s.pop()}var p,d,f=i(u)%3,m=3*c[l[u]],g=[t[m+0],t[m+1],t[m+2]],v=e(r,g),y=l[u+1],b=l[u+2];if(-1===b&&-1===y)return void((s.size()t[3*c[l[e]]+n])throw new Error("left child is > parent!");i+=o(a,r+1)}if(-1!==s){if(t[3*c[l[s]]+n]0&&(e=":"+ao(t).join(" OR :")),new ym(e)}function qs(e,r){if(r){t.Debug&&Lm.time("assignSecondaryStructure");var i=[];e.eachModel(function(t){t.eachChain(function(t){i.push(t.chainname)})});var n=i.slice().sort(),o=[];n.forEach(function(t){o.push(i.indexOf(t))});var a=r.helices;a=a.filter(function(t){return ro(n,t[0])>=0}),a.sort(function(t,e){var r=t[0],i=e[0],a=t[1],s=e[1];if(r===i)return a===s?0:a=0}),c.sort(function(t,e){var r=t[0],i=e[0];if(r===i)return 0;var a=ro(n,r),s=ro(n,i);return o[a]=e;)r=Math.floor(r/e),n+=gb[r%e],i+=1;return i>=5&&Lm.warn("chainname overflow"),n}function Zs(e,r){t.Debug&&Lm.time("calculateChainnames");var i=!0;if(e.eachChain(function(t){t.chainname&&(i=!1)}),i){var n=e.modelStore,o=e.chainStore,a=e.residueStore,s=function(t,e,r,i){for(var s=o.count,c=0;c500)return void(t.Debug&&Lm.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName()));var u,l,h=[],p=[],d=[];if(o>50){var f=new Hs(e,!0),m=e.isCg()?1.2:2.3;for(u=a;u500)return void Lm.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var h=t.getBonds(),p=h.atomIndices1,d=h.atomIndices2,f=h.bondOrders,m=p.length,g=0;g1&&(c.x-=1),s.x<0&&(c.x+=1),s.y>1&&(c.y-=1),s.y<0&&(c.y+=1),s.z>1&&(c.z-=1),s.z<0&&(c.z+=1),t&&c.add(t),u.setPosition(c),u.multiplyMatrices(i.fracToCart,u),u.multiply(i.cartToFrac),e.push(u)}),e}if(e.unitcell){t.Debug&&Lm.time("buildUnitcellAssembly");var i=e.unitcell,n=e.center.clone().applyMatrix4(i.cartToFrac),o=Ws(i.spacegroup),a=new v,s=new v,c=new v;n.x>1&&(a.x-=1),n.x<0&&(a.x+=1),n.y>1&&(a.y-=1),n.y<0&&(a.y+=1),n.z>1&&(a.z-=1),n.z<0&&(a.z+=1);var u,l=new hb("UNITCELL"),h=r();if(e.biomolDict.NCS){u=[new y].concat(e.biomolDict.NCS.partList[0].matrixList);var p=[];h.forEach(function(t){u.forEach(function(e){p.push(t.clone().multiply(e))})}),l.addPart(p)}else l.addPart(h);var d=new v,f=new hb("SUPERCELL"),m=Array.prototype.concat.call(r(d.set(1,0,0)),r(d.set(0,1,0)),r(d.set(0,0,1)),r(d.set(-1,0,0)),r(d.set(0,-1,0)),r(d.set(0,0,-1)),r(d.set(1,1,0)),r(d.set(1,0,1)),r(d.set(0,1,1)),r(d.set(-1,-1,0)),r(d.set(-1,0,-1)),r(d.set(0,-1,-1)),r(d.set(1,-1,-1)),r(d.set(1,1,-1)),r(d.set(1,-1,1)),r(d.set(-1,1,1)),r(d.set(-1,-1,1)),r(d.set(-1,1,-1)),r(d.set(0,1,-1)),r(d.set(0,-1,1)),r(d.set(1,0,-1)),r(d.set(-1,0,1)),r(d.set(1,-1,0)),r(d.set(-1,1,0)),r(),r(d.set(1,1,1)),r(d.set(-1,-1,-1)));if(e.biomolDict.NCS){var g=[];m.forEach(function(t){u.forEach(function(e){g.push(t.clone().multiply(e))})}),f.addPart(g)}else f.addPart(m);e.biomolDict.UNITCELL=l,e.biomolDict.SUPERCELL=f,t.Debug&&Lm.timeEnd("buildUnitcellAssembly")}}function ic(t){var e=t.trim().toUpperCase();parseInt(e.charAt(0))&&(e=e.substr(1)),parseInt(e.charAt(0))&&(e=e.substr(1));var r=e.length;if(0===r)return"";if(1===r)return e;if(2===r){if(-1!==yb.indexOf(e))return e;if(-1!==vb.indexOf(e[0]))return e[0]}return r>=3&&-1!==vb.indexOf(e[0])?e[0]:""}function nc(t){var e=t.bondHash,r=e.countArray,i=e.offsetArray,n=e.indexArray,o=t.getBondProxy();t.eachResidue(function(t){var e=t.residueType;if(void 0===e.bonds){var a=t.atomOffset,s=[],c=[],u=[],l={};t.eachAtom(function(t){for(var e=t.index,h=i[e],p=r[e],d=0,f=p;dg){var v=g;g=m,m=v}var y=m+"|"+g;void 0===l[y]&&(l[y]=!0,s.push(m-a),c.push(g-a),u.push(o.bondOrder))}}),e.bonds={atomIndices1:s,atomIndices2:c,bondOrders:u}}})}function oc(t,e){return t+"|"+e}function ac(t,e,r,i){return t+"|"+e.join(",")+"|"+(r?1:0)+"|"+(i||"")}function sc(t,e,r){if(0!==r[0]&&0!==r[8]&&0!==r[4])for(var i=t.length,n=r[0],o=r[1],a=r[2],s=e[0],c=e[1],u=e[2],l=-s+n+n/2,h=-c+o+o/2,p=-u+a+a/2,d=0;d.9*e[3*n+n])if(o>0)for(var a=0;a<3;++a)t[i+a]-=e[3*n+a];else for(var s=0;s<3;++s)t[i+s]+=e[3*n+s]}return t}}function uc(t,e,r){if(0!==e[0]&&0!==e[8]&&0!==e[4]){for(var i=t.length,n=3;n.5&&(t[n+o]-=e[3*o+o]*Math.round(a))}return t}}function lc(t,e,r){return[la(e,r[0],3,0,t),la(e,r[1],3,1,t),la(e,r[2],3,2,t)]}function hc(t){return[Aa(t,3,0),Aa(t,3,1),Aa(t,3,2)]}function pc(t,e,r,i,n){for(var o=t.length,a=new Float32Array(o),s=0;s1&&(h=1),i(e,r,n,o,l,f),i(e,r,n,o,h,m),m.sub(f).normalize(),m.toArray(a,g)}}function a(e,r,i,n,o){for(var a,s=r.next(),c=r.next(),u=r.next(),l=r.size,h=l-1,p=n||0,d=0;dr&&c.bondSet.clear(b)}else("OH"===l.atomname&&"TYR"===l.resname||"OH"===h.atomname&&"TYR"===h.resname)&&(function(t,e,i,n){var o,a;t.atomname===i?(o=t,a=e):(o=e,a=t),f.index=o.residueIndex;var s=f.getAtomIndexByName(n);return g.subVectors(s,o),y.subVectors(s,a),So(g.angleTo(y))r&&c.bondSet.clear(b)))}}return{atomSet:c.atomSet,bondSet:c.bondSet,bondStore:c.bondStore}}function Uc(t,e){e=e||{};for(var r=Xn(e.angleStep,Math.PI/90),i=t.length,n=t.length/12,o=new Float32Array(n),a=new Float32Array(3*n),s=new Array(n),c=new Array(n),u=new Array(n),l=new Array(n),h=new Array(n),p=0,d=0,f=0,m=Ga(),g=Ga(),v=Ga(),y=Ga(),b=Ga(),x=Ga(),_=Ga(),w=Ga(),S=Ga(),A=Ga(),M=Ga(),P=Ga(),E=Ga(),T=Ga(),C=Ga(),I=0,R=0;R0;Wa(w,y,S);var n=Ha(w,x)<0;if(Qa(w,x,Ha(x,b)),Wa(A,b,w),Qa(w,x,Ha(x,_)),Wa(M,_,w),0!==Za(A)&&0!==Za(M)){Ja(A,A),Ja(M,M);var R=o[I]=Math.acos(Ha(A,M));s[I]=(xg*R).toFixed(1)+String.fromCharCode(176),$a(T,A,x),Ja(T,T),Ha(T,M)<0&&ns(T,T),Rc(w,S,A,T,R/2),Ya(w,a,3*I);var L=Math.ceil(R/r),O=L+2,D=new Float32Array(3*O),N=new Float32Array(3*O),k=new Float32Array(9*L),B=new Float32Array(36);c[I]=D,u[I]=N,l[I]=k,h[I]=B,i?(Wa(w,m,v),Ja(w,w),Qa(P,w,1/Ha(A,w)),Xa(P,P,v)):(Qa(P,b,1/Ha(A,b)),Xa(P,P,g)),n?(Wa(w,y,g),Ja(w,w),Qa(E,w,1/Ha(M,w)),Xa(E,E,g)):(Qa(E,_,1/Ha(M,_)),Xa(E,E,v)),Xa(C,S,A),Ya(P,D,0),Ya(C,N,0),Ya(P,B,0),Ya(C,B,3),Ya(i?v:g,B,6),Ya(i?v:g,B,9),Ya(C,B,12),Ya(S,B,15);for(var F=function(t,e){var r=9*e,i=3*e;Ya(S,k,r),Ya(C,k,r+3),Ya(C,D,i),Rc(C,S,A,T,t),Ya(C,k,r+6),Ya(C,N,i)},z=0,U=r;Ua?u[l]=-1:(o=Math.sqrt(a-n),u[l]=Math.floor(o)),++l;A[h]=c,S[h]=u}}function o(r){var i,n,o,a,s,c,u,l,h,p,d,f,m,v,_,M,T,I,R=3*r,O=r;i=Math.floor(.5+g*(t[R]+w[0])),n=Math.floor(.5+g*(t[R+1]+w[1])),o=Math.floor(.5+g*(t[R+2]+w[2]));var D,N=e[O],k=S[N],B=0,F=b*x,z=A[N];for(p=0;p=y||v>=b||_>=x)){var U=m*F+v*x+_;if(P)if(E[U]&L){if(E[U]&L){var j=C[U];j!==R&&(a=i+u-Math.floor(.5+g*(t[j]+w[0])),s=n+l-Math.floor(.5+g*(t[j+1]+w[1])),c=o+h-Math.floor(.5+g*(t[j+2]+w[2])),u*u+l*l+h*h=y||d>=b||f>=x)){var F=p*B+d*x+f;if(E[F]&O){if(P){var z=C[F];a=Math.floor(.5+g*(t[z]+w[0])),s=Math.floor(.5+g*(t[z+1]+w[1])),c=Math.floor(.5+g*(t[z+2]+w[2])),u*u+l*l+h*h-1&&a-1&&c-1&&s0);var f,m=v*v,g=new Uint16Array(3);for(t=0;t=m)||(E[n]|=D,P&&E[n]&O&&(o.toArray(t,e,r,g),f=g[0]*a+g[1]*x+g[2],C[n]=C[f])));console.timeEnd("EDTSurface fastdistancemap")}function h(t,e,r,i){var n,o,a,s,c,u,l,h,p,d,f,m,g=new Uint16Array(3),v=0;if(0===r)return v;var _=-1,w=-1,S=-1,A=b*x;for(l=0,p=r;l-1&&w-1&&S-1&&(f=_*A+x*w+S,E[f]&L&&!(E[f]&O)?(e.fromArray(_,w,S,g),s=_-g[0],c=w-g[1],u=S-g[2],d=s*s+c*c+u*u,T[f]=d,E[f]|=O,E[f]|=D,i[v]=_,i[v+1]=w,i[v+2]=S,v+=3):E[f]&L&&E[f]&O&&(s=_-g[0],c=w-g[1],u=S-g[2],(d=s*s+c*c+u*u)-1&&w-1&&S-1&&(f=_*A+x*w+S,E[f]&L&&!(E[f]&O)?(e.fromArray(_,w,S,g),s=_-g[0],c=w-g[1],u=S-g[2],d=s*s+c*c+u*u,T[f]=d,E[f]|=O,E[f]|=D,i[v]=_,i[v+1]=w,i[v+2]=S,v+=3):E[f]&L&&E[f]&O&&(s=_-g[0],c=w-g[1],u=S-g[2],(d=s*s+c*c+u*u)-1&&w-1&&S-1&&(f=_*A+x*w+S,E[f]&L&&!(E[f]&O)?(e.fromArray(_,w,S,g),s=_-g[0],c=w-g[1],u=S-g[2],d=s*s+c*c+u*u,T[f]=d,E[f]|=O,E[f]|=D,i[v]=_,i[v+1]=w,i[v+2]=S,v+=3):E[f]&L&&E[f]&O&&(s=_-g[0],c=w-g[1],u=S-g[2],(d=s*s+c*c+u*u)E&&(E=R)}this.neighbourListLength=27*E+1,this.withinRadii=function(n,o,a,c,p){for(var d=0,f=s(n,u),y=s(o,l),x=s(a,h),_=Math.max(0,f-1),w=Math.max(0,y-1),P=Math.max(0,x-1),E=Math.min(m,f+1),T=Math.min(g,y+1),C=Math.min(v,x+1),I=_;I<=E;++I)for(var R=I*b,L=w;L<=T;++L)for(var O=L*v,D=P;D<=C;++D)for(var N=R+O+D,k=S[N],B=k+A[N],F=k;FP&&(P=A[l]);o(),a(),s(),H=-1}function n(t,e,r){for(var i=0;i=0;){if(o!==i&&o!==n&&u(o,t,e,r))return H=o,o;o=j[++a]}return H=-1,-1}function u(e,r,i,n){var o=3*e,a=M[e],s=t[o]-r,c=t[o+1]-i,u=t[o+2]-n;return s*s+c*c+u*u=0;)t0&&s0&&e(g-1),h.growIfFull(),h.resno[g]=_,void 0!==S&&(h.sstruc[g]=S.charCodeAt(0)),void 0!==A&&(h.inscode[g]=A.charCodeAt(0)),h.atomOffset[g]=m,h.atomCount[g]=0,h.count+=1,h.chainIndex[g]=v,p.residueCount[v]+=1),l.count+=1,l.residueIndex[m]=g,h.atomCount[g]+=1,n=t,o=b,a=x,s=_,c=A,u=w},this.finalize=function(){r=a,i=u,g>-1&&e(g)}}function qc(t){switch(t=t.toLowerCase()){case"polymer":return my;case"non-polymer":return gy;case"macrolide":return vy;case"water":return yy;default:return fy}}function Yc(t,e,r){var i=""+t;return e&&(i+=":"+e),r&&(i+="^"+r),i}function Zc(t){return!t||t[0]!==t[t.length-1]||"'"!==t[0]&&'"'!==t[0]?t:t.substring(1,t.length-1)}function Kc(t,e){Array.isArray(t[e])||Object.keys(t).forEach(function(e){t[e]=[t[e]]})}function Qc(t){return"?"!==t}function Jc(t,e){return Qc(t)?t:e}function tu(t){switch(t.toLowerCase()){case"?":case"sing":return 1;case"doub":return 2;case"trip":return 3;case"quad":return 4}return 0}function eu(t,e,r){var i,n,o=e.atomStore,a=e.atomMap,s=t.chem_comp,c=t.chem_comp_atom,u=t.chem_comp_bond;s&&(s.name&&(e.title=s.name.trim().replace(bS,"")),s.id&&(e.id=s.id.trim().replace(bS,"")));var l={};if(c){var h,p,d,f;for(n=c.comp_id.length,i=0;if*f)return n.growIfFull(),n.atomTypeId[m]=n.atomTypeId[t],n.x[m]=p.x,n.y[m]=p.y,n.z[m]=p.z,n.occupancy[m]=n.occupancy[t],n.serial[m]=m,n.altloc[m]="A".charCodeAt(0),r.addAtom(0,"","","HET",1,1),void(m+=1)}}})}(b)}function iu(t,e,r){var i,n,o,a,s=[],c=[],u=t.struct_conf;if(u)for(Kc(u,"id"),i=0,n=u.beg_auth_seq_id.length;i0){o=o.split("(");var c=s(o[0]),u=s(o[1]);Object.keys(c).forEach(function(t){Object.keys(u).forEach(function(e){var r=new y;r.multiplyMatrices(c[t],u[e]),i[t+"x"+e]=r})})}else i=s(o);var l=[];for(var h in i)l.push(i[h]);var p=t;/^(0|[1-9][0-9]*)$/.test(p)&&(p="BU"+p);for(var d=a.asym_id_list[e].split(","),f=0,m=d.length;fS){var A=w;w=S,S=A;var M=m;m=x,x=M}if(0!==w&&0!==S)for(var P=0;Po&&++s;e=new Int32Array(s)}for(r=0,i=0;r65535){for(var i=[],n=0;n6,"non valid type "+a);var s=t.readUint32(),c=Bu(t,a,s);Ru(t),e[n]={name:o,type:Ou(a),value:c}}return e}function $u(t,e,r){var i,n=t.readUint32(),o=0;if(n===dA)return Iu(t.readUint32()!==dA,"wrong empty tag for list of variables"),[];Iu(n!==mA,"wrong tag for list of variables");var a=t.readUint32();i=new Array(a);for(var s=0;s6,"non valid type "+d);var f=t.readUint32(),m=t.readUint32();2===r&&(Iu(m>0,"offsets larger than 4GB not supported"),m=t.readUint32()),l[0]===e&&(o+=f),i[s]={name:c,dimensions:l,attributes:p,type:Ou(d),size:f,offset:m,record:l[0]===e}}return{variables:i,recordStep:o}}function Hu(t){for(var e=1,r=0;t>=e&&r<32;)r++,e<<=1;return r}function Wu(t,e){var r=1,i=0;wA[0]=1;for(var n=0;n>=8;for(;0!==a;)wA[o++]=255&a,a>>=8;r=o}var s=1;for(r--;wA[r]>=s;)i++,s*=2;return i+8*r}function Xu(t,e,r,i){for(var n=(1<=8;)a=a<<8|e[s++],c|=a>>o<0&&(o>o&(1<8;)SA[s++]=Xu(t,e,8,a),i-=8;i>0&&(SA[s++]=Xu(t,e,i,a));for(var c=r-1;c>0;c--){for(var u=0,l=s-1;l>=0;l--){u=u<<8|SA[l];var h=u/n[c]|0;SA[l]=h,u-=h*n[c]}o[c]=u}o[0]=SA[0]|SA[1]<<8|SA[2]<<16|SA[3]<<24}function Yu(t){return t.trim().split(DA).map(parseFloat)}function Zu(){this.regexp={vertex_pattern:/^v\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,normal_pattern:/^vn\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,uv_pattern:/^vt\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}}function Ku(){this.propertyNameMapping={}}function Qu(t){return t.replace($A,"")}function Ju(t){function e(){if(o(/^<\?xml\s*/)){for(var t={attributes:{}};!a()&&!s("?>");){var e=n();if(!e)return t;t.attributes[e.name]=e.value}return o(/\?>\s*/),t}}function r(){var t=o(HA);if(t){for(var e={name:t[1],attributes:{},children:[]};!(a()||s(">")||s("?>")||s("/>"));){var c=n();if(!c)return e;e.attributes[c.name]=c.value}if(o(/^\s*\/>\s*/))return e;o(/\??>\s*/),e.content=i();for(var u;u=r();)e.children.push(u);return o(/^<\/[\w-:.]+>\s*/),e}}function i(){var t=o(WA);return t?t[1]:""}function n(){var t=o(XA);if(t)return{name:t[1],value:Qu(t[2])}}function o(e){var r=t.match(e);if(r)return t=t.slice(r[0].length),r}function a(){return 0===t.length}function s(e){return 0===t.indexOf(e)}return t=t.trim().replace(//g,""),function(){return{declaration:e(),root:r()}}()}function tl(t,e,r){var i=t.icode.value,n=t.chain.value,o=t.altcode.value,a=t.resnum.value;return i.trim()&&(a+="^"+i),n.trim()&&(a+=":"+n),e&&(a+="."+e),r&&o.trim()&&(a+="%"+o),a+="/"+(parseInt(t.model.value)-1)}function el(t,e,r){void 0===t[e]?t[e]=r:t[e]|=r}function rl(t,e){return void 0!==t&&t.value===e}function il(t){var e=t.inscode,r=t.chainname,i=t.atomname,n=t.altloc,o=t.resno;return e&&(o+="^"+e),r&&(o+=":"+r),i&&(o+="."+i),n&&(o+="%"+n),o+="/"+t.modelIndex}function nl(t,e,r){for(var i=0,n=e.getElementsByTagName("clash"),o=0,a=n.length;o0&&(i+=1),e.getElementsByTagName("bond-outlier").length>0&&(i+=1),e.getElementsByTagName("plane-outlier").length>0&&(i+=1),rl(r.rota,"OUTLIER")&&(i+=1),rl(r.rama,"OUTLIER")&&(i+=1),rl(r.RNApucker,"outlier")&&(i+=1),i}function ol(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])}}return t}function al(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)}function sl(t,e,r,i,n){if(e.subarray&&t.subarray)return void t.set(e.subarray(r,r+i),n);for(var o=0;o>>16&65535|0,a=0;0!==r;){a=r>2e3?2e3:r,r-=a;do{n=n+e[i++]|0,o=o+n|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}function ll(t,e,r,i){var n=tM,o=i+r;t^=-1;for(var a=i;a>>8^n[255&(t^e[a])];return-1^t}function hl(t,e){var r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P;r=t.state,i=t.next_in,M=t.input,n=i+(t.avail_in-5),o=t.next_out,P=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,h=r.wnext,p=r.window,d=r.hold,f=r.bits,m=r.lencode,g=r.distcode,v=(1<>>24,d>>>=x,f-=x,0===(x=b>>>16&255))P[o++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<>>=x,f-=x),f<15&&(d+=M[i++]<>>24,d>>>=x,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<c){t.msg="invalid distance too far back",r.mode=eM;break t}if(d>>>=x,f-=x,x=o-a,w>x){if((x=w-x)>l&&r.sane){t.msg="invalid distance too far back",r.mode=eM;break t}if(S=0,A=p,0===h){if(S+=u-x,x<_){_-=x;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}}else if(h2;)P[o++]=A[S++],P[o++]=A[S++],P[o++]=A[S++],_-=3;_&&(P[o++]=A[S++],_>1&&(P[o++]=A[S++]))}else{S=o-w;do{P[o++]=P[S++],P[o++]=P[S++],P[o++]=P[S++],_-=3}while(_>2);_&&(P[o++]=P[S++],_>1&&(P[o++]=P[S++]))}break}}break}}while(i>3,i-=_,f-=_<<3,d&=(1<=1&&0===I[_];_--);if(w>_&&(w=_),0===_)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(x=1;x<_&&0===I[x];x++);for(w0&&(t===aM||1!==_))return-1;for(R[1]=0,y=1;ynM||t===cM&&P>oM)return 1;for(;;){f=y-A,a[b]d?(m=L[O+a[b]],g=T[C+a[b]]):(m=96,g=0),c=1<>A)+u]=f<<24|m<<16|g|0}while(0!==u);for(c=1<>=1;if(0!==c?(E&=c-1,E+=c):E=0,b++,0==--I[y]){if(y===_)break;y=e[r+a[b]]}if(y>w&&(E&h)!==l){for(0===A&&(A=w),p+=x,S=y-A,M=1<nM||t===cM&&P>oM)return 1;l=E&h,n[l]=w<<24|S<<16|p-o|0}}return 0!==E&&(n[p+E]=y-A<<24|64<<16|0),s.bits=w,0}function dl(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function fl(){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 ml(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=EM,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(oP),e.distcode=e.distdyn=new Int32Array(aP),e.sane=1,e.back=-1,bM):wM}function gl(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,ml(t)):wM}function vl(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?wM:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,gl(t))):wM}function yl(t,e){var r,i;return t?(i=new fl,t.state=i,i.window=null,r=vl(t,e),r!==bM&&(t.state=null),r):wM}function bl(t){if(sP){var e;for(QA=new Int32Array(512),JA=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(pl(fM,t.lens,0,288,QA,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;pl(mM,t.lens,0,32,JA,0,t.work,{bits:5}),sP=!1}t.lencode=QA,t.lenbits=9,t.distcode=JA,t.distbits=5}function xl(t,e,r,i){var n,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(sl(o.window,e,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),sl(o.window,e,r-i,n,o.wnext),i-=n,i?(sl(o.window,e,r-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,r.check=ll(r.check,E,2,0),u=0,l=0,r.mode=TM;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=rP;break}if((15&u)!==PM){t.msg="unknown compression method",r.mode=rP;break}if(u>>>=4,l-=4,w=8+(15&u),0===r.wbits)r.wbits=w;else if(w>r.wbits){t.msg="invalid window size",r.mode=rP;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=ll(r.check,E,2,0)),u=0,l=0,r.mode=CM;case CM:for(;l<32;){if(0===s)break t;s--,u+=i[o++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=ll(r.check,E,4,0)),u=0,l=0,r.mode=IM;case IM:for(;l<16;){if(0===s)break t;s--,u+=i[o++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=ll(r.check,E,2,0)),u=0,l=0,r.mode=RM;case RM:if(1024&r.flags){for(;l<16;){if(0===s)break t;s--,u+=i[o++]<>>8&255,r.check=ll(r.check,E,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=LM;case LM:if(1024&r.flags&&(d=r.length,d>s&&(d=s),d&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),sl(r.head.extra,i,o,d,w)),512&r.flags&&(r.check=ll(r.check,i,d,o)),s-=d,o+=d,r.length-=d),r.length))break t;r.length=0,r.mode=OM;case OM:if(2048&r.flags){if(0===s)break t;d=0;do{w=i[o+d++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&d>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=FM;break;case kM:for(;l<32;){if(0===s)break t;s--,u+=i[o++]<>>=7&l,l-=7&l,r.mode=JM;break}for(;l<3;){if(0===s)break t;s--,u+=i[o++]<>>=1,l-=1,3&u){case 0:r.mode=UM;break;case 1:if(bl(r),r.mode=WM,e===yM){u>>>=2,l-=2;break t}break;case 2:r.mode=GM;break;case 3:t.msg="invalid block type",r.mode=rP}u>>>=2,l-=2;break;case UM:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break t;s--,u+=i[o++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=rP;break}if(r.length=65535&u,u=0,l=0,r.mode=jM,e===yM)break t;case jM:r.mode=VM;case VM:if(d=r.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break t;sl(n,i,o,d,a),s-=d,o+=d,c-=d,a+=d,r.length-=d;break}r.mode=FM;break;case GM:for(;l<14;){if(0===s)break t;s--,u+=i[o++]<>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=rP;break}r.have=0,r.mode=$M;case $M:for(;r.have>>=3,l-=3}for(;r.have<19;)r.lens[T[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},S=pl(dM,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,S){t.msg="invalid code lengths set",r.mode=rP;break}r.have=0,r.mode=HM;case HM:for(;r.have>>24, +v=P>>>16&255,y=65535&P,!(g<=l);){if(0===s)break t;s--,u+=i[o++]<>>=g,l-=g,r.lens[r.have++]=y;else{if(16===y){for(M=g+2;l>>=g,l-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=rP;break}w=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===y){for(M=g+3;l>>=g,l-=g,w=0,d=3+(7&u),u>>>=3,l-=3}else{for(M=g+7;l>>=g,l-=g,w=0,d=11+(127&u),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=rP;break}for(;d--;)r.lens[r.have++]=w}}if(r.mode===rP)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=rP;break}if(r.lenbits=9,A={bits:r.lenbits},S=pl(fM,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,S){t.msg="invalid literal/lengths set",r.mode=rP;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},S=pl(mM,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,S){t.msg="invalid distances set",r.mode=rP;break}if(r.mode=WM,e===yM)break t;case WM:r.mode=XM;case XM:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,r.hold=u,r.bits=l,hl(t,p),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,i=t.input,s=t.avail_in,u=r.hold,l=r.bits,r.mode===FM&&(r.back=-1);break}for(r.back=0;P=r.lencode[u&(1<>>24,v=P>>>16&255,y=65535&P,!(g<=l);){if(0===s)break t;s--,u+=i[o++]<>b)],g=P>>>24,v=P>>>16&255,y=65535&P,!(b+g<=l);){if(0===s)break t;s--,u+=i[o++]<>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,r.length=y,0===v){r.mode=QM;break}if(32&v){r.back=-1,r.mode=FM;break}if(64&v){t.msg="invalid literal/length code",r.mode=rP;break}r.extra=15&v,r.mode=qM;case qM:if(r.extra){for(M=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=YM;case YM:for(;P=r.distcode[u&(1<>>24,v=P>>>16&255,y=65535&P,!(g<=l);){if(0===s)break t;s--,u+=i[o++]<>b)],g=P>>>24,v=P>>>16&255,y=65535&P,!(b+g<=l);){if(0===s)break t;s--,u+=i[o++]<>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,64&v){t.msg="invalid distance code",r.mode=rP;break}r.offset=y,r.extra=15&v,r.mode=ZM;case ZM:if(r.extra){for(M=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=rP;break}r.mode=KM;case KM:if(0===c)break t;if(d=p-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=rP;break}d>r.wnext?(d-=r.wnext,f=r.wsize-d):f=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=n,f=a-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{n[a++]=m[f++]}while(--d);0===r.length&&(r.mode=XM);break;case QM:if(0===c)break t;n[a++]=r.length,c--,r.mode=XM;break;case JM:if(r.wrap){for(;l<32;){if(0===s)break t;s--,u|=i[o++]<>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e}function Pl(t,e){if(e<65537&&(t.subarray&&uP||!t.subarray&&cP))return String.fromCharCode.apply(null,al(t,e));for(var r="",i=0;i4)s[i++]=65533,r+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&r1?s[i++]=65533:n<65536?s[i++]=n:(n-=65536,s[i++]=55296|n>>10&1023,s[i++]=56320|1023&n)}return Pl(s,i)}function Cl(t,e){var r;for(e=e||t.length,e>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+lP[t[r]]>e?r:e}function Il(){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 Rl(){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}function Ll(t){if(!(this instanceof Ll))return new Ll(t);this.options=ol({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 Il,this.strm.avail_out=0;var r=yl(this.strm,e.windowBits);if(r!==pP)throw new Error(dP[r]);this.header=new Rl,Sl(this.strm,this.header)}function Ol(t,e){var r=new Ll(e);if(r.push(t,!0),r.err)throw r.msg;return r.result}function Dl(t){var e;t instanceof ArrayBuffer&&(t=new Uint8Array(t));try{e=Ol(t)}catch(r){e=t}return e}"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,r=window.console,i={},n=function(){},o="memory".split(","),a="assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn".split(",");t=o.pop();)r[t]||(r[t]=i);for(;e=a.pop();)r[e]||(r[e]=n)}(),void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,r){for(var i=window.atob(this.toDataURL(e,r).split(",")[1]),n=i.length,o=n>>2,a=new Uint8Array(n),s=new Uint32Array(a.buffer,0,o),c=0,u=0;c0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}),Number.isNaN||(Number.isNaN=function(t){return t!==t}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var e=arguments;if(void 0===t||null===t)throw new TypeError("Cannot convert first argument to object");for(var r,i=Object(t),n=!1,o=1;o1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),i);if(o+c>i)return!1;for(var u=-1;++ur.length)&&(e=r.length),e-=t.length;var i=r.indexOf(t,e);return-1!==i&&i===e}),String.prototype.repeat||(String.prototype.repeat=function(t){if(null===this)throw new TypeError("can't convert "+this+" to object");var e=""+this;if(t=+t,Number.isNaN(t)&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t===1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0===e.length||0===t)return"";if(e.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||(Array.prototype.includes=function(t){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),r=parseInt(e.length,10)||0;if(0===r)return!1;var i,n=parseInt(arguments[1],10)||0;n>=0?i=n:(i=r+n)<0&&(i=0);for(var o;i0?1:-1)*Math.floor(Math.abs(e)):e},i=Math.pow(2,53)-1,n=function(t){var e=r(t);return Math.min(Math.max(e,0),i)};return function(t){var r=this,i=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var o,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!e(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(o=arguments[2])}for(var s,c=n(i.length),u=e(r)?Object(new r(c)):new Array(c),l=0;l0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(t){var e=arguments;if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),i=1;i>=4,r[n]=e[19===n?3&t|8:t]);return r.join("")}}(),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,i,n){return i+(t-e)*(n-i)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*zp.DEG2RAD},radToDeg:function(t){return t*zp.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};Object.defineProperties(h.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(h.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t=new h,e=new h;return function(r,i){return t.set(r,r),e.set(i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),i=Math.sin(e),n=this.x-t.x,o=this.y-t.y;return this.x=n*r-o*i+t.x,this.y=n*i+o*r+t.y,this}});var Up=0;p.DEFAULT_IMAGE=void 0,p.DEFAULT_MAPPING=300,Object.defineProperty(p.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(p.prototype,l.prototype,{constructor:p,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=zp.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),e.width=t.width,e.height=t.height;var r=e.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case Vh:t.x=t.x-Math.floor(t.x);break;case Gh:t.x=t.x<0?0:1;break;case $h:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case Vh:t.y=t.y-Math.floor(t.y);break;case Gh:t.y=t.y<0?0:1;break;case $h:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.assign(d.prototype,{isVector4:!0,set:function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,i=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*n,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*n,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*n,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*n,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,i,n,o=t.elements,a=o[0],s=o[4],c=o[8],u=o[1],l=o[5],h=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(c-p)<.01&&Math.abs(h-d)<.01){if(Math.abs(s+u)<.1&&Math.abs(c+p)<.1&&Math.abs(h+d)<.1&&Math.abs(a+l+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(l+1)/2,v=(f+1)/2,y=(s+u)/4,b=(c+p)/4,x=(h+d)/4;return m>g&&m>v?m<.01?(r=0,i=.707106781,n=.707106781):(r=Math.sqrt(m),i=y/r,n=b/r):g>v?g<.01?(r=.707106781,i=0,n=.707106781):(i=Math.sqrt(g),r=y/i,n=x/i):v<.01?(r=.707106781,i=.707106781,n=0):(n=Math.sqrt(v),r=b/n,i=x/n),this.set(r,i,n,e),this}var _=Math.sqrt((d-h)*(d-h)+(c-p)*(c-p)+(u-s)*(u-s));return Math.abs(_)<.001&&(_=1),this.x=(d-h)/_,this.y=(c-p)/_,this.z=(u-s)/_,this.w=Math.acos((a+l+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,i){return void 0===t&&(t=new d,e=new d),t.set(r,r,r,r),e.set(i,i,i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(f.prototype,l.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),m.prototype=Object.create(f.prototype),m.prototype.constructor=m,m.prototype.isWebGLRenderTargetCube=!0,Object.assign(g,{slerp:function(t,e,r,i){return r.copy(t).slerp(e,i)},slerpFlat:function(t,e,r,i,n,o,a){var s=r[i+0],c=r[i+1],u=r[i+2],l=r[i+3],h=n[o+0],p=n[o+1],d=n[o+2],f=n[o+3];if(l!==f||s!==h||c!==p||u!==d){var m=1-a,g=s*h+c*p+u*d+l*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,a=Math.sin(a*x)/b}var _=a*v;if(s=s*m+h*_,c=c*m+p*_,u=u*m+d*_,l=l*m+f*_,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+l*l);s*=w,c*=w,u*=w,l*=w}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=l}}),Object.defineProperties(g.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(g.prototype,{set:function(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,i=t._y,n=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(r/2),u=a(i/2),l=a(n/2),h=s(r/2),p=s(i/2),d=s(n/2);return"XYZ"===o?(this._x=h*u*l+c*p*d,this._y=c*p*l-h*u*d,this._z=c*u*d+h*p*l,this._w=c*u*l-h*p*d):"YXZ"===o?(this._x=h*u*l+c*p*d,this._y=c*p*l-h*u*d,this._z=c*u*d-h*p*l,this._w=c*u*l+h*p*d):"ZXY"===o?(this._x=h*u*l-c*p*d,this._y=c*p*l+h*u*d,this._z=c*u*d+h*p*l,this._w=c*u*l-h*p*d):"ZYX"===o?(this._x=h*u*l-c*p*d,this._y=c*p*l+h*u*d,this._z=c*u*d-h*p*l,this._w=c*u*l+h*p*d):"YZX"===o?(this._x=h*u*l+c*p*d,this._y=c*p*l+h*u*d,this._z=c*u*d-h*p*l,this._w=c*u*l-h*p*d):"XZY"===o&&(this._x=h*u*l-c*p*d,this._y=c*p*l-h*u*d,this._z=c*u*d+h*p*l,this._w=c*u*l+h*p*d),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,i=r[0],n=r[4],o=r[8],a=r[1],s=r[5],c=r[9],u=r[2],l=r[6],h=r[10],p=i+s+h;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(l-c)*e,this._y=(o-u)*e,this._z=(a-n)*e):i>s&&i>h?(e=2*Math.sqrt(1+i-s-h),this._w=(l-c)/e,this._x=.25*e,this._y=(n+a)/e, +this._z=(o+u)/e):s>h?(e=2*Math.sqrt(1+s-i-h),this._w=(o-u)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(c+l)/e):(e=2*Math.sqrt(1+h-i-s),this._w=(a-n)/e,this._x=(o+u)/e,this._y=(c+l)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new v;return function(r,i){return void 0===e&&(e=new v),t=r.dot(i)+1,t<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,i),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,i=t._y,n=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=r*u+o*a+i*c-n*s,this._y=i*u+o*s+n*a-r*c,this._z=n*u+o*c+r*s-i*a,this._w=o*u-r*a-i*s-n*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,i=this._y,n=this._z,o=this._w,a=o*t._w+r*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=n,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(i+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,a),u=Math.sin((1-e)*c)/s,l=Math.sin(e*c)/s;return this._w=o*u+this._w*l,this._x=r*u+this._x*l,this._y=i*u+this._y*l,this._z=n*u+this._z*l,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(v.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t=new g;return function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new g;return function(e,r){return this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),applyMatrix3:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6]*i,this.y=n[1]*e+n[4]*r+n[7]*i,this.z=n[2]*e+n[5]*r+n[8]*i,this},applyMatrix4:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements,o=1/(n[3]*e+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*r+n[8]*i+n[12])*o,this.y=(n[1]*e+n[5]*r+n[9]*i+n[13])*o,this.z=(n[2]*e+n[6]*r+n[10]*i+n[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,i=this.z,n=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*i-a*r,u=s*r+a*e-n*i,l=s*i+n*r-o*e,h=-n*e-o*r-a*i;return this.x=c*s+h*-n+u*-a-l*-o,this.y=u*s+h*-o+l*-n-c*-a,this.z=l*s+h*-a+c*-o-u*-n,this},project:function(){var t=new y;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new y;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*r+n[8]*i,this.y=n[1]*e+n[5]*r+n[9]*i,this.z=n[2]*e+n[6]*r+n[10]*i,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t=new v,e=new v;return function(r,i){return t.set(r,r,r),e.set(i,i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var r=this.x,i=this.y,n=this.z;return this.x=i*t.z-n*t.y,this.y=n*t.x-r*t.z,this.z=r*t.y-i*t.x,this},crossVectors:function(t,e){var r=t.x,i=t.y,n=t.z,o=e.x,a=e.y,s=e.z;return this.x=i*s-n*a,this.y=n*o-r*s,this.z=r*a-i*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new v;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new v;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(zp.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(y.prototype,{isMatrix4:!0,set:function(t,e,r,i,n,o,a,s,c,u,l,h,p,d,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=i,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=l,g[14]=h,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new y).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t=new v;return function(e){var r=this.elements,i=e.elements,n=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=i[0]*n,r[1]=i[1]*n,r[2]=i[2]*n,r[4]=i[4]*o,r[5]=i[5]*o,r[6]=i[6]*o,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,r=t.x,i=t.y,n=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(i),c=Math.sin(i),u=Math.cos(n),l=Math.sin(n);if("XYZ"===t.order){var h=o*u,p=o*l,d=a*u,f=a*l;e[0]=s*u,e[4]=-s*l,e[8]=c,e[1]=p+d*c,e[5]=h-f*c,e[9]=-a*s,e[2]=f-h*c,e[6]=d+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*u,g=s*l,v=c*u,y=c*l;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*l,e[5]=o*u,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*u,g=s*l,v=c*u,y=c*l;e[0]=m-y*a,e[4]=-o*l,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*u,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var h=o*u,p=o*l,d=a*u,f=a*l;e[0]=s*u,e[4]=d*c-p,e[8]=h*c+f,e[1]=s*l,e[5]=f*c+h,e[9]=p*c-d,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=w-b*l,e[8]=_*l+x,e[1]=l,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=x*l+_,e[10]=b-w*l}else if("XZY"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=-l,e[8]=c*u,e[1]=b*l+w,e[5]=o*u,e[9]=x*l-_,e[2]=_*l-x,e[6]=a*u,e[10]=w*l+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,i=t._y,n=t._z,o=t._w,a=r+r,s=i+i,c=n+n,u=r*a,l=r*s,h=r*c,p=i*s,d=i*c,f=n*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+f),e[4]=l-v,e[8]=h+g,e[1]=l+v,e[5]=1-(u+f),e[9]=d-m,e[2]=h-g,e[6]=d+m,e[10]=1-(u+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new v,e=new v,r=new v;return function(i,n,o){var a=this.elements;return r.subVectors(i,n),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(o,r),0===t.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(o,r)),t.normalize(),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],u=r[1],l=r[5],h=r[9],p=r[13],d=r[2],f=r[6],m=r[10],g=r[14],v=r[3],y=r[7],b=r[11],x=r[15],_=i[0],w=i[4],S=i[8],A=i[12],M=i[1],P=i[5],E=i[9],T=i[13],C=i[2],I=i[6],R=i[10],L=i[14],O=i[3],D=i[7],N=i[11],k=i[15];return n[0]=o*_+a*M+s*C+c*O,n[4]=o*w+a*P+s*I+c*D,n[8]=o*S+a*E+s*R+c*N,n[12]=o*A+a*T+s*L+c*k,n[1]=u*_+l*M+h*C+p*O,n[5]=u*w+l*P+h*I+p*D,n[9]=u*S+l*E+h*R+p*N,n[13]=u*A+l*T+h*L+p*k,n[2]=d*_+f*M+m*C+g*O,n[6]=d*w+f*P+m*I+g*D,n[10]=d*S+f*E+m*R+g*N,n[14]=d*A+f*T+m*L+g*k,n[3]=v*_+y*M+b*C+x*O,n[7]=v*w+y*P+b*I+x*D,n[11]=v*S+y*E+b*R+x*N,n[15]=v*A+y*T+b*L+x*k,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t=new v;return function(e){for(var r=this,i=0,n=e.count;i>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,i){if(e=zp.euclideanModulo(e,1),r=zp.clamp(r,0,1),i=zp.clamp(i,0,1),0===r)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+r):i+r-i*r,o=2*i-n;this.r=t(o,n,e+1/3),this.g=t(o,n,e),this.b=t(o,n,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var i,n=r[1],o=r[2];switch(n){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,e(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,e(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return e(i[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u=r[1],l=u.length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(t&&t.length>0){var u=qp[t];void 0!==u?this.setHex(u):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,i=t||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),c=Math.min(n,o,a),u=(c+s)/2;if(c===s)e=0,r=0;else{var l=s-c;switch(r=u<=.5?l/(s+c):l/(2-s-c),s){case n:e=(o-a)/l+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\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\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\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\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\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\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\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\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\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\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\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;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\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 ) ); }\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}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\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}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, 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}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\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 = value.rgb * cLogLuvM;\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}\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 = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n", +lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\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\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\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\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\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\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\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#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\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#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\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\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\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}\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",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\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\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\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\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( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, 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( 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 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\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\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\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\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\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\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n", +shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\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#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\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\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\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\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\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\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\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\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\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",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\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",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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\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\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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\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\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},Qp={basic:{uniforms:Zp.merge([Yp.common,Yp.specularmap,Yp.envmap,Yp.aomap,Yp.lightmap,Yp.fog]),vertexShader:Kp.meshbasic_vert,fragmentShader:Kp.meshbasic_frag},lambert:{uniforms:Zp.merge([Yp.common,Yp.specularmap,Yp.envmap,Yp.aomap,Yp.lightmap,Yp.emissivemap,Yp.fog,Yp.lights,{emissive:{value:new et(0)}}]),vertexShader:Kp.meshlambert_vert,fragmentShader:Kp.meshlambert_frag},phong:{uniforms:Zp.merge([Yp.common,Yp.specularmap,Yp.envmap,Yp.aomap,Yp.lightmap,Yp.emissivemap,Yp.bumpmap,Yp.normalmap,Yp.displacementmap,Yp.gradientmap,Yp.fog,Yp.lights,{emissive:{value:new et(0)},specular:{value:new et(1118481)},shininess:{value:30}}]),vertexShader:Kp.meshphong_vert,fragmentShader:Kp.meshphong_frag},standard:{uniforms:Zp.merge([Yp.common,Yp.envmap,Yp.aomap,Yp.lightmap,Yp.emissivemap,Yp.bumpmap,Yp.normalmap,Yp.displacementmap,Yp.roughnessmap,Yp.metalnessmap,Yp.fog,Yp.lights,{emissive:{value:new et(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Kp.meshphysical_vert,fragmentShader:Kp.meshphysical_frag},points:{uniforms:Zp.merge([Yp.points,Yp.fog]),vertexShader:Kp.points_vert,fragmentShader:Kp.points_frag},dashed:{uniforms:Zp.merge([Yp.common,Yp.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Kp.linedashed_vert,fragmentShader:Kp.linedashed_frag},depth:{uniforms:Zp.merge([Yp.common,Yp.displacementmap]),vertexShader:Kp.depth_vert,fragmentShader:Kp.depth_frag},normal:{uniforms:Zp.merge([Yp.common,Yp.bumpmap,Yp.normalmap,Yp.displacementmap,{opacity:{value:1}}]),vertexShader:Kp.normal_vert,fragmentShader:Kp.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Kp.cube_vert,fragmentShader:Kp.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Kp.equirect_vert,fragmentShader:Kp.equirect_frag},distanceRGBA:{uniforms:Zp.merge([Yp.common,Yp.displacementmap,{referencePosition:{value:new v},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Kp.distanceRGBA_vert,fragmentShader:Kp.distanceRGBA_frag},shadow:{uniforms:Zp.merge([Yp.lights,{color:{value:new et(0)},opacity:{value:1}}]),vertexShader:Kp.shadow_vert,fragmentShader:Kp.shadow_frag}};Qp.physical={uniforms:Zp.merge([Qp.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Kp.meshphysical_vert,fragmentShader:Kp.meshphysical_frag},Object.assign(rt.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){var e=this;this.makeEmpty();for(var r=0,i=t.length;rthis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new h).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new h).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new h;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}), +nt.prototype=Object.create(p.prototype),nt.prototype.constructor=nt;var Jp=0;Object.assign(at.prototype,l.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){var e=this;if(void 0!==t)for(var r in t){var i=t[r];if(void 0!==i)if("shading"!==r){var n=e[r];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):e[r]="overdraw"===r?Number(i):i:console.warn("THREE."+e.type+": '"+r+"' is not a property of this material.")}else console.warn("THREE."+e.type+": .shading has been removed. Use the boolean .flatShading instead."),e.flatShading=1===i;else console.warn("THREE.Material: '"+r+"' parameter is undefined.")}},toJSON:function(t){function e(t){var e=[];for(var r in t){var i=t[r];delete i.metadata,e.push(i)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearCoat&&(i.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(i.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ql&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),this.side!==Hl&&(i.side=this.side),this.vertexColors!==ql&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),r){var n=e(t.textures),o=e(t.images);n.length>0&&(i.textures=n),o.length>0&&(i.images=o)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var i=e.length;r=new Array(i);for(var n=0;n!==i;++n)r[n]=e[n].clone()}return this.clippingPlanes=r,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),st.prototype=Object.create(at.prototype),st.prototype.constructor=st,st.prototype.isShaderMaterial=!0,st.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Zp.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},st.prototype.toJSON=function(t){var e=at.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},ct.prototype=Object.create(at.prototype),ct.prototype.constructor=ct,ct.prototype.isMeshDepthMaterial=!0,ct.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},ut.prototype=Object.create(at.prototype),ut.prototype.constructor=ut,ut.prototype.isMeshDistanceMaterial=!0,ut.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},Object.assign(lt.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,i=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;sn&&(n=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(e,r,i),this.max.set(n,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,i=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;sn&&(n=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(e,r,i),this.max.set(n,o,a),this},setFromPoints:function(t){var e=this;this.makeEmpty();for(var r=0,i=t.length;rthis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new v).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t=new v;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new v).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new v;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new v;return function(e){var r=e||new ht;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new v,new v,new v,new v,new v,new v,new v,new v];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(ht.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new lt;return function(e,r){var i=this.center;void 0!==r?i.copy(r):t.setFromPoints(e).getCenter(i);for(var n=0,o=0,a=e.length;othis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(t){var e=t||new lt;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(pt.prototype,{isMatrix3:!0,set:function(t,e,r,i,n,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=i,u[2]=a,u[3]=e,u[4]=n,u[5]=s,u[6]=r,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t=new v;return function(e){for(var r=this,i=0,n=e.count;i1))return i.copy(n).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return i.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new v).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new v,e=new pt;return function(r,i){var n=i||e.getNormalMatrix(r),o=this.coplanarPoint(t).applyMatrix4(r),a=this.normal.applyMatrix3(n).normalize();return this.constant=-o.dot(a),this}}(),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(ft.prototype,{set:function(t,e,r,i,n,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,i=r[0],n=r[1],o=r[2],a=r[3],s=r[4],c=r[5],u=r[6],l=r[7],h=r[8],p=r[9],d=r[10],f=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-i,l-s,f-h,y-m).normalize(),e[1].setComponents(a+i,l+s,f+h,y+m).normalize(),e[2].setComponents(a+n,l+c,f+p,y+g).normalize(),e[3].setComponents(a-n,l-c,f-p,y-g).normalize(),e[4].setComponents(a-o,l-u,f-d,y-v).normalize(),e[5].setComponents(a+o,l+u,f+d,y+v).normalize(),this},intersectsObject:function(){var t=new ht;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new ht;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,r=t.center,i=-t.radius,n=0;n<6;n++){if(e[n].distanceToPoint(r)0?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}}),vt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],vt.DefaultOrder="XYZ",Object.defineProperties(vt.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(vt.prototype,{isEuler:!0,set:function(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._order=i||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var i=zp.clamp,n=t.elements,o=n[0],a=n[4],s=n[8],c=n[1],u=n[5],l=n[9],h=n[2],p=n[6],d=n[10];return e=e||this._order,"XYZ"===e?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-i(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(i(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-i(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===e?(this._z=Math.asin(i(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-l,u),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e?(this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new y;return function(e,r,i){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,i)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new g;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new v(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(yt.prototype,{set:function(t){this.mask=1<1){for(var i=0;i1){for(var i=0;i0){a.children=[];for(var c=0;c0&&(o.geometries=l),h.length>0&&(o.materials=h),p.length>0&&(o.textures=p),d.length>0&&(o.images=d)}return o.object=a,o},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){var r=this;if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var i=0;i0)for(var f=0;f0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r,i=this;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,i,n,o=this;for(r=0,i=this.faces.length;r0&&(e+=r[i].distanceTo(r[i-1])),t.lineDistances[i]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new lt),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new ht),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(!t||!t.isGeometry)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);var i,n=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,u=this.faceVertexUvs[0],l=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(i=(new pt).getNormalMatrix(e));for(var d=0,f=a.length;d=0;r--){var m=d[r];for(c.faces.splice(m,1),a=0,s=this.faceVertexUvs.length;a0,_=y.vertexNormals.length>0,w=1!==y.color.r||1!==y.color.g||1!==y.color.b,S=y.vertexColors.length>0,A=0;if(A=t(A,0,0),A=t(A,1,!0),A=t(A,2,!1),A=t(A,3,b),A=t(A,4,x),A=t(A,5,_),A=t(A,6,w),A=t(A,7,S),h.push(A),h.push(y.a,y.b,y.c),h.push(y.materialIndex),b){var M=n.faceVertexUvs[0][u];h.push(i(M[0]),i(M[1]),i(M[2]))}if(x&&h.push(e(y.normal)),_){var P=y.vertexNormals;h.push(e(P[0]),e(P[1]),e(P[2]))}if(w&&h.push(r(y.color)),S){var E=y.vertexColors;h.push(r(E[0]),r(E[1]),r(E[2]))}}return o.data={},o.data.vertices=c,o.data.normals=p,f.length>0&&(o.data.colors=f),g.length>0&&(o.data.uvs=[g]),o.data.faces=h,o},clone:function(){return(new Mt).copy(this)},copy:function(t){var e,r,i,n,o,a,s=this;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var c=t.vertices;for(e=0,r=c.length;e0,s=o[1]&&o[1].length>0,c=t.morphTargets,u=c.length;if(u>0){e=[];for(var l=0;l0){p=[];for(var l=0;l65535?Ot:Rt)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new Pt(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){(new pt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new y;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new y;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new y;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new y;return function(e,r,i){return t.makeTranslation(e,r,i),this.applyMatrix(t),this}}(),scale:function(){var t=new y;return function(e,r,i){return t.makeScale(e,r,i),this.applyMatrix(t),this}}(),lookAt:function(){var t=new bt;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new Dt(3*e.vertices.length,3),i=new Dt(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",i.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var n=new Dt(e.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var i;return!0===e.verticesNeedUpdate&&(i=this.attributes.position,void 0!==i&&(i.copyVector3sArray(e.vertices),i.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(i=this.attributes.normal,void 0!==i&&(i.copyVector3sArray(e.normals),i.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(i=this.attributes.color,void 0!==i&&(i.copyColorsArray(e.colors),i.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(i=this.attributes.uv,void 0!==i&&(i.copyVector2sArray(e.uvs),i.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(i=this.attributes.lineDistance,void 0!==i&&(i.copyArray(e.lineDistances),i.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new kt).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=this,r=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new Pt(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){var i=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Pt(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new Pt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var o=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Pt(o,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Pt(a,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var s=Bt(t.indices)>65535?Uint32Array:Uint16Array,c=new s(3*t.indices.length);this.setIndex(new Pt(c,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var u in t.morphTargets){for(var l=[],h=t.morphTargets[u],p=0,d=h.length;p0){var g=new Dt(4*t.skinIndices.length,4);this.addAttribute("skinIndex",g.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var v=new Dt(4*t.skinWeights.length,4);this.addAttribute("skinWeight",v.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new lt);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new lt,e=new v;return function(){null===this.boundingSphere&&(this.boundingSphere=new ht);var r=this.attributes.position;if(r){var i=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(i);for(var n=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Ft).copy(this)},copy:function(t){var e,r,i,n=this;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var o=t.index;null!==o&&this.setIndex(o.clone());var a=t.attributes;for(e in a){var s=a[e];n.addAttribute(e,s.clone())}var c=t.morphAttributes;for(e in c){var u=[],l=c[e];for(r=0,i=l.length;r0)if(s=p*f-d,c=p*d-f,l=h*g,s>=0)if(c>=-l)if(c<=l){var v=1/g;s*=v,c*=v,u=s*(s+p*c+2*d)+c*(p*s+c+2*f)+m}else c=h,s=Math.max(0,-(p*c+d)),u=-s*s+c*(c+2*f)+m;else c=-h,s=Math.max(0,-(p*c+d)),u=-s*s+c*(c+2*f)+m;else c<=-l?(s=Math.max(0,-(-p*h+d)),c=s>0?-h:Math.min(Math.max(-h,-f),h),u=-s*s+c*(c+2*f)+m):c<=l?(s=0,c=Math.min(Math.max(-h,-f),h),u=c*(c+2*f)+m):(s=Math.max(0,-(p*h+d)),c=s>0?h:Math.min(Math.max(-h,-f),h),u=-s*s+c*(c+2*f)+m);else c=p>0?-h:h,s=Math.max(0,-(p*c+d)),u=-s*s+c*(c+2*f)+m +;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),u}}(),intersectSphere:function(){var t=new v;return function(e,r){t.subVectors(e.center,this.origin);var i=t.dot(this.direction),n=t.dot(t)-i*i,o=e.radius*e.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=i-a,c=i+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,i,n,o,a,s,c=1/this.direction.x,u=1/this.direction.y,l=1/this.direction.z,h=this.origin;return c>=0?(r=(t.min.x-h.x)*c,i=(t.max.x-h.x)*c):(r=(t.max.x-h.x)*c,i=(t.min.x-h.x)*c),u>=0?(n=(t.min.y-h.y)*u,o=(t.max.y-h.y)*u):(n=(t.max.y-h.y)*u,o=(t.min.y-h.y)*u),r>o||n>i?null:((n>r||r!==r)&&(r=n),(o=0?(a=(t.min.z-h.z)*l,s=(t.max.z-h.z)*l):(a=(t.max.z-h.z)*l,s=(t.min.z-h.z)*l),r>s||a>i?null:((a>r||r!==r)&&(r=a),(s=0?r:i,e)))},intersectsBox:function(){var t=new v;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new v,e=new v,r=new v,i=new v;return function(n,o,a,s,c){e.subVectors(o,n),r.subVectors(a,n),i.crossVectors(e,r);var u,l=this.direction.dot(i);if(l>0){if(s)return null;u=1}else{if(!(l<0))return null;u=-1,l=-l}t.subVectors(this.origin,n);var h=u*this.direction.dot(r.crossVectors(t,r));if(h<0)return null;var p=u*this.direction.dot(e.cross(t));if(p<0)return null;if(h+p>l)return null;var d=-u*t.dot(i);return d<0?null:this.at(d/l,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(Ht.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new v).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new v).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new v;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new v,e=new v;return function(r,i){t.subVectors(r,this.start),e.subVectors(this.end,this.start);var n=e.dot(e),o=e.dot(t),a=o/n;return i&&(a=zp.clamp(a,0,1)),a}}(),closestPointToPoint:function(t,e,r){var i=this.closestPointToPointParameter(t,e),n=r||new v;return this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(Wt,{normal:function(){var t=new v;return function(e,r,i,n){var o=n||new v;o.subVectors(i,r),t.subVectors(e,r),o.cross(t);var a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),barycoordFromPoint:function(){var t=new v,e=new v,r=new v;return function(i,n,o,a,s){t.subVectors(a,n),e.subVectors(o,n),r.subVectors(i,n);var c=t.dot(t),u=t.dot(e),l=t.dot(r),h=e.dot(e),p=e.dot(r),d=c*h-u*u,f=s||new v;if(0===d)return f.set(-2,-1,-1);var m=1/d,g=(h*l-u*p)*m,y=(c*p-u*l)*m;return f.set(1-g-y,y,g)}}(),containsPoint:function(){var t=new v;return function(e,r,i,n){var o=Wt.barycoordFromPoint(e,r,i,n,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Wt.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new v,e=new v;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new v).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return Wt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new dt).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Wt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Wt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new dt,e=[new Ht,new Ht,new Ht],r=new v,i=new v;return function(n,o){var a=o||new v,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(n,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0){var s=o[a[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=c.length;tr.far?null:{distance:c,point:x.clone(),object:t}}function r(r,i,n,o,u,l,h,p){a.fromBufferAttribute(o,l),s.fromBufferAttribute(o,h),c.fromBufferAttribute(o,p);var g=e(r,r.material,i,n,a,s,c,b);return g&&(u&&(d.fromBufferAttribute(u,l),f.fromBufferAttribute(u,h),m.fromBufferAttribute(u,p),g.uv=t(b,a,s,c,d,f,m)),g.face=new St(l,h,p,Wt.normal(a,s,c)),g.faceIndex=l),g}var i=new y,n=new $t,o=new ht,a=new v,s=new v,c=new v,u=new v,l=new v,p=new v,d=new h,f=new h,m=new h,g=new v,b=new v,x=new v;return function(h,g){var v=this,y=this.geometry,x=this.material,_=this.matrixWorld;if(void 0!==x&&(null===y.boundingSphere&&y.computeBoundingSphere(),o.copy(y.boundingSphere),o.applyMatrix4(_),!1!==h.ray.intersectsSphere(o)&&(i.getInverse(_),n.copy(h.ray).applyMatrix4(i),null===y.boundingBox||!1!==n.intersectsBox(y.boundingBox)))){var w;if(y.isBufferGeometry){var S,A,M,P,E,T=y.index,C=y.attributes.position,I=y.attributes.uv;if(null!==T)for(P=0,E=T.count;P0&&(D=F);for(var z=0,U=B.length;zo)){var a=i.ray.origin.distanceTo(t);ai.far||n.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),Fe.prototype=Object.assign(Object.create(bt.prototype),{constructor:Fe,copy:function(t){var e=this;bt.prototype.copy.call(this,t,!1);for(var r=t.levels,i=0,n=r.length;i1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var n=t.distanceTo(e);i[0].object.visible=!0;for(var o=1,a=i.length;o=i[o].distance;o++)i[o-1].object.visible=!1,i[o].object.visible=!0;for(;os)){d.applyMatrix4(o.matrixWorld);var M=i.ray.origin.distanceTo(d);Mi.far||n.push({distance:M,point:p.clone().applyMatrix4(o.matrixWorld),index:x,face:null,faceIndex:null,object:o})}}else for(var x=0,_=y.length/3-1;x<_;x+=f){l.fromArray(y,3*x),h.fromArray(y,3*x+3);var A=e.distanceSqToSegment(l,h,d,p);if(!(A>s)){d.applyMatrix4(o.matrixWorld);var M=i.ray.origin.distanceTo(d);Mi.far||n.push({distance:M,point:p.clone().applyMatrix4(o.matrixWorld),index:x,face:null,faceIndex:null,object:o})}}}else if(c.isGeometry)for(var P=c.vertices,E=P.length,x=0;xs)){d.applyMatrix4(o.matrixWorld);var M=i.ray.origin.distanceTo(d);Mi.far||n.push({distance:M,point:p.clone().applyMatrix4(o.matrixWorld),index:x,face:null,faceIndex:null,object:o})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),$e.prototype=Object.assign(Object.create(Ge.prototype),{constructor:$e,isLineSegments:!0}),He.prototype=Object.assign(Object.create(Ge.prototype),{constructor:He,isLineLoop:!0}),We.prototype=Object.create(at.prototype),We.prototype.constructor=We,We.prototype.isPointsMaterial=!0,We.prototype.copy=function(t){return at.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Xe.prototype=Object.assign(Object.create(bt.prototype),{constructor:Xe,isPoints:!0,raycast:function(){var t=new y,e=new $t,r=new ht;return function(i,n){function o(t,r){var o=e.distanceSqToPoint(t);if(oi.far)return;n.push({distance:u,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=i.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),r.radius+=u,!1!==i.ray.intersectsSphere(r)){t.getInverse(c),e.copy(i.ray).applyMatrix4(t);var l=u/((this.scale.x+this.scale.y+this.scale.z)/3),h=l*l,p=new v;if(s.isBufferGeometry){var d=s.index,f=s.attributes,m=f.position.array;if(null!==d)for(var g=d.array,y=0,b=g.length;y=-Number.EPSILON&&T>=-Number.EPSILON&&E>=-Number.EPSILON))return!1;return!0}return function(e,r){var i=e.length;if(i<3)return null;var n,o,a,s=[],c=[],u=[];if(id.area(e)>0)for(o=0;o2;){if(h--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),r?u:s;if(n=o,l<=n&&(n=0),o=n+1,l<=o&&(o=0),a=o+1,l<=a&&(a=0),t(e,n,o,a,l,c)){var p,d,f,m,g;for(p=c[n],d=c[o],f=c[a],s.push([e[p],e[d],e[f]]),u.push([c[n],c[o],c[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function i(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=u*l-c*h)<0||f>p)return[]}else{if(d>0||d0||fM?[]:x===M?o?[]:[y]:_<=M?[y,b]:[y,S]}function o(t,e,r,i){var n=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,c=i.x-t.x,u=i.y-t.y,l=n*s-o*a,h=n*u-o*c;if(Math.abs(l)>Number.EPSILON){var p=c*s-u*a;return l>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,c,u,l,h,p={},d=t.concat(),f=0,m=e.length;f0;){if(--_<0){console.log('THREE.ShapeUtils: Infinite Loop! Holes left:" + indepHoles.length + ", Probably Hole outside Shape!');break}for(a=x;ai&&(a=0);var s=o(m[t],m[n],m[a],r[e]);if(!s)return!1;var c=r.length-1,u=e-1;u<0&&(u=c);var l=e+1;return l>c&&(l=0),!!(s=o(r[e],r[u],r[l],m[t]))}(a,w)&&!function(t,e){var r,i,o;for(r=0;r0)return!0;return!1}(s,c)&&!function(t,r){var i,o,a,s,c;for(i=0;i0)return!0;return!1}(s,c)){i=w,g.splice(y,1),h=m.slice(0,a+1),p=m.slice(a),d=r.slice(i),f=r.slice(0,i+1),m=h.concat(d).concat(f).concat(p),x=a;break}if(i>=0)break;v[l]=!0}if(i>=0)break}}return m}(t,e),v=id.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var d=Math.sqrt(l),f=Math.sqrt(c*c+u*u),m=e.x-s/d,g=e.y+a/d,v=r.x-u/f,y=r.y+c/f,b=((v-m)*u-(y-g)*c)/(a*u-s*c);i=m+a*b-t.x,n=g+s*b-t.y;var x=i*i+n*n;if(x<=2)return new h(i,n);o=Math.sqrt(x/2)}else{var _=!1;a>Number.EPSILON?c>Number.EPSILON&&(_=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(_=!0):Math.sign(s)===Math.sign(u)&&(_=!0),_?(i=-s,n=a,o=Math.sqrt(l)):(i=a,n=s,o=Math.sqrt(l/2))}return new h(i/o,n/o)}function n(t,e){var r,i;for(Z=t.length;--Z>=0;){r=Z,i=Z-1,i<0&&(i=t.length-1);var n=0,o=T+2*M;for(n=0;n=0;j--){for(G=j/M,$=S*Math.cos(G*Math.PI/2),V=A*Math.sin(G*Math.PI/2),Z=0,K=U.length;Z0||0===t.search(/^data\:image\/jpeg/);o.format=r?lp:hp,o.needsUpdate=!0,void 0!==e&&e(o)},r,i),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Qr.prototype=Object.assign(Object.create(bt.prototype),{constructor:Qr,isLight:!0,copy:function(t){return bt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=bt.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Jr.prototype=Object.assign(Object.create(Qr.prototype),{constructor:Jr,isHemisphereLight:!0,copy:function(t){return Qr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(ti.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),ei.prototype=Object.assign(Object.create(ti.prototype),{constructor:ei,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*zp.RAD2DEG*t.angle,i=this.mapSize.width/this.mapSize.height,n=t.distance||e.far;r===e.fov&&i===e.aspect&&n===e.far||(e.fov=r,e.aspect=i,e.far=n,e.updateProjectionMatrix())}}),ri.prototype=Object.assign(Object.create(Qr.prototype),{constructor:ri,isSpotLight:!0,copy:function(t){return Qr.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ii.prototype=Object.assign(Object.create(Qr.prototype),{constructor:ii,isPointLight:!0,copy:function(t){return Qr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),ni.prototype=Object.assign(Object.create(ti.prototype),{constructor:ni}),oi.prototype=Object.assign(Object.create(Qr.prototype),{constructor:oi,isDirectionalLight:!0,copy:function(t){return Qr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ai.prototype=Object.assign(Object.create(Qr.prototype),{constructor:ai,isAmbientLight:!0}),si.prototype=Object.assign(Object.create(Qr.prototype),{constructor:si,isRectAreaLight:!0,copy:function(t){return Qr.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Qr.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var cd={arraySlice:function(t,e,r){return cd.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){function e(e,r){return t[e]-t[r]}for(var r=t.length,i=new Array(r),n=0;n!==r;++n)i[n]=n;return i.sort(e),i},sortedArray:function(t,e,r){for(var i=t.length,n=new t.constructor(i),o=0,a=0;a!==i;++o)for(var s=r[o]*e,c=0;c!==e;++c)n[a++]=t[s+c];return n},flattenJSON:function(t,e,r,i){for(var n=1,o=t[0];void 0!==o&&void 0===o[i];)o=t[n++];if(void 0!==o){var a=o[i];if(void 0!==a)if(Array.isArray(a))do{a=o[i],void 0!==a&&(e.push(o.time),r.push.apply(r,a)),o=t[n++]}while(void 0!==o);else if(void 0!==a.toArray)do{a=o[i],void 0!==a&&(e.push(o.time),a.toArray(r,r.length)),o=t[n++]}while(void 0!==o);else do{a=o[i],void 0!==a&&(e.push(o.time),r.push(a)),o=t[n++]}while(void 0!==o)}}};Object.assign(ci.prototype,{evaluate:function(t){var e=this,r=this.parameterPositions,i=this._cachedIndex,n=r[i],o=r[i-1];t:{e:{var a;r:{i:if(!(t=o)break t;var c=r[1];t=o)break e}a=i,i=0}}for(;i>>1;te;)--o;if(++o,0!==n||o!==i){n>=o&&(o=Math.max(o,1),n=o-1);var a=this.getValueSize();this.times=cd.arraySlice(r,n,o),this.values=cd.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var t=this,e=!0,r=this.getValueSize();r-Math.floor(r)!=0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),e=!1);var i=this.times,n=this.values,o=i.length;0===o&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),e=!1);for(var a=null,s=0;s!==o;s++){var c=i[s];if("number"==typeof c&&isNaN(c)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",t,s,c),e=!1;break}if(null!==a&&a>c){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",t,s,c,a),e=!1;break}a=c}if(void 0!==n&&cd.isTypedArray(n))for(var s=0,u=n.length;s!==u;++s){var l=n[s];if(isNaN(l)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",t,s,l),e=!1;break}}return e},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),i=2302===this.getInterpolation(),n=1,o=t.length-1,a=1;a0){t[n]=t[o];for(var f=o*r,m=n*r,p=0;p!==r;++p)e[m+p]=e[f+p];++n}return n!==t.length&&(this.times=cd.arraySlice(t,0,n),this.values=cd.arraySlice(e,0,n*r)),this}},di.prototype=Object.assign(Object.create(ud),{constructor:di,ValueTypeName:"vector"}),fi.prototype=Object.assign(Object.create(ci.prototype),{constructor:fi,interpolate_:function(t,e,r,i){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(r-e)/(i-e),u=s+a;s!==u;s+=4)g.slerpFlat(n,0,o,s-a,o,s,c);return n}}),mi.prototype=Object.assign(Object.create(ud),{constructor:mi,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new fi(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),gi.prototype=Object.assign(Object.create(ud),{constructor:gi,ValueTypeName:"number"}),vi.prototype=Object.assign(Object.create(ud),{constructor:vi,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),yi.prototype=Object.assign(Object.create(ud),{constructor:yi,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),bi.prototype=Object.assign(Object.create(ud),{constructor:bi,ValueTypeName:"color"}),xi.prototype=ud,ud.constructor=xi,Object.assign(xi,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=xi._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],i=[];cd.flattenJSON(t.keys,r,i,"value"),t.times=r,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:cd.convertArray(t.times,Array),values:cd.convertArray(t.values,Array)};var i=t.getInterpolation();i!==t.DefaultInterpolation&&(e.interpolation=i)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gi;case"vector":case"vector2":case"vector3":case"vector4":return di;case"color":return bi;case"quaternion":return mi;case"bool":case"boolean":return yi;case"string":return vi}throw new Error("Unsupported typeName: "+t)}}),Object.assign(_i,{parse:function(t){for(var e=[],r=t.tracks,i=1/(t.fps||1),n=0,o=r.length;n!==o;++n)e.push(xi.parse(r[n]).scale(i));return new _i(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,i={name:t.name,duration:t.duration,tracks:e},n=0,o=r.length;n!==o;++n)e.push(xi.toJSON(r[n]));return i},CreateFromMorphTargetSequence:function(t,e,r,i){for(var n=e.length,o=[],a=0;a1){var u=c[1],l=i[u];l||(i[u]=l=[]),l.push(s)}}var h=[];for(var u in i)h.push(_i.CreateFromMorphTargetSequence(u,i[u],e,r));return h},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var r=function(t,e,r,i,n){if(0!==r.length){var o=[],a=[];cd.flattenJSON(r,o,a,i),0!==o.length&&n.push(new t(e,o,a))}},i=[],n=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[i+1]:0,s=r>2?t.skinWeights[i+2]:0,c=r>3?t.skinWeights[i+3]:0;e.skinWeights.push(new d(o,a,s,c))}if(t.skinIndices)for(var i=0,n=t.skinIndices.length;i1?t.skinIndices[i+1]:0,h=r>2?t.skinIndices[i+2]:0,p=r>3?t.skinIndices[i+3]:0;e.skinIndices.push(new d(u,l,h,p))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}function r(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var i=0,n=t.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var l=e.faces,h=t.morphColors[0].colors,i=0,n=l.length;i0&&(e.animations=r)}return function(n,o){void 0!==n.data&&(n=n.data),void 0!==n.scale?n.scale=1/n.scale:n.scale=1;var a=new Mt;return t(n,a),e(n,a),r(n,a),i(n,a),a.computeFaceNormals(),a.computeBoundingSphere(),void 0===n.materials||0===n.materials.length?{geometry:a}:{geometry:a,materials:Ai.prototype.initMaterials(n.materials,o,this.crossOrigin)}}}()}),Object.assign(Pi.prototype,{load:function(t,e,r,i){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var n=this;new Wr(n.manager).load(t,function(r){var o=null;try{o=JSON.parse(r)}catch(e){return void 0!==i&&i(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.");n.parse(o,e)},r,i)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),i=this.parseImages(t.images,function(){void 0!==e&&e(a)}),n=this.parseTextures(t.textures,i),o=this.parseMaterials(t.materials,n),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e=this,r={};if(void 0!==t)for(var i=new Mi,n=new Si,o=0,a=t.length;o0){var n=new Hr(e),o=new Yr(n);o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new je(c,u):new Xt(c,u);break;case"LOD":a=new Fe;break;case"Line":a=new Ge(n(e.geometry),o(e.material),e.mode);break;case"LineLoop":a=new He(n(e.geometry),o(e.material));break;case"LineSegments":a=new $e(n(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new Xe(n(e.geometry),o(e.material));break;case"Sprite":a=new Be(o(e.material));break;case"Group":a=new qe;break;default:a=new bt}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var l=e.children,h=0;h0)){c=n;break}c=n-1}if(n=c,i[n]===r)return n/(o-1);var u=i[n];return(n+(r-u)/(i[n+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var i=this.getPoint(e);return this.getPoint(r).clone().sub(i).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,i,n,o=this,a=new v,s=[],c=[],u=[],l=new v,h=new y;for(r=0;r<=t;r++)i=r/t,s[r]=o.getTangentAt(i),s[r].normalize();c[0]=new v,u[0]=new v;var p=Number.MAX_VALUE,d=Math.abs(s[0].x),f=Math.abs(s[0].y),m=Math.abs(s[0].z);for(d<=p&&(p=d,a.set(1,0,0)),f<=p&&(p=f,a.set(0,1,0)),m<=p&&a.set(0,0,1),l.crossVectors(s[0],a).normalize(),c[0].crossVectors(s[0],l),u[0].crossVectors(s[0],c[0]),r=1;r<=t;r++)c[r]=c[r-1].clone(),u[r]=u[r-1].clone(),l.crossVectors(s[r-1],s[r]),l.length()>Number.EPSILON&&(l.normalize(),n=Math.acos(zp.clamp(s[r-1].dot(s[r]),-1,1)),c[r].applyMatrix4(h.makeRotationAxis(l,n))),u[r].crossVectors(s[r],c[r]);if(!0===e)for(n=Math.acos(zp.clamp(c[0].dot(c[t]),-1,1)),n/=t,s[0].dot(l.crossVectors(c[0],c[t]))>0&&(n=-n),r=1;r<=t;r++)c[r].applyMatrix4(h.makeRotationAxis(s[r],n*r)),u[r].crossVectors(s[r],c[r]);return{tangents:s,normals:c,binormals:u}}}),Fi.prototype=Object.create(Bi.prototype),Fi.prototype.constructor=Fi,Fi.prototype.isLineCurve=!0,Fi.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},Fi.prototype.getPointAt=function(t){return this.getPoint(t)},Fi.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},zi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:zi,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Fi(e,t))},getPoint:function(t){for(var e=this,r=t*this.getLength(),i=this.getCurveLengths(),n=0;n=r){var o=i[n]-r,a=e.curves[n],s=a.getLength(),c=0===s?0:1-o/s;return a.getPointAt(c)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){var t=this;if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],r=0,i=0,n=this.curves.length;i1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Mt,r=0,i=t.length;re;)r-=e;re.length-2?e.length-1:i+1],c=e[i>e.length-3?e.length-1:i+2];return new h(Ei(n,o.x,a.x,s.x,c.x),Ei(n,o.y,a.y,s.y,c.y))},Vi.prototype=Object.create(Bi.prototype),Vi.prototype.constructor=Vi,Vi.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,n=this.v3;return new h(ki(t,e.x,r.x,i.x,n.x),ki(t,e.y,r.y,i.y,n.y))},Gi.prototype=Object.create(Bi.prototype),Gi.prototype.constructor=Gi,Gi.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new h(Ri(t,e.x,r.x,i.x),Ri(t,e.y,r.y,i.y))};var fd=Object.assign(Object.create(zi.prototype),{fromPoints:function(t){var e=this;this.moveTo(t[0].x,t[0].y);for(var r=1,i=t.length;r0){var u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)}});$i.prototype=fd,fd.constructor=$i,Hi.prototype=Object.assign(Object.create(fd),{constructor:Hi,getPointsHoles:function(t){for(var e=this,r=[],i=0,n=this.holes.length;i1){for(var v=!1,y=[],b=0,x=p.length;bNumber.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[n],u=-u),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var l=u*(t.x-a.x)-c*(t.y-a.y);if(0===l)return!0;if(l<0)continue;i=!i}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return i})(S.p,p[M].p)&&(b!==M&&y.push({froms:b,tos:M,hole:w}),A?(A=!1,h[M].push(S)):v=!0);A&&h[b].push(S)}y.length>0&&(v||(d=h))}for(var P,m=0,E=p.length;m0){this.source.connect(this.filters[0]);for(var e=1,r=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,r=this.filters.length;e=.5)for(var o=0;o!==n;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,i){g.slerpFlat(t,e,t,e,t,r,i)},_lerp:function(t,e,r,i,n){for(var o=1-i,a=0;a!==n;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*i}}}),Object.assign(nn.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,i=this._bindings[r];void 0!==i&&i.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,i=this._targetGroup.nCachedObjects_,n=r.length;i!==n;++i)r[i].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(on,{Composite:nn,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new on.Composite(t,e,r):new on(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=/((?:[\w-]+[\/:])*)/,e=/([\w-\.]+)?/,r=/(?:\.([\w-]+)(?:\[(.+)\])?)?/,i=/\.([\w-]+)(?:\[(.+)\])?/,n=new RegExp("^"+t.source+e.source+r.source+i.source+"$"),o=["material","materials","bones"];return function(t){var e=n.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var a=r.nodeName.substring(i+1);-1!==o.indexOf(a)&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=a)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}}(),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r=i){var p=i++,d=r[p];n[d.uuid]=h,r[h]=d,n[l]=p,r[p]=u;for(var f=0,m=a;f!==m;++f){var g=o[f],v=g[p],y=g[h];g[h]=v,g[p]=y}}}this.nCachedObjects_=i},uncache:function(t){for(var e=arguments,r=this._objects,i=r.length,n=this.nCachedObjects_,o=this._indicesByUUID,a=this._bindings,s=a.length,c=0,u=arguments.length;c!==u;++c){var l=e[c],h=l.uuid,p=o[h];if(void 0!==p)if(delete o[h],p0)for(var c=this._interpolants,u=this._propertyBindings,l=0,h=c.length;l!==h;++l)c[l].evaluate(a),u[l].accumulate(i,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,i=this.loop,n=this._loopCount;if(2200===i){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===i;if(-1===n&&(t>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&n))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var i=this._interpolantSettings;r?(i.endingStart=2401,i.endingEnd=2401):(i.endingStart=t?this.zeroSlopeAtStart?2401:Pp:2402,i.endingEnd=e?this.zeroSlopeAtEnd?2401:Pp:2402)},_scheduleFading:function(t,e,r){var i=this._mixer,n=i.time,o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=e,a[1]=n+t,s[1]=r,this}}),Object.assign(cn.prototype,l.prototype,{_bindAction:function(t,e){var r=this,i=t._localRoot||this._root,n=t._clip.tracks,o=n.length,a=t._propertyBindings,s=t._interpolants,c=i.uuid,u=this._bindingsByRootAndName,l=u[c];void 0===l&&(l={},u[c]=l);for(var h=0;h!==o;++h){var p=n[h],d=p.name,f=l[d];if(void 0!==f)a[h]=f;else{if(void 0!==(f=a[h])){null===f._cacheIndex&&(++f.referenceCount,r._addInactiveBinding(f,c,d));continue}var m=e&&e._propertyBindings[h].binding.parsedPath;f=new rn(on.create(i,d,m),p.ValueTypeName,p.getValueSize()),++f.referenceCount,r._addInactiveBinding(f,c,d),a[h]=f}s[h].resultBuffer=f.buffer}},_activateAction:function(t){var e=this;if(!this._isActiveAction(t)){if(null===t._cacheIndex){var r=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,r)}for(var o=t._propertyBindings,a=0,s=o.length;a!==s;++a){var c=o[a];0==c.useCount++&&(e._lendBinding(c),c.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){var e=this;if(this._isActiveAction(t)){for(var r=t._propertyBindings,i=0,n=r.length;i!==n;++i){var o=r[i];0==--o.useCount&&(o.restoreOriginalState(),e._takeBackBinding(o))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),Bn.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},Bn.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Fn.prototype=Object.create($e.prototype),Fn.prototype.constructor=Fn;var bd=new v,xd=new zn,_d=new zn,wd=new zn;Un.prototype=Object.create(Bi.prototype),Un.prototype.constructor=Un,Un.prototype.getPoint=function(t){var e=this.points,r=e.length,i=(r-(this.closed?0:1))*t,n=Math.floor(i),o=i-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/e.length)+1)*e.length:0===o&&n===r-1&&(n=r-2,o=1);var a,s,c,u;if(this.closed||n>0?a=e[(n-1)%r]:(bd.subVectors(e[0],e[1]).add(e[0]),a=bd),s=e[n%r],c=e[(n+1)%r],this.closed||n+2r&&(t=r),t},Xf=function(t){return t.length>=3?[].slice.call(t):t[0]},$d=function(t){var e,r;for(t._clipped=!1,t._unclipped=t.slice(0),e=r=0;r<3;e=++r)e<3?((t[e]<0||t[e]>255)&&(t._clipped=!0),t[e]<0&&(t[e]=0),t[e]>255&&(t[e]=255)):3===e&&(t[e]<0&&(t[e]=0),t[e]>1&&(t[e]=1));return t._clipped||delete t._unclipped,t},Td=Math.PI,jf=Math.round,Wd=Math.cos,Kd=Math.floor,Mf=Math.pow,vf=Math.log,Gf=Math.sin,$f=Math.sqrt,Bd=Math.atan2,xf=Math.max,kd=Math.abs,Rd=2*Td,Cd=Td/3,Pd=Td/180,Id=180/Td,Gd=function(){return arguments[0]instanceof Md?arguments[0]:function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,arguments,function(){})},Nd=[],Gd.version="1.3.3",Dd={},Ld=[],Od=!1,Md=function(){function t(){var t,e,r,i,n,o,a,s,c,u=arguments;for(o=this,e=[],s=0,i=arguments.length;s3?e[3]:1]},Zf=function(t){return 255*(t<=.00304?12.92*t:1.055*Mf(t,1/2.4)-.055)},pf=function(t){return t>Ed.t1?t*t*t:Ed.t2*(t-Ed.t0)},Ed={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},Of=function(){var t,e,r,i,n,o,a,s;return i=Xf(arguments),r=i[0],e=i[1],t=i[2],n=Ff(r,e,t),o=n[0],a=n[1],s=n[2],[116*a-16,500*(o-a),200*(a-s)]},zf=function(t){return(t/=255)<=.04045?t/12.92:Mf((t+.055)/1.055,2.4)},Yf=function(t){return t>Ed.t3?Mf(t,1/3):t/Ed.t2+Ed.t0},Ff=function(){var t,e,r,i,n,o,a;return i=Xf(arguments),r=i[0],e=i[1],t=i[2],r=zf(r),e=zf(e),t=zf(t),n=Yf((.4124564*r+.3575761*e+.1804375*t)/Ed.Xn),o=Yf((.2126729*r+.7151522*e+.072175*t)/Ed.Yn),a=Yf((.0193339*r+.119192*e+.9503041*t)/Ed.Zn),[n,o,a]},Gd.lab=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["lab"]),function(){})},Dd.lab=hf,Md.prototype.lab=function(){return Of(this._rgb)},Fd=function(t){var e,r,i,n,o,a,s,c,u,l,h;return t=function(){var e,r,i;for(i=[],r=0,e=t.length;r=360;)r-=360;d[u]=r}return Gd(d,e).alpha(i/l)},Dd.rgb=function(){var t,e,r,i;e=Xf(arguments),r=[];for(t in e)i=e[t],r.push(i);return r},Gd.rgb=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["rgb"]),function(){})},Md.prototype.rgb=function(t){return null==t&&(t=!0),t?this._rgb.map(Math.round).slice(0,3):this._rgb.slice(0,3)},Md.prototype.rgba=function(t){return null==t&&(t=!0),t?[Math.round(this._rgb[0]),Math.round(this._rgb[1]),Math.round(this._rgb[2]),this._rgb[3]]:this._rgb.slice(0)},Ld.push({p:3,test:function(t){var e;return e=Xf(arguments),"array"===Wf(e)&&3===e.length?"rgb":4===e.length&&"number"===Wf(e[3])&&e[3]>=0&&e[3]<=1?"rgb":void 0}}),Jd=function(t){var e,r,i,n,o,a;if(t.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),a=parseInt(t,16),n=a>>16,i=a>>8&255,r=255&a,[n,i,r,1];if(t.match(/^#?([A-Fa-f0-9]{8})$/))return 9===t.length&&(t=t.substr(1)),a=parseInt(t,16),n=a>>24&255,i=a>>16&255,r=a>>8&255,e=jf((255&a)/255*100)/100,[n,i,r,e];if(null!=Dd.css&&(o=Dd.css(t)))return o;throw"unknown color: "+t},Cf=function(t,e){var r,i,n,o,a,s,c;return null==e&&(e="rgb"),a=t[0],n=t[1],i=t[2],r=t[3],a=Math.round(a),n=Math.round(n),i=Math.round(i),c=a<<16|n<<8|i,s="000000"+c.toString(16),s=s.substr(s.length-6),o="0"+jf(255*r).toString(16),o=o.substr(o.length-2),"#"+function(){switch(e.toLowerCase()){case"rgba":return s+o;case"argb":return o+s;default:return s}}()},Dd.hex=function(t){return Jd(t)},Gd.hex=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["hex"]),function(){})},Md.prototype.hex=function(t){return null==t&&(t="rgb"),Cf(this._rgb,t)},Ld.push({p:4,test:function(t){if(1===arguments.length&&"string"===Wf(t))return"hex"}}),rf=function(){var t,e,r,i,n,o,a,s,c,u,l,h,p,d;if(t=Xf(arguments),n=t[0],l=t[1],a=t[2],0===l)c=i=e=255*a;else{for(d=[0,0,0],r=[0,0,0],p=a<.5?a*(1+l):a+l-a*l,h=2*a-p,n/=360,d[0]=n+1/3,d[1]=n,d[2]=n-1/3,o=s=0;s<=2;o=++s)d[o]<0&&(d[o]+=1),d[o]>1&&(d[o]-=1),6*d[o]<1?r[o]=h+6*(p-h)*d[o]:2*d[o]<1?r[o]=p:3*d[o]<2?r[o]=h+(p-h)*(2/3-d[o])*6:r[o]=h;u=[jf(255*r[0]),jf(255*r[1]),jf(255*r[2])],c=u[0],i=u[1],e=u[2]}return t.length>3?[c,i,e,t[3]]:[c,i,e]},Rf=function(t,e,r){var i,n,o,a,s;return void 0!==t&&t.length>=3&&(a=t,t=a[0],e=a[1],r=a[2]),t/=255,e/=255,r/=255,o=Math.min(t,e,r),xf=Math.max(t,e,r),n=(xf+o)/2,xf===o?(s=0,i=Number.NaN):s=n<.5?(xf-o)/(xf+o):(xf-o)/(2-xf-o),t===xf?i=(e-r)/(xf-o):e===xf?i=2+(r-t)/(xf-o):r===xf&&(i=4+(t-e)/(xf-o)),i*=60,i<0&&(i+=360),[i,s,n]},Gd.hsl=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["hsl"]),function(){})},Dd.hsl=rf,Md.prototype.hsl=function(){return Rf(this._rgb)},nf=function(){var t,e,r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v;if(t=Xf(arguments),n=t[0],m=t[1],v=t[2],v*=255,0===m)c=i=e=v;else switch(360===n&&(n=0),n>360&&(n-=360),n<0&&(n+=360),n/=60,o=Kd(n),r=n-o,a=v*(1-m),s=v*(1-m*r),g=v*(1-m*(1-r)),o){case 0:u=[v,g,a],c=u[0],i=u[1],e=u[2];break;case 1:l=[s,v,a],c=l[0],i=l[1],e=l[2];break;case 2:h=[a,v,g],c=h[0],i=h[1],e=h[2];break;case 3:p=[a,s,v],c=p[0],i=p[1],e=p[2];break;case 4:d=[g,a,v],c=d[0],i=d[1],e=d[2];break;case 5:f=[v,a,s],c=f[0],i=f[1],e=f[2]}return[c,i,e,t.length>3?t[3]:1]},Lf=function(){var t,e,r,i,n,o,a,s,c;return a=Xf(arguments),o=a[0],r=a[1],t=a[2],n=Math.min(o,r,t),xf=Math.max(o,r,t),e=xf-n,c=xf/255,0===xf?(i=Number.NaN,s=0):(s=e/xf,o===xf&&(i=(r-t)/e),r===xf&&(i=2+(t-o)/e),t===xf&&(i=4+(o-r)/e),(i*=60)<0&&(i+=360)),[i,s,c]},Gd.hsv=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["hsv"]),function(){})},Dd.hsv=nf,Md.prototype.hsv=function(){return Lf(this._rgb)},Sf=function(t){var e,r,i;return"number"===Wf(t)&&t>=0&&t<=16777215?(i=t>>16,r=t>>8&255,e=255&t,[i,r,e,1]):(console.warn("unknown num color: "+t),[0,0,0,1])},kf=function(){var t,e,r,i;return i=Xf(arguments),r=i[0],e=i[1],t=i[2],(r<<16)+(e<<8)+t},Gd.num=function(t){return new Md(t,"num")},Md.prototype.num=function(t){return null==t&&(t="rgb"),kf(this._rgb,t)},Dd.num=Sf,Ld.push({p:1,test:function(t){if(1===arguments.length&&"number"===Wf(t)&&t>=0&&t<=16777215)return"num"}}),Qd=function(){var t,e,r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b;if(r=Xf(arguments),s=r[0],n=r[1],e=r[2],n/=100,a=a/100*255,t=255*n,0===n)h=a=i=e;else switch(360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360),s/=60,c=Kd(s),o=s-c,u=e*(1-n),l=u+t*(1-o),y=u+t*o,b=u+t,c){case 0:p=[b,y,u],h=p[0],a=p[1],i=p[2];break;case 1:d=[l,b,u],h=d[0],a=d[1],i=d[2];break;case 2:f=[u,b,y],h=f[0],a=f[1],i=f[2];break;case 3:m=[u,l,b],h=m[0],a=m[1],i=m[2];break;case 4:g=[y,u,b],h=g[0],a=g[1],i=g[2];break;case 5:v=[b,u,l],h=v[0],a=v[1],i=v[2]}return[h,a,i,r.length>3?r[3]:1]},Tf=function(){var t,e,r,i,n,o,a,s,c;return c=Xf(arguments),s=c[0],n=c[1],e=c[2],a=Math.min(s,n,e),xf=Math.max(s,n,e),i=xf-a,r=100*i/255,t=a/(255-i)*100,0===i?o=Number.NaN:(s===xf&&(o=(n-e)/i),n===xf&&(o=2+(e-s)/i),e===xf&&(o=4+(s-n)/i),(o*=60)<0&&(o+=360)),[o,r,t]},Gd.hcg=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["hcg"]),function(){})},Dd.hcg=Qd,Md.prototype.hcg=function(){return Tf(this._rgb)},Xd=function(t){var e,r,i,n,o,a,s,c;if(t=t.toLowerCase(),null!=Gd.colors&&Gd.colors[t])return Jd(Gd.colors[t]);if(o=t.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=o.slice(1,4),n=a=0;a<=2;n=++a)s[n]=+s[n];s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(s=o.slice(1,5),n=c=0;c<=3;n=++c)s[n]=+s[n];else if(o=t.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=o.slice(1,4),n=e=0;e<=2;n=++e)s[n]=jf(2.55*s[n]);s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(s=o.slice(1,5),n=r=0;r<=2;n=++r)s[n]=jf(2.55*s[n]);s[3]=+s[3]}else(o=t.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(i=o.slice(1,4),i[1]*=.01,i[2]*=.01,s=rf(i),s[3]=1):(o=t.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(i=o.slice(1,4),i[1]*=.01,i[2]*=.01,s=rf(i),s[3]=+o[4]);return s},Ef=function(t){var e;return e=t[3]<1?"rgba":"rgb","rgb"===e?e+"("+t.slice(0,3).map(jf).join(",")+")":"rgba"===e?e+"("+t.slice(0,3).map(jf).join(",")+","+t[3]+")":void 0},Uf=function(t){return jf(100*t)/100},ef=function(t,e){var r;return r=e<1?"hsla":"hsl",t[0]=Uf(t[0]||0),t[1]=Uf(100*t[1])+"%",t[2]=Uf(100*t[2])+"%","hsla"===r&&(t[3]=e),r+"("+t.join(",")+")"},Dd.css=function(t){return Xd(t)},Gd.css=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["css"]),function(){})},Md.prototype.css=function(t){return null==t&&(t="rgb"),"rgb"===t.slice(0,3)?Ef(this._rgb):"hsl"===t.slice(0,3)?ef(this.hsl(),this.alpha()):void 0},Dd.named=function(t){return Jd(qf[t])},Ld.push({p:5,test:function(t){if(1===arguments.length&&null!=qf[t])return"named"}}),Md.prototype.name=function(t){var e,r;arguments.length&&(qf[t]&&(this._rgb=Jd(qf[t])),this._rgb[3]=1),e=this.hex();for(r in qf)if(e===qf[r])return r;return e},df=function(){var t,e,r,i;return i=Xf(arguments),r=i[0],t=i[1],e=i[2],e*=Pd,[r,Wd(e)*t,Gf(e)*t]},ff=function(){var t,e,r,i,n,o,a,s,c,u,l;return r=Xf(arguments),s=r[0],n=r[1],a=r[2],u=df(s,n,a),t=u[0],e=u[1],i=u[2],l=hf(t,e,i),c=l[0],o=l[1],i=l[2],[c,o,i,r.length>3?r[3]:1]},lf=function(){var t,e,r,i,n,o;return o=Xf(arguments),n=o[0],t=o[1],e=o[2],r=$f(t*t+e*e),i=(Bd(e,t)*Id+360)%360,0===jf(1e4*r)&&(i=Number.NaN),[n,r,i]},Df=function(){var t,e,r,i,n,o,a;return o=Xf(arguments),n=o[0],r=o[1],e=o[2],a=Of(n,r,e),i=a[0],t=a[1],e=a[2],lf(i,t,e)},Gd.lch=function(){var t;return t=Xf(arguments),new Md(t,"lch")},Gd.hcl=function(){var t;return t=Xf(arguments),new Md(t,"hcl")},Dd.lch=ff,Dd.hcl=function(){var t,e,r,i;return i=Xf(arguments),e=i[0],t=i[1],r=i[2],ff([r,t,e])},Md.prototype.lch=function(){return Df(this._rgb)},Md.prototype.hcl=function(){return Df(this._rgb).reverse()},Pf=function(t){var e,r,i,n,o,a,s,c,u;return null==t&&(t="rgb"),c=Xf(arguments),s=c[0],n=c[1],e=c[2],s/=255,n/=255,e/=255,o=1-Math.max(s,Math.max(n,e)),i=o<1?1/(1-o):0,r=(1-s-o)*i,a=(1-n-o)*i,u=(1-e-o)*i,[r,a,u,o]},Hd=function(){var t,e,r,i,n,o,a,s,c;return e=Xf(arguments),i=e[0],a=e[1],c=e[2],o=e[3],t=e.length>4?e[4]:1,1===o?[0,0,0,t]:(s=i>=1?0:255*(1-i)*(1-o),n=a>=1?0:255*(1-a)*(1-o),r=c>=1?0:255*(1-c)*(1-o),[s,n,r,t])},Dd.cmyk=function(){return Hd(Xf(arguments))},Gd.cmyk=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["cmyk"]),function(){})},Md.prototype.cmyk=function(){return Pf(this._rgb)},Dd.gl=function(){var t,e,r,i,n;for(i=function(){var t,r;t=Xf(arguments),r=[];for(e in t)n=t[e],r.push(n);return r}.apply(this,arguments),t=r=0;r<=2;t=++r)i[t]*=255;return i},Gd.gl=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["gl"]),function(){})},Md.prototype.gl=function(){var t;return t=this._rgb,[t[0]/255,t[1]/255,t[2]/255,t[3]]},Nf=function(t,e,r){var i;return i=Xf(arguments),t=i[0],e=i[1],r=i[2],t=yf(t),e=yf(e),r=yf(r),.2126*t+.7152*e+.0722*r},yf=function(t){return t/=255,t<=.03928?t/12.92:Mf((t+.055)/1.055,2.4)},Nd=[],of=function(t,e,r,i){var n,o,a,s;for(null==r&&(r=.5),null==i&&(i="rgb"),"object"!==Wf(t)&&(t=Gd(t)),"object"!==Wf(e)&&(e=Gd(e)),a=0,o=Nd.length;at?o(r,c):o(c,a)},r=Nf(this._rgb),this._rgb=(r>t?o(Gd("black"),this):o(this,Gd("white"))).rgba()),this):Nf(this._rgb)},Hf=function(t){var e,r,i,n;return n=t/100,n<66?(i=255,r=-155.25485562709179-.44596950469579133*(r=n-2)+104.49216199393888*vf(r),e=n<20?0:.8274096064007395*(e=n-10)-254.76935184120902+115.67994401066147*vf(e)):(i=351.97690566805693+.114206453784165*(i=n-55)-40.25366309332127*vf(i),r=325.4494125711974+.07943456536662342*(r=n-50)-28.0852963507957*vf(r),e=255),[i,r,e]},Bf=function(){var t,e,r,i,n,o,a,s;for(o=Xf(arguments),n=o[0],t=o[2],i=1e3,r=4e4,e=.4;r-i>e;)s=.5*(r+i),a=Hf(s),a[2]/a[0]>=t/n?r=s:i=s;return jf(s)},Gd.temperature=Gd.kelvin=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["temperature"]),function(){})},Dd.temperature=Dd.kelvin=Dd.K=Hf,Md.prototype.temperature=function(){return Bf(this._rgb)},Md.prototype.kelvin=Md.prototype.temperature,Gd.contrast=function(t,e){var r,i,n,o;return"string"!==(n=Wf(t))&&"number"!==n||(t=new Md(t)),"string"!==(o=Wf(e))&&"number"!==o||(e=new Md(e)),r=t.luminance(),i=e.luminance(),r>i?(r+.05)/(i+.05):(i+.05)/(r+.05)},Gd.distance=function(t,e,r){var i,n,o,a,s,c,u;null==r&&(r="lab"),"string"!==(s=Wf(t))&&"number"!==s||(t=new Md(t)),"string"!==(c=Wf(e))&&"number"!==c||(e=new Md(e)),o=t.get(r),a=e.get(r),u=0;for(n in o)i=(o[n]||0)-(a[n]||0),u+=i*i;return Math.sqrt(u)},Gd.deltaE=function(t,e,r,i){var n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,E,T,C,I;for(null==r&&(r=1),null==i&&(i=1),"string"!==(x=Wf(t))&&"number"!==x||(t=new Md(t)),"string"!==(_=Wf(e))&&"number"!==_||(e=new Md(e)),w=t.lab(),n=w[0],a=w[1],c=w[2],S=e.lab(),o=S[0],s=S[1],u=S[2],l=$f(a*a+c*c),h=$f(s*s+u*u),P=n<16?.511:.040975*n/(1+.01765*n),A=.0638*l/(1+.0131*l)+.638,b=l<1e-6?0:180*Bd(c,a)/Td;b<0;)b+=360;for(;b>=360;)b-=360;return E=b>=164&&b<=345?.56+kd(.2*Wd(Td*(b+168)/180)):.36+kd(.4*Wd(Td*(b+35)/180)),p=l*l*l*l,y=$f(p/(p+1900)),M=A*(y*E+1-y),v=n-o,g=l-h,f=a-s,m=c-u,d=f*f+m*m-g*g,T=v/(r*P),C=g/(i*A),I=M,$f(T*T+C*C+d/(I*I))},Md.prototype.get=function(t){var e,r,i,n,o,a;return i=this,o=t.split("."),n=o[0],e=o[1],a=i[n](),e?(r=n.indexOf(e),r>-1?a[r]:console.warn("unknown channel "+e+" in mode "+n)):a},Md.prototype.set=function(t,e){var r,i,n,o,a,s;if(n=this,a=t.split("."),o=a[0],r=a[1],r)if(s=n[o](),(i=o.indexOf(r))>-1)if("string"===Wf(e))switch(e.charAt(0)){case"+":case"-":s[i]+=+e;break;case"*":s[i]*=+e.substr(1);break;case"/":s[i]/=+e.substr(1);break;default:s[i]=+e}else s[i]=e;else console.warn("unknown channel "+r+" in mode "+o);else s=e;return Gd(s,o).alpha(n.alpha())},Md.prototype.clipped=function(){return this._rgb._clipped||!1},Md.prototype.alpha=function(t){return arguments.length?Gd.rgb([this._rgb[0],this._rgb[1],this._rgb[2],t]):this._rgb[3]},Md.prototype.darken=function(t){var e,r;return null==t&&(t=1),r=this,e=r.lab(),e[0]-=Ed.Kn*t,Gd.lab(e).alpha(r.alpha())},Md.prototype.brighten=function(t){return null==t&&(t=1),this.darken(-t)},Md.prototype.darker=Md.prototype.darken,Md.prototype.brighter=Md.prototype.brighten,Md.prototype.saturate=function(t){var e,r;return null==t&&(t=1),r=this,e=r.lch(),e[1]+=t*Ed.Kn,e[1]<0&&(e[1]=0),Gd.lch(e).alpha(r.alpha())},Md.prototype.desaturate=function(t){return null==t&&(t=1),this.saturate(-t)},Md.prototype.premultiply=function(){var t,e;return e=this.rgb(),t=this.alpha(),Gd(e[0]*t,e[1]*t,e[2]*t,t)},zd=function(t,e,r){if(!zd[r])throw"unknown blend mode "+r;return zd[r](t,e)},Ud=function(t){return function(e,r){var i,n;return i=Gd(r).rgb(),n=Gd(e).rgb(),Gd(t(i,n),"rgb")}},Zd=function(t){return function(e,r){var i,n,o;for(o=[],i=n=0;n<=3;i=++n)o[i]=t(e[i],r[i]);return o}},wf=function(t,e){return t},_f=function(t,e){return t*e/255},qd=function(t,e){return t>e?e:t},mf=function(t,e){return t>e?t:e},Vf=function(t,e){return 255*(1-(1-t/255)*(1-e/255))},Af=function(t,e){return e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255))},Vd=function(t,e){return 255*(1-(1-e/255)/(t/255))},Yd=function(t,e){return 255===t?255:(t=e/255*255/(1-t/255),t>255?255:t)},zd.normal=Ud(Zd(wf)),zd.multiply=Ud(Zd(_f)),zd.screen=Ud(Zd(Vf)),zd.overlay=Ud(Zd(Af)),zd.darken=Ud(Zd(qd)),zd.lighten=Ud(Zd(mf)),zd.dodge=Ud(Zd(Yd)),zd.burn=Ud(Zd(Vd)),Gd.blend=zd,Gd.analyze=function(t){var e,r,i,n;for(i={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},r=0,e=t.length;ri.max&&(i.max=n),i.count+=1);return i.domain=[i.min,i.max],i.limits=function(t,e){return Gd.limits(i,t,e)},i},Gd.scale=function(t,e){var r,i,n,o,a,s,c,u,l,h,p,d,f,m,g,v,y,b,x,_;return u="rgb",l=Gd("#ccc"),f=0,a=[0,1],d=[],p=[0,0],r=!1,n=[],h=!1,c=0,s=1,o=!1,i={},m=!0,x=function(t){var e,r,i,o,a,s;if(null==t&&(t=["#fff","#000"]),null!=t&&"string"===Wf(t)&&null!=Gd.brewer&&(t=Gd.brewer[t]||Gd.brewer[t.toLowerCase()]||t),"array"===Wf(t)){for(t=t.slice(0),e=i=0,o=t.length-1;0<=o?i<=o:i>=o;e=0<=o?++i:--i)r=t[e],"string"===Wf(r)&&(t[e]=Gd(r));for(d.length=0,e=s=0,a=t.length-1;0<=a?s<=a:s>=a;e=0<=a?++s:--s)d.push(e/(t.length-1))}return b(),n=t},v=function(t){var e,i;if(null!=r){for(i=r.length-1,e=0;e=r[e];)e++;return e-1}return 0},_=function(t){return t},y=function(t,e){var o,a,h,f,g,y,b,x;if(null==e&&(e=!1),isNaN(t))return l;if(e?x=t:r&&r.length>2?(o=v(t),x=o/(r.length-2),x=p[0]+x*(1-p[0]-p[1])):s!==c?(x=(t-c)/(s-c),x=p[0]+x*(1-p[0]-p[1]),x=Math.min(1,Math.max(0,x))):x=1,e||(x=_(x)),f=Math.floor(1e4*x),m&&i[f])a=i[f];else{if("array"===Wf(n))for(h=g=0,b=d.length-1;0<=b?g<=b:g>=b;h=0<=b?++g:--g){if(y=d[h],x<=y){a=n[h];break}if(x>=y&&h===d.length-1){a=n[h];break}if(x>y&&x=l;e=0<=l?++h:--h)d.push(e/(i-1));return a=[c,s],g},g.mode=function(t){return arguments.length?(u=t,b(),g):u},g.range=function(t,e){return x(t,e),g},g.out=function(t){return h=t,g},g.spread=function(t){return arguments.length?(f=t,g):f},g.correctLightness=function(t){return null==t&&(t=!0),o=t,b(),_=o?function(t){var e,r,i,n,o,a,s,c,u;for(e=y(0,!0).lab()[0],r=y(1,!0).lab()[0],s=e>r,i=y(t,!0).lab()[0],o=e+(r-e)*t,n=i-o,c=0,u=1,a=20;Math.abs(n)>.01&&a-- >0;)!function(){s&&(n*=-1),n<0?(c=t,t+=.5*(u-t)):(u=t,t+=.5*(c-t)),i=y(t,!0).lab()[0],n=i-o}();return t}:function(t){return t},g},g.padding=function(t){return null!=t?("number"===Wf(t)&&(t=[t,t]),p=t,g):p},g.colors=function(e,i){var o,s,c,u,l,h,p;if(null==i&&(i="hex"),0===arguments.length)return n.map(function(t){return t[i]()});if(e)return 1===e?g(.5)[i]():(s=a[0],o=a[1]-s,function(){l=[];for(var t=0;0<=e?te;0<=e?t++:t--)l.push(t);return l}.apply(this).map(function(t){return g(s+t/(e-1)*o)[i]()}));if(t=[],h=[],r&&r.length>2)for(c=p=1,u=r.length;1<=u?pu;c=1<=u?++p:--p)h.push(.5*(r[c-1]+r[c]));else h=a;return h.map(function(t){return g(t)[i]()})},g.cache=function(t){return null!=t?m=t:m},g},null==Gd.scales&&(Gd.scales={}),Gd.scales.cool=function(){return Gd.scale([Gd.hsl(180,1,.9),Gd.hsl(250,.7,.4)])},Gd.scales.hot=function(){return Gd.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},Gd.analyze=function(t,e,r){var i,n,o,a,s,c,u;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==r&&(r=function(){return!0}),i=function(t){null==t||isNaN(t)||(s.values.push(t),s.sum+=t,ts.max&&(s.max=t),s.count+=1)},u=function(t,n){if(r(t,n))return i(null!=e&&"function"===Wf(e)?e(t):null!=e&&"string"===Wf(e)||"number"===Wf(e)?t[e]:t)},"array"===Wf(t))for(a=0,o=t.length;a=B;w=1<=B?++O:--O)M.push(E+w/r*(xf-E));M.push(xf)}else if("l"===e.substr(0,1)){if(E<=0)throw"Logarithmic scales are only possible for values > 0";for(T=Math.LOG10E*vf(E),P=Math.LOG10E*vf(xf),M.push(E),w=it=1,F=r-1;1<=F?it<=F:it>=F;w=1<=F?++it:--it)M.push(Mf(10,T+w/r*(P-T)));M.push(xf)}else if("q"===e.substr(0,1)){for(M.push(E),w=i=1,$=r-1;1<=$?i<=$:i>=$;w=1<=$?++i:--i)D=(rt.length-1)*w/r,N=Kd(D),N===D?M.push(rt[N]):(k=D-N,M.push(rt[N]*(1-k)+rt[N+1]*k));M.push(xf)}else if("k"===e.substr(0,1)){for(I=rt.length,g=new Array(I),x=new Array(r),Q=!0,R=0,y=null,y=[],y.push(E),w=n=1,H=r-1;1<=H?n<=H:n>=H;w=1<=H?++n:--n)y.push(E+w/r*(xf-E));for(y.push(xf);Q;){for(S=o=0,W=r-1;0<=W?o<=W:o>=W;S=0<=W?++o:--o)x[S]=0;for(w=a=0,X=I-1;0<=X?a<=X:a>=X;w=0<=X?++a:--a){for(et=rt[w],C=Number.MAX_VALUE,S=s=0,q=r-1;0<=q?s<=q:s>=q;S=0<=q?++s:--s)(_=kd(y[S]-et))=Y;S=0<=Y?++c:--c)L[S]=null;for(w=u=0,Z=I-1;0<=Z?u<=Z:u>=Z;w=0<=Z?++u:--u)b=g[w],null===L[b]?L[b]=rt[w]:L[b]+=rt[w];for(S=l=0,K=r-1;0<=K?l<=K:l>=K;S=0<=K?++l:--l)L[S]*=1/x[S];for(Q=!1,S=h=0,z=r-1;0<=z?h<=z:h>=z;S=0<=z?++h:--h)if(L[S]!==y[w]){Q=!0;break}y=L,R++,R>200&&(Q=!1)}for(A={},S=p=0,U=r-1;0<=U?p<=U:p>=U;S=0<=U?++p:--p)A[S]=[];for(w=d=0,j=I-1;0<=j?d<=j:d>=j;w=0<=j?++d:--d)b=g[w],A[b].push(rt[w]);for(J=[],S=f=0,V=r-1;0<=V?f<=V:f>=V;S=0<=V?++f:--f)J.push(A[S][0]),J.push(A[S][A[S].length-1]);for(J=J.sort(function(t,e){return t-e}),M.push(J[0]),w=m=1,G=J.length-1;m<=G;w=m+=2)tt=J[w],isNaN(tt)||-1!==M.indexOf(tt)||M.push(tt)}return M},tf=function(t,e,r){var i,n,o,a;return i=Xf(arguments),t=i[0],e=i[1],r=i[2],isNaN(t)&&(t=0),t/=360,t<1/3?(n=(1-e)/3,a=(1+e*Wd(Rd*t)/Wd(Cd-Rd*t))/3,o=1-(n+a)):t<2/3?(t-=1/3,a=(1-e)/3,o=(1+e*Wd(Rd*t)/Wd(Cd-Rd*t))/3,n=1-(a+o)):(t-=2/3,o=(1-e)/3,n=(1+e*Wd(Rd*t)/Wd(Cd-Rd*t))/3,a=1-(o+n)),a=gf(r*a*3),o=gf(r*o*3),n=gf(r*n*3),[255*a,255*o,255*n,i.length>3?i[3]:1]},If=function(){var t,e,r,i,n,o,a,s;return a=Xf(arguments),o=a[0],e=a[1],t=a[2],Rd=2*Math.PI,o/=255,e/=255,t/=255,n=Math.min(o,e,t),i=(o+e+t)/3,s=1-n/i,0===s?r=0:(r=(o-e+(o-t))/2,r/=Math.sqrt((o-e)*(o-e)+(o-t)*(e-t)),r=Math.acos(r),t>e&&(r=Rd-r),r/=Rd),[360*r,s,i]},Gd.hsi=function(){return function(t,e,r){r.prototype=t.prototype;var i=new r,n=t.apply(i,e);return Object(n)===n?n:i}(Md,Jf.call(arguments).concat(["hsi"]),function(){})},Dd.hsi=tf,Md.prototype.hsi=function(){return If(this._rgb)},af=function(t,e,r,i){var n,o,a,s,c,u,l,h,p,d,f,m;return"hsl"===i?(f=t.hsl(),m=e.hsl()):"hsv"===i?(f=t.hsv(),m=e.hsv()):"hcg"===i?(f=t.hcg(),m=e.hcg()):"hsi"===i?(f=t.hsi(),m=e.hsi()):"lch"!==i&&"hcl"!==i||(i="hcl",f=t.hcl(),m=e.hcl()),"h"===i.substr(0,1)&&(a=f[0],p=f[1],u=f[2],s=m[0],d=m[1],l=m[2]),isNaN(a)||isNaN(s)?isNaN(a)?isNaN(s)?o=Number.NaN:(o=s,1!==u&&0!==u||"hsv"===i||(h=d)):(o=a,1!==l&&0!==l||"hsv"===i||(h=p)):(n=s>a&&s-a>180?s-(a+360):s180?s+360-a:s-a,o=a+r*n),null==h&&(h=p+r*(d-p)),c=u+r*(l-u),Gd[i](o,h,c)},Nd=Nd.concat(function(){var t,e,r,i;for(r=["hsv","hsl","hsi","hcl","lch","hcg"],i=[],e=0,t=r.length;e>16&255)/255,e[r+1]=(t>>8&255)/255,e[r+2]=(255&t)/255,e},em.prototype.atomColorToArray=function(t,e,r){return this.colorToArray(this.atomColor(t),e,r)},em.prototype.bondColor=function(t,e){return this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)},em.prototype.bondColorToArray=function(t,e,r,i){return this.colorToArray(this.bondColor(t,e),r,i)},em.prototype.volumeColorToArray=function(t,e,r){return this.colorToArray(this.volumeColor(t),e,r)},em.prototype.positionColorToArray=function(t,e,r){return this.colorToArray(this.positionColor(t),e,r)},Do.prototype={active:!0,params:null,execute:function(t){var e,r;return this.active&&this._listener&&(r=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,r),this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},ko.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,e,r,i){var n,o=this._indexOfListener(t,r);if(-1!==o){if(n=this._bindings[o],n.isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else n=new Do(this,t,e,r,i),this._addBinding(n);return this.memorize&&this._prevParams&&n.execute(this._prevParams),n},_addBinding:function(t){var e=this._bindings.length;do{--e}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var r,i=this,n=this._bindings.length;n--;)if(r=i._bindings[n],r._listener===t&&r.context===e)return n;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,r){return No(t,"add"),this._registerListener(t,!1,e,r)},addOnce:function(t,e,r){return No(t,"addOnce"),this._registerListener(t,!0,e,r)},remove:function(t,e){No(t,"remove");var r=this._indexOfListener(t,e);return-1!==r&&(this._bindings[r]._destroy(),this._bindings.splice(r,1)),t},removeAll:function(){for(var t=this,e=this._bindings.length;e--;)t._bindings[e]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(t){if(this.active){var e,r=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=r),i){e=this._bindings.slice(),this._shouldPropagate=!0;do{i--}while(e[i]&&this._shouldPropagate&&!1!==e[i].execute(r))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var rm={PROTEIN:1,NUCLEIC:2,RNA:3,DNA:4,POLYMER:5,WATER:6,HELIX:7,SHEET:8,TURN:9,BACKBONE:10,SIDECHAIN:11,ALL:12,HETERO:13,ION:14,SACCHARIDE:15,SUGAR:15,BONDED:16,RING:17 +},im=["*","","ALL"],nm=[rm.BACKBONE,rm.SIDECHAIN,rm.BONDED,rm.RING],om=[rm.POLYMER,rm.WATER],am=["ALA","GLY","SER"],sm=["CYS","SER","THR"],cm=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],um=["PHE","TRP","TYR","HIS"],lm=["ASN","GLN"],hm=["ASP","GLU"],pm=["ARG","HIS","LYS"],dm=["ARG","ASP","GLU","HIS","LYS"],fm=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],mm=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],gm=["HIS","PHE","PRO","TRP","TYR"],vm=["ALA","GLY","ILE","LEU","VAL"],ym=function(t){this.signals={stringChanged:new ko},this.setString(t)},bm={type:{configurable:!0}};bm.type.get=function(){return"selection"},ym.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.selection=Bo(t)}catch(t){this.selection={error:t.message}}var r=this.selection;this.string=t,this.test=$o(r),this.residueTest=Ho(r),this.chainTest=Wo(r),this.modelTest=Xo(r),this.atomOnlyTest=$o(r,!0),this.residueOnlyTest=Ho(r,!0),this.chainOnlyTest=Wo(r,!0),this.modelOnlyTest=Xo(r,!0),e||this.signals.stringChanged.dispatch(this.string)}},Object.defineProperties(ym.prototype,bm);var xm=function(t){function e(e){var r=this;t.call(this,e);var i=e.dataList||[];this.colormakerList=[],this.selectionList=[],i.forEach(function(t){var e=t[0],i=t[1],n=t[2];void 0===n&&(n={}),km.hasScheme(e)?Object.assign(n,{scheme:e,structure:r.structure}):Object.assign(n,{scheme:"uniform",value:new et(e).getHex()}),r.colormakerList.push(km.getScheme(n)),r.selectionList.push(new ym(i))})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){for(var e=this,r=0,i=this.selectionList.length;ri).lines},Hm.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},Hm.prototype.asText=function(){return this.isBinary()?so(this.data):this.data},Hm.prototype.chunkToLines=function(t,e,r){var i=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(i),partialLine:""};var n=[],o=this.isBinary()?so(t):t,a=o.lastIndexOf(i);if(-1===a)e+=o;else{var s=e+o.substr(0,a);n=n.concat(s.split(i)),e=a===o.length-i.length?"":o.substr(a+i.length)}return r&&""!==e&&n.push(e),{lines:n,partialLine:e}},Hm.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},Hm.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,r=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=r.partialLine,r.lines}},Hm.prototype.eachChunk=function(t){for(var e=this,r=this.chunkSize,i=this.data.length,n=this.chunkCount(),o=0;o>>0:0,o=t.byteLength-n,a=n;t.buffer&&(t.byteLength!==t.buffer.byteLength&&(a=t.byteOffset+n),t=t.buffer),this._lastWrittenByte=i?o:0,this.buffer=t,this.length=o,this.byteLength=o,this.byteOffset=a,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,a,o),this._mark=0,this._marks=[]};cg.prototype.available=function(t){return void 0===t&&(t=1),this.offset+t<=this.length},cg.prototype.isLittleEndian=function(){return this.littleEndian},cg.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},cg.prototype.isBigEndian=function(){return!this.littleEndian},cg.prototype.setBigEndian=function(){return this.littleEndian=!1,this},cg.prototype.skip=function(t){return void 0===t&&(t=1),this.offset+=t,this},cg.prototype.seek=function(t){return this.offset=t,this},cg.prototype.mark=function(){return this._mark=this.offset,this},cg.prototype.reset=function(){return this.offset=this._mark,this},cg.prototype.pushMark=function(){return this._marks.push(this.offset),this},cg.prototype.popMark=function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this},cg.prototype.rewind=function(){return this.offset=0,this},cg.prototype.ensureAvailable=function(t){if(void 0===t&&(t=1),!this.available(t)){var e=this.offset+t,r=2*e,i=new Uint8Array(r);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=r,this._data=new DataView(this.buffer)}return this},cg.prototype.readBoolean=function(){return 0!==this.readUint8()},cg.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},cg.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},cg.prototype.readByte=function(){return this.readUint8()},cg.prototype.readBytes=function(t){var e=this;void 0===t&&(t=1);for(var r=new Uint8Array(t),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)};var ug=function(t){function e(e){t.call(this),this.surface=e,this._records=[]}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mimeType:{configurable:!0},defaultName:{configurable:!0},defaultExt:{configurable:!0}};return r.mimeType.get=function(){return"application/vnd.ms-pki.stl"},r.defaultName.get=function(){return"surface"},r.defaultExt.get=function(){return"stl"},e.prototype.getData=function(){var t=this,e=this.surface.index.length/3,r=2*e+3*e*4*4+80+4,i=new cg(r);i.skip(80),i.writeUint32(e);for(var n=new v,o=new v,a=new v,s=new v,c=0;cthis.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t}},Um.add("shader/chunk/dull_interior_fragment.glsl","#ifdef DULL_INTERIOR\nif( gl_FrontFacing == false ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#endif"),Um.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),Um.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),Um.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Um.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip )\ndiscard;\n#endif"),Um.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),Um.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Um.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),Um.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");var hg=/^(?!\/\/)\s*#include\s+(\S+)/gim,pg={};if("undefined"!=typeof window&&window.WebGLRenderingContext){var dg=window.WebGLRenderingContext.prototype,fg=dg.getShaderParameter;dg.getShaderParameter=function(){return!t.Debug||fg.apply(this,arguments)};var mg=dg.getShaderInfoLog;dg.getShaderInfoLog=function(){return t.Debug?mg.apply(this,arguments):""};var gg=dg.getProgramParameter;dg.getProgramParameter=function(e,r){return!t.Debug&&r===dg.LINK_STATUS||gg.apply(this,arguments)};var vg=dg.getProgramInfoLog;dg.getProgramInfoLog=function(){return t.Debug?vg.apply(this,arguments):""}}var yg=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];yg.forEach(function(t){t.forEach(function(t){t[0]*=.0625,t[1]*=.0625})}),ua.prototype.constructor=ua;var bg=2*Math.PI,xg=180/Math.PI,_g=new v,wg=new y,Sg=new y,Ag=new h,Mg=new y,Pg=new y,Eg=new Float32Array(4),Tg=new Uint8Array(4),Cg=new y;La.prototype.constructor=La;var Ig=function(t,e){this.signals={moved:new ko,scrolled:new ko,dragged:new ko,dropped:new ko,clicked:new ko,hovered:new ko,doubleClicked:new ko};var r=Object.assign({},e);this.hoverTimeout=Xn(r.hoverTimeout,50),this.handleScroll=Xn(r.handleScroll,!0),this.doubleClickSpeed=Xn(r.doubleClickSpeed,500),this.domElement=t,this.domElement.style.touchAction="none",this.position=new h,this.prevPosition=new h,this.down=new h,this.canvasPosition=new h,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=void 0,this.buttons=void 0,this.pressed=void 0,this.altKey=void 0,this.ctrlKey=void 0,this.metaKey=void 0,this.shiftKey=void 0,this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();var i={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,i),document.addEventListener("wheel",this._onMousewheel,i),document.addEventListener("MozMousePixelScroll",this._onMousewheel,i),document.addEventListener("mousemove",this._onMousemove,i),document.addEventListener("mousedown",this._onMousedown,i),document.addEventListener("mouseup",this._onMouseup,i),document.addEventListener("contextmenu",this._onContextmenu,i), +document.addEventListener("touchstart",this._onTouchstart,i),document.addEventListener("touchend",this._onTouchend,i),document.addEventListener("touchmove",this._onTouchmove,i),this.prevClickCP=new h},Rg={key:{configurable:!0}};Rg.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},Ig.prototype.setParameters=function(t){var e=Object.assign({},t);this.hoverTimeout=Xn(e.hoverTimeout,this.hoverTimeout)},Ig.prototype._listen=function(){var t=window.performance.now(),e=this.canvasPosition;this.doubleClickPending&&t-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),t-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(e.x,e.y))),window.requestAnimationFrame(this._listen)},Ig.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var r=0;r=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail/3:-t.deltaY/(t.deltaMode?.33:30),this.signals.scrolled.dispatch(r),setTimeout(function(){e.scrolled=!0},this.hoverTimeout)}},Ig.prototype._onMousemove=function(t){t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(t),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.clientX,t.clientY),this._setCanvasPosition(t);var e=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,r),this.pressed&&this.signals.dragged.dispatch(e,r)},Ig.prototype._onMousedown=function(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=Da(t),this.pressed=!0,this._setCanvasPosition(t))},Ig.prototype._onMouseup=function(t){t.target===this.domElement&&t.preventDefault(),this._setKeys(t);var e=this.canvasPosition;this._distance()<4&&(this.lastClicked=window.performance.now(),this.doubleClickPending&&this.prevClickCP.distanceTo(e)<4?(this.signals.doubleClicked.dispatch(e.x,e.y),this.doubleClickPending=!1):(this.signals.clicked.dispatch(e.x,e.y),this.doubleClickPending=!0),this.prevClickCP.copy(e)),this.which=void 0,this.buttons=void 0,this.pressed=void 0},Ig.prototype._onContextmenu=function(t){t.target===this.domElement&&t.preventDefault()},Ig.prototype._onTouchstart=function(t){if(t.target===this.domElement)switch(t.preventDefault(),this.pressed=!0,t.touches.length){case 1:this.moving=!1,this.hovering=!1,this.down.set(t.touches[0].pageX,t.touches[0].pageY),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);break;case 2:this.down.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.lastTouchDistance=Oa(t)}},Ig.prototype._onTouchend=function(t){t.target===this.domElement&&t.preventDefault(),this.which=void 0,this.buttons=void 0,this.pressed=void 0},Ig.prototype._onTouchmove=function(t){switch(t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,t.touches.length){case 1:this._setKeys(t),this.which=1,this.buttons=1,this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);var e=this.prevPosition.x-this.position.x,r=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,r),this.pressed&&this.signals.dragged.dispatch(e,r);break;case 2:var i=Oa(t),n=i-this.lastTouchDistance;if(this.lastTouchDistance=i,this.prevPosition.copy(this.position),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),Math.abs(n)>2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(n/2);else{this.which=3,this.buttons=2;var o=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(o,a),this.pressed&&this.signals.dragged.dispatch(o,a)}}},Ig.prototype._distance=function(){return this.position.distanceTo(this.down)},Ig.prototype._setCanvasPosition=function(t){var e,r,i=this.domElement.getBoundingClientRect();"offsetX"in t&&"offsetY"in t?(e=t.offsetX,r=t.offsetY):(e=t.clientX-i.left,r=t.clientY-i.top),this.canvasPosition.set(e,i.height-r)},Ig.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},Ig.prototype.dispose=function(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove)},Object.defineProperties(Ig.prototype,Rg);var Lg=new y,Og=new y,Dg=new y,Ng=new v,kg=new g,Bg=new y,Fg=new v,zg=new v,Ug=function(t,e){var r=e||{};this.rotateSpeed=Xn(r.rotateSpeed,2),this.zoomSpeed=Xn(r.zoomSpeed,1.2),this.panSpeed=Xn(r.panSpeed,1),this.stage=t,this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},jg={component:{configurable:!0},atom:{configurable:!0}};jg.component.get=function(){return this.stage.transformComponent},jg.atom.get=function(){return this.stage.transformAtom},Ug.prototype._setPanVector=function(t,e,r){var i,n=this.viewer.camera;if(r=-r||0,r+=n.position.z,"OrthographicCamera"===n.type)i=1/n.zoom;else{var o=wo(n.fov);i=-2*r*Math.tan(o/2)/this.viewer.height}Fg.set(t,e,0),Fg.multiplyScalar(this.panSpeed*i)},Ug.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},Ug.prototype._transformPanVector=function(){Bg.extractRotation(this.component.transform),Bg.premultiply(this.viewer.rotationGroup.matrix),Bg.getInverse(Bg),Fg.applyMatrix4(Bg)},Ug.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},Ug.prototype.pan=function(t,e){this._setPanVector(t,e),Bg.getInverse(this.viewer.rotationGroup.matrix),Fg.applyMatrix4(Bg),this.controls.translate(Fg)},Ug.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(Fg),this.component.updateMatrix())},Ug.prototype.panAtom=function(t,e){this.atom&&this.component&&(this.atom.positionToVector3(zg),zg.add(this.viewer.translationGroup.position),zg.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,zg.z),this._transformPanVector(),this.atom.positionAdd(Fg),this.component.updateRepresentations({position:!0}))},Ug.prototype.rotate=function(t,e){var r=this._getRotateXY(t,e),i=r[0],n=r[1];Lg.makeRotationX(n),Og.makeRotationY(i),Lg.multiply(Og),this.controls.applyMatrix(Lg)},Ug.prototype.rotateComponent=function(t,e){if(this.component){var r=this._getRotateXY(t,e),i=r[0],n=r[1];Dg.extractRotation(this.component.transform),Dg.premultiply(this.viewer.rotationGroup.matrix),Dg.getInverse(Dg),Ng.set(1,0,0),Ng.applyMatrix4(Dg),Lg.makeRotationAxis(Ng,n),Ng.set(0,1,0),Ng.applyMatrix4(Dg),Og.makeRotationAxis(Ng,i),Lg.multiply(Og),kg.setFromRotationMatrix(Lg),this.component.quaternion.premultiply(kg),this.component.updateMatrix()}},Object.defineProperties(Ug.prototype,jg);var Vg=function(t,e){this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver},Gg={type:{configurable:!0},altKey:{configurable:!0},ctrlKey:{configurable:!0},metaKey:{configurable:!0},shiftKey:{configurable:!0},canvasPosition:{configurable:!0},component:{configurable:!0},object:{configurable:!0},position:{configurable:!0},closestBondAtom:{configurable:!0},arrow:{configurable:!0},atom:{configurable:!0},axes:{configurable:!0},bond:{configurable:!0},box:{configurable:!0},cone:{configurable:!0},clash:{configurable:!0},contact:{configurable:!0},cylinder:{configurable:!0},distance:{configurable:!0},ellipsoid:{configurable:!0},octahedron:{configurable:!0},mesh:{configurable:!0},slice:{configurable:!0},sphere:{configurable:!0},tetrahedron:{configurable:!0},torus:{configurable:!0},surface:{configurable:!0},unitcell:{configurable:!0},unknown:{configurable:!0},volume:{configurable:!0}};Gg.type.get=function(){return this.picker.type},Gg.altKey.get=function(){return this.mouse.altKey},Gg.ctrlKey.get=function(){return this.mouse.ctrlKey},Gg.metaKey.get=function(){return this.mouse.metaKey},Gg.shiftKey.get=function(){return this.mouse.shiftKey},Gg.canvasPosition.get=function(){return this.mouse.canvasPosition},Gg.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},Gg.object.get=function(){return this.picker.getObject(this.pid)},Gg.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},Gg.closestBondAtom.get=function(){if("bond"===this.type){var t=this.bond,e=this.controls;return Na(this.canvasPosition,e.getPositionOnCanvas(t.atom1),e.getPositionOnCanvas(t.atom2))?t.atom1:t.atom2}},Gg.arrow.get=function(){return this._objectIfType("arrow")},Gg.atom.get=function(){return this._objectIfType("atom")},Gg.axes.get=function(){return this._objectIfType("axes")},Gg.bond.get=function(){return this._objectIfType("bond")},Gg.box.get=function(){return this._objectIfType("box")},Gg.cone.get=function(){return this._objectIfType("cone")},Gg.clash.get=function(){return this._objectIfType("clash")},Gg.contact.get=function(){return this._objectIfType("contact")},Gg.cylinder.get=function(){return this._objectIfType("cylinder")},Gg.distance.get=function(){return this._objectIfType("distance")},Gg.ellipsoid.get=function(){return this._objectIfType("ellipsoid")},Gg.octahedron.get=function(){return this._objectIfType("octahedron")},Gg.mesh.get=function(){return this._objectIfType("mesh")},Gg.slice.get=function(){return this._objectIfType("slice")},Gg.sphere.get=function(){return this._objectIfType("sphere")},Gg.tetrahedron.get=function(){return this._objectIfType("tetrahedron")},Gg.torus.get=function(){return this._objectIfType("torus")},Gg.surface.get=function(){return this._objectIfType("surface")},Gg.unitcell.get=function(){return this._objectIfType("unitcell")},Gg.unknown.get=function(){return this._objectIfType("unknown")},Gg.volume.get=function(){return this._objectIfType("volume")},Vg.prototype._objectIfType=function(t){return this.type===t?this.object:void 0},Vg.prototype.getLabel=function(){var t="nothing";return this.arrow?t="arrow: "+(this.arrow.name||this.pid)+" ("+this.arrow.shape.name+")":this.atom?t="atom: "+this.atom.qualifiedName()+" ("+this.atom.structure.name+")":this.axes?t="axes":this.bond?t="bond: "+this.bond.atom1.qualifiedName()+" - "+this.bond.atom2.qualifiedName()+" ("+this.bond.structure.name+")":this.box?t="box: "+(this.box.name||this.pid)+" ("+this.box.shape.name+")":this.cone?t="cone: "+(this.cone.name||this.pid)+" ("+this.cone.shape.name+")":this.clash?t="clash: "+this.clash.clash.sele1+" - "+this.clash.clash.sele2:this.contact?t="contact: "+this.contact.atom1.qualifiedName()+" - "+this.contact.atom2.qualifiedName()+" ("+this.contact.structure.name+")":this.cylinder?t="cylinder: "+(this.cylinder.name||this.pid)+" ("+this.cylinder.shape.name+")":this.distance?t="distance: "+this.distance.atom1.qualifiedName()+" - "+this.distance.atom2.qualifiedName()+" ("+this.distance.structure.name+")":this.ellipsoid?t="ellipsoid: "+(this.ellipsoid.name||this.pid)+" ("+this.ellipsoid.shape.name+")":this.octahedron?t="octahedron: "+(this.octahedron.name||this.pid)+" ("+this.octahedron.shape.name+")":this.mesh?t="mesh: "+(this.mesh.name||this.mesh.serial)+" ("+this.mesh.shape.name+")":this.slice?t="slice: "+this.slice.value.toPrecision(3)+" ("+this.slice.volume.name+")":this.sphere?t="sphere: "+(this.sphere.name||this.pid)+" ("+this.sphere.shape.name+")":this.surface?t="surface: "+this.surface.surface.name:this.tetrahedron?t="tetrahedron: "+(this.tetrahedron.name||this.pid)+" ("+this.tetrahedron.shape.name+")":this.torus?t="torus: "+(this.torus.name||this.pid)+" ("+this.torus.shape.name+")":this.unitcell?t="unitcell: "+this.unitcell.unitcell.spacegroup+" ("+this.unitcell.structure.name+")":this.unknown?t="unknown":this.volume&&(t="volume: "+this.volume.value.toPrecision(3)+" ("+this.volume.volume.name+")"),t},Object.defineProperties(Vg.prototype,Gg);var $g=function(t){this.stage=t,this.viewer=t.viewer};$g.prototype.pick=function(t,e){var r=this.viewer.pick(t,e);if(r.picker&&"ignore"!==r.picker.type&&void 0!==r.pid){var i=r.picker.array;if(!(i&&r.pid>=i.length))return new Vg(r,this.stage);console.error("pid >= picker.array.length")}};var Hg=new g,Wg=new v,Xg=new v,qg=new v,Yg=new v,Zg=new y,Kg=new v,Qg=new y,Jg=function(t){this.stage=t,this.viewer=t.viewer,this.signals={changed:new ko}},tv={position:{configurable:!0},rotation:{configurable:!0}};tv.position.get=function(){return this.viewer.translationGroup.position},tv.rotation.get=function(){return this.viewer.rotationGroup.quaternion},Jg.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},Jg.prototype.getPositionOnCanvas=function(t,e){var r=go(e),i=this.viewer;return qg.copy(t).add(i.translationGroup.position).applyMatrix4(i.rotationGroup.matrix).project(i.camera),r.set((qg.x+1)*i.width/2,(qg.y+1)*i.height/2)},Jg.prototype.getOrientation=function(t){var e=yo(t);e.copy(this.viewer.rotationGroup.matrix);var r=-this.viewer.camera.position.z;return e.scale(Yg.set(r,r,r)),e.setPosition(this.viewer.translationGroup.position),e},Jg.prototype.orient=function(t){yo(t).decompose(Wg,Hg,Xg);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(Hg),e.translationGroup.position.copy(Wg),e.camera.position.z=-Xg.z,e.updateZoom(),this.changed()},Jg.prototype.translate=function(t){this.viewer.translationGroup.position.add(vo(t)),this.changed()},Jg.prototype.center=function(t){this.viewer.translationGroup.position.copy(vo(t)).negate(),this.changed()},Jg.prototype.zoom=function(t){this.distance(this.viewer.camera.position.z*(1-t))},Jg.prototype.distance=function(t){this.viewer.camera.position.z=t,this.viewer.updateZoom(),this.changed()},Jg.prototype.spin=function(t,e){Zg.getInverse(this.viewer.rotationGroup.matrix),Kg.copy(vo(t)).applyMatrix4(Zg),this.viewer.rotationGroup.rotateOnAxis(Kg,e),this.changed()},Jg.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(bo(t)),this.changed()},Jg.prototype.align=function(t){Qg.getInverse(yo(t)),this.viewer.rotationGroup.setRotationFromMatrix(Qg),this.changed()},Jg.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix(yo(t)),this.changed()},Object.defineProperties(Jg.prototype,tv);var ev=function(t,e){for(var r=[],i=arguments.length-2;i-- >0;)r[i]=arguments[i+2];this.duration=Xn(t,1e3),this.controls=e,this.startTime=window.performance.now(),this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],(n=this)._init.apply(n,r);var n},rv={done:{configurable:!0},paused:{configurable:!0}};rv.done.get=function(){return 1===this.alpha},rv.paused.get=function(){return this._paused},ev.prototype._init=function(){},ev.prototype._tick=function(){},ev.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Lo(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach(function(t){return t()}),this.done},ev.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},ev.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},ev.prototype.toggle=function(){this._paused?this.resume():this.pause()},ev.prototype.then=function(t){var e,r=this;return e=this.done?Promise.resolve():new Promise(function(t){return r._resolveList.push(t)}),e.then(t)},Object.defineProperties(ev.prototype,rv);var iv=function(t){function e(e){for(var r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];t.apply(this,[Xn(e,1/0)].concat(r))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){Array.isArray(t)?this.axis=(new v).fromArray(t):this.axis=Xn(t,new v(0,1,0)),this.angle=Xn(e,.01)},e.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},e}(ev),nv=function(t){function e(e){for(var r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];t.apply(this,[Xn(e,1/0)].concat(r))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,r){Array.isArray(t)?this.axis=(new v).fromArray(t):this.axis=Xn(t,new v(0,1,0)),this.angleStep=Xn(e,.01),this.angleEnd=Xn(r,.2),this.angleSum=0,this.direction=1},e.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=Lo(0,1,Math.abs(this.angleSum)/this.angleEnd),r=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,r*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},e}(ev),ov=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.moveFrom=vo(Xn(t,new v)),this.moveTo=vo(Xn(e,new v))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(ev),av=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.zoomFrom=t,this.zoomTo=e},e.prototype._tick=function(){this.controls.distance(Io(this.zoomFrom,this.zoomTo,this.alpha))},e}(ev),sv=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.rotateFrom=bo(t),this.rotateTo=bo(e),this._currentRotation=new g},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(ev),cv=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,r){this.valueFrom=t,this.valueTo=e,this.callback=r},e.prototype._tick=function(){this.callback(Io(this.valueFrom,this.valueTo,this.alpha))},e}(ev),uv=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(ev),lv=function(t){this._list=t||[],this._resolveList=[]},hv={done:{configurable:!0}};hv.done.get=function(){return this._list.every(function(t){return t.done})},lv.prototype.then=function(t){var e,r=this;return e=this.done?Promise.resolve():new Promise(function(t){r._resolveList.push(t),r._list.forEach(function(t){t.then(function(){r._resolveList.forEach(function(t){t()}),r._resolveList.length=0})})}),e.then(t)},Object.defineProperties(lv.prototype,hv);var pv=function(t){this.stage=t,this.viewer=t.viewer,this.controls=t.viewerControls,this.animationList=[],this.finishedList=[]},dv={paused:{configurable:!0}};dv.paused.get=function(){return this.animationList.every(function(t){return t.paused})},pv.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},pv.prototype.remove=function(t){var e=this.animationList,r=e.indexOf(t);r>-1&&e.splice(r,1)},pv.prototype.run=function(t){for(var e=this,r=this.finishedList,i=this.animationList,n=i.length,o=0;o0;)r[i]=arguments[i+1];if(!this.disabled){var n=this.mouse.key||0,o=this.mouse.buttons||0;this.actionList.forEach(function(i){i.type===t&&i.key===n&&i.button===o&&i.callback.apply(i,[e.stage].concat(r))})}},gv.prototype.add=function(t,e){var r=ka(t),i=r[0],n=r[1],o=r[2];this.actionList.push({type:i,key:n,button:o,callback:e})},gv.prototype.remove=function(t,e){var r=t.includes("*"),i=ka(t),n=i[0],o=i[1],a=i[2],s=this.actionList.filter(function(t){return!((t.type===n||r&&""===n)&&(t.key===o||r&&0===o)&&(t.button===a||r&&0===a)&&(t.callback===e||void 0===e))});this.actionList=s},gv.prototype.preset=function(t){var e=this;this.clear(),(mv[t]||[]).forEach(function(t){return(r=e).add.apply(r,t);var r})},gv.prototype.clear=function(){this.actionList.length=0};var vv=function(){};vv.autoView=function(t){t.autoView(1e3)},vv.toggleAnimations=function(t){t.animationControls.toggle()},vv.toggleRock=function(t){t.toggleRock()},vv.toggleSpin=function(t){t.toggleSpin()};var yv={default:[["i",vv.toggleSpin],["k",vv.toggleRock],["p",vv.toggleAnimations],["r",vv.autoView]]},bv=function(t,e){var r=e||{};this.stage=t,this.actionList=[],this.disabled=r.disabled||!1,this.preset(r.preset||"default")};bv.prototype.run=function(t){var e=this;this.disabled||this.actionList.forEach(function(r){r.keyCode===t&&r.callback(e.stage)})},bv.prototype.add=function(t,e){var r=t.charCodeAt(0);this.actionList.push({keyCode:r,callback:e})},bv.prototype.remove=function(t,e){var r=t.charCodeAt(0),i=this.actionList.filter(function(t){return!(t.keyCode===r&&(t.callback===e||void 0===e))});this.actionList=i},bv.prototype.preset=function(t){var e=this;this.clear(),(yv[t]||[]).forEach(function(t){return(r=e).add.apply(r,t);var r})},bv.prototype.clear=function(){this.actionList.length=0};var xv=function(t){this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)};xv.prototype._onClick=function(t,e){var r=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(r),this.controls.run("clickPick",r)},xv.prototype._onHover=function(t,e){var r=this.stage.pickingControls.pick(t,e);r&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=r.component,this.stage.transformAtom=r.atom),this.stage.signals.hovered.dispatch(r),this.controls.run("hoverPick",r)},xv.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var _v=function(t){this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)};_v.prototype._onMove=function(){this.stage.tooltip.style.display="none"},_v.prototype._onScroll=function(t){this.controls.run("scroll",t)},_v.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},_v.prototype._onClick=function(t,e){this.controls.run("click",t,e)},_v.prototype._onDblclick=function(t,e){this.controls.run("doubleClick",t,e)},_v.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},_v.prototype.dispose=function(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var wv=function(t){this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};wv.prototype._onTick=function(t){this.animationControls.run(t)},wv.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var Sv=!!Em&&{passive:!0},Av=function(t){this.stage=t,this.controls=t.keyControls,this.domElement=t.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this.domElement.autofocus=!0,this.domElement.focus(),this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,Sv),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)};Av.prototype._onKeydown=function(){},Av.prototype._onKeyup=function(){},Av.prototype._onKeypress=function(t){this.controls.run(t.keyCode)},Av.prototype._focusDomElement=function(){this.domElement.focus()},Av.prototype.dispose=function(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,Sv),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)};var Mv=function(t,e,r,i){var n=i||{};this.offsetX=Xn(n.offsetX,0),this.offsetY=Xn(n.offsetY,0),this.visible=Xn(n.visible,!0),this.component=t,this.stage=t.stage,this.viewer=this.stage.viewer,this.position=e,this._viewerPosition=new v,this._updateViewerPosition(),this._canvasPosition=new v,this._cameraPosition=new v,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"fixed",zIndex:1+(parseInt(this.viewer.container.style.zIndex)||0),pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif",left:"-10000px"}),this.viewer.container.appendChild(this.element),this.setContent(r),this.updateVisibility(),this.viewer.signals.ticked.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};Mv.prototype.setContent=function(t){var e=this.element.style.display;"none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof window.Element?(this.element.innerHTML="",this.element.appendChild(t)):this.element.innerHTML=t,this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)},Mv.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},Mv.prototype.getVisibility=function(){return this.visible&&this.component.visible},Mv.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},Mv.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},Mv.prototype._update=function(){if(this.getVisibility()){var t=this.element.style,e=this._canvasPosition,r=this._viewerPosition,i=this._clientRect +;if(this._cameraPosition.copy(r).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)return void(t.display="none");t.display="block",t.opacity=1-Lo(this.viewer.scene.fog.near,this.viewer.scene.fog.far,this._cameraPosition.length()),this.stage.viewerControls.getPositionOnCanvas(r,e),t.bottom=this.offsetX+e.y+i.height/2+"px",t.left=this.offsetY+e.x-i.width/2+"px"}},Mv.prototype.dispose=function(){this.viewer.container.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var Pv=new y,Ev=new v,Tv=new g,Cv=function(t){this.component=t,this.stage=t.stage,this.viewer=t.stage.viewer,this.signals={changed:new ko}},Iv={position:{configurable:!0},rotation:{configurable:!0}};Iv.position.get=function(){return this.component.position},Iv.rotation.get=function(){return this.component.quaternion},Cv.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},Cv.prototype.spin=function(t,e){Pv.getInverse(this.viewer.rotationGroup.matrix),Ev.copy(vo(t)).applyMatrix4(Pv),Pv.extractRotation(this.component.transform),Pv.premultiply(this.viewer.rotationGroup.matrix),Pv.getInverse(Pv),Ev.copy(vo(t)),Ev.applyMatrix4(Pv),Pv.makeRotationAxis(Ev,e),Tv.setFromRotationMatrix(Pv),this.component.quaternion.premultiply(Tv),this.changed()},Object.defineProperties(Cv.prototype,Iv),Ka.__deps=[Qa],Ja.__deps=[Qa,Za];var Rv=new v,Lv=function(){},Ov={Picker:{configurable:!0},Buffer:{configurable:!0}};Ov.Picker.get=function(){return $m.get(this.type)},Ov.Buffer.get=function(){return Gm.get(this.type)},Lv.getShapeKey=function(t){return this.type+t[0].toUpperCase()+t.substr(1)},Lv.valueToShape=function(t,e,r){var i=t[this.getShapeKey(e)];switch(this.fields[e]){case"v3":case"c":os(r,i);break;default:i.push(r)}},Lv.objectToShape=function(t,e){var r=this;Object.keys(this.fields).forEach(function(i){r.valueToShape(t,i,e[i])}),this.valueToShape(t,"name",e.name),this.expandBoundingBox(t.boundingBox,e)},Lv.valueFromShape=function(t,e,r){var i=t[this.getShapeKey(r)];switch(this.fields[r]){case"v3":return(new v).fromArray(i,3*e);case"c":return(new et).fromArray(i,3*e);default:return i[e]}},Lv.objectFromShape=function(t,e){var r=this,i={shape:t,name:this.valueFromShape(t,e,"name")};return Object.keys(this.fields).forEach(function(n){i[n]=r.valueFromShape(t,e,n)}),i},Lv.arrayFromShape=function(t,e){var r=t[this.getShapeKey(e)];switch(this.fields[e]){case"s":return r;default:return new Float32Array(r)}},Lv.dataFromShape=function(t){var e=this,r={};return this.Picker&&(r.picking=new this.Picker(t)),Object.keys(this.fields).forEach(function(i){r[i]=e.arrayFromShape(t,i)}),r},Lv.bufferFromShape=function(t,e){return new this.Buffer(this.dataFromShape(t),e)},Object.defineProperties(Lv,Ov);var Dv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},fields:{configurable:!0}};return r.type.get=function(){return"sphere"},r.fields.get=function(){return{position:"v3",color:"c",radius:"f"}},e.positionFromShape=function(t,e){return this.valueFromShape(t,e,"position")},e.expandBoundingBox=function(t,e){t.expandByPoint(Rv.fromArray(e.position))},Object.defineProperties(e,r),e}(Lv),Nv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},fields:{configurable:!0}};return r.type.get=function(){return"box"},r.fields.get=function(){return{position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"}},Object.defineProperties(e,r),e}(Dv),kv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"octahedron"},Object.defineProperties(e,r),e}(Nv),Bv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"tetrahedron"},Object.defineProperties(e,r),e}(Nv),Fv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},fields:{configurable:!0}};return r.type.get=function(){return"cylinder"},r.fields.get=function(){return{position1:"v3",position2:"v3",color:"c",radius:"f"}},e.positionFromShape=function(t,e){var r=this.valueFromShape(t,e,"position1"),i=this.valueFromShape(t,e,"position2");return r.add(i).multiplyScalar(.5)},e.expandBoundingBox=function(t,e){t.expandByPoint(Rv.fromArray(e.position1)),t.expandByPoint(Rv.fromArray(e.position2))},Object.defineProperties(e,r),e}(Lv),zv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"arrow"},Object.defineProperties(e,r),e}(Fv),Uv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"cone"},Object.defineProperties(e,r),e}(Fv),jv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},fields:{configurable:!0}};return r.type.get=function(){return"ellipsoid"},r.fields.get=function(){return{position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"}},Object.defineProperties(e,r),e}(Dv),Vv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"torus"},Object.defineProperties(e,r),e}(jv),Gv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},fields:{configurable:!0}};return r.type.get=function(){return"text"},r.fields.get=function(){return{position:"v3",color:"c",size:"f",text:"s"}},Object.defineProperties(e,r),e}(Dv),$v=function(t){this.array=t};$v.prototype.getIndex=function(t){return this.array?this.array[t]:t},$v.prototype.getObject=function(){return{}},$v.prototype._applyTransformations=function(t,e,r){return e&&t.applyMatrix4(e.matrix),r&&t.applyMatrix4(r.matrix),t},$v.prototype._getPosition=function(){return new v},$v.prototype.getPosition=function(t,e,r){return this._applyTransformations(this._getPosition(t),e,r)};var Hv=function(t){function e(e){t.call(this),this.shape=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0},data:{configurable:!0},type:{configurable:!0}};return r.primitive.get=function(){},r.data.get=function(){return this.shape},r.type.get=function(){return this.primitive.type},e.prototype.getObject=function(t){return this.primitive.objectFromShape(this.shape,t)},e.prototype._getPosition=function(t){return this.primitive.positionFromShape(this.shape,t)},Object.defineProperties(e.prototype,r),e}($v),Wv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return Fv},Object.defineProperties(e.prototype,r),e}(Hv),Xv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return zv},Object.defineProperties(e.prototype,r),e}(Hv),qv=function(t){function e(e,r){t.call(this,e),this.structure=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"atom"},r.data.get=function(){return this.structure},e.prototype.getObject=function(t){return this.structure.getAtomProxy(this.getIndex(t))},e.prototype._getPosition=function(t){return(new v).copy(this.getObject(t))},Object.defineProperties(e.prototype,r),e}($v),Yv=function(t){function e(e){t.call(this),this.axes=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"axes"},r.data.get=function(){return this.axes},e.prototype.getObject=function(){return{axes:this.axes}},e.prototype._getPosition=function(){return this.axes.center.clone()},Object.defineProperties(e.prototype,r),e}($v),Zv=function(t){function e(e,r,i){t.call(this,e),this.structure=r,this.bondStore=i||r.bondStore}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"bond"},r.data.get=function(){return this.structure},e.prototype.getObject=function(t){var e=this.structure.getBondProxy(this.getIndex(t));return e.bondStore=this.bondStore,e},e.prototype._getPosition=function(t){var e=this.getObject(t);return(new v).copy(e.atom1).add(e.atom2).multiplyScalar(.5)},Object.defineProperties(e.prototype,r),e}($v),Kv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"contact"},Object.defineProperties(e.prototype,r),e}(Zv),Qv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return Uv},Object.defineProperties(e.prototype,r),e}(Hv),Jv=function(t){function e(e,r,i){t.call(this,e),this.validation=r,this.structure=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"clash"},r.data.get=function(){return this.validation},e.prototype.getObject=function(t){var e=this.validation,r=this.getIndex(t);return{validation:e,index:r,clash:e.clashArray[r]}},e.prototype._getAtomProxyFromSele=function(t){var e=new ym(t),r=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(r)},e.prototype._getPosition=function(t){var e=this.getObject(t).clash,r=this._getAtomProxyFromSele(e.sele1),i=this._getAtomProxyFromSele(e.sele2);return(new v).copy(r).add(i).multiplyScalar(.5)},Object.defineProperties(e.prototype,r),e}($v),ty=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"distance"},Object.defineProperties(e.prototype,r),e}(Zv),ey=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return jv},Object.defineProperties(e.prototype,r),e}(Hv),ry=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return kv},Object.defineProperties(e.prototype,r),e}(Hv),iy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return Nv},Object.defineProperties(e.prototype,r),e}(Hv),ny=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"ignore"},Object.defineProperties(e.prototype,r),e}($v),oy=function(t){function e(e,r){t.call(this,e),this.mesh=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"mesh"},e.prototype.getObject=function(){var t=this.mesh;return{shape:this.shape,name:t.name,serial:t.serial}},e.prototype._getPosition=function(){return this.__position||(this.__position=Ba(this.mesh.position)),this.__position},Object.defineProperties(e.prototype,r),e}(Hv),ay=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return Dv},Object.defineProperties(e.prototype,r),e}(Hv),sy=function(t){function e(e,r){t.call(this,e),this.surface=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"surface"},r.data.get=function(){return this.surface},e.prototype.getObject=function(t){return{surface:this.surface,index:this.getIndex(t)}},e.prototype._getPosition=function(){return this.surface.center.clone()},Object.defineProperties(e.prototype,r),e}($v),cy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return Bv},Object.defineProperties(e.prototype,r),e}(Hv),uy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={primitive:{configurable:!0}};return r.primitive.get=function(){return Vv},Object.defineProperties(e.prototype,r),e}(Hv),ly=function(t){function e(e,r){t.call(this),this.unitcell=e,this.structure=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"unitcell"},r.data.get=function(){return this.unitcell},e.prototype.getObject=function(){return{unitcell:this.unitcell,structure:this.structure}},e.prototype._getPosition=function(){return this.unitcell.getCenter(this.structure)},Object.defineProperties(e.prototype,r),e}($v),hy=(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};r.type.get=function(){return"unknown"},Object.defineProperties(e.prototype,r)}($v),function(t){function e(e,r){t.call(this,e),this.volume=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},data:{configurable:!0}};return r.type.get=function(){return"volume"},r.data.get=function(){return this.volume},e.prototype.getObject=function(t){var e=this.volume,r=this.getIndex(t);return{volume:e,index:r,value:e.data[r]}},e.prototype._getPosition=function(t){var e=this.volume.position,r=this.getIndex(t);return new v(e[3*r],e[3*r+1],e[3*r+2])},Object.defineProperties(e.prototype,r),e}($v)),py=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"slice"},Object.defineProperties(e.prototype,r),e}(hy);$m.add("arrow",Xv),$m.add("box",iy),$m.add("cone",Qv),$m.add("cylinder",Wv),$m.add("ellipsoid",ey),$m.add("octahedron",ry),$m.add("sphere",ay),$m.add("tetrahedron",cy),$m.add("torus",uy);var dy=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};dy.prototype.get=function(t){return 0!=(this._words[t>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,a=e>>>5,s=o;s>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>r,this},dy.prototype._isRangeValue=function(t,e,r){for(var i=this._words,n=!0===r?4294967295:0,o=t>>>5,a=e>>>5,s=o;s>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0?f>e&&(e=f):f>r&&(r=f),Fa(s.copy(t),h,u);var m=c.subVectors(s,u).normalize().dot(h),g=s.distanceTo(u);m>0?g>i&&(i=g):g>n&&(n=g),Fa(s.copy(t),p,u);var v=c.subVectors(s,u).normalize().dot(p),y=s.distanceTo(u);v>0?y>o&&(o=y):y>a&&(a=y)}),{d1a:e,d2a:i,d3a:o,d1b:-r,d2b:-n,d3b:-a}},Is.prototype.constructor=Is,Rs.prototype.constructor=Rs,Ns.__deps=[Ls,Os,Ds,lo],ks.__deps=[Bs],Bs.__deps=[Wa,$a,qa,Va],zs.__deps=[wo,ts,es,Ka,Qa,rs,is,Wa,ns,_s,Ss,Ms,As,Ps];var Zy=function(t,e,r){this.name=t||"",this.path=e||"",this.info={},this.center=new v,this.boundingBox=new lt,r instanceof Mt||r instanceof Ft||r instanceof qe?this.fromGeometry(r):r&&(this.set(r.position,r.index,r.normal,r.color,r.atomindex,r.contour),this.boundingBox.setFromArray(r.position),this.boundingBox.getCenter(this.center))},Ky={type:{configurable:!0}};Ky.type.get=function(){return"Surface"},Zy.prototype.set=function(t,e,r,i,n,o){this.position=t,this.index=e,this.normal=r,this.color=i,this.atomindex=n,this.size=t.length/3,this.contour=o},Zy.prototype.fromGeometry=function(e){t.Debug&&Lm.time("GeometrySurface.fromGeometry");var r;e instanceof Mt?(e.computeVertexNormals(!0),r=(new Ft).fromGeometry(e)):r=e instanceof Ft?e:e[0],r.boundingBox||r.computeBoundingBox(), +this.boundingBox.copy(r.boundingBox),this.boundingBox.getCenter(this.center);var i,n,o;if(r instanceof Ft){var a=r.attributes,s=!!a.normal&&a.normal.array;(!s||0===s[0]&&0===s[1]&&0===s[2])&&r.computeVertexNormals(),i=a.position.array,n=a.index?a.index.array:null,o=a.normal.array}this.set(i,n,o,void 0,void 0),t.Debug&&Lm.timeEnd("GeometrySurface.setGeometry")},Zy.prototype.getPosition=function(){return this.position},Zy.prototype.getColor=function(t){var e=t||{};e.surface=this;var r=this.size,i=new Float32Array(3*r),n=km.getScheme(e);if(n.volumeColor||"random"===e.scheme)for(var o=0;o=t&&f<=e||r&&(fe)){var m=3*h;u[h]=f,l[m+0]=n[d+0],l[m+1]=n[d+1],l[m+2]=n[d+2],o&&(c[h]=o[p]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),o&&(this.atomindex=new Float32Array(this._atomindexBuffer,0,h))}this._filterHash=a}},Object.defineProperties(tb.prototype,eb),tb.prototype.getValueForSigma=Qy.prototype.getValueForSigma,tb.prototype.getSigmaForValue=Qy.prototype.getSigmaForValue,tb.prototype.getDataAtomindex=Qy.prototype.getDataAtomindex,tb.prototype.getDataPosition=Qy.prototype.getDataPosition,tb.prototype.getDataColor=Qy.prototype.getDataColor,tb.prototype.getDataPicking=Qy.prototype.getDataPicking,tb.prototype.getDataSize=Qy.prototype.getDataSize;var rb=function(e,r){t.Debug&&Lm.time("BondHash init");for(var i=e.count,n=e.atomIndex1,o=e.atomIndex2,a=new Uint8Array(r),s=new Int32Array(r),c=0;ca?s.set(e[n].subarray(0,a)):s.set(e[n]),e[n]=s}},ib.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},ib.prototype.copyFrom=function(t,e,r,i){for(var n=this,o=0,a=this._fields.length;o0;)s-=1;a<=s&&(a===o?o=s:s===o&&(o=a),e(a,s),a+=1,s-=1)}while(a<=s);r(i,s),r(a,n)}}Lm.time("Store.sort");var i=this,n=new this.constructor(1);r(0,this.count-1),Lm.timeEnd("Store.sort")},ib.prototype.clear=function(){this.count=0},ib.prototype.dispose=function(){var t=this;delete this.length,delete this.count;for(var e=0,r=this._fields.length;e0&&(h[r]=M.angleTo(P)),t=Math.cos(x.angleTo(_)),f[r]=180/Math.PI*Math.acos(t),i=x.length(),n=_.length(),p[r]=Math.sqrt(n*i)/Math.max(2,2*(1-t)),d[r]=Math.abs(y.dot(M)),w.copy(x).multiplyScalar(p[r]/i),S.copy(_).multiplyScalar(p[r]/n),w.subVectors(R,w),S.subVectors(L,S),w.toArray(u,e+3),S.toArray(u,e+6),E.subVectors(I,T),E.toArray(m,e),P.copy(M),T.copy(w);for(w.fromArray(u,3),S.fromArray(u,6),M.subVectors(w,S).normalize(),I.index=o.getAtomIndexByType(0,C),T.copy(I),A.copy(I),Fa(A,M,w),A.toArray(u,0),E.subVectors(T,w),E.toArray(m,0),w.fromArray(u,3*s-6),S.fromArray(u,3*s-9),M.subVectors(w,S).normalize(),I.index=o.getAtomIndexByType(s-1,C),T.copy(I),A.copy(I),Fa(A,M,w),A.toArray(u,3*s-3),r=s-3;re?B=!0:l.bending[F]>t&&(B=!0)),B){if(F-g<4){g=F,B=!1;continue}D.index=L.traceAtomIndex,T=l.axis.subarray(3*g+3,3*F),C=l.center.subarray(3*g,3*F+3),p=Ba(T).normalize(),d=Ba(C),I.fromArray(C),Fa(I,p,d),R.fromArray(C,C.length-3),Fa(R,p,d),p.subVectors(R,I),p.toArray(b,y),d.toArray(x,y),I.toArray(_,y),R.toArray(w,y),f.atomColorToArray(D,S,y),A.push(D.index),M.push(m.atomRadius(D)),P.push(u+g),E.push(u+F+1-g),y+=3,g=F,B=!1}var z=new Float32Array(A);return{axis:new Float32Array(b),center:new Float32Array(x),begin:new Float32Array(_),end:new Float32Array(w),color:new Float32Array(S),picking:new qv(z,s),size:new Float32Array(M),residueOffset:P,residueCount:E}}},Gs.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},peek:function(){return this.content[0]},remove:function(t){for(var e=this,r=this.content.length,i=0;i0;){var i=Math.floor((t+1)/2)-1,n=e.content[i];if(!(e.scoreFunction(r)":"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"},lb={"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":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},hb=function(t){this.name=t||"",this.partList=[]},pb={type:{configurable:!0}};pb.type.get=function(){return"Assembly"},hb.prototype.addPart=function(t,e){var r=new db(t,e);return this.partList.push(r),r},hb.prototype._getCount=function(t,e){var r=0;return this.partList.forEach(function(i){r+=i[e](t)}),r},hb.prototype.getAtomCount=function(t){return this._getCount(t,"getAtomCount")},hb.prototype.getResidueCount=function(t){return this._getCount(t,"getResidueCount")},hb.prototype.getInstanceCount=function(){var t=0;return this.partList.forEach(function(e){t+=e.matrixList.length}),t},hb.prototype.isIdentity=function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new y).equals(e.matrixList[0]))return!1;var r=[];return t.eachChain(function(t){r.push(t.chainname)}),r=ao(r),e.chainList.length===r.length},hb.prototype.getBoundingBox=function(t){var e=new lt;return this.partList.forEach(function(r){var i=r.getBoundingBox(t);e.expandByPoint(i.min),e.expandByPoint(i.max)}),e},hb.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter()},hb.prototype.getSelection=function(){var t=[];return this.partList.forEach(function(e){t=t.concat(e.chainList)}),Xs(t)},Object.defineProperties(hb.prototype,pb);var db=function(t,e){this.matrixList=t||[],this.chainList=e||[]},fb={type:{configurable:!0}};fb.type.get=function(){return"AssemblyPart"},db.prototype._getCount=function(t,e){var r=0,i=this.chainList;return t.eachChain(function(t){(0===i.length||i.includes(t.chainname))&&(r+=t[e])}),this.matrixList.length*r},db.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},db.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},db.prototype.getBoundingBox=function(t){var e=new lt,r=new lt,i=this.getSelection(),n=t.getBoundingBox(i);return this.matrixList.forEach(function(t){r.copy(n).applyMatrix4(t),e.expandByPoint(r.min),e.expandByPoint(r.max)}),e},db.prototype.getSelection=function(){return Xs(this.chainList)},db.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},db.prototype.getInstanceList=function(){for(var t=this,e=[],r=0,i=this.matrixList.length;r=t.residueCount)){a.index=o+l,s.index=o+l+h,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-r[h-2])>i)return!1}return!0},r=function(t,r){return e(t,r,[5.45,5.18,6.37],2.1)},i=function(t,r){return e(t,r,[6.1,10.4,13],1.42)},n=function(t){for(var e=t.residueStore,n=t.residueIndexStart,o=0,a=t.residueCount;o1&&n.bending[s]<20&&(e.sstruc[r+s]="h".charCodeAt(0),e.sstruc[r+s+1]="h".charCodeAt(0))}};return function(e){t.Debug&&Lm.time("calculateSecondaryStructure"),e.eachPolymer(function(t){if(!(t.residueCount<4)){if(t.isCg())o(t);else{if(!t.isProtein())return;n(t)}var e,r=0;t.eachResidue(function(t){t.sstruc===e?r+=1:(1===r&&(t.index-=1,t.sstruc="c"),r=1,e=t.sstruc)})}}),t.Debug&&Lm.timeEnd("calculateSecondaryStructure")}}(),gb="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vb=["H","C","O","N","S","P"],yb=["NA","CL","FE"],bb=function(t,e,r){this.structure=t,r=r||ic(e),this.atomname=e,this.element=r,this.vdw=Iy[r],this.covalent=Ry[r]},xb=function(t){this.structure=t,this.dict={},this.list=[]};xb.prototype.add=function(t,e){t=t.toUpperCase(),e=e?e.toUpperCase():ic(t);var r=oc(t,e),i=this.dict[r];if(void 0===i){var n=new bb(this.structure,t,e);i=this.list.length,this.dict[r]=i,this.list.push(n)}return i},xb.prototype.get=function(t){return this.list[t]};var _b=function(t,e,r,i,n,o){this.structure=t,this.resname=e,this.atomTypeIdList=r,this.hetero=i?1:0,this.chemCompType=n,this.bonds=o,this.rings=void 0,this.atomCount=r.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();var a=$y[this.backboneType],s=$y[this.backboneStartType],c=$y[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=void 0!==u?u:-1;var l=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=void 0!==l?l:-1;var h=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=void 0!==h?h:-1;var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=void 0!==p?p:-1;var d=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=void 0!==d?d:-1;var f;f=Fy.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=void 0!==f?f:-1,this.bondReferenceAtomIndices=[]};_b.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=Vy;break;case 4:case 5:t=Gy;break;default:return e}for(var r=this.structure.atomMap,i=this.atomTypeIdList,n=0,o=this.atomCount;n=2?t(h,e[h],a):r[h]=2;else if(1===r[h]&&c&&c!==h){var p=[h];i[h]=1,n.push(p);for(var d=o.length-1;d>=0;--d){var f=o[d];if(f===h)break;p.push(f),i[f]=1}}}r[a]=2,o.pop()}for(var e=this.getBondGraph(),r=new Int8Array(this.atomCount),i=new Int8Array(this.atomCount),n=[],o=[],a=0;a1)for(var y=0;y1)for(var x=0;x0){var e=this.residueStore.atomOffset[this.residueIndex];return t.includes(this.index-e)}return!1},Mb.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},Mb.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},Mb.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},Mb.prototype.isHetero=function(){return 1===this.residueType.hetero},Mb.prototype.isProtein=function(){return 3===this.residueType.moleculeType},Mb.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},Mb.prototype.isRna=function(){return 4===this.residueType.moleculeType},Mb.prototype.isDna=function(){return 5===this.residueType.moleculeType},Mb.prototype.isWater=function(){return 1===this.residueType.moleculeType},Mb.prototype.isIon=function(){return 2===this.residueType.moleculeType},Mb.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},Mb.prototype.isHelix=function(){return Ey.includes(this.sstruc)},Mb.prototype.isSheet=function(){return Ty.includes(this.sstruc)},Mb.prototype.isTurn=function(){return Cy.includes(this.sstruc)&&this.isProtein()},Mb.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},Mb.prototype.isRing=function(){return 1===this.residueType.getRings().flags[this.index-this.residueAtomOffset]},Mb.prototype.distanceTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,n=t.index,o=e.x[i]-r.x[n],a=e.y[i]-r.y[n],s=e.z[i]-r.z[n],c=o*o+a*a+s*s;return Math.sqrt(c)},Mb.prototype.connectedTo=function(t){var e=this.atomStore,r=t.atomStore,i=this.index,n=t.index;if(e.altloc&&r.altloc){var o=e.altloc[i],a=r.altloc[n];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=e.x[i]-r.x[n],c=e.y[i]-r.y[n],u=e.z[i]-r.z[n],l=s*s+c*c+u*u;if(l<64&&this.isCg())return!0;if(isNaN(l))return!1;var h=this.covalent+t.covalent,p=h+.3,d=h-.5;return ld*d},Mb.prototype.positionFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this},Mb.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var r=this.index,i=this.atomStore;return t[e+0]=i.x[r],t[e+1]=i.y[r],t[e+2]=i.z[r],t},Mb.prototype.positionToVector3=function(t){return void 0===t&&(t=new v),t.x=this.x,t.y=this.y,t.z=this.z,t},Mb.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},Mb.prototype.positionAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},Mb.prototype.positionSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},Mb.prototype.getResidueBonds=function(t){var e,r,i,n,o=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(t||(n=[]),e=c.indexOf(a);-1!==e;){if(i=u[e]+o,t)return i;n.push(i),e=c.indexOf(a,e+1)}for(r=u.indexOf(a);-1!==r;){if(i=c[r]+o,t)return i;n.push(i),r=u.indexOf(a,r+1)}return n},Mb.prototype.qualifiedName=function(t){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},Mb.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Mb.prototype.toObject=function(){return{index:this.index,residueIndex:this.residueIndex,atomno:this.atomno,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelindex:this.modelindex}},Object.defineProperties(Mb.prototype,Pb);var Eb=function(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap,this.index=e},Tb={entity:{configurable:!0},entityIndex:{configurable:!0},chain:{configurable:!0},chainIndex:{configurable:!0},atomOffset:{configurable:!0},atomCount:{configurable:!0},atomEnd:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0},resno:{configurable:!0},sstruc:{configurable:!0},inscode:{configurable:!0},residueType:{configurable:!0},resname:{configurable:!0},hetero:{configurable:!0},moleculeType:{configurable:!0},backboneType:{configurable:!0},backboneStartType:{configurable:!0},backboneEndType:{configurable:!0},traceAtomIndex:{configurable:!0},direction1AtomIndex:{configurable:!0},direction2AtomIndex:{configurable:!0},backboneStartAtomIndex:{configurable:!0},backboneEndAtomIndex:{configurable:!0},rungEndAtomIndex:{configurable:!0}};Tb.entity.get=function(){return this.structure.entityList[this.entityIndex]},Tb.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},Tb.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},Tb.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},Tb.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},Tb.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},Tb.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},Tb.atomCount.get=function(){return this.residueStore.atomCount[this.index]},Tb.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},Tb.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},Tb.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},Tb.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},Tb.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},Tb.resno.get=function(){return this.residueStore.resno[this.index]},Tb.resno.set=function(t){this.residueStore.resno[this.index]=t},Tb.sstruc.get=function(){ +return this.residueStore.getSstruc(this.index)},Tb.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},Tb.inscode.get=function(){return this.residueStore.getInscode(this.index)},Tb.inscode.set=function(t){this.residueStore.getInscode(this.index,t)},Tb.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},Tb.resname.get=function(){return this.residueType.resname},Tb.hetero.get=function(){return this.residueType.hetero},Tb.moleculeType.get=function(){return this.residueType.moleculeType},Tb.backboneType.get=function(){return this.residueType.backboneType},Tb.backboneStartType.get=function(){return this.residueType.backboneStartType},Tb.backboneEndType.get=function(){return this.residueType.backboneEndType},Tb.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},Tb.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},Tb.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},Tb.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},Tb.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},Tb.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},Eb.prototype.eachAtom=function(t,e){var r,i=this.atomCount,n=this.atomOffset,o=this.structure._ap,a=n+i;if(e&&e.atomOnlyTest){var s=e.atomOnlyTest;for(r=n;r0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},Eb.prototype.isHetero=function(){return 1===this.residueType.hetero},Eb.prototype.isWater=function(){return 1===this.residueType.moleculeType},Eb.prototype.isIon=function(){return 2===this.residueType.moleculeType},Eb.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},Eb.prototype.isHelix=function(){return Ey.includes(this.sstruc)},Eb.prototype.isSheet=function(){return Ty.includes(this.sstruc)},Eb.prototype.isTurn=function(){return Cy.includes(this.sstruc)&&this.isProtein()},Eb.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},Eb.prototype.getResname1=function(){return Dy[this.resname.toUpperCase()]||"X"},Eb.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},Eb.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},Eb.prototype.getAtomByName=function(t){return this.residueType.getAtomByName(t)},Eb.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},Eb.prototype.getAtomnameList=function(){var t=this;console.warn("getAtomnameList - might be expensive");for(var e=this.atomCount,r=this.atomOffset,i=new Array(e),n=0;n=t){var r=this.structure.getResidueProxy(e);if(r.connectedTo(this))return r}else if(e===t-1){var i=this.chainStore.residueCount[this.chainIndex],n=this.structure.getResidueProxy(t+i-1);if(n.connectedTo(this))return n}},Eb.prototype.getBonds=function(){return this.residueType.getBonds(this)},Eb.prototype.getRings=function(){return this.residueType.getRings()},Eb.prototype.qualifiedName=function(t){var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex},Eb.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Eb.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(Eb.prototype,Tb);var Cb=function(t,e,r){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueIndexStart=e,this.residueIndexEnd=r,this.residueCount=r-e+1;var i=this.structure.getResidueProxy(this.residueIndexStart),n=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==i.getPreviousConnectedResidue();var o=n.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=this.isNextConnected&&void 0!==o.getNextConnectedResidue(),this.isCyclic=n.connectedTo(i),this.__residueProxy=this.structure.getResidueProxy()},Ib={chainIndex:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0}};Ib.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},Ib.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},Ib.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},Cb.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},Cb.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},Cb.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},Cb.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},Cb.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},Cb.prototype.getAtomIndexByType=function(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));var r=this.__residueProxy;r.index=this.residueIndexStart+t;var i;switch(e){case"trace":i=r.traceAtomIndex;break;case"direction1":i=r.direction1AtomIndex;break;case"direction2":i=r.direction2AtomIndex;break;default:var n=r.getAtomByName(e);i=n?n.index:void 0}return i},Cb.prototype.eachAtom=function(t,e){this.eachResidue(function(r){r.eachAtom(t,e)},e)},Cb.prototype.eachAtomN=function(t,e,r){var i,n=this,o=this.residueCount,a=new Array(t);for(i=0;i=n&&r=t&&e.apply(this,s)}})}},Cb.prototype.eachResidue=function(t){for(var e=this.structure.getResidueProxy(),r=this.residueCount,i=this.residueIndexStart,n=0;n1&&t(new Cb(o,r,u.index)),r=i)):(m!==by&&u.index-r>1&&t(new Cb(o,r,u.index)),r=i)}i-r>1&&this.structure.getResidueProxy(r).backboneEndType&&t(new Cb(o,r,i))},Rb.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},Rb.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Rb.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(Rb.prototype,Lb);var Ob=function(t,e){this.structure=t,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e},Db={chainOffset:{configurable:!0},chainCount:{configurable:!0},residueOffset:{configurable:!0},atomOffset:{configurable:!0},chainEnd:{configurable:!0},residueEnd:{configurable:!0},atomEnd:{configurable:!0},residueCount:{configurable:!0},atomCount:{configurable:!0}};Db.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},Db.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},Db.chainCount.get=function(){return this.modelStore.chainCount[this.index]},Db.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},Db.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},Db.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},Db.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},Db.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},Db.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},Db.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},Db.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},Ob.prototype.eachAtom=function(t,e){this.eachChain(function(r){r.eachAtom(t,e)},e)},Ob.prototype.eachResidue=function(t,e){this.eachChain(function(r){r.eachResidue(t,e)},e)},Ob.prototype.eachPolymer=function(t,e){if(e&&e.chainOnlyTest){var r=e.chainOnlyTest;this.eachChain(function(i){r(i)&&i.eachPolymer(t,e)})}else this.eachChain(function(r){r.eachPolymer(t,e)})},Ob.prototype.eachChain=function(t,e){var r,i=this.chainCount,n=this.chainOffset,o=this.structure._cp,a=n+i;if(e&&e.test){var s=e.chainOnlyTest;if(s)for(r=n;r1?(C=r.atomRadius(w),I=C*g/(.5*T),x.calculateShiftDir(N),m?(R=2*y*C,N.multiplyScalar(R),N.negate(),D.subVectors(S,w).multiplyScalar(Math.max(.1,R/1.88)),w.positionToArray(n,P),S.positionToArray(o,P),T>=2&&(O.addVectors(w,N).add(D).toArray(n,P+3),O.addVectors(S,N).sub(D).toArray(o,P+3),T>=3&&(O.subVectors(w,N).add(D).toArray(n,P+6),O.subVectors(S,N).sub(D).toArray(o,P+6)))):(R=(y-g)*C,N.multiplyScalar(R),2===T?(O.addVectors(w,N).toArray(n,P),O.subVectors(w,N).toArray(n,P+3),O.addVectors(S,N).toArray(o,P),O.subVectors(S,N).toArray(o,P+3)):3===T?(w.positionToArray(n,P),O.addVectors(w,N).toArray(n,P+3),O.subVectors(w,N).toArray(n,P+6),S.positionToArray(o,P),O.addVectors(S,N).toArray(o,P+3),O.subVectors(S,N).toArray(o,P+6)):(w.positionToArray(n,P),S.positionToArray(o,P)))):(w.positionToArray(n,P),S.positionToArray(o,P))),a&&(i.bondColorToArray(x,1,a,P),i.bondColorToArray(x,0,s,P),f&&T>1))for(M=1;M1))for(M=1;M1))for(I=u[L]*g/(m?1:.5*T),M=m?1:0;M1))for(I=l[L]*g/(m?1:.5*T),M=m?1:0;Ma&&(a=e),r>s&&(s=r),u>c&&(c=u)},e),r.min.set(i,n,o),r.max.set(a,s,c),t.Debug&&Lm.timeEnd("getBoundingBox"),r},Nb.prototype.getPrincipalAxes=function(e){t.Debug&&Lm.time("getPrincipalAxes");var r=0,i=new cs(3,this.atomCount),n=i.data;return this.eachAtom(function(t){n[r+0]=t.x,n[r+1]=t.y,n[r+2]=t.z,r+=3},e),t.Debug&&Lm.timeEnd("getPrincipalAxes"),new Yy(i)},Nb.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter():this.center.clone()},Nb.prototype.hasCoords=function(){var t=this.atomStore;return 0!==wa(t.x)||0!==_a(t.x)||0!==wa(t.y)||0!==_a(t.y)||0!==wa(t.z)||0!==_a(t.z)},Nb.prototype.getSequence=function(t){var e=[],r=this.getResidueProxy();return this.eachAtom(function(t){r.index=t.residueIndex,t.index===r.traceAtomIndex&&e.push(r.getResname1())},t),e},Nb.prototype.getAtomIndices=function(t){var e;if(t&&t.string)e=[],this.eachAtom(function(t){e.push(t.index)},t);else{var r={what:{index:!0}};e=this.getAtomData(r).index}return e},Nb.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain(function(t){t.residueCount&&e.add(t.chainname)},t),e.size},Nb.prototype.updatePosition=function(t){var e=0;this.eachAtom(function(r){r.positionFromArray(t,e),e+=3})},Nb.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Cs(this.atomStore,this.boundingBox)},Nb.prototype.dispose=function(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondStore,delete this.atomStore,delete this.residueStore,delete this.chainStore,delete this.modelStore,delete this.frames,delete this.boxes,delete this.cif,delete this.bondSet,delete this.atomSet},Object.defineProperties(Nb.prototype,kb);var Bb=function(t,e){var r;"function"==typeof t.eachAtom?r=t.atomCount:t instanceof Float32Array&&(r=t.length/3);var i;"function"==typeof e.eachAtom?i=e.atomCount:t instanceof Float32Array&&(i=e.length/3);var n=Math.min(r,i),o=new cs(3,n),a=new cs(3,n);this.coords1t=new cs(n,3),this.coords2t=new cs(n,3),this.A=new cs(3,3),this.W=new cs(1,3),this.U=new cs(3,3),this.V=new cs(3,3),this.VH=new cs(3,3),this.R=new cs(3,3),this.tmp=new cs(3,3),this.c=new cs(3,3),this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,o,n),this.prepCoords(e,a,n),this._superpose(o,a)};Bb.prototype._superpose=function(e,r){this.mean1=fs(e),this.mean2=fs(r),ms(e,this.mean1),ms(r,this.mean2),us(this.coords1t,e),us(this.coords2t,r),ls(this.A,this.coords2t,this.coords1t),xs(this.A,this.W,this.U,this.V),hs(this.V,this.VH),ds(this.R,this.U,this.VH),ps(this.R)<0&&(t.Debug&&Lm.log("R not a right handed system"),ds(this.tmp,this.c,this.VH),ds(this.R,this.U,this.tmp))},Bb.prototype.prepCoords=function(t,e,r){var i=0,n=3*r,o=e.data;"function"==typeof t.eachAtom?t.eachAtom(function(t){i=r)if(this.interpolateType)if(this._currentStep>this.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),i.hasFrame(this._currentFrame)){this._currentStep+=1;var n=this._currentStep/(this.interpolateStep+1);i.setFrameInterpolated.apply(i,this._currentFrame.concat([n],[this.interpolateType])),this._previousTime=this._currentTime}else i.loadFrame(this._currentFrame);else{var o=this._next();i.hasFrame(o)?(i.setFrame(o),this._previousTime=this._currentTime):i.loadFrame(o)}window.requestAnimationFrame(this._animate)}},Fb.prototype._next=function(){var t;return t="forward"===this._direction?this.traj.currentFrame+this.step:this.traj.currentFrame-this.step,(t>this.end||t=this.end?e=this.start:"backward"===this.direction&&t<=this.start&&(e=this.end),this.traj.setFrame(e),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}},Fb.prototype.pause=function(){this._run=!1,this.signals.haltedRunning.dispatch()},Fb.prototype.stop=function(){this.pause(),this.traj.setFrame(this.start)},Object.defineProperties(Fb.prototype,zb);var Ub=function(t,e,r){this.signals={countChanged:new ko,frameChanged:new ko,playerChanged:new ko};var i=r||{};this.deltaTime=Xn(i.deltaTime,0),this.timeOffset=Xn(i.timeOffset,0),this.centerPbc=Xn(i.centerPbc,!1),this.removePbc=Xn(i.removePbc,!1),this.removePeriodicity=Xn(i.removePeriodicity,!1),this.superpose=Xn(i.superpose,!1),this.name=t.replace(/^.*[\\\/]/,""),this.trajPath=t,this.initialCoords=null,this.structureCoords=null,this.selection=new ym(Xn(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add(function(){this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},this),this._frameCount=0,this._currentFrame=-1},jb={frameCount:{configurable:!0}, +currentFrame:{configurable:!0}};jb.frameCount.get=function(){return this._frameCount},jb.currentFrame.get=function(){return this._currentFrame},Ub.prototype._init=function(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new Fb(this))},Ub.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new ym("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},Ub.prototype._saveInitialCoords=function(){var t=this;this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,function(){return t._saveInitialCoords()})},Ub.prototype._saveStructureCoords=function(){var t={what:{position:!0}};this.structureCoords=this.structure.getAtomData(t).position},Ub.prototype.setSelection=function(t){return this.selection.setString(t),this},Ub.prototype._getIndices=function(t){var e=0,r=t.test,i=[];return this.structure.eachAtom(function(t){r(t)&&i.push(e),e+=1}),i},Ub.prototype._makeSuperposeCoords=function(){var t=this,e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);for(var r=this.initialCoords,i=this.coords2,n=0;n0&&this.centerPbc){var n=[e[0],e[4],e[8]];sc(r,lc(this.backboneIndices,r,n),n)}if(this.removePeriodicity){uc(r,e,hc(r))}this.removePbc&&cc(r,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(r),this.frameCache[t]=r,this.boxCache[t]=e,this.frameCacheSize+=1},Ub.prototype._setFrameCount=function(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))},Ub.prototype.dispose=function(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()},Ub.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},Ub.prototype.getPath=function(t,e){Lm.error("Trajectory.getPath not implemented",t,e)},Ub.prototype.getFrameTime=function(t){return this.timeOffset+t*this.deltaTime},Object.defineProperties(Ub.prototype,jb),Um.add("shader/Mesh.vert","#define STANDARD\nuniform float nearClip;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#elif defined( NOLIGHT )\nvarying vec3 vColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#elif defined( NOLIGHT )\nvColor = color;\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\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Um.add("shader/Mesh.frag","#define STANDARD\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\nuniform float clipRadius;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\n#elif defined( NOLIGHT )\nvarying vec3 vColor;\n#else\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars\n#include lights_physical_pars_fragment\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.7 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#elif defined( NOLIGHT )\ngl_FragColor = vec4( vColor, opacity );\n#else\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_flip\n#include normal_fragment\n#include dull_interior_fragment\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#include opaque_back_fragment\n#endif\n}");var Vb={f:1,v2:2,v3:3,c:3},Gb=function(t,e){var r=t||{},i=e||{};this.opaqueBack=Xn(i.opaqueBack,!1),this.dullInterior=Xn(i.dullInterior,!1),this.side=Xn(i.side,"double"),this.opacity=Xn(i.opacity,1),this.depthWrite=Xn(i.depthWrite,!0),this.clipNear=Xn(i.clipNear,0),this.clipRadius=Xn(i.clipRadius,0),this.clipCenter=Xn(i.clipCenter,new v),this.flatShaded=Xn(i.flatShaded,!1),this.background=Xn(i.background,!1),this.wireframe=Xn(i.wireframe,!1),this.roughness=Xn(i.roughness,.4),this.metalness=Xn(i.metalness,0),this.diffuse=Xn(i.diffuse,16777215),this.forceTransparent=Xn(i.forceTransparent,!1),this.disablePicking=Xn(i.disablePicking,!1),this.geometry=new Ft,this.indexVersion=0,this.wireframeIndexVersion=-1,this.uniforms=Zp.merge([Yp.common,{fogColor:{value:null},fogNear:{value:0},fogFar:{value:0},opacity:{value:this.opacity},nearClip:{value:0},clipRadius:{value:this.clipRadius},clipCenter:{value:this.clipCenter}},{emissive:{value:new et(0)},roughness:{value:this.roughness},metalness:{value:this.metalness}},Yp.ambient,Yp.lights]),this.uniforms.diffuse.value.set(this.diffuse),this.pickingUniforms={nearClip:{value:0},objectId:{value:0},opacity:{value:this.opacity}},this.group=new qe,this.wireframeGroup=new qe,this.pickingGroup=new qe,this.matrix=Xn(i.matrix,new y);var n=r.position||r.position1;this._positionDataSize=n?n.length/3:0,this.addAttributes({position:{type:"v3",value:r.position},color:{type:"c",value:r.color},primitiveId:{type:"f",value:r.primitiveId}}),r.index&&this.initIndex(r.index),this.picking=r.picking,this.makeWireframeGeometry()},$b={parameters:{configurable:!0},matrix:{configurable:!0},transparent:{configurable:!0},size:{configurable:!0},attributeSize:{configurable:!0},pickable:{configurable:!0},dynamic:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};$b.parameters.get=function(){return{opaqueBack:{updateShader:!0},dullInterior:{updateShader:!0},side:{updateShader:!0,property:!0},opacity:{uniform:!0},depthWrite:{property:!0},clipNear:{updateShader:!0,property:!0},clipRadius:{updateShader:!0,property:!0,uniform:!0},clipCenter:{uniform:!0},flatShaded:{updateShader:!0},background:{updateShader:!0},wireframe:{updateVisibility:!0},roughness:{uniform:!0},metalness:{uniform:!0},diffuse:{uniform:!0},matrix:{}}},$b.matrix.set=function(t){this.setMatrix(t)},$b.matrix.get=function(){return this.group.matrix.clone()},$b.transparent.get=function(){return this.opacity<1||this.forceTransparent},$b.size.get=function(){return this._positionDataSize},$b.attributeSize.get=function(){return this.size},$b.pickable.get=function(){return!!this.picking&&!this.disablePicking},$b.dynamic.get=function(){return!0},$b.vertexShader.get=function(){},$b.fragmentShader.get=function(){},Gb.prototype.setMatrix=function(t){mc(this.group,t),mc(this.wireframeGroup,t),mc(this.pickingGroup,t)},Gb.prototype.initIndex=function(t){this.geometry.setIndex(new Pt(t,1)),this.geometry.getIndex().setDynamic(this.dynamic)},Gb.prototype.makeMaterial=function(){var t=fc(this.side),e=new st({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!0,fog:!0,side:t});e.vertexColors=Zl,e.extensions.derivatives=this.flatShaded,e.extensions.fragDepth=this.isImpostor,e.clipNear=this.clipNear;var r=new st({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!1,fog:!0,side:t});r.vertexColors=Zl,r.clipNear=this.clipNear;var i=new st({uniforms:this.pickingUniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:!1,depthWrite:this.depthWrite,lights:!1,fog:!1,side:t,blending:Kl});i.vertexColors=Zl,i.extensions.fragDepth=this.isImpostor,i.clipNear=this.clipNear,this.material=e,this.wireframeMaterial=r,this.pickingMaterial=i,this.updateShader()},Gb.prototype.makeWireframeGeometry=function(){this.makeWireframeIndex();var t=this.geometry,e=this.wireframeIndex,r=new Ft;r.attributes=t.attributes,e&&(r.setIndex(new Pt(e,1).setDynamic(this.dynamic)),r.setDrawRange(0,this.wireframeIndexCount)),this.wireframeGeometry=r},Gb.prototype.makeWireframeIndex=function(){function t(t,r){if(t>r){var i=t;t=r,r=i}var n=e[t];return void 0===n?(e[t]=[r],!0):!n.includes(r)&&(n.push(r),!0)}var e=[],r=this.geometry,i=r.index;if(this.wireframe)if(i){var n=i.array,o=n.length;r.drawRange.count!==1/0&&(o=r.drawRange.count);var a;if(this.wireframeIndex&&this.wireframeIndex.length>2*o)a=this.wireframeIndex;else{var s=r.attributes.position.count;a=lo(2*o,s)}var c=0;e.length=0;for(var u=0;u2*f?this.wireframeIndex:lo(2*f,f);for(var m=0,g=0;mthis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new Pt(this.wireframeIndex,1).setDynamic(this.dynamic));else{var t=this.wireframeGeometry.getIndex();t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)},Gb.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},Gb.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,r=this.geometry,i=this[t];return this.isLine?e=new $e(r,i):this.isPoint?(e=new Xe(r,i),this.sortParticles&&(e.sortParticles=!0)):e=new Xt(r,i),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},Gb.prototype.getMesh=function(){return this._getMesh("material")},Gb.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),t=new $e(this.wireframeGeometry,this.wireframeMaterial),t.frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},Gb.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},Gb.prototype.getShader=function(t,e){return ca(t,this.getDefines(e))},Gb.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},Gb.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},Gb.prototype.getDefines=function(t){var e={};return this.clipNear&&(e.NEAR_CLIP=1),this.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.background)&&(e.NOLIGHT=1),this.flatShaded&&(e.FLAT_SHADED=1),this.opaqueBack&&(e.OPAQUE_BACK=1),this.dullInterior&&(e.DULL_INTERIOR=1)),e},Gb.prototype.getParameters=function(){var t=this,e={};for(var r in t.parameters)e[r]=t[r];return e},Gb.prototype.addUniforms=function(t){this.uniforms=Zp.merge([this.uniforms,t]),this.pickingUniforms=Zp.merge([this.pickingUniforms,t])},Gb.prototype.addAttributes=function(t){var e=this;for(var r in t){var i=void 0,n=t[r],o=e.attributeSize*Vb[n.type];n.value?(o!==n.value.length&&Lm.error("attribute value has wrong length",r),i=n.value):i=uo("float32",o),e.geometry.addAttribute(r,new Pt(i,Vb[n.type]).setDynamic(e.dynamic))}},Gb.prototype.updateRenderOrder=function(){function t(t){t.renderOrder=e}var e=this.getRenderOrder();this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)},Gb.prototype.updateShader=function(){var t=this.material,e=this.wireframeMaterial,r=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,r.vertexShader=this.getVertexShader("picking"),r.fragmentShader=this.getFragmentShader("picking"),r.needsUpdate=!0},Gb.prototype.setParameters=function(t){var e=this;if(t){var r=t,i=this.parameters,n={},o={},a=!1,s=!1;for(var c in r){var u=r[c];void 0!==u&&(void 0!==i[c]&&(e[c]=u,i[c].property&&(!0!==i[c].property?n[i[c].property]=u:n[c]=u),i[c].uniform&&(!0!==i[c].uniform?o[i[c].uniform]=u:o[c]=u),i[c].updateShader&&(a=!0),i[c].updateVisibility&&(s=!0),e.dynamic&&"wireframe"===c&&!0===u&&e.updateWireframeIndex(),"flatShaded"===c&&(e.material.extensions.derivatives=e.flatShaded),"forceTransparent"===c&&(n.transparent=e.transparent)))}this.setProperties(n),this.setUniforms(o),a&&this.updateShader(),s&&this.setVisibility(this.visible)}},Gb.prototype.setAttributes=function(t){var e=this,r=this.geometry,i=r.attributes;for(var n in t)if("picking"!==n){var o=t[n],a=o.length;if("index"===n){var s=r.getIndex();r.setDrawRange(0,1/0),a>s.array.length?r.setIndex(new Pt(o,1).setDynamic(e.dynamic)):(s.set(o),s.needsUpdate=a>0,s.updateRange.count=a,r.setDrawRange(0,a)),e.indexVersion++,e.wireframe&&e.updateWireframeIndex()}else{var c=i[n];a>c.array.length?r.addAttribute(n,new Pt(o,c.itemSize).setDynamic(e.dynamic)):(i[n].set(o),i[n].needsUpdate=a>0,i[n].updateRange.count=a)}}},Gb.prototype.setUniforms=function(t){var e=this;if(t){var r=this.material.uniforms,i=this.wireframeMaterial.uniforms,n=this.pickingMaterial.uniforms;for(var o in t)"opacity"===o&&e.setProperties({transparent:e.transparent}),void 0!==r[o]&&(r[o].value.isVector3?r[o].value.copy(t[o]):r[o].value.set?r[o].value.set(t[o]):r[o].value=t[o]),void 0!==i[o]&&(i[o].value.isVector3?i[o].value.copy(t[o]):i[o].value.set?i[o].value.set(t[o]):i[o].value=t[o]),void 0!==n[o]&&(n[o].value.isVector3?n[o].value.copy(t[o]):n[o].value.set?n[o].value.set(t[o]):n[o].value=t[o])}},Gb.prototype.setProperties=function(t){var e=this;if(t){var r=this.material,i=this.wireframeMaterial,n=this.pickingMaterial;for(var o in t){var a=t[o];"transparent"===o?e.updateRenderOrder():"side"===o&&(a=fc(a)),void 0!==r[o]&&(r[o]=a),void 0!==i[o]&&(i[o]=a),void 0!==n[o]&&(n[o]=a)}r.needsUpdate=!0,i.needsUpdate=!0,n.needsUpdate=!0}},Gb.prototype.setVisibility=function(t){this.visible=t,this.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))},Gb.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},Object.defineProperties(Gb.prototype,$b);var Hb=function(t){function e(e,r){var i=e||{};!i.primitiveId&&i.position&&(i.primitiveId=ma(i.position.length/3)),t.call(this,i,r),this.addAttributes({normal:{type:"v3",value:i.normal}}),void 0===i.normal&&this.geometry.computeVertexNormals()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return r.vertexShader.get=function(){return"Mesh.vert"},r.fragmentShader.get=function(){return"Mesh.frag"},Object.defineProperties(e.prototype,r),e}(Gb),Wb=new lt,Xb=[zv,Nv,Uv,Fv,jv,kv,Dv,Bv,Gv,Vv],qb=function(t,e){var r=this;this.name=Xn(t,"shape");var i=e||{};this.aspectRatio=Xn(i.aspectRatio,1.5),this.sphereDetail=Xn(i.sphereDetail,2),this.radialSegments=Xn(i.radialSegments,50),this.disableImpostor=Xn(i.disableImpostor,!1),this.openEnded=Xn(i.openEnded,!1),this.labelParams=Xn(i.labelParams,{}),this.boundingBox=new lt,this.bufferList=[],this.meshCount=0,Xb.forEach(function(t){Object.keys(t.fields).forEach(function(e){r[t.getShapeKey(e)]=[]}),r[t.getShapeKey("name")]=[]})},Yb={center:{configurable:!0},type:{configurable:!0}};qb.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},qb.prototype.addMesh=function(t,e,r,i,n){t=xo(t),e=xo(e),Array.isArray(r)&&(r=lo(r,t.length)),i&&(i=xo(i));var o={position:t,color:e,index:r,normal:i},a=new oy(this,Object.assign({serial:this.meshCount,name:n},o)),s=new Hb(Object.assign({picking:a},o));return this.bufferList.push(s),Wb.setFromArray(t),this.boundingBox.union(Wb),this.meshCount+=1,this},qb.prototype.addSphere=function(t,e,r,i){return Dv.objectToShape(this,{position:t,color:e,radius:r,name:i}),this},qb.prototype.addEllipsoid=function(t,e,r,i,n,o){return jv.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:n,name:o}),this},qb.prototype.addTorus=function(t,e,r,i,n,o){return Vv.objectToShape(this,{position:t,color:e,radius:r,majorAxis:i,minorAxis:n,name:o}),this},qb.prototype.addCylinder=function(t,e,r,i,n){return Fv.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:n}),this},qb.prototype.addCone=function(t,e,r,i,n){return Uv.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:n}),this},qb.prototype.addArrow=function(t,e,r,i,n){return zv.objectToShape(this,{position1:t,position2:e,color:r,radius:i,name:n}),this},qb.prototype.addBox=function(t,e,r,i,n,o){return Nv.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:n,name:o}),this},qb.prototype.addOctahedron=function(t,e,r,i,n,o){return kv.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:n,name:o}),this},qb.prototype.addTetrahedron=function(t,e,r,i,n,o){return Bv.objectToShape(this,{position:t,color:e,size:r,heightAxis:i,depthAxis:n,name:o}),this},qb.prototype.addText=function(t,e,r,i){return Gv.objectToShape(this,{position:t,color:e,size:r,text:i}),this},qb.prototype.addLabel=function(t,e,r,i){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,r,i)},qb.prototype.getBufferList=function(){var t=this,e=[],r={aspectRatio:this.aspectRatio,sphereDetail:this.sphereDetail,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded,labelParams:this.labelParams};return Xb.forEach(function(i){t[i.getShapeKey("color")].length&&e.push(i.bufferFromShape(t,r))}),this.bufferList.concat(e)},qb.prototype.dispose=function(){var t=this;this.bufferList.forEach(function(t){t.dispose()}),this.bufferList.length=0,Xb.forEach(function(e){Object.keys(e.fields).forEach(function(r){t[e.getShapeKey(r)].length=0}),t[e.getShapeKey("name")].length=0})},Yb.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter()),this._center},Yb.type.get=function(){return"Shape"},Object.defineProperties(qb.prototype,Yb);var Zb=function(t,e,r){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:km.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:km.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=e,this.tasks=new lg,this.queue=new gc(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=km.getSchemes())};Zb.prototype.init=function(t){var e=t||{};this.clipNear=Xn(e.clipNear,0),this.clipRadius=Xn(e.clipRadius,0),this.clipCenter=Xn(e.clipCenter,new v),this.flatShaded=Xn(e.flatShaded,!1),this.side=Xn(e.side,"double"),this.opacity=Xn(e.opacity,1),this.depthWrite=Xn(e.depthWrite,!0),this.wireframe=Xn(e.wireframe,!1),this.setColor(e.color,e),this.colorScheme=Xn(e.colorScheme,"uniform"),this.colorScale=Xn(e.colorScale,""),this.colorReverse=Xn(e.colorReverse,!1),this.colorValue=Xn(e.colorValue,9474192),this.colorDomain=Xn(e.colorDomain,void 0),this.colorMode=Xn(e.colorMode,"hcl"),this.visible=Xn(e.visible,!0),this.quality=Xn(e.quality,void 0),this.roughness=Xn(e.roughness,.4),this.metalness=Xn(e.metalness,0),this.diffuse=Xn(e.diffuse,16777215),this.lazy=Xn(e.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=Xn(e.matrix,new y),this.disablePicking=Xn(e.disablePicking,!1);var r=this.parameters;!0===r.sphereDetail&&(r.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===r.radialSegments&&(r.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===r.openEnded&&(r.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===r.disableImpostor&&(r.disableImpostor={type:"boolean",rebuild:!0}),"low"===e.quality?(r.sphereDetail&&(this.sphereDetail=0),r.radialSegments&&(this.radialSegments=5)):"medium"===e.quality?(r.sphereDetail&&(this.sphereDetail=1),r.radialSegments&&(this.radialSegments=10)):"high"===e.quality?(r.sphereDetail&&(this.sphereDetail=2),r.radialSegments&&(this.radialSegments=20)):(r.sphereDetail&&(this.sphereDetail=Xn(e.sphereDetail,1)),r.radialSegments&&(this.radialSegments=Xn(e.radialSegments,10))),r.openEnded&&(this.openEnded=Xn(e.openEnded,!0)),r.disableImpostor&&(this.disableImpostor=Xn(e.disableImpostor,!1))},Zb.prototype.getColorParams=function(t){return Object.assign({scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode},t)},Zb.prototype.getBufferParams=function(t){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,matrix:this.matrix,disablePicking:this.disablePicking},t)},Zb.prototype.setColor=function(t,e){var r=Object.keys(km.getSchemes());return"string"==typeof t&&r.includes(t.toLowerCase())?e?e.colorScheme=t:this.setParameters({colorScheme:t}):void 0!==t&&(t=new et(t).getHex(),e?(e.colorScheme="uniform",e.colorValue=t):this.setParameters({colorScheme:"uniform",colorValue:t})),this},Zb.prototype.create=function(){},Zb.prototype.update=function(){this.build()},Zb.prototype.build=function(t){return this.lazy&&!this.visible?void(this.lazyProps.build=!0):this.prepare?(this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),void this.queue.push(t||!1)):(this.tasks.increment(),void this.make())},Zb.prototype.make=function(e,r){t.Debug&&Lm.time("Representation.make "+this.type);var i=function(){e?(this.update(e),this.viewer.requestRender(),this.tasks.decrement(),r&&r()):(this.clear(),this.create(),this.manualAttach||this.disposed||(t.Debug&&Lm.time("Representation.attach "+this.type),this.attach(function(){t.Debug&&Lm.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),r&&r()}.bind(this)))),t.Debug&&Lm.timeEnd("Representation.make "+this.type)}.bind(this);this.prepare?this.prepare(i):i()},Zb.prototype.attach=function(t){this.setVisibility(this.visible),t()},Zb.prototype.setVisibility=function(t,e){if(this.visible=t,this.visible){var r=this.lazyProps,i=r.bufferParams,n=r.what;if(r.build)return r.build=!1,void this.build();(Object.keys(i).length||Object.keys(n).length)&&(r.bufferParams={},r.what={},this.updateParameters(i,n))}return this.bufferList.forEach(function(e){e.setVisibility(t)}),e||this.viewer.requestRender(),this},Zb.prototype.setParameters=function(t,e,r){var i=this,n=t||{},o=this.parameters;this.setColor(n.color,n),e=e||{},r=r||!1;var a={};for(var s in n)void 0!==n[s]&&void 0!==o[s]&&(o[s].int&&(n[s]=parseInt(n[s])),o[s].float&&(n[s]=parseFloat(n[s])),(n[s]!==i[s]||n[s].equals&&!n[s].equals(i[s]))&&(i[s]&&i[s].set?i[s].set(n[s]):i[s]=n[s],o[s].buffer&&(!0===o[s].buffer?a[s]=n[s]:a[o[s].buffer]=n[s]),o[s].update&&(e[o[s].update]=!0),!o[s].rebuild||"impostor"===o[s].rebuild&&Rm&&!i.disableImpostor||(r=!0)));return r?this.build():this.updateParameters(a,e),this},Zb.prototype.updateParameters=function(t,e){if(this.lazy&&!this.visible)return Object.assign(this.lazyProps.bufferParams,t),void Object.assign(this.lazyProps.what,e);this.bufferList.forEach(function(e){e.setParameters(t)}),Object.keys(e).length&&this.update(e),this.viewer.requestRender()},Zb.prototype.getParameters=function(){var t=this,e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(function(r){null!==t.parameters[r]&&(e[r]=t[r])}),e},Zb.prototype.clear=function(){var t=this;this.bufferList.forEach(function(e){t.viewer.remove(e),e.dispose()}),this.bufferList.length=0,this.viewer.requestRender()},Zb.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var Kb=function(t){function e(e,r,i){Array.isArray(e)||(e=[e]),t.call(this,e,r,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){t.prototype.init.call(this,e),this.build()},e.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t),t.setParameters(e.getBufferParams())}),this.setVisibility(this.visible),t()},e}(Zb),Qb=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={isSurface:{configurable:!0}};return r.isSurface.get=function(){return!0},Object.defineProperties(e.prototype,r),e}(Hb),Jb=function(t){this.size=t.size,this.side=t.side,this.wireframe=t.wireframe,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.background=t.background,this.disablePicking=t.disablePicking,this.group=new qe,this.wireframeGroup=new qe,this.pickingGroup=new qe,this.matrix=t.matrix,this.frontMeshes=[],this.backMeshes=[];var e=t,r=new t.constructor;e.makeMaterial(),r.makeMaterial(),r.picking=t.picking,r.geometry=t.geometry,r.wireframeGeometry=t.wireframeGeometry,r.setParameters(t.getParameters()),r.updateShader(),e.setParameters({side:"front"}),r.setParameters({side:"back",opacity:r.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=r},tx={matrix:{configurable:!0},pickable:{configurable:!0}};tx.matrix.set=function(t){Gb.prototype.setMatrix.call(this,t)},tx.matrix.get=function(){return this.group.matrix.clone()},tx.pickable.get=function(){return!!this.picking&&!this.disablePicking},Jb.prototype.getMesh=function(t){var e,r;return t?(r=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(r=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(r),this.setParameters({side:this.side}),(new qe).add(r,e)},Jb.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},Jb.prototype.getPickingMesh=function(){return this.getMesh(!0)},Jb.prototype.setAttributes=function(t){this.buffer.setAttributes(t)}, +Jb.prototype.setParameters=function(t){t=Object.assign({},t),"front"===t.side?(this.frontMeshes.forEach(vc),this.backMeshes.forEach(yc)):"back"===t.side?(this.frontMeshes.forEach(yc),this.backMeshes.forEach(vc)):"double"===t.side&&(this.frontMeshes.forEach(vc),this.backMeshes.forEach(vc)),void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,void 0!==t.side&&(this.side=t.side),delete t.side,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)},Jb.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},Object.defineProperties(Jb.prototype,tx),Jb.prototype.setVisibility=Gb.prototype.setVisibility,Um.add("shader/Line.vert","uniform float nearClip;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Um.add("shader/Line.frag","uniform float opacity;\nuniform float nearClip;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");var ex=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={isLine:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return r.isLine.get=function(){return!0},r.vertexShader.get=function(){return"Line.vert"},r.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,r),e}(Gb),rx=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof Qy?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new v,this.__boxCenter=new v,this.box=new lt,this.__box=new lt,this._position=new v,this.setBox=function(){this._position.copy(r.translationGroup.position).negate(),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.viewer.signals.ticked.add(this.setBox,this),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=Xn(r.colorScheme,"uniform"),r.colorValue=Xn(r.colorValue,14540253),this.isolevelType=Xn(r.isolevelType,"sigma"),this.isolevel=Xn(r.isolevel,2),this.negateIsolevel=Xn(r.negateIsolevel,!1),this.smooth=Xn(r.smooth,0),this.background=Xn(r.background,!1),this.opaqueBack=Xn(r.opaqueBack,!0),this.boxSize=Xn(r.boxSize,0),this.colorVolume=Xn(r.colorVolume,void 0),this.contour=Xn(r.contour,!1),this.useWorker=Xn(r.useWorker,!0),this.wrap=Xn(r.wrap,!1),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.prepare=function(t){var e=this;if(this.volume){var r;if(r="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(r*=-1),!this.surface||this.__isolevel!==r||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=r,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var i=function(r){e.surface=r,t()};this.useWorker?this.volume.getSurfaceWorker(r,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(r,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t()}else t()},e.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new ex(e,this.getBufferParams({wireframe:!1}));else{e.normal=this.surface.getNormal(),e.picking=this.surface.getPicking();var r=new Qb(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new Jb(r)}this.bufferList.push(t)},e.prototype.update=function(t){if(0!==this.bufferList.length){t=t||{};var e={};t.position&&(e.position=this.surface.getPosition()),t.color&&(e.color=this.surface.getColor(this.getColorParams())),t.index&&(e.index=this.surface.getIndex()),t.normal&&(e.normal=this.surface.getNormal()),this.bufferList.forEach(function(t){t.setAttributes(e)})}},e.prototype.setParameters=function(e,r,i){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,r,i),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&(r.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),t.prototype.dispose.call(this)},e}(Zb),ix=new y,nx=new pt,ox=function(t){function e(e,r,i){var n,o=e||{},a=r||{},s=i.attributes.position.array,c=i.attributes.normal.array,u=i.index?i.index.array:void 0,l=o.position.length/3,h=s.length/3,p=l*h,d=new Float32Array(3*p),f=new Float32Array(3*p),m=new Float32Array(3*p);u&&(n=lo(l*u.length,p)),t.call(this,{position:d,color:m,index:n,normal:f,primitiveId:o.primitiveId||ga(l,h),picking:o.picking},a),this.setAttributes(o),this.geoPosition=s,this.geoNormal=c,this.geoIndex=u,this.positionCount=l,this.geoPositionCount=h,this.transformedGeoPosition=new Float32Array(3*h),this.transformedGeoNormal=new Float32Array(3*h),this.meshPosition=d,this.meshColor=m,this.meshIndex=n,this.meshNormal=f,this.meshIndex=n,this.makeIndex()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={updateNormals:{configurable:!0}};return e.prototype.applyPositionTransform=function(){},e.prototype.setAttributes=function(t,e){var r,i,n,o,a,s,c,u,l,h=this,p=this.geometry.attributes,d=this.updateNormals;t.position&&(r=t.position,n=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,p.position.needsUpdate=!0,(d||e)&&(o=this.geoNormal,l=this.meshNormal,s=this.transformedGeoNormal,p.normal.needsUpdate=!0)),t.color&&(i=t.color,u=this.meshColor,p.color.needsUpdate=!0);for(var f=this.positionCount,m=this.geoPositionCount,g=0;g 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\nreturn false;\n}else{\ncameraNormal = normalize( cameraPos - cameraSpherePos );\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nreturn false;\n}else{\ncameraNormal = normalize( cameraPos - cameraSpherePos );\n}\n#endif\nreturn true;\n}\nreturn false;\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( - ( nearClip - 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\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_flip\n#include normal_fragment\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var cx=function(t){function e(e,r){t.call(this,e,r),this.index=lo(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index,1),this.addAttributes({mapping:{type:this.mappingType,value:null}}),this.setAttributes({primitiveId:ma(this.size)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={attributeSize:{configurable:!0},indexSize:{configurable:!0},mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingType:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.attributeSize.get=function(){return this.size*this.mappingSize},r.indexSize.get=function(){return this.size*this.mappingIndicesSize},r.mapping.get=function(){},r.mappingIndices.get=function(){},r.mappingIndicesSize.get=function(){},r.mappingType.get=function(){},r.mappingSize.get=function(){},r.mappingItemSize.get=function(){},e.prototype.addAttributes=function(e){var r={};for(var i in e){var n=e[i];r[i]={type:n.type,value:null}}t.prototype.addAttributes.call(this,r)},e.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},e.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=ha(t.position1,t.position2));var e,r,i,n,o,a,s,c=this.size,u=this.mappingSize,l=this.geometry.attributes;for(var h in t)if("index"!==h&&"picking"!==h){r=t[h],e=l[h],i=e.itemSize,n=e.array;for(var p=0;p0&&this.alphaTest<=1&&(r.ALPHATEST=this.alphaTest.toPrecision(2)),r},e.prototype.setUniforms=function(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.tex&&this.tex.dispose()},r.isPoint.get=function(){return!0},r.vertexShader.get=function(){return"Point.vert"},r.fragmentShader.get=function(){return"Point.frag"},Object.defineProperties(e.prototype,r),e}(Gb),mx=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Qy?(this.surface=void 0,this.volume=new tb(e)):(this.surface=e,this.volume=void 0),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.colorScheme=Xn(r.colorScheme,"uniform"),r.colorValue=Xn(r.colorValue,14540253),this.thresholdType=Xn(r.thresholdType,"sigma"),this.thresholdMin=Xn(r.thresholdMin,2),this.thresholdMax=Xn(r.thresholdMax,1/0),this.thresholdOut=Xn(r.thresholdOut,!1),this.dotType=Xn(r.dotType,"point"),this.radius=Xn(r.radius,.1),this.scale=Xn(r.scale,1),this.pointSize=Xn(r.pointSize,1),this.sizeAttenuation=Xn(r.sizeAttenuation,!0),this.sortParticles=Xn(r.sortParticles,!1),this.useTexture=Xn(r.useTexture,!1),this.alphaTest=Xn(r.alphaTest,.5),this.forceTransparent=Xn(r.forceTransparent,!1),this.edgeBleach=Xn(r.edgeBleach,0),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.create=function(){var t={};if(this.volume){var e,r,i=this.volume;"sigma"===this.thresholdType?(e=i.getValueForSigma(this.thresholdMin),r=i.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,r=this.thresholdMax),i.setFilter(e,r,this.thresholdOut),t.position=i.getDataPosition(),t.color=i.getDataColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=i.getDataSize(this.radius,this.scale),t.picking=i.getDataPicking())}else{var n=this.surface;t.position=n.getPosition(),t.color=n.getColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=n.getSize(this.radius,this.scale),t.picking=n.getPicking())}"sphere"===this.dotType?this.dotBuffer=new dx(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new fx(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)},e.prototype.update=function(t){if(0!==this.bufferList.length){t=t||{};var e={};t.color&&(this.volume?e.color=this.volume.getDataColor(this.getColorParams()):e.color=this.surface.getColor(this.getColorParams())),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?e.radius=this.volume.getDataSize(this.radius,this.scale):e.radius=this.surface.getSize(this.radius,this.scale)),this.dotBuffer.setAttributes(e)}},e.prototype.setParameters=function(e,r,i){return r=r||{},e&&void 0!==e.thresholdType&&this.volume instanceof Qy&&("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=e.radiusType,r.radius=!0,"sphere"!==this.dotType||Rm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(r.radius=!0,"sphere"!==this.dotType||Rm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(r.scale=!0,"sphere"!==this.dotType||Rm&&!this.disableImpostor||(i=!0)),t.prototype.setParameters.call(this,e,r,i),this},e}(Zb);Um.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}"),Um.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float nearClip;\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.7 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");var gx=new Uint16Array([0,1,2,1,3,2]),vx=new Float32Array([0,1,0,0,1,1,1,0]),yx=function(t){function e(e,r){var i=e||{},n=r||{};t.call(this,{position:i.position,index:gx,picking:i.picking},n),this.forceTransparent=!0,this.filter=Xn(n.filter,"nearest");var o=new b(i.imageData,i.width,i.height);o.flipY=!0,this.tex=o;for(var a=i.imageData.length,s=new Uint8Array(a),c=0;c>16&255,s[c+1]=u>>8&255,s[c+2]=255&u}var l=new b(s,i.width,i.height);l.flipY=!0,l.minFilter=Hh,l.magFilter=Hh,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new h(i.width,i.height)}}),this.geometry.addAttribute("uv",new Pt(vx,2))}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={parameters:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return r.parameters.get=function(){return Object.assign.call(this,{filter:{updateShader:!0,uniform:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e);return this.filter.startsWith("cubic")&&(r.CUBIC_INTERPOLATION=1,this.filter.endsWith("bspline")?r.BSPLINE_FILTER=1:this.filter.endsWith("catmulrom")?r.CATMULROM_FILTER=1:this.filter.endsWith("mitchell")&&(r.MITCHELL_FILTER=1)),r},e.prototype.updateTexture=function(){var t=this.tex;this.filter.startsWith("cubic")?(t.minFilter=Hh, +t.magFilter=Hh):"linear"===this.filter?(t.minFilter=qh,t.magFilter=qh):(t.minFilter=Hh,t.magFilter=Hh),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.updateTexture();var e=this.material;e.uniforms.map.value=this.tex,e.blending=Ql,e.needsUpdate=!0;var r=this.wireframeMaterial;r.uniforms.map.value=this.tex,r.blending=Ql,r.needsUpdate=!0;var i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=Ql,i.needsUpdate=!0},e.prototype.setUniforms=function(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},r.vertexShader.get=function(){return"Image.vert"},r.fragmentShader.get=function(){return"Image.frag"},Object.defineProperties(e.prototype,r),e}(Gb),bx=function(t,e){var r=e||{};this.dimension=Xn(r.dimension,"x"),this.positionType=Xn(r.positionType,"percent"),this.position=Xn(r.position,30),this.thresholdType=Xn(r.thresholdType,"sigma"),this.thresholdMin=Xn(r.thresholdMin,-1/0),this.thresholdMax=Xn(r.thresholdMax,1/0),this.normalize=Xn(r.normalize,!1),this.volume=t};bx.prototype.getPositionFromCoordinate=function(t){var e,r=this.dimension,i=this.volume,n=i.matrix,o=(new v).setFromMatrixPosition(n)[r],a=(new v).setFromMatrixScale(n)[r];return e="x"===r?i.nx:"y"===r?i.ny:i.nz,Math.round(((t-o)/(e/100)+1)/a)},bx.prototype.getData=function(t){function e(t){return Math.round(t/100*(o-1))}function r(t,e,r,i){return 3*(r*a.ny*a.nx+e*a.nx+t)+i}function i(t,e,r,i){m.set(t,e,r).applyMatrix4(c).toArray(f,i)}var n=this;t=t||{};var o,a=this.volume,s=a.data,c=a.matrix;o="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var u,l,h,p,d,f=new Float32Array(12),m=new v,g=0,y=0,b=0,x=a.nx,_=a.ny,w=a.nz;"x"===this.dimension?(h=e(a.nx),p=a.ny-1,d=a.nz-1,u=a.nz,l=a.ny,g=h,x=g+1,i(h,0,0,0),i(h,p,0,3),i(h,0,d,6),i(h,p,d,9)):"y"===this.dimension?(h=a.nx-1,p=e(a.ny),d=a.nz-1,u=a.nz,l=a.nx,y=p,_=y+1,i(0,p,0,0),i(h,p,0,3),i(0,p,d,6),i(h,p,d,9)):"z"===this.dimension&&(h=a.nx-1,p=a.ny-1,d=e(a.nz),u=a.nx,l=a.ny,b=d,w=b+1,i(0,0,d,0),i(0,p,d,3),i(h,0,d,6),i(h,p,d,9));var S,A,M=0,P=0,E=new Uint8Array(u*l*4),T=new Float32Array(u*l);"sigma"===this.thresholdType?(S=a.getValueForSigma(this.thresholdMin),A=a.getValueForSigma(this.thresholdMax)):(S=this.thresholdMin,A=this.thresholdMax);var C=Object.assign({},t.colorParams,{volume:a});this.normalize&&(C.domain=[0,1]);var I,R,L,O=km.getScheme(C),D=new Float32Array(3),N=O.getScale();if(this.normalize){I=1/0,R=-1/0;for(var k=y;k<_;++k)for(var B=g;BR&&(R=U)}L=R-I}for(var j=y;j<_;++j)for(var V=g;VS&&H0&&this.updateData(t,e)},this)},e.prototype.updateData=function(){this.build()},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.structure=this.structure,e},e.prototype.getAtomParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},e.prototype.getBondParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},e.prototype.setSelection=function(t,e){return this.selection.setString(t,e),this},e.prototype.setParameters=function(e,r,i){return r=r||{},e&&void 0!==e.radiusType&&("size"===e.radiusType?this.radius=1:this.radius=e.radiusType,delete e.radiusType,r.radius=!0,Rm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(r.radius=!0,Rm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(r.radius=!0,Rm&&!this.disableImpostor||(i=!0)),e&&void 0!==e.defaultAssembly&&(i=!0),t.prototype.setParameters.call(this,e,r,i),this},e.prototype.getParameters=function(){return Object.assign(t.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},e.prototype.attach=function(t){var e=this.viewer,r=this.bufferList;this.dataList.forEach(function(t){t.bufferList.forEach(function(i){r.push(i),e.add(i,t.instanceList)})}),this.setVisibility(this.visible),t()},e.prototype.clear=function(){this.dataList.length=0,t.prototype.clear.call(this)},e.prototype.dispose=function(){this.structureView.dispose(),delete this.structure,delete this.structureView,t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Zb),wx=new v,Sx=new v,Ax=new v,Mx=new v(0,1,0),Px=function(t){function e(e,r){var i=e||{},n=r||{},o=Xn(n.radialSegments,10),a=Xn(n.openEnded,!0),s=(new y).makeRotationX(Math.PI/2),c=new Rr(1,1,1,o,1,a);c.applyMatrix(s);var u=i.position1.length,l=i.radius.length,h=c.attributes.position.array.length/3,p=u/3,d=new Float32Array(2*p*h);ga(p,h,0,d),ga(p,h,p*h,d);var f=new Float32Array(2*u),m=new Float32Array(2*u);t.call(this,{position:f,color:m,primitiveId:d,picking:i.picking},n,c),this.__center=new Float32Array(u),this._position=f,this._color=m,this._from=new Float32Array(2*u),this._to=new Float32Array(2*u),this._radius=new Float32Array(2*l),this.setAttributes(i,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={updateNormals:{configurable:!0}};return e.prototype.applyPositionTransform=function(t,e,r){Sx.fromArray(this._from,r),Ax.fromArray(this._to,r),t.lookAt(Sx,Ax,Mx);var i=this._radius[e];wx.set(i,i,Sx.distanceTo(Ax)),t.scale(wx)},e.prototype.setAttributes=function(e,r){var i={};e.position1&&e.position2&&(ha(e.position1,e.position2,this.__center),ha(e.position1,this.__center,this._position),ha(this.__center,e.position2,this._position,e.position1.length),this._from.set(e.position1),this._from.set(this.__center,e.position1.length),this._to.set(this.__center),this._to.set(e.position2,this.__center.length),i.position=this._position),e.color&&e.color2&&(this._color.set(e.color),this._color.set(e.color2,e.color.length),i.color=this._color),e.radius&&(this._radius.set(e.radius),this._radius.set(e.radius,e.radius.length),i.radius=this._radius),t.prototype.setAttributes.call(this,i,r)},r.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,r),e}(ox);Um.add("shader/CylinderImpostor.vert","\nattribute vec3 mapping;\nattribute vec3 position1;\nattribute vec3 position2;\nattribute float radius;\nvarying vec3 axis;\nvarying vec4 base_radius;\nvarying vec4 end_b;\nvarying vec3 U;\nvarying vec3 V;\nvarying vec4 w;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\nattribute vec3 color2;\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#endif\nuniform mat4 modelViewMatrixInverse;\nuniform float ortho;\n#include matrix_scale\nvoid main(){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\nvColor1 = color;\nvColor2 = color2;\n#endif\nbase_radius.w = radius * matrixScale( modelViewMatrix );\nvec3 center = position;\nvec3 dir = normalize( position2 - position1 );\nfloat ext = length( position2 - position1 ) / 2.0;\nvec3 cam_dir;\nif( ortho == 0.0 ){\ncam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;\n}else{\ncam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;\n}\ncam_dir = normalize( cam_dir );\nvec3 ldir;\nfloat b = dot( cam_dir, dir );\nend_b.w = b;\nif( b < 0.0 )\nldir = -ext * dir;\nelse\nldir = ext * dir;\nvec3 left = normalize( cross( cam_dir, ldir ) );\nleft = radius * left;\nvec3 up = radius * normalize( cross( left, ldir ) );\naxis = normalize( normalMatrix * ldir );\nU = normalize( normalMatrix * up );\nV = normalize( normalMatrix * left );\nvec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );\nbase_radius.xyz = base4.xyz / base4.w;\nvec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );\nvec4 end4 = top_position;\nend_b.xyz = end4.xyz / end4.w;\nw = modelViewMatrix * vec4(\ncenter + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0\n);\ngl_Position = projectionMatrix * w;\ngl_Position.z = 0.99;\n}"),Um.add("shader/CylinderImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\nuniform mat4 projectionMatrix;\nuniform float ortho;\nvarying vec3 axis;\nvarying vec4 base_radius;\nvarying vec4 end_b;\nvarying vec3 U;\nvarying vec3 V;\nvarying vec4 w;\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\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat distSq3( vec3 v3a, vec3 v3b ){\nreturn (\n( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +\n( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +\n( v3a.z - v3b.z ) * ( v3a.z - v3b.z )\n);\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}\nfloat calcClip( vec3 cameraPos ){\nreturn dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );\n}\nvoid main(){\nvec3 point = w.xyz / w.w;\nvec3 base = base_radius.xyz;\nfloat vRadius = base_radius.w;\nvec3 end = end_b.xyz;\nfloat b = end_b.w;\nvec3 end_cyl = end;\nvec3 surface_point = point;\nvec3 ray_target = surface_point;\nvec3 ray_origin = vec3(0.0);\nvec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);\nmat3 basis = mat3( U, V, axis );\nvec3 diff = ray_target - 0.5 * (base + end_cyl);\nvec3 P = diff * basis;\nfloat dz = dot( axis, ray_direction );\nfloat radius2 = vRadius*vRadius;\nvec3 D = vec3(dot(U, ray_direction),\ndot(V, ray_direction),\ndz);\nfloat a0 = P.x*P.x + P.y*P.y - radius2;\nfloat a1 = P.x*D.x + P.y*D.y;\nfloat a2 = D.x*D.x + D.y*D.y;\nfloat d = a1*a1 - a0*a2;\nif (d < 0.0)\ndiscard;\nfloat dist = (-a1 + sqrt(d)) / a2;\nvec3 new_point = ray_target + dist * ray_direction;\nvec3 tmp_point = new_point - base;\nvec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );\nray_origin = mix( ray_origin, surface_point, ortho );\nfloat front_cap_test = dot( tmp_point, axis );\nfloat end_cap_test = dot((new_point - end_cyl), axis);\n#ifndef CAP\nvec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\nvec3 tmp_point2 = new_point2 - base;\n#endif\nif (front_cap_test < 0.0)\n{\nfloat dNV = dot(-axis, ray_direction);\nif (dNV < 0.0)\ndiscard;\nfloat near = dot(-axis, (base)) / dNV;\nvec3 front_point = ray_direction * near + ray_origin;\nif (dot(front_point - base, front_point-base) > radius2)\ndiscard;\n#ifdef CAP\nnew_point = front_point;\n_normal = axis;\n#else\nnew_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end_cyl) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end_cyl, new_point2-base) < radius2)\ndiscard;\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV = dot(axis, ray_direction);\nif (dNV < 0.0)\ndiscard;\nfloat near = dot(axis, end_cyl) / dNV;\nvec3 end_point = ray_direction * near + ray_origin;\nif( dot(end_point - end_cyl, end_point-base) > radius2 )\ndiscard;\n#ifdef CAP\nnew_point = end_point;\n_normal = axis;\n#else\nnew_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;\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( new_point );\n#ifdef NEAR_CLIP\nif( calcClip( new_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\nif( calcClip( new_point ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_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;\nnew_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -new_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( new_point, end_cyl ) < distSq3( new_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 );\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var Ex=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Tx=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),Cx=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingType:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return Ex},r.mappingIndices.get=function(){return Tx},r.mappingIndicesSize.get=function(){return 12},r.mappingType.get=function(){return"v3"},r.mappingSize.get=function(){return 6},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(cx),Ix=function(t){function e(e,r){t.call(this,e,r);var i=r||{};this.openEnded=Xn(i.openEnded,!1),this.addUniforms({modelViewMatrixInverse:{value:new y},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={parameters:{configurable:!0},isImpostor:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return r.parameters.get=function(){return Object.assign.call(this,{openEnded:{updateShader:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var r=t.prototype.getDefines.call(this,e);return this.openEnded||(r.CAP=1),r},r.isImpostor.get=function(){return!0},r.vertexShader.get=function(){return"CylinderImpostor.vert"},r.fragmentShader.get=function(){return"CylinderImpostor.frag"},Object.defineProperties(e.prototype,r),e}(Cx),Rx=function(t,e){return t.color2||(t.color2=t.color),!Rm||e&&e.disableImpostor?new Px(t,e):new Ix(t,e)};Gm.add("cylinder",Rx);var Lx=function(t){function e(e,r){var i=e.position1.length/3,n=4*i;t.call(this,{position:new Float32Array(3*n),color:new Float32Array(3*n)},r),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={isLine:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return e.prototype.setAttributes=function(t){var e,r,i,n,o,a,s=this.geometry.attributes;t.position1&&t.position2&&(e=t.position1,r=t.position2,o=s.position.array,s.position.needsUpdate=!0),t.color&&t.color2&&(i=t.color,n=t.color2,a=s.color.array,s.color.needsUpdate=!0);for(var c,u,l,h,p,d,f,m,g,v,y,b=this.size,x=0;x5&&s>15e3||s>7e5){var p=Math.min(1.5,Math.max(.1,2e3/(s/n)));c&&(p=Math.min(p,.15)),e.addRepresentation("surface",{sele:"polymer",surfaceType:"sas",probeRadius:1.4,scaleFactor:p,colorScheme:u,colorScale:l,colorReverse:h,useWorker:!1})}else s>25e4?e.addRepresentation("backbone",{lineOnly:!0,colorScheme:u,colorScale:l,colorReverse:h}):s>1e5?e.addRepresentation("backbone",{quality:"low",disableImpostor:!0,colorScheme:u,colorScale:l,colorReverse:h,scale:2}):s>8e4?e.addRepresentation("backbone",{colorScheme:u,colorScale:l,colorReverse:h,scale:2}):(e.addRepresentation("cartoon",{colorScheme:u,colorScale:l,colorReverse:h,scale:.7,aspectRatio:5,quality:"auto"}),s<5e4&&e.addRepresentation("base",{colorScheme:u,colorScale:l,colorReverse:h,quality:"auto"}),e.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));e.structure.frames.length&&e.addTrajectory()}else"surface"!==e.type&&"volume"!==e.type||e.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},$x.prototype.loadFile=function(t,e){var r=Object.assign({},this.defaultFileParams,e),i=new Bx(this,r);i.name=Jn(t).name,this.addComponent(i);var n=this.tasks;n.increment();var o,a=function(t){return this.removeComponent(i),i=this.addComponentFromObject(t,r),"script"===i.type?i.run():r.defaultRepresentation&&this.defaultFileRepresentation(i),n.decrement(),i}.bind(this),s=function(t){throw i.setStatus(t),n.decrement(),t},c=Xn(r.ext,Jn(t).ext);return o=zm.isTrajectory(c)?Promise.reject(new Error('loadFile: ext "'+c+'" is a trajectory and must be loaded into a structure component')):ra(t,r),o.then(a,s)},$x.prototype.addComponent=function(t){if(!t)return void Lm.warn("Stage.addComponent: no component given");this.compList.push(t),this.signals.componentAdded.dispatch(t)},$x.prototype.addComponentFromObject=function(t,e){var r=Vm.get(t.type);if(r){var i=new r(this,t,e);return this.addComponent(i),i}Lm.warn("no component for object type",t.type)},$x.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},$x.prototype.removeAllComponents=function(t){this.compList.slice().forEach(function(e){t&&e.type!==t||this.removeComponent(e)},this)},$x.prototype.handleResize=function(){this.viewer.handleResize()},$x.prototype.setSize=function(t,e){var r=this.viewer.container;r!==document.body&&(void 0!==t&&(r.style.width=t),void 0!==e&&(r.style.height=e),this.handleResize())},$x.prototype.toggleFullscreen=function(t){function e(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!e()&&i.lastFullscreenElement){var t=i.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),i.handleResize(),i.signals.fullscreenChanged.dispatch(!1)}}if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Lm.log("fullscreen mode (currently) not possible");var i=this;t=t||this.viewer.container,this.lastFullscreenElement=t,e()?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(){i.handleResize()},100))},$x.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},$x.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},$x.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},$x.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},$x.prototype.setFocus=function(t){var e=Eo(t/2,0,49.9),r=100-e,i=(r-e)/2;this.setParameters({clipNear:e,clipFar:r,fogNear:To(r-i),fogFar:To(r+i)})},$x.prototype.getZoomForBox=function(t){var e=t.getSize(Gx),r=Math.max(e.x,e.y,e.z),i=Math.min(e.x,e.y,e.z),n=r+Math.sqrt(i),o=wo(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=a/s,u=s=this.V[n][o]?(r="S",this.score=this.S[n][o]):this.V[n][o]>=this.H[n][o]?(r="V",this.score=this.V[n][o]):(r="H",this.score=this.H[n][o]),t.Debug&&Lm.log("Alignment: SCORE",this.score),t.Debug&&Lm.log("Alignment: S, V, H",this.S[n][o],this.V[n][o],this.H[n][o]);n>0&&o>0;)"S"===r?e.S[n][o]===e.S[n-1][o-1]+i(n-1,o-1)?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--n,--o,r="S"):e.S[n][o]===e.V[n][o]?r="V":e.S[n][o]===e.H[n][o]?r="H":(--n,--o):"V"===r?e.V[n][o]===e.V[n-1][o]+e.gapExtensionPenalty?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n,r="V"):e.V[n][o]===e.S[n-1][o]+e.gap(0)?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n,r="S"):--n:"H"===r?e.H[n][o]===e.H[n][o-1]+e.gapExtensionPenalty?(e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o,r="H"):e.H[n][o]===e.S[n][o-1]+e.gap(0)?(e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o,r="S"):--o:Lm.error("Alignment: no matrix");for(;n>0;)e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n;for(;o>0;)e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o;t.Debug&&Lm.timeEnd("Alignment.trace"),t.Debug&&Lm.log([this.ali1,this.ali2])};var Yx=function(t){function e(e){var r=this;t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=Xn(e.reverse,!0)),this.scalePerModel={},this.structure.eachModel(function(t){r.domain=[t.atomOffset,t.atomEnd],r.scalePerModel[t.index]=r.getScale()})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.index)},e}(em);km.add("atomindex",Yx);var Zx=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="OrRd"),!e.domain){var r,i=1/0,n=-1/0;e.sele&&(r=new ym(e.sele)),this.structure.eachAtom(function(t){var e=t.bfactor;i=Math.min(i,e),n=Math.max(n,e)},r),this.domain=[i,n]}this.bfactorScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.bfactorScale(t.bfactor)},e}(em);km.add("bfactor",Zx);var Kx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var r={},i={};this.structure.eachModel(function(t){var e=0,n={};t.eachChain(function(t){void 0===n[t.chainid]&&(n[t.chainid]=e,e+=1)}),this.domain=[0,e-1],r[t.index]=n,i[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=r[t.modelIndex];return i[t.modelIndex](e[t.chainid])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("chainid",Kx);var Qx=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="Spectral"),e.domain){var r=this.getScale();this.atomColor=function(t){return r(t.chainIndex)}}else{var i={};this.structure.eachModel(function(t){this.domain=[t.chainOffset,t.chainEnd],i[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){return i[t.modelIndex](t.chainIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("chainindex",Qx);var Jx=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var r={},i={};this.structure.eachModel(function(t){var e=0,n={};t.eachChain(function(t){void 0===n[t.chainname]&&(n[t.chainname]=e,e+=1)}),this.domain=[0,e-1],r[t.index]=n,i[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=r[t.modelIndex];return i[t.modelIndex](e[t.chainname])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("chainname",Jx);var t_=function(t){function e(e){t.call(this,e),e.scale||(this.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});var r=e.structure.validation||{};this.rsrzDict=r.rsrzDict||{},this.rsccDict=r.rsccDict||{}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.resno;t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var r=this.rsrzDict[e];if(void 0!==r)return this.rsrzScale(r);var i=this.rsccDict[e];return void 0!==i?this.rsccScale(i):9474192},e}(em);km.add("densityfit",t_);var e_={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}},r_=12,i_=1.04,n_=.25,o_=function(t){function e(e){function r(t){return t.isProtein()?e_[t.resname]&&e_[t.resname][t.atomname]||e_.backbone[t.atomname]||0:0}t.call(this,e),e.scale||(this.scale="rwb"),e.domain||(this.domain=[-.5,0,.5]);var i=this.getScale(),n=this.structure,o=new Float32Array(n.atomCount),a=[],s=[];n.eachAtom(function(t){if(o[t.index]=r(t)*t.occupancy,"N"===t.atomname){var e=Pc(t);void 0!==e&&(a.push(e),s.push(n_*t.occupancy))}});var c=this.structure.getBoundingBox();c.expandByScalar(i_);var u=Ec(a),l=new Cs(u,c),h=new Cs(this.structure.atomStore,c),p=this.atomProxy,d=new v,f=r_*r_;this.positionColor=function(t){for(var e=0,r=h.within(t.x,t.y,t.z,r_),n=0;n=3?10813478:9474192},e}(em);km.add("geoquality",l_);var h_=function(t){function e(e){t.call(this,e),e.scale||(this.scale="RdYlGn");var r,i={};for(r in Ly)i[r]=Ly[r][0];if(!e.domain){var n,o=1/0,a=-1/0;for(r in i)n=i[r],o=Math.min(o,n),a=Math.max(a,n);this.domain=[o,0,a]}var s=this.getScale();this.atomColor=function(t){return s(i[t.resname]||Oy)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("hydrophobicity",h_);var p_=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rainbow"),e.domain||(this.domain=[0,this.structure.modelStore.count]);var r=this.getScale();this.atomColor=function(t){return r(t.modelIndex)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("modelindex",p_);var d_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}},e}(em);km.add("moleculetype",d_);var f_=function(t){function e(e){t.call(this,e),e.scale||(this.scale="PuBu"),e.domain||(this.domain=[0,1]);var r=this.getScale();this.atomColor=function(t){return r(t.occupancy)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("occupancy",f_);var m_=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rwb"),e.domain||(this.domain=[-1,1]),this.partialchargeScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.partialchargeScale(t.partialCharge)},e}(em);km.add("partialcharge",m_);var g_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return Tc()},e.prototype.volumeColor=function(){return Tc()},e.prototype.positionColor=function(){return Tc()},e}(em);km.add("random",g_);var v_=function(t){function e(e){var r=this;if(t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=Xn(e.reverse,!0)),e.domain){var i=this.getScale();this.atomColor=function(t){return i(t.residueIndex)}}else{var n={};this.structure.eachChain(function(t){r.domain=[t.residueOffset,t.residueEnd],n[t.index]=r.getScale()}),this.atomColor=function(t){return n[t.chainIndex](t.residueIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(em);km.add("residueindex",v_);var y_={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:10526975,G:16740464,I:8454143,C:16747595,T:10551200,U:16744576,DA:10526975,DG:16740464,DI:8454143,DC:16747595,DT:10551200,DU:16744576},b_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return y_[t.resname]||16711935},e}(em);km.add("resname",b_);var x_={alphaHelix:16711808,threeTenHelix:10485888,piHelix:6291584,betaStrand:16762880,betaTurn:6324479,coil:16777215,dna:11403518,rna:16580962,carbohydrate:10921722},__=function(t){function e(e){t.call(this,e),this.rp=this.structure.getResidueProxy()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.sstruc,r=this.rp;return"h"===e?x_.alphaHelix:"g"===e?x_.threeTenHelix:"i"===e?x_.piHelix:"e"===e||"b"===e?x_.betaStrand:"t"===e?x_.betaTurn:(r.index=t.residueIndex,r.isDna()?x_.dna:r.isRna()?x_.rna:r.isSaccharide()?x_.carbohydrate:r.isProtein()||"s"===e||"l"===e?x_.coil:8421504)},e}(em);km.add("sstruc",__);var w_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return this.value},e.prototype.bondColor=function(){return this.value},e.prototype.valueColor=function(){return this.value},e.prototype.volumeColor=function(){return this.value},e}(em);km.add("uniform",w_);var S_=function(t){function e(e){t.call(this,e),this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.volumeColor=function(t){return this.valueScale(this.volume.data[t])},e}(em);km.add("value",S_);var A_=function(t){function e(e){t.call(this,e);var r=this.volume;if(r&&r.inverseMatrix){var i=this.getScale(),n=r.inverseMatrix,o=r.data,a=r.nx,s=r.ny,c=a*s,u=new v;this.positionColor=function(t){u.copy(t),u.applyMatrix4(n);var e=Math.floor(u.x),r=Math.floor(u.y),l=Math.floor(u.z),h=(l*s+r)*a+e,p=h+1,d=h+a,f=h+c,m=d+1,g=f+1,v=d+c,y=v+1,b=o[h],x=o[p],_=o[d],w=o[f],S=o[m],A=o[g],M=o[v],P=o[y],E=u.x-e,T=u.y-r,C=u.z-l,I=Io(b,x,E),R=Io(w,A,E),L=Io(_,S,E),O=Io(M,P,E),D=Io(I,L,T),N=Io(R,O,T),k=Io(D,N,C);return i(k)}}else{var l=this.value;this.positionColor=function(){return l}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.positionColor=function(){},e}(em);km.add("volume",A_);var M_=function(t){function e(e,r,i){var n=this,o=i||{};o.name=Xn(o.name,r.name),t.call(this,e,o),this.script=r,this.status="loaded",this.script.signals.nameChanged.add(function(t){n.setName(t)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"script"},e.prototype.addRepresentation=function(){},e.prototype.removeRepresentation=function(){},e.prototype.run=function(){var t=this;this.setStatus("running"),this.script.call(this.stage).then(function(){t.setStatus("finished")}),this.setStatus("called")},e.prototype.dispose=function(){this.signals.disposed.dispatch()},e.prototype.setVisibility=function(){},e.prototype.getCenter=function(){},e.prototype.getZoom=function(){},e.prototype.getBox=function(){},Object.defineProperties(e.prototype,r),e}(Bx);Vm.add("script",M_);var P_=function(t){function e(e,r,i){var n=i||{};n.name=Xn(n.name,r.name),t.call(this,e,n),this.shape=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"shape"},e.prototype.addRepresentation=function(e,r){return t.prototype.addRepresentation.call(this,e,this.shape,r)},e.prototype.getBoxUntransformed=function(){return this.shape.boundingBox},e.prototype.getCenterUntransformed=function(){return this.shape.center},e.prototype.dispose=function(){this.shape.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,r),e}(Bx);Vm.add("shape",P_);var E_=function(t){function e(e,r,i,n){ +var o=this,a=i||{};a.name=Xn(a.name,r.name),t.call(this,e,a),this.signals=Object.assign(this.signals,{frameChanged:new ko,playerChanged:new ko,countChanged:new ko,parametersChanged:new ko}),this.trajectory=r,this.parent=n,this.status="loaded",this.defaultStep=Xn(a.defaultStep,void 0),this.defaultTimeout=Xn(a.defaultTimeout,50),this.defaultInterpolateType=Xn(a.defaultInterpolateType,""),this.defaultInterpolateStep=Xn(a.defaultInterpolateStep,5),this.defaultMode=Xn(a.defaultMode,"loop"),this.defaultDirection=Xn(a.defaultDirection,"forward"),r.signals.frameChanged.add(function(t){o.signals.frameChanged.dispatch(t)}),r.signals.playerChanged.add(function(t){o.signals.playerChanged.dispatch(t)}),r.signals.countChanged.add(function(t){o.signals.countChanged.dispatch(t)}),void 0!==a.initialFrame&&this.setFrame(a.initialFrame)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"trajectory"},e.prototype.addRepresentation=function(e,r){return t.prototype.addRepresentation.call(this,e,this.trajectory,r)},e.prototype.setFrame=function(t){this.trajectory.setFrame(t)},e.prototype.setParameters=function(t){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)},e.prototype.dispose=function(){this.trajectory.dispose(),t.prototype.dispose.call(this)},e.prototype.getCenter=function(){},Object.defineProperties(e.prototype,r),e}(Bx),T_=function(t){function e(e,r,i){var n=i||{};n.timeOffset=Xn(n.timeOffset,e.timeOffset),n.deltaTime=Xn(n.deltaTime,e.deltaTime),t.call(this,"",r,n),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"frames"},e.prototype._makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=null},e.prototype._loadFrame=function(t,e){var r,i=this.frames[t];if(this.atomIndices){var n=this.atomIndices,o=n.length;r=new Float32Array(3*o);for(var a=0;a0&&(i="( "+e.join(" ) AND ( ")+" )"),new ym(i)},r.prototype.getStructure=function(){return this.structure.getStructure()},r.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},r.prototype.eachAtom=function(t,e){var r=this.getAtomProxy(),i=this.getAtomSet(e),n=this.atomStore.count;if(i.getSize() 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat w = clamp(\nsmoothness * ( abs( dFdx( texCoord.x ) ) + abs( dFdy( texCoord.y ) ) ),\n0.0,\n0.5\n);\nfloat a = smoothstep( 0.5 - w, 0.5 + w, sdf );\na = pow( a, 1.0 / gamma );\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( 0.5 + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var k_={},B_=function(t){var e=Object.assign({},t);if(this.font=Xn(e.font,["sans-serif"]),this.size=Xn(e.size,36),this.style=Xn(e.style,"normal"),this.variant=Xn(e.variant,"normal"),this.weight=Xn(e.weight,"normal"),this.outline=Xn(e.outline,0),this.width=Xn(e.width,2048),this.height=Xn(e.height,2048),this.gamma=1,"undefined"!=typeof navigator){var r=navigator.userAgent;r.match(/Chrome/)&&r.match(/OS X/)&&(this.gamma=.5)}this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.build(),this.populate(),this.texture=new nt(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};B_.prototype.build=function(){var t=this.size+2*this.outline+Math.round(this.size/4),e=this.width/4,r=document.createElement("canvas");r.width=e,r.height=t;var i=r.getContext("2d");i.font=this.style+" "+this.variant+" "+this.weight+" "+this.size+"px "+this.font,i.fillStyle="#FF0000",i.textAlign="left",i.textBaseline="bottom",i.lineJoin="round";for(var n=[],o=3*this.outline,a=0;athis.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>this.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]},B_.prototype.get=function(t){return this.mapped[t]||this.placeholder},B_.prototype.draw=function(t){var e=this.lineHeight,r=this.outline,i=this.context,n=this.scratch,o=this.maxWidth,a=this.colors,s=r,c=e-this.outline,u=i.measureText(t),l=Math.min(o,Math.ceil(u.width+2*s+1));i.clearRect(0,0,l,e);var h,p,d,f,m;if(0===this.outline)for(i.fillText(t,s,c),f=i.getImageData(0,0,l,e),m=f.data,d=3,h=0,p=m.length/4;h0;--h)d=h>1?2*h-2:h,i.strokeStyle=a[d-1],i.lineWidth=d,i.strokeText(t,s,c);i.globalCompositeOperation="multiply",i.fillStyle="#FF00FF",i.fillText(t,s,c),f=i.getImageData(0,0,l,e),m=f.data,d=0;var g=this.gamma;for(h=0,p=m.length/4;h= 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}"),Um.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float nearClip;\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.7 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var z_=function(t){function e(e,r){t.call(this,e,r);var i=r||{};this.linewidth=Xn(i.linewidth,2),this.addUniforms({linewidth:{value:this.linewidth},resolution:{value:new h},projectionMatrixInverse:{value:new y}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={parameters:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return r.parameters.get=function(){return Object.assign.call(this,{linewidth:{uniform:!0}},t.prototype.parameters)},r.vertexShader.get=function(){return"WideLine.vert"},r.fragmentShader.get=function(){return"WideLine.frag"},Object.defineProperties(e.prototype,r),e}(hx),U_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"number",precision:2,max:10,min:.5},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.side=Xn(r.side,"double"),r.opacity=Xn(r.opacity,.5),this.atomTriple=Xn(r.atomTriple,[]),this.arcVisible=Xn(r.arcVisible,!0),this.lineOpacity=Xn(r.lineOpacity,1),this.linewidth=Xn(r.linewidth,2),this.sectorVisible=Xn(r.sectorVisible,!0),this.vectorVisible=Xn(r.vectorVisible,!0),t.prototype.init.call(this,r)},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=Dc(this.structureView,this.atomTriple),e=Nc(t),r=this.n=e.labelPosition.length/3,i=new et(this.labelColor);this.textBuffer=new F_({position:e.labelPosition,size:pa(r,this.labelSize),color:da(r,i.r,i.g,i.b),text:e.labelText},this.getLabelBufferParams());var n=new et(this.colorValue);this.vectorBuffer=new z_({position1:e.vectorPosition1,position2:e.vectorPosition2,color:da(2*r,n.r,n.g,n.b),color2:da(2*r,n.r,n.g,n.b)},this.getBufferParams({linewidth:this.linewidth,visible:this.vectorVisible})),this.arcLength=e.arcPosition1.length/3,this.arcBuffer=new z_({position1:e.arcPosition1,position2:e.arcPosition2,color:da(this.arcLength,n.r,n.g,n.b),color2:da(this.arcLength,n.r,n.g,n.b)},this.getBufferParams({linewidth:2,visible:this.arcVisible})),this.sectorLength=e.sectorPosition.length/3,this.sectorMeshBuffer=new Hb({position:e.sectorPosition,color:da(this.sectorLength,n.r,n.g,n.b)},this.getBufferParams({visible:this.sectorVisible,opacity:this.sectorOpacity})),this.sectorDoubleSidedBuffer=new Jb(this.sectorMeshBuffer),this.dataList.push({sview:this.structureView,bufferList:[this.textBuffer,this.vectorBuffer,this.arcBuffer,this.sectorDoubleSidedBuffer]})}},e.prototype.updateData=function(e,r){t.prototype.updateData.call(this,e,r);var i={},n={},o={};if(e.color){var a=new et(this.colorValue);i.color=i.color2=da(2*this.n,a.r,a.g,a.b),n.color=n.color2=da(this.arcLength,a.r,a.g,a.b),o.color=da(this.sectorLength,a.r,a.g,a.b)}this.vectorBuffer.setAttributes(i),this.arcBuffer.setAttributes(n),this.sectorMeshBuffer.setAttributes(o)},e.prototype.setParameters=function(e){var r={};return t.prototype.setParameters.call(this,e,r,!1),!e||void 0===e.vectorVisible&&void 0===e.arcVisible&&void 0===e.sectorVisible||this.setVisibility(this.visible),e&&e.lineOpacity&&(this.vectorBuffer.setParameters({opacity:e.lineOpacity}),this.arcBuffer.setParameters({opacity:e.lineOpacity})),e&&void 0!==e.opacity&&(this.vectorBuffer.setParameters({opacity:this.lineOpacity}),this.arcBuffer.setParameters({opacity:this.lineOpacity})),e&&e.linewidth&&(this.vectorBuffer.setParameters({linewidth:e.linewidth}),this.arcBuffer.setParameters({linewidth:e.linewidth})),this},e.prototype.setVisibility=function(e,r){return t.prototype.setVisibility.call(this,e,!0),this.vectorBuffer.setVisibility(this.vectorVisible&&this.visible),this.arcBuffer.setVisibility(this.arcVisible&&this.visible),this.sectorDoubleSidedBuffer.setVisibility(this.sectorVisible&&this.visible),r||this.viewer.requestRender(),this},e}(N_);Fm.add("angle",U_);var j_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="axes",this.parameters=Object.assign({radius:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radius=Xn(r.radius,.5),r.colorValue=Xn(r.colorValue,"lightgreen"),this.showAxes=Xn(r.showAxes,!0),this.showBox=Xn(r.showBox,!1),t.prototype.init.call(this,r)},e.prototype.getPrincipalAxes=function(){var t,e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)},e.prototype.getAxesData=function(t){var e=this.getPrincipalAxes(t),r=new et(this.colorValue),i=0,n=0;this.showAxes&&(i+=6,n+=3),this.showBox&&(i+=8,n+=12);var o=new Float32Array(3*i),a=da(i,r.r,r.g,r.b),s=pa(i,this.radius),c=new Float32Array(3*n),u=new Float32Array(3*n),l=da(n,r.r,r.g,r.b),h=pa(n,this.radius),p=0;if(this.showAxes){var d=function(t,e){t.toArray(o,2*p),e.toArray(o,2*p+3),t.toArray(c,p),e.toArray(u,p),p+=3};d(e.begA,e.endA),d(e.begB,e.endB),d(e.begC,e.endC)}if(this.showBox){var f=new v,m=e.getProjectedScaleForAtoms(t),g=m.d1a,y=m.d2a,b=m.d3a,x=m.d1b,_=m.d2b,w=m.d3b;console.log(g,y,b,x,_,w);var S=2*p,A=function(t,r,i){f.copy(e.center).addScaledVector(e.normVecA,t).addScaledVector(e.normVecB,r).addScaledVector(e.normVecC,i),f.toArray(o,S),S+=3};A(g,y,b),A(g,y,w),A(g,_,w),A(g,_,b),A(x,_,w),A(x,_,b),A(x,y,b),A(x,y,w);var M=p,P=function(t,e){f.fromArray(o,2*p+3*t).toArray(c,M),f.fromArray(o,2*p+3*e).toArray(u,M),M+=3};P(0,1),P(0,3),P(0,6),P(1,2),P(1,7),P(2,3),P(2,4),P(3,5),P(4,5),P(4,7),P(5,6),P(6,7)}var E=new Yv(e);return{vertex:{position:o,color:a,radius:s,picking:E},edge:{position1:c,position2:u,color:l,color2:l,radius:h,picking:E}}},e.prototype.create=function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new dx(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Rx(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})},e.prototype.updateData=function(t,e){var r=this.getAxesData(e.sview),i={},n={};t&&!t.position||(i.position=r.vertex.position,n.position1=r.edge.position1,n.position2=r.edge.position2),t&&!t.color||(i.color=r.vertex.color,n.color=r.edge.color,n.color2=r.edge.color),t&&!t.radius||(i.radius=r.vertex.radius,n.radius=r.edge.radius),this.sphereBuffer.setAttributes(i),this.cylinderBuffer.setAttributes(n)},e}(_x);Fm.add("axes",j_);var V_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radius=Xn(r.radius,.15),this.aspectRatio=Xn(r.aspectRatio,2),this.lineOnly=Xn(r.lineOnly,!1),this.cylinderOnly=Xn(r.cylinderOnly,!1),this.multipleBond=Xn(r.multipleBond,"off"),this.bondSpacing=Xn(r.bondSpacing,1),this.bondScale=Xn(r.bondScale,.4),this.linewidth=Xn(r.linewidth,2),t.prototype.init.call(this,r)},e.prototype.getAtomParams=function(e,r){return r=Object.assign({radiusParams:{radius:this.radius,scale:this.scale*this.aspectRatio}},r),t.prototype.getAtomParams.call(this,e,r)},e.prototype.getAtomData=function(t,e,r){return t.getAtomData(this.getAtomParams(e,r))},e.prototype.getBondParams=function(e,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},r),t.prototype.getBondParams.call(this,e,r)},e.prototype.getBondData=function(t,e,r){return t.getBondData(this.getBondParams(e,r))},e.prototype.createData=function(t){var e=[];if(this.lineOnly)this.lineBuffer=new z_(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{var r=new Rx(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(r),!this.cylinderOnly){var i=new dx(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}},e.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var r=this.getBondData(e.sview,t);if(this.lineOnly){var i={};t&&!t.position||(i.position1=r.position1,i.position2=r.position2),t&&!t.color||(i.color=r.color,i.color2=r.color2),e.bufferList[0].setAttributes(i)}else{var n={};if(t&&!t.position||(n.position1=r.position1,n.position2=r.position2),t&&!t.color||(n.color=r.color,n.color2=r.color2),t&&!t.radius||(n.radius=r.radius),e.bufferList[0].setAttributes(n),!this.cylinderOnly){var o=this.getAtomData(e.sview,t),a={};t&&!t.position||(a.position=o.position),t&&!t.color||(a.color=o.color),t&&!t.radius||(a.radius=o.radius),e.bufferList[1].setAttributes(a)}}},e.prototype.setParameters=function(e){var r=!1,i={};return e&&(e.aspectRatio||e.bondSpacing||e.bondScale)&&(i.radius=!0,Rm&&!this.disableImpostor||(r=!0)),t.prototype.setParameters.call(this,e,i,r),this},e}(_x);Fm.add("ball+stick",V_);var G_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=Xn(r.aspectRatio,1),r.radius=Xn(r.radius,.25),t.prototype.init.call(this,r)},e.prototype.getAtomData=function(t,e,r){return t.getBackboneAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){return t.getBackboneBondData(this.getBondParams(e,r))},e}(V_);Fm.add("backbone",G_);var $_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.aspectRatio=Xn(r.aspectRatio,1),r.radius=Xn(r.radius,.3),t.prototype.init.call(this,r)},e.prototype.getAtomData=function(t,e,r){return t.getRungAtomData(this.getAtomParams(e,r))},e.prototype.getBondData=function(t,e,r){var i=this.getBondParams(e,r);return i.colorParams.rung=!0,t.getRungBondData(i)},e}(V_);Fm.add("base",$_),Bc.prototype={constructor:Bc,getAtomIterator:function(t,e){function r(){var t=this.get(u);return u+=1,t}function i(r){var i=l[c%4];if(i.index=o.getAtomIndexByType(r,t),e&&r>0&&re)&&(s=!0,n.set(i.index),o.addBond(a,i,1))}s&&n.set(a.index)});var a=new dy(o.count,!0);return Lm.timeEnd("Contact within"),{atomSet:n,bondSet:a,bondStore:o}};var Z_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="contact",this.parameters=Object.assign({contactType:{type:"select",rebuild:!0,options:{polar:"polar",polarBackbone:"polar backbone"}},maxDistance:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxAngle:{type:"integer",max:180,min:0,rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radius=Xn(r.radius,.25),this.contactType=Xn(r.contactType,"polarBackbone"),this.maxDistance=Xn(r.maxDistance,3.5),this.maxAngle=Xn(r.maxAngle,40),t.prototype.init.call(this,r)},e.prototype.getContactData=function(t){return{polar:Fc,polarBackbone:zc}[this.contactType](t,this.maxDistance,this.maxAngle)},e.prototype.getBondData=function(t,e,r){var i=t.getBondData(this.getBondParams(e,r));return i.picking&&(i.picking=new Kv(i.picking.array,i.picking.structure,r.bondStore)),i},e.prototype.createData=function(t){var e=this.getContactData(t);return{bufferList:[new Rx(this.getBondData(t,void 0,{bondSet:e.bondSet,bondStore:e.bondStore}),this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],bondSet:e.bondSet,bondStore:e.bondStore}},e.prototype.updateData=function(t,e){if(!t||t.position){var r=this.getContactData(e.sview);e.bondSet=r.bondSet,e.bondStore=r.bondStore}var i={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(e.sview,t,i),o={};t&&!t.position||(o.position=ha(n.position1,n.position2),o.position1=n.position1,o.position2=n.position2),t&&!t.color||(o.color=n.color,o.color2=n.color2),t&&!t.radius||(o.radius=n.radius),e.bufferList[0].setAttributes(o)},e}(_x);Fm.add("contact",Z_);var K_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="dihedral",this.parameters=Object.assign({atomQuad:{type:"hidden",rebuild:!0},lineOpacity:{type:"range",min:0,max:1,step:.01},lineVisible:{type:"boolean",default:!0},linewidth:{type:"number",precision:2,max:10,min:.5},planeVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.side=Xn(r.side,"double"),r.opacity=Xn(r.opacity,.5),this.atomQuad=Xn(r.atomQuad,[]),this.lineOpacity=Xn(r.lineOpacity,1),this.lineVisible=Xn(r.lineVisible,!0),this.linewidth=Xn(r.linewidth,2),this.planeVisible=Xn(r.planeVisible,!0),this.sectorVisible=Xn(r.sectorVisible,!0),t.prototype.init.call(this,r)},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=Ic(this.structureView,this.atomQuad),e=Uc(t,{planeVisible:this.planeVisible}),r=this.n=e.labelText.length,i=new et(this.labelColor);this.textBuffer=new F_({position:e.labelPosition,size:pa(r,this.labelSize),color:da(r,i.r,i.g,i.b),text:e.labelText},this.getLabelBufferParams());var n=new et(this.colorValue);this.lineLength=e.linePosition1.length/3;var o=da(this.lineLength,n.r,n.g,n.b);this.lineBuffer=new z_({position1:e.linePosition1,position2:e.linePosition2,color:o,color2:o},this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),this.planeLength=e.planePosition.length/3,this.planeMeshBuffer=new Hb({position:e.planePosition,color:da(this.planeLength,n.r,n.g,n.b)},this.getBufferParams({visible:this.planeVisible})),this.planeDoubleSidedBuffer=new Jb(this.planeMeshBuffer),this.sectorLength=e.sectorPosition.length/3,this.sectorMeshBuffer=new Hb({position:e.sectorPosition,color:da(this.sectorLength,n.r,n.g,n.b)},this.getBufferParams({visible:this.sectorVisible})),this.sectorDoubleSidedBuffer=new Jb(this.sectorMeshBuffer),this.dataList.push({sview:this.structureView,bufferList:[this.textBuffer,this.lineBuffer,this.planeDoubleSidedBuffer,this.sectorDoubleSidedBuffer]})}},e.prototype.updateData=function(e,r){t.prototype.updateData.call(this,e,r);var i={},n={},o={};if(e.color){var a=new et(this.colorValue);i.color=i.color2=da(this.lineLength,a.r,a.g,a.b),n.color=da(this.planeLength,a.r,a.g,a.b),o.color=da(this.sectorLength,a.r,a.g,a.b)}this.lineBuffer.setAttributes(i),this.planeMeshBuffer.setAttributes(n),this.sectorMeshBuffer.setAttributes(o)},e.prototype.setParameters=function(e){var r={};return t.prototype.setParameters.call(this,e,r,!1),!e||void 0===e.lineVisible&&void 0===e.sectorVisible||this.setVisibility(this.visible),e&&e.lineOpacity&&this.lineBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.lineBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.lineBuffer.setParameters({linewidth:e.linewidth}),this},e.prototype.setVisibility=function(e,r){return t.prototype.setVisibility.call(this,e,!0),this.lineBuffer.setVisibility(this.lineVisible&&this.visible),this.sectorDoubleSidedBuffer.setVisibility(this.sectorVisible&&this.visible),r||this.viewer.requestRender(),this},e}(N_);Fm.add("dihedral",K_);var Q_=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="distance",this.parameters=Object.assign({labelUnit:{type:"select",rebuild:!0,options:{"":"",angstrom:"angstrom",nm:"nm"}},atomPair:{type:"hidden",rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.radius=Xn(r.radius,.15),this.labelUnit=Xn(r.labelUnit,""),this.atomPair=Xn(r.atomPair,[]),t.prototype.init.call(this,r)},e.prototype.getDistanceData=function(t,e){var r=e.length,i=new Array(r),n=new Float32Array(3*r),o=new ym,a=new ym,s=new nb,c=t.getAtomProxy(),u=t.getAtomProxy(),l=0;e.forEach(function(e,r){var h=e[0],p=e[1];if(Number.isInteger(h)&&Number.isInteger(p))c.index=h,u.index=p;else{o.setString(h),a.setString(p);var d=t.getAtomIndices(o),f=t.getAtomIndices(a);if(!d.length||!f.length)return void(l+=1);c.index=d[0],u.index=f[0]}s.addBond(c,u,1),r-=l;var m=c.distanceTo(u);switch(this.labelUnit){case"angstrom":i[r]=m.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":i[r]=(m/10).toFixed(2)+" nm";break;default:i[r]=m.toFixed(2)}var g=3*r;n[g+0]=(c.x+u.x)/2,n[g+1]=(c.y+u.y)/2,n[g+2]=(c.z+u.z)/2},this),l>0&&(r-=l,n=n.subarray(0,3*r));var h=new dy(s.count,!0);return{text:i,position:n,bondSet:h,bondStore:s}},e.prototype.getBondData=function(t,e,r){var i=t.getBondData(this.getBondParams(e,r));return i.picking&&(i.picking=new ty(i.picking.array,i.picking.structure,r.bondStore)),i},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=this.atomPair.length;if(0!==t){var e=this.getDistanceData(this.structureView,this.atomPair),r=new et(this.labelColor);this.textBuffer=new F_({position:e.position,size:pa(t,this.labelSize),color:da(t,r.r,r.g,r.b),text:e.text},this.getLabelBufferParams());var i={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(this.structureView,void 0,i);this.cylinderBuffer=new Rx(n,this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bondSet:e.bondSet,bondStore:e.bondStore,position:e.position,bufferList:[this.textBuffer,this.cylinderBuffer]})}}},e.prototype.updateData=function(t,e){var r={bondSet:e.bondSet,bondStore:e.bondStore},i=this.getBondData(e.sview,t,r),n={},o={},a=this.atomPair.length;if(t.labelSize&&(o.size=pa(a,this.labelSize)),t.labelColor){var s=new et(this.labelColor);o.color=da(a,s.r,s.g,s.b)}t.color&&(n.color=i.color,n.color2=i.color2),(t.radius||t.scale)&&(n.radius=i.radius),this.textBuffer.setAttributes(o),this.cylinderBuffer.setAttributes(n)},e}(N_);Fm.add("distance",Q_);var J_=function(t){function e(e,r){var i=r||{},n=e.position.length/3,o=2*n,a=new et(Xn(i.color,"grey")),s=new Float32Array(3*o),c=da(o,a.r,a.g,a.b);t.call(this,{position:s,color:c},i),this.scale=Xn(i.scale,1),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={isLine:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return e.prototype.setAttributes=function(t){var e,r,i,n=this.geometry.attributes;t.position&&t.vector&&(e=t.position,r=t.vector,i=n.position.array,n.position.needsUpdate=!0);var o,a,s=this.size/2,c=this.scale +;if(t.position&&t.vector)for(var u=0;u 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}"),Um.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\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\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, nearClip - 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( - ( nearClip - 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\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 );\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");var rw=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]),iw=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]),nw=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingType:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return r.mapping.get=function(){return rw},r.mappingIndices.get=function(){return iw},r.mappingIndicesSize.get=function(){return 36},r.mappingType.get=function(){return"v3"},r.mappingSize.get=function(){return 8},r.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,r),e}(cx),ow=function(t){function e(e,r){t.call(this,e,r);var i=e||{},n=r||{},o=Xn(n.shrink,.14);this.addUniforms({modelViewProjectionMatrix:{value:new y},modelViewProjectionMatrixInverse:{value:new y},modelViewMatrixInverseTranspose:{value:new y},shrink:{value:o}}),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(i),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={parameters:{configurable:!0},isImpostor:{configurable:!0},vertexShader:{configurable:!0},fragmentShader:{configurable:!0}};return r.parameters.get=function(){return Object.assign.call(this,{shrink:{uniform:!0}},t.prototype.parameters)},r.isImpostor.get=function(){return!0},r.vertexShader.get=function(){return"HyperballStickImpostor.vert"},r.fragmentShader.get=function(){return"HyperballStickImpostor.frag"},Object.defineProperties(e.prototype,r),e}(nw),aw=function(t,e){return!Rm||e&&e.disableImpostor?(t.radius=va(t.radius,t.radius2),new Px(t,e)):new ow(t,e)},sw=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="hyperball",this.parameters=Object.assign({shrink:{type:"number",precision:3,max:1,min:.001,buffer:!0}},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};r.scale=Xn(r.scale,.2),r.radius=Xn(r.radius,"vdw"),this.shrink=Xn(r.shrink,.12),t.prototype.init.call(this,r)},e.prototype.getBondParams=function(e,r){return e&&!e.radius||(r=Object.assign({radius2:!0},r)),t.prototype.getBondParams.call(this,e,r)},e.prototype.createData=function(t){var e=new dx(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));return this.__center=new Float32Array(3*t.bondCount),{bufferList:[e,new aw(t.getBondData(this.getBondParams()),this.getBufferParams({shrink:this.shrink,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))]}},e.prototype.updateData=function(t,e){var r=e.sview.getAtomData(this.getAtomParams()),i=e.sview.getBondData(this.getBondParams()),n={},o={};if(!t||t.position){n.position=r.position;var a=i.position1,s=i.position2;o.position=ha(a,s,this.__center),o.position1=a,o.position2=s}t&&!t.color||(n.color=r.color,o.color=i.color,o.color2=i.color2),t&&!t.radius||(n.radius=r.radius,o.radius=i.radius,o.radius2=i.radius2),e.bufferList[0].setAttributes(n),e.bufferList[1].setAttributes(o)},e}(ew);Fm.add("hyperball",sw),jc.prototype={constructor:jc,atomLabel:function(t){var e,r=this.type;switch(r){case"atomname":e=t.atomname;break;case"atomindex":e=""+t.index;break;case"occupancy":e=t.occupancy.toFixed(2);break;case"bfactor":e=t.bfactor.toFixed(2);break;case"serial":e=""+t.serial;break;case"element":e=t.element;break;case"atom":e=t.atomname+"|"+t.index;break;case"resname":e=t.resname;break;case"resno":e=""+t.resno;break;case"res":var i=t.resname.toUpperCase();e=(Dy[i]||i)+t.resno;break;case"text":e=this.text[t.index];break;default:e=t.qualifiedName()}return void 0===e?"":e}},jc.types={"":"",atomname:"atom name",atomindex:"atom index",occupancy:"occupancy",bfactor:"b-factor",serial:"serial",element:"element",atom:"atom name + index",resname:"residue name",resno:"residue no",res:"residue name + no",text:"text",qualified:"qualified name"};var cw=function(t){function e(e,r,i){t.call(this,e,r,i),this.type="label",this.parameters=Object.assign({labelType:{type:"select",options:jc.types,rebuild:!0},labelText:{type:"hidden",rebuild:!0},fontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:!0},fontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:!0},fontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:!0},sdf:{type:"boolean",buffer:!0},xOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},yOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},zOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},attachment:{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},showBorder:{type:"boolean",buffer:!0},borderColor:{type:"color",buffer:!0},borderWidth:{type:"number",precision:2,max:.3,min:0,buffer:!0},showBackground:{type:"boolean",rebuild:!0},backgroundColor:{type:"color",buffer:!0},backgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},backgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:!0}},this.parameters,{side:null,flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null,diffuse:null}),this.init(i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};this.labelType=Xn(r.labelType,"res"),this.labelText=Xn(r.labelText,{}),this.fontFamily=Xn(r.fontFamily,"sans-serif"),this.fontStyle=Xn(r.fontStyle,"normal"),this.fontWeight=Xn(r.fontWeight,"bold"),this.sdf=Xn(r.sdf,"Chrome"===Pm),this.xOffset=Xn(r.xOffset,0),this.yOffset=Xn(r.yOffset,0),this.zOffset=Xn(r.zOffset,.5),this.attachment=Xn(r.attachment,"bottom-left"),this.showBorder=Xn(r.showBorder,!1),this.borderColor=Xn(r.borderColor,"lightgrey"),this.borderWidth=Xn(r.borderWidth,.15),this.showBackground=Xn(r.showBackground,!1),this.backgroundColor=Xn(r.backgroundColor,"lightgrey"),this.backgroundMargin=Xn(r.backgroundMargin,.5),this.backgroundOpacity=Xn(r.backgroundOpacity,1),t.prototype.init.call(this,r)},e.prototype.createData=function(t){var e={position:!0,color:!0,radius:!0},r=t.getAtomData(this.getAtomParams(e)),i=[],n=new jc(this.labelType,this.labelText);return t.eachAtom(function(t){i.push(n.atomLabel(t))}),{bufferList:[new F_({position:r.position,size:r.radius,color:r.color,text:i},this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,sdf:this.sdf,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}))]}},e.prototype.updateData=function(t,e){var r=e.sview.getAtomData(this.getAtomParams(t)),i={};t&&!t.position||(i.position=r.position),t&&!t.radius||(i.size=r.radius),t&&!t.color||(i.color=r.color),e.bufferList[0].setAttributes(i)},e}(_x);Fm.add("label",cw);var uw=function(t){function e(e,r,i){t.call(this,e,r,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)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var r=e||{};this.multipleBond=Xn(r.multipleBond,"off"),this.bondSpacing=Xn(r.bondSpacing,1),this.linewidth=Xn(r.linewidth,2),this.lines=Xn(r.lines,!0),this.crosses=Xn(r.crosses,"lone"),this.crossSize=Xn(r.crossSize,.4),t.prototype.init.call(this,r)},e.prototype.getBondParams=function(e,r){return r=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{radius:.1,scale:1}},r),t.prototype.getBondParams.call(this,e,r)},e.prototype._crossData=function(t,e){if(!t||t.position||t.color){var r={};"lone"===this.crosses&&(r.atomSet=Vc(e));var i,n,o,a,s,c,u=e.getAtomData(this.getAtomParams(t,r)),l={},h=u.position,p=u.color,d=u.picking,f=(h||p).length,m=3*f;t&&!t.position||(i=l.position1=new Float32Array(m),n=l.position2=new Float32Array(m),s=this.crossSize/2),t&&!t.color||(o=l.color=new Float32Array(m),a=l.color2=new Float32Array(m)),t&&!t.picking||(c=new Float32Array(3*u.picking.array.length));for(var g=0;g0)continue;var o=void 0,st=void 0,vt=void 0,yt=void 0,bt=void 0;if(U){if(yt=h.split(fS),bt=10===yt.length?1:0,x=yt[2],q&&"CA"!==x)continue;o=parseFloat(yt[6-bt]),st=parseFloat(yt[7-bt]),vt=parseFloat(yt[8-bt])}else{if(x=h.substr(12,4).trim(),q&&"CA"!==x)continue;o=parseFloat(h.substr(30,8)),st=parseFloat(h.substr(38,8)),vt=parseFloat(h.substr(46,8))}if(X){var xt=3*s;if(a[xt+0]=o,a[xt+1]=st,a[xt+2]=vt,s+=1,K)continue}var _t=void 0;U?(d=parseInt(yt[1]),_t="",_="H"===h[0]?1:0,f=bt?"":yt[4],m=parseInt(yt[5-bt]),b="",g=yt[3],S="",v=0):(d=parseInt(h.substr(6,5),$),G&&99999===d&&($=16),_="H"===h[0]?1:0,f=h[21].trim(),m=parseInt(h.substr(22,4),H)||1,G&&9999===m&&(H=16),b=h[26].trim(),g=h.substr(17,4).trim()||"MOL",w=parseFloat(h.substr(60,6)),S=h[16].trim(),v=parseFloat(h.substr(54,6)),r||(_t=h.substr(76,2).trim(),f||(f=h.substr(72,4).trim()))),ht.growIfFull(),ht.atomTypeId[ft]=lt.add(x,_t),ht.x[ft]=o,ht.y[ft]=st,ht.z[ft]=vt,ht.serial[ft]=d,ht.altloc[ft]=S.charCodeAt(0),ht.occupancy[ft]=isNaN(v)?0:v,U?(ht.partialCharge[ft]=parseFloat(yt[9-bt]),ht.radius[ft]=parseFloat(yt[10-bt])):ht.bfactor[ft]=isNaN(w)?0:w;var wt=Yc(m,f,b);!_||nt[wt]||pS.includes(g)?D||N===f||(L+=1,O=L.toString()):N===f&&B===g&&(zy.includes(g)||k===m&&F===b)||(L+=1,O=L.toString(),k=m,B=g,F=b),V.addAtom(mt,f,O,g,m,_,void 0,b),J[d]=ft,ft+=1,D=!1,N=f}else if("CONECT"===p){var St=J[parseInt(h.substr(6,5))],At=[11,16,21,26],Mt={};if(void 0===St)continue;for(var Pt=0;Pt<4;++Pt){var Et=parseInt(h.substr(At[Pt],5));if(!Number.isNaN(Et)&&void 0!==(Et=J[Et]))if(St0)continue;var ot=it[c].replace(yS,"");if(E&&"CA"!==ot)continue;var at=parseFloat(it[y]),st=parseFloat(it[b]),ct=parseFloat(it[x]);if(P){var ut=3*i;if(r[ut+0]=at,r[ut+1]=st,r[ut+2]=ct,i+=1,X>0)continue}var lt=it[u],ht=parseInt(it[s]),pt=it[v];pt="?"===pt?"":pt;var dt=it[a],ft=it[l],mt="H"===it[d][0]?1:0,gt=it[m],vt=parseFloat(it[_]),yt=parseFloat(it[w]),bt=it[p];if(bt="."===bt?"":bt,$.growIfFull(),$.atomTypeId[W]=G.add(ot,gt),$.x[W]=at,$.y[W]=st,$.z[W]=ct,$.serial[W]=parseInt(it[f]),$.bfactor[W]=isNaN(vt)?0:vt,$.occupancy[W]=isNaN(yt)?0:yt,$.altloc[W]=bt.charCodeAt(0),A.addAtom(X,dt,ft,lt,ht,mt,void 0,pt),t.Debug){var xt=I[ft];void 0!==xt&&xt!==dt&&t.Debug&&Lm.warn(xt,dt)}I[ft]=dt;var _t=it[h];R[_t]||(R[_t]=new Set),R[_t].add(S.chainStore.count-1),W+=1}else{var wt=o.match(vS),St=wt.length;F===B.length&&(F=0);for(var At=0;Atw)continue}d=T.substr(5,5).trim(),f=parseInt(T.substr(0,5)),m=parseInt(T.substr(15,5)),A.growIfFull(),A.atomTypeId[M]=S.add(p),A.x[M]=R,A.y[M]=L,A.z[M]=O,A.serial[M]=m,o.addAtom(P,"","",d,f,0,"l"),M+=1}}}t.Debug&&Lm.time("GroParser._parse "+this.name);var r,i,n=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=this.cAlphaOnly,u=n.frames,l=n.boxes,h=this.streamer.peekLines(3);n.title=h[0].trim();var p,d,f,m,g=h[2].length-h[2].lastIndexOf(".")-1,v=5+g,y=20,b=20+v,x=20+2*v,_=parseInt(h[1]),w=_+3,S=n.atomMap,A=n.atomStore;A.resize(_);var M=0,P=0,E=0;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),o.finalize(),n.finalizeAtoms(),Zs(n),Ks(n),n.finalizeBonds(),mb(n),t.Debug&&Lm.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(sS);zm.add("gro",_S);var wS=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],SS=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],AS=wS.concat(SS),MS={0:"i".charCodeAt(0),1:"s".charCodeAt(0),2:"h".charCodeAt(0),3:"e".charCodeAt(0),4:"g".charCodeAt(0),5:"b".charCodeAt(0),6:"t".charCodeAt(0),7:"l".charCodeAt(0),"-1":"".charCodeAt(0)},PS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"mmtf"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&Lm.time("MmtfParser._parse "+this.name);var e,r,i,n,o,a=this.structure,s=Tu(Pu(this.streamer.data));["depositionDate","releaseDate","resolution","rFree","rWork","experimentalMethods"].forEach(function(t){void 0!==s[t]&&(a.header[t]=s[t])});var c,u,l,h,p,d;if(a.id=s.structureId,a.title=s.title,this.firstModelOnly||this.asTrajectory){for(p=1,h=s.chainsPerModel[0],l=0,e=0,r=h;e0&&(a.biomolDict.NCS=at)}var ct=s.unitCell;ct&&Array.isArray(ct)&&ct[0]?a.unitcell=new lS({a:ct[0],b:ct[1],c:ct[2],alpha:ct[3],beta:ct[4],gamma:ct[5],spacegroup:s.spaceGroup}):a.unitcell=void 0,ec(a,!0),tc(a,!0),a.finalizeAtoms(),a.finalizeBonds(),rc(a),t.Debug&&Lm.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(sS);zm.add("mmtf",PS);var ES=/\s+/,TS={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0},CS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"mol2"},r.prototype._parse=function(){function e(t,e,S){for(var A=t;AMOLECULE"===M?(v=y,d=0,++m):"@ATOM"===M?(v=b,f=h.count,s&&(i=0,r=new Float32Array(3*g),c.push(r),m>0&&(u=!0))):v="@BOND"===M?x:0;else if(v===y){if(0===d)n.title=M,n.id=M;else if(1===d){var P=M.split(ES);g=parseInt(P[0])}++d}else if(v===b){var E=M.split(ES);if(a&&m>0)continue;var T=parseFloat(E[2]),C=parseFloat(E[3]),I=parseFloat(E[4]);if(s){var R=3*i;if(r[R+0]=T,r[R+1]=C,r[R+2]=I,i+=1,u)continue}var L=E[0],O=E[1],D=E[5].split(".")[0],N=E[6]?parseInt(E[6]):1,k=E[7]?E[7]:"",B=E[8]?parseFloat(E[8]):0;h.growIfFull(),h.atomTypeId[p]=l.add(O,D),h.x[p]=T,h.y[p]=C,h.z[p]=I,h.serial[p]=L,h.partialCharge[p]=B,o.addAtom(m,"","",k,N,1),p+=1}else if(v===x){if(a&&m>0)continue;if(s&&m>0)continue;var F=M.split(ES);_.index=parseInt(F[1])-1+f,w.index=parseInt(F[2])-1+f;var z=TS[F[3]];n.bondStore.addBond(_,w,z)}}}t.Debug&&Lm.time("Mol2Parser._parse "+this.name);var r,i,n=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=n.frames,u=!1,l=n.atomMap,h=n.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");var p=0,d=0,f=0,m=-1,g=0,v=0,y=1,b=2,x=3,_=n.getAtomProxy(),w=n.getAtomProxy();this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),o.finalize(),n.finalizeAtoms(),Zs(n),tc(n,!0),ec(n,!0),n.finalizeBonds(),nc(n),mb(n),t.Debug&&Lm.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(sS);zm.add("mol2",CS);var IS=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,r),e}(mS);zm.add("pqr",IS);var RS=/> <(.+)>/,LS=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"sdf"},r.prototype._parse=function(){function e(t,e,a){for(var C=t;C0&&(l=!0));else if(v>=M&&v0)continue;var R=parseFloat(I.substr(0,10)),L=parseFloat(I.substr(10,10)),O=parseFloat(I.substr(20,10));if(o){var D=3*c;if(s[D+0]=R,s[D+1]=L,s[D+2]=O,c+=1,l)continue}var N=I.substr(31,3).trim(),k=N+(g+1);p.growIfFull(),p.atomTypeId[g]=h.add(k,N),p.x[g]=R,p.y[g]=L,p.z[g]=O,p.serial[g]=g,p.formalCharge[g]=0,i.addAtom(y,"","","HET",1,1),g+=1}else if(v>=E&&v0)continue;if(o&&y>0)continue;f.index=parseInt(I.substr(0,3))-1+b,m.index=parseInt(I.substr(3,3))-1+b;var B=parseInt(I.substr(6,3));r.bondStore.addBond(f,m,B)}else if(I.match(/M {2}CHG/))for(var F=parseInt(I.substr(6,3)),z=0,U=10;z0)return void Lm.error("dcd format with fixed atoms unsupported, aborting");for(var v=a.NATOM,y=4*v,b=0,x=a.NSET;b=1&&(i.timeOffset=(a.ISTART-1)*i.deltaTime),t.Debug&&Lm.timeEnd("DcdParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(lA);zm.add("dcd",hA);var pA={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6},dA=0,fA=10,mA=11,gA=12,vA=function(t){var e=new cg(t);e.setBigEndian(),Iu("CDF"!==e.readChars(3),"should start with CDF");var r=e.readByte();Iu(r>2,"unknown version"),this.header=ju(e,r),this.buffer=e},yA={version:{configurable:!0},recordDimension:{configurable:!0},dimensions:{configurable:!0},globalAttributes:{configurable:!0},variables:{configurable:!0}};yA.version.get=function(){return 1===this.header.version?"classic format":"64-bit offset format"},yA.recordDimension.get=function(){return this.header.recordDimension},yA.dimensions.get=function(){return this.header.dimensions},yA.globalAttributes.get=function(){return this.header.globalAttributes},yA.variables.get=function(){return this.header.variables},vA.prototype.hasDataVariable=function(t){return-1!==this.header.variables.findIndex(function(e){return e.name===t})},vA.prototype.getDataVariable=function(t){var e;return e="string"==typeof t?this.header.variables.find(function(e){return e.name===t}):t,Iu(void 0===e,"variable not found"),this.buffer.seek(e.offset),e.record?Uu(this.buffer,e,this.header.recordDimension):zu(this.buffer,e)},Object.defineProperties(vA.prototype,yA);var bA=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"nctraj"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&Lm.time("NctrajParser._parse "+this.name);var e=new vA(this.streamer.data),r=this.frames,i=r.coordinates,n=r.boxes,o=r.times;e.getDataVariable("coordinates").forEach(function(t){i.push(new Float32Array(t))}),e.hasDataVariable("cell_lengths")&&e.getDataVariable("cell_lengths").forEach(function(t){n.push(new Float32Array(t))}),e.hasDataVariable("time")&&e.getDataVariable("time").forEach(function(t){o.push(t)}),o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),t.Debug&&Lm.timeEnd("NctrajParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(lA);zm.add("nctraj",bA),zm.add("ncdf",bA),zm.add("nc",bA);var xA=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"trr"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&Lm.time("TrrParser._parse "+this.name);for(var e=po(this.streamer.data),r=new DataView(e),i=this.frames,n=i.coordinates,o=i.boxes,a=i.times,s=0;;){s+=8;var c=r.getInt32(s);s+=4,s+=c;var u=r.getInt32(s+8),l=r.getInt32(s+12),h=r.getInt32(s+16),p=r.getInt32(s+28),d=r.getInt32(s+32),f=r.getInt32(s+36),m=r.getInt32(s+40);s+=52;var g=u/9,v=3*m;if(8===g?a.push(r.getFloat64(s)):a.push(r.getFloat32(s)),s+=2*g,u){var y=new Float32Array(9);if(8===g)for(var b=0;b<9;++b)y[b]=10*r.getFloat64(s),s+=8;else for(var x=0;x<9;++x)y[x]=10*r.getFloat32(s),s+=4;o.push(y)}if(s+=l,s+=h,p){var _=void 0;if(8===g){_=new Float32Array(v);for(var w=0;w>8&65280|M>>24&255} +_=new Float32Array(e,s,v);for(var P=0;P=e.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),t.Debug&&Lm.timeEnd("TrrParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(lA);zm.add("trr",xA);var _A=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]),wA=new Uint8Array(32),SA=new Int32Array(32),AA=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"xtc"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&Lm.time("XtcParser._parse "+this.name);for(var e=po(this.streamer.data),r=new DataView(e),i=this.frames,n=i.coordinates,o=i.boxes,a=i.times,s=new Int32Array(6),c=new Int32Array(3),u=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),p=new Float32Array(3),d=0,f=new Int32Array(3),m=new Uint32Array(f.buffer);;){var g=void 0,v=r.getInt32(d+4);d+=12;var y=3*v;a.push(r.getFloat32(d)),d+=4;for(var b=new Float32Array(9),x=0;x<9;++x)b[x]=10*r.getFloat32(d),d+=4;if(o.push(b),v<=9)for(var _=0;_16777215?(u[0]=Hu(c[0]),u[1]=Hu(c[1]),u[2]=Hu(c[2]),M=0):M=Wu(3,c);var P=r.getInt32(d);d+=4;var E=P-1;E=9>E?9:E;var T=_A[E]/2|0,C=_A[P]/2|0;l[0]=l[1]=l[2]=_A[P];var I=4*Math.ceil(r.getInt32(d)/4);d+=4;var R=1/A,L=0,O=0,D=new Uint8Array(e,d);for(h[0]=h[1]=h[2]=0;O0){h[0]=h[1]=h[2]=0;for(var B=0;B9?_A[P-1]/2|0:0):k>0&&(T=C,C=_A[P]/2|0),l[0]=l[1]=l[2]=_A[P],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}d+=I}for(var z=0;z=e.byteLength)break}a.length>=1&&(i.timeOffset=a[0]),a.length>=2&&(i.deltaTime=a[1]-a[0]),t.Debug&&Lm.timeEnd("XtcParser._parse "+this.name)},Object.defineProperties(r.prototype,i),r}(lA);zm.add("xtc",AA);var MA=function(t){function e(e,r){var i=r||{};t.call(this,e,i),this.volume=new Qy(this.name,this.path),this.voxelSize=Xn(i.voxelSize,1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0},__objName:{configurable:!0}};return r.type.get=function(){return"volume"},r.__objName.get=function(){return"volume"},e.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix()),t.prototype._afterParse.call(this)},e.prototype.getMatrix=function(){return new y},Object.defineProperties(e.prototype,r),e}(oS),PA=/\s+/,EA=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,TA=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0}};return i.type.get=function(){return"cube"},r.prototype._parse=function(){function e(t,e){var r=n[t].trim().split(PA)[e];return parseFloat(r)}function r(t,e,r){for(var i=t;i=o.atomCount+6+l)for(var a=n.match(EA),h=0,p=a.length;h0?0:1;this.streamer.eachChunkOfLines(function(t){r(0,t.length,t)}),i.header=o,i.setData(s,o.NVZ,o.NVY,o.NVX),t.Debug&&Lm.timeEnd("CubeParser._parse "+this.name)},r.prototype.getMatrix=function(){var t=this.volume.header,e=new y;return e.multiply((new y).makeTranslation(t.originX,t.originY,t.originZ)),e.multiply((new y).makeBasis(t.basisZ,t.basisY,t.basisX)),e},Object.defineProperties(r.prototype,i),r}(MA);zm.add("cub",TA),zm.add("cube",TA);var CA=function(e){function r(){e.apply(this,arguments)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"dsn6"},i.isBinary.get=function(){return!0},r.prototype._parse=function(){t.Debug&&Lm.time("Dsn6Parser._parse "+this.name);var e,r,i=this.volume,n={},o=po(this.streamer.data),a=new Int16Array(o),s=new Uint8Array(o),c=String.fromCharCode.apply(null,s.subarray(0,512));if(c.startsWith(":-)"))n.xStart=parseInt(c.substr(10,5)),n.yStart=parseInt(c.substr(15,5)),n.zStart=parseInt(c.substr(20,5)),n.xExtent=parseInt(c.substr(32,5)),n.yExtent=parseInt(c.substr(38,5)),n.zExtent=parseInt(c.substr(42,5)),n.xRate=parseInt(c.substr(52,5)),n.yRate=parseInt(c.substr(58,5)),n.zRate=parseInt(c.substr(62,5)),n.xlen=parseFloat(c.substr(73,10))*this.voxelSize,n.ylen=parseFloat(c.substr(83,10))*this.voxelSize,n.zlen=parseFloat(c.substr(93,10))*this.voxelSize,n.alpha=parseFloat(c.substr(103,10)),n.beta=parseFloat(c.substr(113,10)),n.gamma=parseFloat(c.substr(123,10)),e=parseFloat(c.substr(138,12))/100,r=parseInt(c.substr(155,8)),n.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(var u=0,l=a.length;u>8&255}n.xStart=a[0],n.yStart=a[1],n.zStart=a[2],n.xExtent=a[3],n.yExtent=a[4],n.zExtent=a[5],n.xRate=a[6],n.yRate=a[7],n.zRate=a[8];var p=1/a[17],d=p*this.voxelSize;n.xlen=a[9]*d,n.ylen=a[10]*d,n.zlen=a[11]*d,n.alpha=a[12]*p,n.beta=a[13]*p,n.gamma=a[14]*p,e=a[15]/100,r=a[16],n.gamma=a[14]*p}i.header=n,t.Debug&&Lm.log(n,e,r);for(var f=new Float32Array(n.xExtent*n.yExtent*n.zExtent),m=512,g=Math.ceil(n.xExtent/8),v=Math.ceil(n.yExtent/8),y=Math.ceil(n.zExtent/8),b=0;ba){var n=r[i].trim();if(""!==n)for(var o=n.split(IA),h=0,p=o.length;h=a&&(g-a)%f!=0&&m=0?r-1:r+e/3)},parseNormalIndex:function(t,e){var r=parseInt(t,10);return 3*(r>=0?r-1:r+e/3)},addVertex:function(t,e,r){var i=this.vertices,n=this.object.geometry.vertices;n.push(i[t+0]),n.push(i[t+1]),n.push(i[t+2]),n.push(i[e+0]),n.push(i[e+1]),n.push(i[e+2]),n.push(i[r+0]),n.push(i[r+1]),n.push(i[r+2])},addVertexLine:function(t){var e=this.vertices,r=this.object.geometry.vertices;r.push(e[t+0]),r.push(e[t+1]),r.push(e[t+2])},addNormal:function(t,e,r){var i=this.normals,n=this.object.geometry.normals;n.push(i[t+0]),n.push(i[t+1]),n.push(i[t+2]),n.push(i[e+0]),n.push(i[e+1]),n.push(i[e+2]),n.push(i[r+0]),n.push(i[r+1]),n.push(i[r+2])},addFace:function(t,e,r,i,n,o,a,s){var c,u=this.vertices.length,l=this.parseVertexIndex(t,u),h=this.parseVertexIndex(e,u),p=this.parseVertexIndex(r,u);if(void 0===i?this.addVertex(l,h,p):(c=this.parseVertexIndex(i,u),this.addVertex(l,h,c),this.addVertex(h,p,c)),void 0!==n){var d=this.normals.length;l=this.parseNormalIndex(n,d),h=n===o?l:this.parseNormalIndex(o,d),p=n===a?l:this.parseNormalIndex(a,d),void 0===i?this.addNormal(l,h,p):(c=this.parseNormalIndex(s,d),this.addNormal(l,h,c),this.addNormal(h,p,c))}},addLineGeometry:function(t){var e=this;this.object.geometry.type="Line";for(var r=this.vertices.length,i=0,n=t.length;i0?_.addAttribute("normal",new Pt(new Float32Array(x.normals),3)):_.computeVertexNormals(),y.push(_)}}return y}};var BA=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={type:{configurable:!0}};return r.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new Zu},Object.defineProperties(e.prototype,r),e}(kA);zm.add("obj",BA),Ku.prototype={constructor:Ku,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),r="",i=0;i=n.elements[c].count&&(c++,u=0);var p=r.parseASCIIElement(n.elements[c].properties,h);r.handleElement(i,n.elements[c].name,p),u++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e0&&(a[C]=I)}else{var R=E.getElementsByTagName("clash"),L=E.getElementsByTagName("mog-bond-outlier"),O=E.getElementsByTagName("mog-angle-outlier");if(L.length>0||O.length>0||R.length>0){var D={};s[C]=D;for(var N=0,k=R.length;N>>1:t>>>1;e[r]=t}return e}(),eM=30,rM=12,iM=15,nM=852,oM=592,aM=0,sM=1,cM=2,uM=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lM=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],hM=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],pM=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],dM=0,fM=1,mM=2,gM=4,vM=5,yM=6,bM=0,xM=1,_M=2,wM=-2,SM=-3,AM=-4,MM=-5,PM=8,EM=1,TM=2,CM=3,IM=4,RM=5,LM=6,OM=7,DM=8,NM=9,kM=10,BM=11,FM=12,zM=13,UM=14,jM=15,VM=16,GM=17,$M=18,HM=19,WM=20,XM=21,qM=22,YM=23,ZM=24,KM=25,QM=26,JM=27,tP=28,eP=29,rP=30,iP=31,nP=32,oP=852,aP=592,sP=!0,cP=!0,uP=!0;try{String.fromCharCode.apply(null,[0])}catch(t){cP=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){uP=!1}for(var lP=new Uint8Array(256),hP=0;hP<256;hP++)lP[hP]=hP>=252?6:hP>=248?5:hP>=240?4:hP>=224?3:hP>=192?2:1;lP[254]=lP[254]=1;var pP=0,dP={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"},fP=Object.prototype.toString;Ll.prototype.push=function(t,e){var r,i,n,o,a,s,c=this,u=this.strm,l=this.options.chunkSize,h=this.options.dictionary,p=!1;if(this.ended)return!1;i=e===~~e?e:!0===e?4:0,"string"==typeof t?u.input=El(t):"[object ArrayBuffer]"===fP.call(t)?u.input=new Uint8Array(t):u.input=t,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new Uint8Array(l),u.next_out=0,u.avail_out=l),r=_l(u,0),2===r&&h&&(s="string"==typeof h?Ml(h):"[object ArrayBuffer]"===fP.call(h)?new Uint8Array(h):h,r=Al(c.strm,s)),-5===r&&!0===p&&(r=pP,p=!1),1!==r&&r!==pP)return c.onEnd(r),c.ended=!0,!1;u.next_out&&(0!==u.avail_out&&1!==r&&(0!==u.avail_in||4!==i&&2!==i)||("string"===c.options.to?(n=Cl(u.output,u.next_out),o=u.next_out-n,a=Tl(u.output,n),u.next_out=o,u.avail_out=l-o,o&&sl(u.output,u.output,n,o,0),c.onData(a)):c.onData(al(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(p=!0)}while((u.avail_in>0||0===u.avail_out)&&1!==r);return 1===r&&(i=4),4===i?(r=wl(this.strm),this.onEnd(r),this.ended=!0,r===pP):2!==i||(this.onEnd(pP),u.avail_out=0,!0)},Ll.prototype.onData=function(t){this.chunks.push(t)},Ll.prototype.onEnd=function(t){t===pP&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=cl(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},jm.add("gz",Dl);var mP=function(){};mP.prototype.getUrl=function(t){},mP.prototype.getExt=function(t){};var gP="//mmtf.rcsb.org/v1.0/full/",vP=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){var e,r=Jn(t),i=r.name.substr(0,4);return!["pdb","cif"].includes(r.ext)||!1!==r.compressed&&"gz"!==r.compressed?"mmtf"===r.ext?e=r.base.endsWith(".bb")?"//mmtf.rcsb.org/v1.0/reduced/"+i:gP+i:r.ext?(Lm.warn("unsupported ext",r.ext),e=gP+i):e=gP+i:e="//files.rcsb.org/download/"+r.path,Yn()+e},e.prototype.getExt=function(t){var e=Jn(t);if("mmtf"===e.ext||!e.ext)return"mmtf"},e}(mP);Bm.add("rcsb",new vP);var yP="//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/",bP=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){var e,r=Jn(t),i=r.name;return r.ext&&"sdf"!==r.ext?(Lm.warn("unsupported ext",r.ext),e=yP+i+"/SDF?record_type=3d"):e=yP+i+"/SDF?record_type=3d",Yn()+e},e.prototype.getExt=function(t){var e=Jn(t);if(!e.ext||"sdf"===e.ext)return"sdf"},e}(mP);Bm.add("pubchem",new bP);var xP=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){return t},e}(mP);Bm.add("ftp",new xP),Bm.add("http",new xP),Bm.add("https",new xP);var _P=/^((http|https|ftp):)*\/\//,wP=function(t){function e(e){t.call(this),this.baseUrl=e||""}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getUrl=function(t){var e=Jn(t),r=this.baseUrl+e.path;return _P.test(this.baseUrl)||(r=Kn(r)),r},e}(mP),SP=function(t){function e(e){t.call(this),this.baseUrl=e||""}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getListing=function(t){t=t||"";var e=this.baseUrl+"dir/"+t;return"/"!==e[e.length-1]&&(e+="/"),ra(e,{ext:"json"}).then(function(e){return{path:t,data:e.data}})},e.prototype.getUrl=function(t){var e=Jn(t);return this.baseUrl+"file/"+e.path+e.query},e.prototype.getCountUrl=function(t){var e=Jn(t);return this.baseUrl+"traj/numframes/"+e.path+e.query},e.prototype.getFrameUrl=function(t,e){var r=Jn(t);return this.baseUrl+"traj/frame/"+e+"/"+r.path+r.query},e.prototype.getFrameParams=function(t,e){return"atomIndices="+e.join(";")},e.prototype.getPathUrl=function(t,e){var r=Jn(t);return this.baseUrl+"traj/path/"+e+"/"+r.path+r.query},e}(mP);"undefined"==typeof window||window.Promise||(window.Promise=i),t.Version="1.0.0-beta.4",t.setDebug=ta,t.ScriptExtensions=Dm,t.DatasourceRegistry=Bm,t.DecompressorRegistry=jm,t.StaticDatasource=wP,t.MdsrvDatasource=SP,t.ParserRegistry=zm,t.autoLoad=ra,t.RepresentationRegistry=Fm,t.ColormakerRegistry=km,t.Colormaker=em,t.Selection=ym,t.PdbWriter=og,t.SdfWriter=ag,t.StlWriter=ug,t.Stage=$x,t.Collection=Ux,t.ComponentCollection=jx,t.RepresentationCollection=Vx,t.Assembly=hb,t.TrajectoryPlayer=Fb,t.superpose=Mc,t.Superposition=Bb,t.guessElement=ic,t.flatten=qn,t.Queue=gc,t.Counter=lg,t.throttle=to,t.download=Qn,t.getQuery=Wn,t.getDataInfo=ea,t.getFileInfo=Jn,t.uniqueArray=ao,t.BufferRepresentation=Kb,t.ArrowBuffer=Rw,t.BoxBuffer=Bw,t.ConeBuffer=Cw,t.CylinderBuffer=Rx,t.EllipsoidBuffer=Gw,t.OctahedronBuffer=qw,t.SphereBuffer=dx,t.TetrahedronBuffer=Jw,t.TextBuffer=F_,t.TorusBuffer=nS,t.Shape=qb,t.Structure=Nb,t.Kdtree=Hs,t.SpatialHash=Cs,t.MolecularSurface=lw,t.Volume=Qy,t.LeftMouseButton=1,t.MiddleMouseButton=2,t.RightMouseButton=3,t.MouseActions=fv,t.KeyActions=vv,t.Signal=ko,t.Matrix3=pt,t.Matrix4=y,t.Vector2=h,t.Vector3=v,t.Box3=lt,t.Quaternion=g,t.Euler=vt,t.Plane=dt,t.Color=et,Object.defineProperty(t,"__esModule",{value:!0})});