Difference between revisions of "Team:SEU-Nanjing-China/static/js/16-fdf7e3d6-chunk-js"

(Created page with "(window["webpackJsonpseu-igem2019"]=window["webpackJsonpseu-igem2019"]||[]).push([[16],{152:function(t,e,i){"use strict";function r(t){return function(t){if(Array.isArray(t)){...")
 
(No difference)

Latest revision as of 15:58, 21 October 2019

(window["webpackJsonpseu-igem2019"]=window["webpackJsonpseu-igem2019"]||[]).push([[16],{152:function(t,e,i){"use strict";function r(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}i.d(e,"a",function(){return r})},182:function(t,e){var i,r,n=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(i===setTimeout)return setTimeout(t,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"===typeof setTimeout?setTimeout:o}catch(t){i=o}try{r="function"===typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var c,u=[],h=!1,l=-1;function p(){h&&c&&(h=!1,c.length?u=c.concat(u):l=-1,u.length&&d())}function d(){if(!h){var t=s(p);h=!0;for(var e=u.length;e;){for(c=u,u=[];++l<e;)c&&c[l].run();l=-1,e=u.length}c=null,h=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function f(t,e){this.fun=t,this.array=e}function m(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];u.push(new f(t,e)),1!==u.length||h||s(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},241:function(t,e,i){"use strict";(function(t){i.d(e,"a",function(){return tg}),"undefined"!==typeof window&&function(){window.console=window.console||{};for(var t,e,i=window.console,r={},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();)i[t]||(i[t]=r);for(;e=a.pop();)i[e]||(i[e]=n)}(),"undefined"===typeof window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var r=window.atob(this.toDataURL(e,i).split(",")[1]),n=r.length,o=n>>2,a=new Uint8Array(n),s=new Uint32Array(a.buffer,0,o),c=0,u=0;c<o;c++)s[c]=r.charCodeAt(u++)|r.charCodeAt(u++)<<8|r.charCodeAt(u++)<<16|r.charCodeAt(u++)<<24;for(var h=3&n;h--;)a[u]=r.charCodeAt(u++);t(new window.Blob([a],{type:e||"image/png"}))}}),Math.cbrt=Math.cbrt||function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},Math.sign||(Math.sign=function(t){return 0===(t=+t)||isNaN(t)?Number(t):t>0?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 i,r=Object(t),n=!1,o=1;o<arguments.length;o++){var a=e[o];if(void 0!==a&&null!==a){for(var s=Object.keys(Object(a)),c=0,u=s.length;c<u;c++){var h=s[c];try{var l=Object.getOwnPropertyDescriptor(a,h);void 0!==l&&l.enumerable&&(r[h]=a[h])}catch(p){n||(n=!0,i=p)}}if(n)throw i}}return r}}),String.prototype.startsWith||function(){var t=function(){var t;try{var e={},i=Object.defineProperty;t=i(e,e,e)&&i}catch(r){}return t}(),e={}.toString,i=function(t){if(null===this)throw TypeError();var i=String(this);if(t&&"[object RegExp]"===e.call(t))throw TypeError();var r=i.length,n=String(t),o=n.length,a=arguments.length>1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),r);if(o+c>r)return!1;for(var u=-1;++u<o;)if(i.charCodeAt(c+u)!==n.charCodeAt(u))return!1;return!0};t?t(String.prototype,"startsWith",{value:i,configurable:!0,writable:!0}):String.prototype.startsWith=i}(),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var i=this.toString();("number"!==typeof e||!isFinite(e)||Math.floor(e)!==e||e>i.length)&&(e=i.length),e-=t.length;var r=i.indexOf(t,e);return-1!==r&&r===e}),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),i=parseInt(e.length,10)||0;if(0===i)return!1;var r,n,o=parseInt(arguments[1],10)||0;for(o>=0?r=o:(r=i+o)<0&&(r=0);r<i;){if(t===(n=e[r])||Number.isNaN(t)&&Number.isNaN(n))return!0;r++}return!1}),Array.from||(Array.from=function(){var t=Object.prototype.toString,e=function(e){return"function"===typeof e||"[object Function]"===t.call(e)},i=Math.pow(2,53)-1,r=function(t){var e=function(t){var e=Number(t);return isNaN(e)?0:0!==e&&isFinite(e)?(e>0?1:-1)*Math.floor(Math.abs(e)):e}(t);return Math.min(Math.max(e,0),i)};return function(t){var i=this,n=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("undefined"!==typeof 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=r(n.length),u=e(i)?Object(new i(c)):new Array(c),h=0;h<c;)s=n[h],u[h]=a?"undefined"===typeof o?a(s,h):a.call(o,s,h):s,h+=1;return u.length=c,u}}()),"undefined"!==typeof window&&function(){for(var t=0,e=["ms","moz","webkit","o"],i=0;i<e.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[e[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[i]+"CancelAnimationFrame"]||window[e[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var i=(new Date).getTime(),r=Math.max(0,16-(i-t)),n=window.setTimeout(function(){e(i+r)},r);return t=i+r,n}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}(),void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),"undefined"!==typeof window&&(void 0===window.performance&&(self.performance={}),void 0===window.performance.now&&function(){var t=Date.now();window.performance.now=function(){return Date.now()-t}}());var r=setTimeout;function n(){}var o="function"===typeof t&&t||function(t){r(t,0)},a=function(t){"undefined"!==typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};function s(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=[],d(t,this)}function c(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o(function(){var i=1===t._state?e.onFulfilled:e.onRejected;if(null!==i){var r;try{r=i(t._value)}catch(n){return void h(e.promise,n)}u(e.promise,r)}else(1===t._state?u:h)(e.promise,t._value)})):t._deferreds.push(e)}function u(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 i=e.then;if(e instanceof s)return t._state=3,t._value=e,void l(t);if("function"===typeof i)return void d((r=i,n=e,function(){r.apply(n,arguments)}),t)}t._state=1,t._value=e,l(t)}catch(o){h(t,o)}var r,n}function h(t,e){t._state=2,t._value=e,l(t)}function l(t){2===t._state&&0===t._deferreds.length&&o(function(){t._handled||a(t._value)});for(var e=0,i=t._deferreds.length;e<i;e++)c(t,t._deferreds[e]);t._deferreds=null}function p(t,e,i){this.onFulfilled="function"===typeof t?t:null,this.onRejected="function"===typeof e?e:null,this.promise=i}function d(t,e){var i=!1;try{t(function(t){i||(i=!0,u(e,t))},function(t){i||(i=!0,h(e,t))})}catch(r){if(i)return;i=!0,h(e,r)}}function f(){}s.prototype.catch=function(t){return this.then(null,t)},s.prototype.then=function(t,e){var i=new this.constructor(n);return c(this,new p(t,e,i)),i},s.all=function(t){var e=Array.prototype.slice.call(t);return new s(function(t,i){if(0===e.length)return t([]);var r=e.length;function n(o,a){try{if(a&&("object"===typeof a||"function"===typeof a)){var s=a.then;if("function"===typeof s)return void s.call(a,function(t){n(o,t)},i)}e[o]=a,0===--r&&t(e)}catch(c){i(c)}}for(var o=0;o<e.length;o++)n(o,e[o])})},s.resolve=function(t){return t&&"object"===typeof t&&t.constructor===s?t:new s(function(e){e(t)})},s.reject=function(t){return new s(function(e,i){i(t)})},s.race=function(t){return new s(function(e,i){for(var r=0,n=t.length;r<n;r++)t[r].then(e,i)})},s._setImmediateFn=function(t){o=t},s._setUnhandledRejectionFn=function(t){a=t},void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"===typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?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 i=Object(t),r=1;r<arguments.length;r++){var n=e[r];if(void 0!==n&&null!==n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])}return i}),Object.assign(f.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var i=this._listeners[t];if(void 0!==i){var r=i.indexOf(e);-1!==r&&i.splice(r,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var i=e.slice(0),r=0,n=i.length;r<n;r++)i[r].call(this,t)}}}});var m="86",g=0,v=1,y=2,b=0,x=1,_=2,w=0,S=1,A=2,M=1,P=2,T=0,E=1,C=2,I=0,R=1,L=2,O=3,N=4,D=5,k=100,F=101,B=102,z=103,U=104,j=200,G=201,V=202,$=203,H=204,W=205,X=206,q=207,Y=208,Z=209,K=210,Q=0,J=1,tt=2,et=3,it=4,rt=5,nt=6,ot=7,at=0,st=1,ct=2,ut=0,ht=1,lt=2,pt=3,dt=4,ft=301,mt=302,gt=303,vt=304,yt=305,bt=306,xt=307,_t=1e3,wt=1001,St=1002,At=1003,Mt=1004,Pt=1005,Tt=1006,Et=1007,Ct=1008,It=1009,Rt=1010,Lt=1011,Ot=1012,Nt=1013,Dt=1014,kt=1015,Ft=1016,Bt=1017,zt=1018,Ut=1019,jt=1020,Gt=1021,Vt=1022,$t=1023,Ht=1024,Wt=1025,Xt=1026,qt=1027,Yt=2001,Zt=2002,Kt=2003,Qt=2004,Jt=2100,te=2101,ee=2102,ie=2103,re=2151,ne=2201,oe=2400,ae=0,se=1,ce=2,ue=3e3,he=3001,le=3007,pe=3002,de=3004,fe=3005,me=3006,ge=3200,ve=3201,ye={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t,e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var n=0;n<36;n++)8===n||13===n||18===n||23===n?i[n]="-":14===n?i[n]="4":(r<=2&&(r=33554432+16777216*Math.random()|0),t=15&r,r>>=4,i[n]=e[19===n?3&t|8:t]);return i.join("")}}(),clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,r,n){return r+(t-e)*(n-r)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-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*ye.DEG2RAD},radToDeg:function(t){return t*ye.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}};function be(t,e){this.x=t||0,this.y=e||0}Object.defineProperties(be.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(be.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 be,e=new be;return function(i,r){return t.set(i,i),e.set(r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(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,i=this.y-t.y;return e*e+i*i},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,i){return this.subVectors(e,t).multiplyScalar(i).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,i){return void 0!==i&&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 i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,o=this.y-t.y;return this.x=n*i-o*r+t.x,this.y=n*r+o*i+t.y,this}});var xe=0;function _e(t,e,i,r,n,o,a,s,c,u){Object.defineProperty(this,"id",{value:xe++}),this.uuid=ye.generateUUID(),this.name="",this.image=void 0!==t?t:_e.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:_e.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:wt,this.wrapT=void 0!==r?r:wt,this.magFilter=void 0!==n?n:Tt,this.minFilter=void 0!==o?o:Ct,this.anisotropy=void 0!==c?c:1,this.format=void 0!==a?a:$t,this.type=void 0!==s?s:It,this.offset=new be(0,0),this.repeat=new be(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:ue,this.version=0,this.onUpdate=null}function we(t,e,i,r){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==r?r:1}function Se(t,e,i){this.uuid=ye.generateUUID(),this.width=t,this.height=e,this.scissor=new we(0,0,t,e),this.scissorTest=!1,this.viewport=new we(0,0,t,e),void 0===(i=i||{}).minFilter&&(i.minFilter=Tt),this.texture=new _e(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function Ae(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==r?r:1}function Me(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}function Pe(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function Te(t,e,i,r,n,o,a,s,c,u,h,l){_e.call(this,null,o,a,s,c,u,r,n,h,l),this.image={data:t,width:e,height:i},this.magFilter=void 0!==c?c:At,this.minFilter=void 0!==u?u:At,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Ee(t,e,i,r,n,o,a,s,c,u){t=void 0!==t?t:[],e=void 0!==e?e:ft,_e.call(this,t,e,i,r,n,o,a,s,c,u),this.flipY=!1}_e.DEFAULT_IMAGE=void 0,_e.DEFAULT_MAPPING=300,Object.defineProperty(_e.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(_e.prototype,f.prototype,{constructor:_e,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 i=this.image;void 0===i.uuid&&(i.uuid=ye.generateUUID()),void 0===t.images[i.uuid]&&(t.images[i.uuid]={uuid:i.uuid,url:function(t){var e;return void 0!==t.toDataURL?e=t:((e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0,t.width,t.height)),e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(i)}),e.image=i.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 _t:t.x=t.x-Math.floor(t.x);break;case wt:t.x=t.x<0?0:1;break;case St: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 _t:t.y=t.y-Math.floor(t.y);break;case wt:t.y=t.y<0?0:1;break;case St: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(we.prototype,{isVector4:!0,set:function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,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,i=this.y,r=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*e+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*e+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*e+o[7]*i+o[11]*r+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,i,r,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?(i=0,r=.707106781,n=.707106781):(r=y/(i=Math.sqrt(m)),n=b/i):g>v?g<.01?(i=.707106781,r=0,n=.707106781):(i=y/(r=Math.sqrt(g)),n=x/r):v<.01?(i=.707106781,r=.707106781,n=0):(i=b/(n=Math.sqrt(v)),r=x/n),this.set(i,r,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(i,r){return void 0===t&&(t=new we,e=new we),t.set(i,i,i,i),e.set(r,r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},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,i){return this.subVectors(e,t).multiplyScalar(i).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,i){return void 0!==i&&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(Se.prototype,f.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"})}}),Object.assign(Ae,{slerp:function(t,e,i,r){return i.copy(t).slerp(e,r)},slerpFlat:function(t,e,i,r,n,o,a){var s=i[r+0],c=i[r+1],u=i[r+2],h=i[r+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(Ae.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(Ae.prototype,{set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,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 i=t._x,r=t._y,n=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(i/2),u=a(r/2),h=a(n/2),l=s(i/2),p=s(r/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 i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,i=t.elements,r=i[0],n=i[4],o=i[8],a=i[1],s=i[5],c=i[9],u=i[2],h=i[6],l=i[10],p=r+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):r>s&&r>l?(e=2*Math.sqrt(1+r-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-r-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-r-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 Me;return function(i,r){return void 0===e&&(e=new Me),(t=i.dot(r)+1)<1e-6?(t=0,Math.abs(i.x)>Math.abs(i.z)?e.set(-i.y,i.x,0):e.set(0,-i.z,i.y)):e.crossVectors(i,r),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 i=t._x,r=t._y,n=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=i*u+o*a+r*c-n*s,this._y=r*u+o*s+n*a-i*c,this._z=n*u+o*c+i*s-r*a,this._w=o*u-i*a-r*s-n*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*t._w+i*t._x+r*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=i,this._y=r,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*(i+this._x),this._y=.5*(r+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=i*u+this._x*h,this._y=r*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(Me.prototype,{isVector3:!0,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,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 Ae;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 Ae;return function(e,i){return this.applyQuaternion(t.setFromAxisAngle(e,i))}}(),applyMatrix3:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements,o=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(t){var e=this.x,i=this.y,r=this.z,n=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*r-a*i,u=s*i+a*e-n*r,h=s*r+n*i-o*e,l=-n*e-o*i-a*r;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 Pe;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new Pe;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,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 Me,e=new Me;return function(i,r){return t.set(i,i,i),e.set(r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(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,i){return this.subVectors(e,t).multiplyScalar(i).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 i=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-i*t.z,this.z=i*t.y-r*t.x,this},crossVectors:function(t,e){var i=t.x,r=t.y,n=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new Me;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new Me;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(ye.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},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(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,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,i){return void 0!==i&&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(Pe.prototype,{isMatrix4:!0,set:function(t,e,i,r,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]=i,g[12]=r,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 Pe).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:function(){var t=new Me;return function(e){var i=this.elements,r=e.elements,n=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i[4]=r[4]*o,i[5]=r[5]*o,i[6]=r[6]*o,i[8]=r[8]*a,i[9]=r[9]*a,i[10]=r[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,i=t.x,r=t.y,n=t.z,o=Math.cos(i),a=Math.sin(i),s=Math.cos(r),c=Math.sin(r),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){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){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){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,i=t._x,r=t._y,n=t._z,o=t._w,a=i+i,s=r+r,c=n+n,u=i*a,h=i*s,l=i*c,p=r*s,d=r*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 Me,e=new Me,i=new Me;return function(r,n,o){var a=this.elements;return i.subVectors(r,n),0===i.lengthSq()&&(i.z=1),i.normalize(),t.crossVectors(o,i),0===t.lengthSq()&&(1===Math.abs(o.z)?i.x+=1e-4:i.z+=1e-4,i.normalize(),t.crossVectors(o,i)),t.normalize(),e.crossVectors(i,t),a[0]=t.x,a[4]=e.x,a[8]=i.x,a[1]=t.y,a[5]=e.y,a[9]=i.y,a[2]=t.z,a[6]=e.z,a[10]=i.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 i=t.elements,r=e.elements,n=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],u=i[1],h=i[5],l=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],b=i[11],x=i[15],_=r[0],w=r[4],S=r[8],A=r[12],M=r[1],P=r[5],T=r[9],E=r[13],C=r[2],I=r[6],R=r[10],L=r[14],O=r[3],N=r[7],D=r[11],k=r[15];return n[0]=o*_+a*M+s*C+c*O,n[4]=o*w+a*P+s*I+c*N,n[8]=o*S+a*T+s*R+c*D,n[12]=o*A+a*E+s*L+c*k,n[1]=u*_+h*M+l*C+p*O,n[5]=u*w+h*P+l*I+p*N,n[9]=u*S+h*T+l*R+p*D,n[13]=u*A+h*E+l*L+p*k,n[2]=d*_+f*M+m*C+g*O,n[6]=d*w+f*P+m*I+g*N,n[10]=d*S+f*T+m*R+g*D,n[14]=d*A+f*E+m*L+g*k,n[3]=v*_+y*M+b*C+x*O,n[7]=v*w+y*P+b*I+x*N,n[11]=v*S+y*T+b*R+x*D,n[15]=v*A+y*E+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 Me;return function(e){for(var i=0,r=e.count;i<r;i++)t.x=e.getX(i),t.y=e.getY(i),t.z=e.getZ(i),t.applyMatrix4(this),e.setXYZ(i,t.x,t.y,t.z);return e}}(),determinant:function(){var t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],o=t[1],a=t[5],s=t[9],c=t[13],u=t[2],h=t[6],l=t[10],p=t[14];return t[3]*(+n*s*h-r*c*h-n*a*l+i*c*l+r*a*p-i*s*p)+t[7]*(+e*s*p-e*c*l+n*o*l-r*o*p+r*c*u-n*s*u)+t[11]*(+e*c*h-e*a*p-n*o*h+i*o*p+n*a*u-i*c*u)+t[15]*(-r*a*u-e*s*h+e*a*l+r*o*h-i*o*l+i*s*u)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var i=this.elements,r=t.elements,n=r[0],o=r[1],a=r[2],s=r[3],c=r[4],u=r[5],h=r[6],l=r[7],p=r[8],d=r[9],f=r[10],m=r[11],g=r[12],v=r[13],y=r[14],b=r[15],x=d*y*l-v*f*l+v*h*m-u*y*m-d*h*b+u*f*b,_=g*f*l-p*y*l-g*h*m+c*y*m+p*h*b-c*f*b,w=p*v*l-g*d*l+g*u*m-c*v*m-p*u*b+c*d*b,S=g*d*h-p*v*h-g*u*f+c*v*f+p*u*y-c*d*y,A=n*x+o*_+a*w+s*S;if(0===A){var M="THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0";if(!0===e)throw new Error(M);return console.warn(M),this.identity()}var P=1/A;return i[0]=x*P,i[1]=(v*f*s-d*y*s-v*a*m+o*y*m+d*a*b-o*f*b)*P,i[2]=(u*y*s-v*h*s+v*a*l-o*y*l-u*a*b+o*h*b)*P,i[3]=(d*h*s-u*f*s-d*a*l+o*f*l+u*a*m-o*h*m)*P,i[4]=_*P,i[5]=(p*y*s-g*f*s+g*a*m-n*y*m-p*a*b+n*f*b)*P,i[6]=(g*h*s-c*y*s-g*a*l+n*y*l+c*a*b-n*h*b)*P,i[7]=(c*f*s-p*h*s+p*a*l-n*f*l-c*a*m+n*h*m)*P,i[8]=w*P,i[9]=(g*d*s-p*v*s-g*o*m+n*v*m+p*o*b-n*d*b)*P,i[10]=(c*v*s-g*u*s+g*o*l-n*v*l-c*o*b+n*u*b)*P,i[11]=(p*u*s-c*d*s-p*o*l+n*d*l+c*o*m-n*u*m)*P,i[12]=S*P,i[13]=(p*v*a-g*d*a+g*o*f-n*v*f-p*o*y+n*d*y)*P,i[14]=(g*u*a-c*v*a-g*o*h+n*v*h+c*o*y-n*u*y)*P,i[15]=(c*d*a-p*u*a+p*o*h-n*d*h-c*o*f+n*u*f)*P,this},scale:function(t){var e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))},makeTranslation:function(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=1-i,o=t.x,a=t.y,s=t.z,c=n*o,u=n*a;return this.set(c*o+i,c*a-r*s,c*s+r*a,0,c*a+r*s,u*a+i,u*s-r*o,0,c*s-r*a,u*s+r*o,n*s*s+i,0,0,0,0,1),this},makeScale:function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,i){return this.makeRotationFromQuaternion(e),this.scale(i),this.setPosition(t),this},decompose:function(){var t=new Me,e=new Pe;return function(i,r,n){var o=this.elements,a=t.set(o[0],o[1],o[2]).length(),s=t.set(o[4],o[5],o[6]).length(),c=t.set(o[8],o[9],o[10]).length();this.determinant()<0&&(a=-a),i.x=o[12],i.y=o[13],i.z=o[14],e.copy(this);var u=1/a,h=1/s,l=1/c;return e.elements[0]*=u,e.elements[1]*=u,e.elements[2]*=u,e.elements[4]*=h,e.elements[5]*=h,e.elements[6]*=h,e.elements[8]*=l,e.elements[9]*=l,e.elements[10]*=l,r.setFromRotationMatrix(e),n.x=a,n.y=s,n.z=c,this}}(),makePerspective:function(t,e,i,r,n,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,s=2*n/(e-t),c=2*n/(i-r),u=(e+t)/(e-t),h=(i+r)/(i-r),l=-(o+n)/(o-n),p=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=l,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makeOrthographic:function(t,e,i,r,n,o){var a=this.elements,s=1/(e-t),c=1/(i-r),u=1/(o-n),h=(e+t)*s,l=(i+r)*c,p=(o+n)*u;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-l,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}),Te.prototype=Object.create(_e.prototype),Te.prototype.constructor=Te,Te.prototype.isDataTexture=!0,Ee.prototype=Object.create(_e.prototype),Ee.prototype.constructor=Ee,Ee.prototype.isCubeTexture=!0,Object.defineProperty(Ee.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});var Ce=new _e,Ie=new Ee;function Re(){this.seq=[],this.map={}}var Le=[],Oe=[],Ne=new Float32Array(16),De=new Float32Array(9);function ke(t,e,i){var r=t[0];if(r<=0||r>0)return t;var n=e*i,o=Le[n];if(void 0===o&&(o=new Float32Array(n),Le[n]=o),0!==e){r.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=i,t[a].toArray(o,s)}return o}function Fe(t,e){var i=Oe[e];void 0===i&&(i=new Int32Array(e),Oe[e]=i);for(var r=0;r!==e;++r)i[r]=t.allocTextureUnit();return i}function Be(t,e){t.uniform1f(this.addr,e)}function ze(t,e){t.uniform1i(this.addr,e)}function Ue(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function je(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 Ge(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function Ve(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function $e(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(De.set(e.elements),t.uniformMatrix3fv(this.addr,!1,De))}function He(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Ne.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Ne))}function We(t,e,i){var r=i.allocTextureUnit();t.uniform1i(this.addr,r),i.setTexture2D(e||Ce,r)}function Xe(t,e,i){var r=i.allocTextureUnit();t.uniform1i(this.addr,r),i.setTextureCube(e||Ie,r)}function qe(t,e){t.uniform2iv(this.addr,e)}function Ye(t,e){t.uniform3iv(this.addr,e)}function Ze(t,e){t.uniform4iv(this.addr,e)}function Ke(t,e){t.uniform1fv(this.addr,e)}function Qe(t,e){t.uniform1iv(this.addr,e)}function Je(t,e){t.uniform2fv(this.addr,ke(e,this.size,2))}function ti(t,e){t.uniform3fv(this.addr,ke(e,this.size,3))}function ei(t,e){t.uniform4fv(this.addr,ke(e,this.size,4))}function ii(t,e){t.uniformMatrix2fv(this.addr,!1,ke(e,this.size,4))}function ri(t,e){t.uniformMatrix3fv(this.addr,!1,ke(e,this.size,9))}function ni(t,e){t.uniformMatrix4fv(this.addr,!1,ke(e,this.size,16))}function oi(t,e,i){var r=e.length,n=Fe(i,r);t.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTexture2D(e[o]||Ce,n[o])}function ai(t,e,i){var r=e.length,n=Fe(i,r);t.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTextureCube(e[o]||Ie,n[o])}function si(t,e,i){this.id=t,this.addr=i,this.setValue=function(t){switch(t){case 5126:return Be;case 35664:return Ue;case 35665:return je;case 35666:return Ge;case 35674:return Ve;case 35675:return $e;case 35676:return He;case 35678:case 36198:return We;case 35680:return Xe;case 5124:case 35670:return ze;case 35667:case 35671:return qe;case 35668:case 35672:return Ye;case 35669:case 35673:return Ze}}(e.type)}function ci(t,e,i){this.id=t,this.addr=i,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Ke;case 35664:return Je;case 35665:return ti;case 35666:return ei;case 35674:return ii;case 35675:return ri;case 35676:return ni;case 35678:return oi;case 35680:return ai;case 5124:case 35670:return Qe;case 35667:case 35671:return qe;case 35668:case 35672:return Ye;case 35669:case 35673:return Ze}}(e.type)}function ui(t){this.id=t,Re.call(this)}ui.prototype.setValue=function(t,e){for(var i=this.seq,r=0,n=i.length;r!==n;++r){var o=i[r];o.setValue(t,e[o.id])}};var hi=/([\w\d_]+)(\])?(\[|\.)?/g;function li(t,e){t.seq.push(e),t.map[e.id]=e}function pi(t,e,i){var r=t.name,n=r.length;for(hi.lastIndex=0;;){var o=hi.exec(r),a=hi.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===n){li(i,void 0===u?new si(s,t,e):new ci(s,t,e));break}var h=i.map[s];void 0===h&&li(i,h=new ui(s)),i=h}}function di(t,e,i){Re.call(this),this.renderer=i;for(var r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),n=0;n<r;++n){var o=t.getActiveUniform(e,n),a=o.name;pi(o,t.getUniformLocation(e,a),this)}}di.prototype.setValue=function(t,e,i){var r=this.map[e];void 0!==r&&r.setValue(t,i,this.renderer)},di.prototype.setOptional=function(t,e,i){var r=e[i];void 0!==r&&this.setValue(t,i,r)},di.upload=function(t,e,i,r){for(var n=0,o=e.length;n!==o;++n){var a=e[n],s=i[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,r)}},di.seqWithValue=function(t,e){for(var i=[],r=0,n=t.length;r!==n;++r){var o=t[r];o.id in e&&i.push(o)}return i};var fi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function mi(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}Object.assign(mi.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"===typeof t?this.setHex(t):"string"===typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(){function t(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}return function(e,i,r){if(e=ye.euclideanModulo(e,1),i=ye.clamp(i,0,1),r=ye.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var n=r<=.5?r*(1+i):r+i-r*i,o=2*r-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 i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(a,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u,h=(u=i[1]).length;if(3===h)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===h)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}t&&t.length>0&&(void 0!==(u=fi[t])?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 i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(){var t=this.r,e=this.g,i=this.b;return this.r=t*t,this.g=e*e,this.b=i*i,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,i,r=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,i=0;else{var h=s-c;switch(i=u<=.5?h/(s+c):h/(2-s-c),s){case n:e=(o-a)/h+(o<a?6:0);break;case o:e=(a-n)/h+2;break;case a:e=(n-o)/h+4}e/=6}return r.h=e,r.s=i,r.l=u,r},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,i){var r=this.getHSL();return r.h+=t,r.s+=e,r.l+=i,this.setHSL(r.h,r.s,r.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}});var gi={common:{diffuse:{value:new mi(15658734)},opacity:{value:1},map:{value:null},offsetRepeat:{value:new we(0,0,1,1)},specularMap:{value:null},alphaMap:{value:null},envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new be(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new mi(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new mi(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},offsetRepeat:{value:new we(0,0,1,1)}}},vi={merge:function(t){for(var e={},i=0;i<t.length;i++){var r=this.clone(t[i]);for(var n in r)e[n]=r[n]}return e},clone:function(t){var e={};for(var i in t)for(var r in e[i]={},t[i]){var n=t[i][r];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture)?e[i][r]=n.clone():Array.isArray(n)?e[i][r]=n.slice():e[i][r]=n}return e}},yi={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 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, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = asin( flipNormal * reflectVec.y ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * 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};\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 = saturate( reflectVec.y * 0.5 + 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 ] ) : 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_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\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 ) * flipNormal;\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 ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\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 ] ) : 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 ( 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;\n#include <common>\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 <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include <common>\n#include <packing>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <skinbase_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 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 <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <normal_flip>\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\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 <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <normal_flip>\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\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 <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\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 <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",shadow_frag:"uniform float opacity;\n#include <common>\n#include <packing>\n#include <bsdfs>\n#include <lights_pars>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n"},bi={basic:{uniforms:vi.merge([gi.common,gi.aomap,gi.lightmap,gi.fog]),vertexShader:yi.meshbasic_vert,fragmentShader:yi.meshbasic_frag},lambert:{uniforms:vi.merge([gi.common,gi.aomap,gi.lightmap,gi.emissivemap,gi.fog,gi.lights,{emissive:{value:new mi(0)}}]),vertexShader:yi.meshlambert_vert,fragmentShader:yi.meshlambert_frag},phong:{uniforms:vi.merge([gi.common,gi.aomap,gi.lightmap,gi.emissivemap,gi.bumpmap,gi.normalmap,gi.displacementmap,gi.gradientmap,gi.fog,gi.lights,{emissive:{value:new mi(0)},specular:{value:new mi(1118481)},shininess:{value:30}}]),vertexShader:yi.meshphong_vert,fragmentShader:yi.meshphong_frag},standard:{uniforms:vi.merge([gi.common,gi.aomap,gi.lightmap,gi.emissivemap,gi.bumpmap,gi.normalmap,gi.displacementmap,gi.roughnessmap,gi.metalnessmap,gi.fog,gi.lights,{emissive:{value:new mi(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:yi.meshphysical_vert,fragmentShader:yi.meshphysical_frag},points:{uniforms:vi.merge([gi.points,gi.fog]),vertexShader:yi.points_vert,fragmentShader:yi.points_frag},dashed:{uniforms:vi.merge([gi.common,gi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yi.linedashed_vert,fragmentShader:yi.linedashed_frag},depth:{uniforms:vi.merge([gi.common,gi.displacementmap]),vertexShader:yi.depth_vert,fragmentShader:yi.depth_frag},normal:{uniforms:vi.merge([gi.common,gi.bumpmap,gi.normalmap,gi.displacementmap,{opacity:{value:1}}]),vertexShader:yi.normal_vert,fragmentShader:yi.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yi.cube_vert,fragmentShader:yi.cube_frag},equirect:{uniforms:{tEquirect:{value:null},tFlip:{value:-1}},vertexShader:yi.equirect_vert,fragmentShader:yi.equirect_frag},distanceRGBA:{uniforms:{lightPos:{value:new Me}},vertexShader:yi.distanceRGBA_vert,fragmentShader:yi.distanceRGBA_frag}};function xi(t,e){this.min=void 0!==t?t:new be(1/0,1/0),this.max=void 0!==e?e:new be(-1/0,-1/0)}function _i(t,e){var i,r,n,o,a,s,c,u,h=t.context,l=t.state;function p(){var e=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),p=new Uint16Array([0,1,2,0,2,3]);i=h.createBuffer(),r=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,i),h.bufferData(h.ARRAY_BUFFER,e,h.STATIC_DRAW),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,r),h.bufferData(h.ELEMENT_ARRAY_BUFFER,p,h.STATIC_DRAW),c=h.createTexture(),u=h.createTexture(),l.bindTexture(h.TEXTURE_2D,c),h.texImage2D(h.TEXTURE_2D,0,h.RGB,16,16,0,h.RGB,h.UNSIGNED_BYTE,null),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),l.bindTexture(h.TEXTURE_2D,u),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,16,16,0,h.RGBA,h.UNSIGNED_BYTE,null),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),n={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},o=function(e){var i=h.createProgram(),r=h.createShader(h.FRAGMENT_SHADER),n=h.createShader(h.VERTEX_SHADER),o="precision "+t.getPrecision()+" float;\n";return h.shaderSource(r,o+e.fragmentShader),h.shaderSource(n,o+e.vertexShader),h.compileShader(r),h.compileShader(n),h.attachShader(i,r),h.attachShader(i,n),h.linkProgram(i),i}(n),a={vertex:h.getAttribLocation(o,"position"),uv:h.getAttribLocation(o,"uv")},s={renderType:h.getUniformLocation(o,"renderType"),map:h.getUniformLocation(o,"map"),occlusionMap:h.getUniformLocation(o,"occlusionMap"),opacity:h.getUniformLocation(o,"opacity"),color:h.getUniformLocation(o,"color"),scale:h.getUniformLocation(o,"scale"),rotation:h.getUniformLocation(o,"rotation"),screenPosition:h.getUniformLocation(o,"screenPosition")}}this.render=function(n,d,f){if(0!==e.length){var m=new Me,g=f.w/f.z,v=.5*f.z,y=.5*f.w,b=16/f.w,x=new be(b*g,b),_=new Me(1,1,0),w=new be(1,1),S=new xi;S.min.set(f.x,f.y),S.max.set(f.x+(f.z-16),f.y+(f.w-16)),void 0===o&&p(),h.useProgram(o),l.initAttributes(),l.enableAttribute(a.vertex),l.enableAttribute(a.uv),l.disableUnusedAttributes(),h.uniform1i(s.occlusionMap,0),h.uniform1i(s.map,1),h.bindBuffer(h.ARRAY_BUFFER,i),h.vertexAttribPointer(a.vertex,2,h.FLOAT,!1,16,0),h.vertexAttribPointer(a.uv,2,h.FLOAT,!1,16,8),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,r),l.disable(h.CULL_FACE),l.buffers.depth.setMask(!1);for(var A=0,M=e.length;A<M;A++){b=16/f.w,x.set(b*g,b);var P=e[A];if(m.set(P.matrixWorld.elements[12],P.matrixWorld.elements[13],P.matrixWorld.elements[14]),m.applyMatrix4(d.matrixWorldInverse),m.applyMatrix4(d.projectionMatrix),_.copy(m),w.x=f.x+_.x*v+v-8,w.y=f.y+_.y*y+y-8,!0===S.containsPoint(w)){l.activeTexture(h.TEXTURE0),l.bindTexture(h.TEXTURE_2D,null),l.activeTexture(h.TEXTURE1),l.bindTexture(h.TEXTURE_2D,c),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGB,w.x,w.y,16,16,0),h.uniform1i(s.renderType,0),h.uniform2f(s.scale,x.x,x.y),h.uniform3f(s.screenPosition,_.x,_.y,_.z),l.disable(h.BLEND),l.enable(h.DEPTH_TEST),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0),l.activeTexture(h.TEXTURE0),l.bindTexture(h.TEXTURE_2D,u),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,w.x,w.y,16,16,0),h.uniform1i(s.renderType,1),l.disable(h.DEPTH_TEST),l.activeTexture(h.TEXTURE1),l.bindTexture(h.TEXTURE_2D,c),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0),P.positionScreen.copy(_),P.customUpdateCallback?P.customUpdateCallback(P):P.updateLensFlares(),h.uniform1i(s.renderType,2),l.enable(h.BLEND);for(var T=0,E=P.lensFlares.length;T<E;T++){var C=P.lensFlares[T];C.opacity>.001&&C.scale>.001&&(_.x=C.x,_.y=C.y,_.z=C.z,b=C.size*C.scale/f.w,x.x=b*g,x.y=b,h.uniform3f(s.screenPosition,_.x,_.y,_.z),h.uniform2f(s.scale,x.x,x.y),h.uniform1f(s.rotation,C.rotation),h.uniform1f(s.opacity,C.opacity),h.uniform3f(s.color,C.color.r,C.color.g,C.color.b),l.setBlending(C.blending,C.blendEquation,C.blendSrc,C.blendDst),t.setTexture2D(C.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0))}}}l.enable(h.CULL_FACE),l.enable(h.DEPTH_TEST),l.buffers.depth.setMask(!0),t.resetGLState()}}}function wi(t,e){var i,r,n,o,a,s,c=t.context,u=t.state,h=new Me,l=new Ae,p=new Me;function d(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),u=new Uint16Array([0,1,2,0,2,3]);i=c.createBuffer(),r=c.createBuffer(),c.bindBuffer(c.ARRAY_BUFFER,i),c.bufferData(c.ARRAY_BUFFER,e,c.STATIC_DRAW),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r),c.bufferData(c.ELEMENT_ARRAY_BUFFER,u,c.STATIC_DRAW),n=function(){var e=c.createProgram(),i=c.createShader(c.VERTEX_SHADER),r=c.createShader(c.FRAGMENT_SHADER);return c.shaderSource(i,["precision "+t.getPrecision()+" 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")),c.shaderSource(r,["precision "+t.getPrecision()+" 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")),c.compileShader(i),c.compileShader(r),c.attachShader(e,i),c.attachShader(e,r),c.linkProgram(e),e}(),o={position:c.getAttribLocation(n,"position"),uv:c.getAttribLocation(n,"uv")},a={uvOffset:c.getUniformLocation(n,"uvOffset"),uvScale:c.getUniformLocation(n,"uvScale"),rotation:c.getUniformLocation(n,"rotation"),scale:c.getUniformLocation(n,"scale"),color:c.getUniformLocation(n,"color"),map:c.getUniformLocation(n,"map"),opacity:c.getUniformLocation(n,"opacity"),modelViewMatrix:c.getUniformLocation(n,"modelViewMatrix"),projectionMatrix:c.getUniformLocation(n,"projectionMatrix"),fogType:c.getUniformLocation(n,"fogType"),fogDensity:c.getUniformLocation(n,"fogDensity"),fogNear:c.getUniformLocation(n,"fogNear"),fogFar:c.getUniformLocation(n,"fogFar"),fogColor:c.getUniformLocation(n,"fogColor"),alphaTest:c.getUniformLocation(n,"alphaTest")};var h=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");h.width=8,h.height=8;var l=h.getContext("2d");l.fillStyle="white",l.fillRect(0,0,8,8),(s=new _e(h)).needsUpdate=!0}function f(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(m,g){if(0!==e.length){void 0===n&&d(),c.useProgram(n),u.initAttributes(),u.enableAttribute(o.position),u.enableAttribute(o.uv),u.disableUnusedAttributes(),u.disable(c.CULL_FACE),u.enable(c.BLEND),c.bindBuffer(c.ARRAY_BUFFER,i),c.vertexAttribPointer(o.position,2,c.FLOAT,!1,16,0),c.vertexAttribPointer(o.uv,2,c.FLOAT,!1,16,8),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r),c.uniformMatrix4fv(a.projectionMatrix,!1,g.projectionMatrix.elements),u.activeTexture(c.TEXTURE0),c.uniform1i(a.map,0);var v=0,y=0,b=m.fog;b?(c.uniform3f(a.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(c.uniform1f(a.fogNear,b.near),c.uniform1f(a.fogFar,b.far),c.uniform1i(a.fogType,1),v=1,y=1):b.isFogExp2&&(c.uniform1f(a.fogDensity,b.density),c.uniform1i(a.fogType,2),v=2,y=2)):(c.uniform1i(a.fogType,0),v=0,y=0);for(var x=0,_=e.length;x<_;x++){(S=e[x]).modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,S.matrixWorld),S.z=-S.modelViewMatrix.elements[14]}e.sort(f);var w=[];for(x=0,_=e.length;x<_;x++){var S,A=(S=e[x]).material;if(!1!==A.visible){S.onBeforeRender(t,m,g,void 0,A,void 0),c.uniform1f(a.alphaTest,A.alphaTest),c.uniformMatrix4fv(a.modelViewMatrix,!1,S.modelViewMatrix.elements),S.matrixWorld.decompose(h,l,p),w[0]=p.x,w[1]=p.y;var M=0;m.fog&&A.fog&&(M=y),v!==M&&(c.uniform1i(a.fogType,M),v=M),null!==A.map?(c.uniform2f(a.uvOffset,A.map.offset.x,A.map.offset.y),c.uniform2f(a.uvScale,A.map.repeat.x,A.map.repeat.y)):(c.uniform2f(a.uvOffset,0,0),c.uniform2f(a.uvScale,1,1)),c.uniform1f(a.opacity,A.opacity),c.uniform3f(a.color,A.color.r,A.color.g,A.color.b),c.uniform1f(a.rotation,A.rotation),c.uniform2fv(a.scale,w),u.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst,A.blendEquationAlpha,A.blendSrcAlpha,A.blendDstAlpha,A.premultipliedAlpha),u.buffers.depth.setTest(A.depthTest),u.buffers.depth.setMask(A.depthWrite),A.map?t.setTexture2D(A.map,0):t.setTexture2D(s,0),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0),S.onAfterRender(t,m,g,void 0,A,void 0)}}u.enable(c.CULL_FACE),t.resetGLState()}}}bi.physical={uniforms:vi.merge([bi.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:yi.meshphysical_vert,fragmentShader:yi.meshphysical_frag},Object.assign(xi.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(){var t=new be;return function(e,i){var r=t.copy(i).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){var e=t||new be;return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new be;return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.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 be).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.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return(e||new be).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new be;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)}});var Si=0;function Ai(){Object.defineProperty(this,"id",{value:Si++}),this.uuid=ye.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=R,this.side=w,this.shading=P,this.vertexColors=T,this.opacity=1,this.transparent=!1,this.blendSrc=H,this.blendDst=W,this.blendEquation=k,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=et,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.needsUpdate=!0}function Mi(t){Ai.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function Pi(t){Ai.call(this),this.type="MeshDepthMaterial",this.depthPacking=ge,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function Ti(t,e){this.min=void 0!==t?t:new Me(1/0,1/0,1/0),this.max=void 0!==e?e:new Me(-1/0,-1/0,-1/0)}function Ei(t,e){this.center=void 0!==t?t:new Me,this.radius=void 0!==e?e:0}function Ci(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function Ii(t,e){this.normal=void 0!==t?t:new Me(1,0,0),this.constant=void 0!==e?e:0}function Ri(t,e,i,r,n,o){this.planes=[void 0!==t?t:new Ii,void 0!==e?e:new Ii,void 0!==i?i:new Ii,void 0!==r?r:new Ii,void 0!==n?n:new Ii,void 0!==o?o:new Ii]}function Li(t,e,i,r){var n=t.context,o=t.state,a=new Ri,s=new Pe,c=e.shadows,u=new be,h=new be(r.maxTextureSize,r.maxTextureSize),l=new Me,p=new Me,d=1,f=2,m=1+(d|f),g=new Array(m),v=new Array(m),y={},b=[new Me(1,0,0),new Me(-1,0,0),new Me(0,0,1),new Me(0,0,-1),new Me(0,1,0),new Me(0,-1,0)],_=[new Me(0,1,0),new Me(0,1,0),new Me(0,1,0),new Me(0,1,0),new Me(0,0,1),new Me(0,0,-1)],M=[new we,new we,new we,new we,new we,new we],P=new Pi;P.depthPacking=ve,P.clipping=!0;for(var T=bi.distanceRGBA,E=vi.clone(T.uniforms),C=0;C!==m;++C){var I=0!==(C&d),R=0!==(C&f),L=P.clone();L.morphTargets=I,L.skinning=R,g[C]=L;var O=new Mi({defines:{USE_SHADOWMAP:""},uniforms:E,vertexShader:T.vertexShader,fragmentShader:T.fragmentShader,morphTargets:I,skinning:R,clipping:!0});v[C]=O}var N=this;function D(e,i,r,n){var o=e.geometry,a=null,s=g,c=e.customDepthMaterial;if(r&&(s=v,c=e.customDistanceMaterial),c)a=c;else{var u=!1;i.morphTargets&&(o&&o.isBufferGeometry?u=o.morphAttributes&&o.morphAttributes.position&&o.morphAttributes.position.length>0:o&&o.isGeometry&&(u=o.morphTargets&&o.morphTargets.length>0)),e.isSkinnedMesh&&!1===i.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var h=e.isSkinnedMesh&&i.skinning,l=0;u&&(l|=d),h&&(l|=f),a=s[l]}if(t.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var p=a.uuid,m=i.uuid,b=y[p];void 0===b&&(b={},y[p]=b);var x=b[m];void 0===x&&(x=a.clone(),b[m]=x),a=x}a.visible=i.visible,a.wireframe=i.wireframe;var _=i.side;return N.renderSingleSided&&_==A&&(_=w),N.renderReverseSided&&(_===w?_=S:_===S&&(_=w)),a.side=_,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,r&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(n),a}function k(e,r,n,o){if(!1!==e.visible){if(e.layers.test(r.layers)&&(e.isMesh||e.isLine||e.isPoints)&&e.castShadow&&(!e.frustumCulled||a.intersectsObject(e))){e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld);var s=i.update(e),c=e.material;if(Array.isArray(c))for(var u=s.groups,h=0,l=u.length;h<l;h++){var d=u[h],f=c[d.materialIndex];if(f&&f.visible){var m=D(e,f,o,p);t.renderBufferDirect(n,null,s,m,e,d)}}else if(c.visible){m=D(e,c,o,p);t.renderBufferDirect(n,null,s,m,e,null)}}for(var g=e.children,v=0,y=g.length;v<y;v++)k(g[v],r,n,o)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=x,this.renderReverseSided=!0,this.renderSingleSided=!0,this.render=function(e,i){if(!1!==N.enabled&&(!1!==N.autoUpdate||!1!==N.needsUpdate)&&0!==c.length){var r;o.disable(n.BLEND),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var d=0,f=c.length;d<f;d++){var m=c[d],g=m.shadow,v=m&&m.isPointLight;if(void 0!==g){var y=g.camera;if(u.copy(g.mapSize),u.min(h),v){var x=u.x,w=u.y;M[0].set(2*x,w,x,w),M[1].set(0,w,x,w),M[2].set(3*x,w,x,w),M[3].set(x,w,x,w),M[4].set(3*x,0,x,w),M[5].set(x,0,x,w),u.x*=4,u.y*=2}if(null===g.map){var S={minFilter:At,magFilter:At,format:$t};g.map=new Se(u.x,u.y,S),g.map.texture.name=m.name+".shadowMap",y.updateProjectionMatrix()}g.isSpotLightShadow&&g.update(m);var A=g.map,P=g.matrix;p.setFromMatrixPosition(m.matrixWorld),y.position.copy(p),v?(r=6,P.makeTranslation(-p.x,-p.y,-p.z)):(r=1,l.setFromMatrixPosition(m.target.matrixWorld),y.lookAt(l),y.updateMatrixWorld(),P.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),P.multiply(y.projectionMatrix),P.multiply(y.matrixWorldInverse)),t.setRenderTarget(A),t.clear();for(var T=0;T<r;T++){if(v){l.copy(y.position),l.add(b[T]),y.up.copy(_[T]),y.lookAt(l),y.updateMatrixWorld();var E=M[T];o.viewport(E)}s.multiplyMatrices(y.projectionMatrix,y.matrixWorldInverse),a.setFromMatrix(s),k(e,i,y,v)}}else console.warn("THREE.WebGLShadowMap:",m,"has no shadow.")}var C=t.getClearColor(),I=t.getClearAlpha();t.setClearColor(C,I),N.needsUpdate=!1}}}function Oi(t){var e={};return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e[t.uuid]},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);var r=e[i.uuid];r&&(t.deleteBuffer(r.buffer),delete e[i.uuid])},update:function(i,r){i.isInterleavedBufferAttribute&&(i=i.data);var n=e[i.uuid];void 0===n?e[i.uuid]=function(e,i){var r=e.array,n=e.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW,o=t.createBuffer();t.bindBuffer(i,o),t.bufferData(i,r,n),e.onUploadCallback();var a=t.FLOAT;return r instanceof Float32Array?a=t.FLOAT:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?a=t.UNSIGNED_SHORT:r instanceof Int16Array?a=t.SHORT:r instanceof Uint32Array?a=t.UNSIGNED_INT:r instanceof Int32Array?a=t.INT:r instanceof Int8Array?a=t.BYTE:r instanceof Uint8Array&&(a=t.UNSIGNED_BYTE),{buffer:o,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(i,r):n.version<i.version&&(!function(e,i,r){var n=i.array,o=i.updateRange;t.bindBuffer(r,e),!1===i.dynamic?t.bufferData(r,n,t.STATIC_DRAW):-1===o.count?t.bufferSubData(r,0,n):0===o.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(t.bufferSubData(r,o.offset*n.BYTES_PER_ELEMENT,n.subarray(o.offset,o.offset+o.count)),o.count=-1)}(n.buffer,i,r),n.version=i.version)}}}function Ni(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._order=r||Ni.DefaultOrder}function Di(){this.mask=1}Object.assign(Ai.prototype,f.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var i=t[e];if(void 0!==i){var r=this[e];void 0!==r?r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[e]="overdraw"===e?Number(i):i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t;e&&(t={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){var e=[];for(var i in t){var r=t[i];delete r.metadata,e.push(r)}return e}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!==R&&(i.blending=this.blending),this.shading!==P&&(i.shading=this.shading),this.side!==w&&(i.side=this.side),this.vertexColors!==T&&(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,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),i.skinning=this.skinning,i.morphTargets=this.morphTargets,i.dithering=this.dithering,e){var n=r(t.textures),o=r(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.shading=t.shading,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.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,i=null;if(null!==e){var r=e.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Mi.prototype=Object.create(Ai.prototype),Mi.prototype.constructor=Mi,Mi.prototype.isShaderMaterial=!0,Mi.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=vi.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},Mi.prototype.toJSON=function(t){var e=Ai.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},Pi.prototype=Object.create(Ai.prototype),Pi.prototype.constructor=Pi,Pi.prototype.isMeshDepthMaterial=!0,Pi.prototype.copy=function(t){return Ai.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},Object.assign(Ti.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,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],h=t[s+1],l=t[s+2];u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),u>n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return this.min.set(e,i,r),this.max.set(n,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;s<c;s++){var u=t.getX(s),h=t.getY(s),l=t.getZ(s);u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),u>n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return this.min.set(e,i,r),this.max.set(n,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(){var t=new Me;return function(e,i){var r=t.copy(i).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}}(),setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){var e=t||new Me;return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new Me;return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(){var t=new Me;return function(e){var i=this;return e.updateMatrixWorld(!0),e.traverse(function(e){var r,n,o=e.geometry;if(void 0!==o)if(o.isGeometry){var a=o.vertices;for(r=0,n=a.length;r<n;r++)t.copy(a[r]),t.applyMatrix4(e.matrixWorld),i.expandByPoint(t)}else if(o.isBufferGeometry){var s=o.attributes.position;if(void 0!==s)for(r=0,n=s.count;r<n;r++)t.fromBufferAttribute(s,r).applyMatrix4(e.matrixWorld),i.expandByPoint(t)}}),this}}(),containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.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 Me).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.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:function(){var t=new Me;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=t.constant&&i>=t.constant},clampPoint:function(t,e){return(e||new Me).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new Me;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new Me;return function(e){var i=e||new Ei;return this.getCenter(i.center),i.radius=.5*this.getSize(t).length(),i}}(),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 Me,new Me,new Me,new Me,new Me,new Me,new Me,new Me];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(Ei.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new Ti;return function(e,i){var r=this.center;void 0!==i?r.copy(i):t.setFromPoints(e).getCenter(r);for(var n=0,o=0,a=e.length;o<a;o++)n=Math.max(n,r.distanceToSquared(e[o]));return this.radius=Math.sqrt(n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(this.center.dot(t.normal)-t.constant)<=this.radius},clampPoint:function(t,e){var i=this.center.distanceToSquared(t),r=e||new Me;return r.copy(t),i>this.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(t){var e=t||new Ti;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(Ci.prototype,{isMatrix3:!0,set:function(t,e,i,r,n,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=n,u[5]=s,u[6]=i,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,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[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 Me;return function(e){for(var i=0,r=e.count;i<r;i++)t.x=e.getX(i),t.y=e.getY(i),t.z=e.getZ(i),t.applyMatrix3(this),e.setXYZ(i,t.x,t.y,t.z);return e}}(),multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,r=e.elements,n=this.elements,o=i[0],a=i[3],s=i[6],c=i[1],u=i[4],h=i[7],l=i[2],p=i[5],d=i[8],f=r[0],m=r[3],g=r[6],v=r[1],y=r[4],b=r[7],x=r[2],_=r[5],w=r[8];return n[0]=o*f+a*v+s*x,n[3]=o*m+a*y+s*_,n[6]=o*g+a*b+s*w,n[1]=c*f+u*v+h*x,n[4]=c*m+u*y+h*_,n[7]=c*g+u*b+h*w,n[2]=l*f+p*v+d*x,n[5]=l*m+p*y+d*_,n[8]=l*g+p*b+d*w,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],o=t[4],a=t[5],s=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-i*n*u+i*a*s+r*n*c-r*o*s},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3.getInverse no longer takes a Matrix4 argument.");var i=t.elements,r=this.elements,n=i[0],o=i[1],a=i[2],s=i[3],c=i[4],u=i[5],h=i[6],l=i[7],p=i[8],d=p*c-u*l,f=u*h-p*s,m=l*s-c*h,g=n*d+o*f+a*m;if(0===g){var v="THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0";if(!0===e)throw new Error(v);return console.warn(v),this.identity()}var y=1/g;return r[0]=d*y,r[1]=(a*l-p*o)*y,r[2]=(u*o-a*c)*y,r[3]=f*y,r[4]=(p*n-a*h)*y,r[5]=(a*s-u*n)*y,r[6]=m*y,r[7]=(o*h-l*n)*y,r[8]=(c*n-o*s)*y,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}}),Object.assign(Ii.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(){var t=new Me,e=new Me;return function(i,r,n){var o=t.subVectors(n,r).cross(e.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return this.orthoPoint(t,e).sub(t).negate()},orthoPoint:function(t,e){var i=this.distanceToPoint(t);return(e||new Me).copy(this.normal).multiplyScalar(i)},intersectLine:function(){var t=new Me;return function(e,i){var r=i||new Me,n=e.delta(t),o=this.normal.dot(n);if(0===o)return 0===this.distanceToPoint(e.start)?r.copy(e.start):void 0;var a=-(e.start.dot(this.normal)+this.constant)/o;return a<0||a>1?void 0:r.copy(n).multiplyScalar(a).add(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new Me).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new Me,e=new Ci;return function(i,r){var n=this.coplanarPoint(t).applyMatrix4(i),o=r||e.getNormalMatrix(i),a=this.normal.applyMatrix3(o).normalize();return this.constant=-n.dot(a),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(Ri.prototype,{set:function(t,e,i,r,n,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(r),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,i=0;i<6;i++)e[i].copy(t.planes[i]);return this},setFromMatrix:function(t){var e=this.planes,i=t.elements,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],c=i[5],u=i[6],h=i[7],l=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return e[0].setComponents(a-r,h-s,f-l,y-m).normalize(),e[1].setComponents(a+r,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 Ei;return function(e){var i=e.geometry;return null===i.boundingSphere&&i.computeBoundingSphere(),t.copy(i.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new Ei;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,i=t.center,r=-t.radius,n=0;n<6;n++){if(e[n].distanceToPoint(i)<r)return!1}return!0},intersectsBox:function(){var t=new Me,e=new Me;return function(i){for(var r=this.planes,n=0;n<6;n++){var o=r[n];t.x=o.normal.x>0?i.min.x:i.max.x,e.x=o.normal.x>0?i.max.x:i.min.x,t.y=o.normal.y>0?i.min.y:i.max.y,e.y=o.normal.y>0?i.max.y:i.min.y,t.z=o.normal.z>0?i.min.z:i.max.z,e.z=o.normal.z>0?i.max.z:i.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,i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}}),Ni.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Ni.DefaultOrder="XYZ",Object.defineProperties(Ni.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(Ni.prototype,{isEuler:!0,set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._order=r||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,i){var r=ye.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(r(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(-r(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(r(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(-r(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(r(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(-r(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!==i&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new Pe;return function(e,i,r){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,i,r)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new Ae;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 Me(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(Di.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},test:function(t){return 0!==(this.mask&t.mask)}});var ki=0;function Fi(){Object.defineProperty(this,"id",{value:ki++}),this.uuid=ye.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Fi.DefaultUp.clone();var t=new Me,e=new Ni,i=new Ae,r=new Me(1,1,1);e.onChange(function(){i.setFromEuler(e,!1)}),i.onChange(function(){e.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:i},scale:{enumerable:!0,value:r},modelViewMatrix:{value:new Pe},normalMatrix:{value:new Ci}}),this.matrix=new Pe,this.matrixWorld=new Pe,this.matrixAutoUpdate=Fi.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Di,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function Bi(){Fi.call(this),this.type="Camera",this.matrixWorldInverse=new Pe,this.projectionMatrix=new Pe}function zi(t,e,i,r,n,o){Bi.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=r,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function Ui(t,e,i,r){Bi.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function ji(t,e,i,r,n,o){this.a=t,this.b=e,this.c=i,this.normal=r&&r.isVector3?r:new Me,this.vertexNormals=Array.isArray(r)?r:[],this.color=n&&n.isColor?n:new mi,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=void 0!==o?o:0}Fi.DefaultUp=new Me(0,1,0),Fi.DefaultMatrixAutoUpdate=!0,Object.assign(Fi.prototype,f.prototype,{isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(t){this.matrix.multiplyMatrices(t,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(){var t=new Ae;return function(e,i){return t.setFromAxisAngle(e,i),this.quaternion.multiply(t),this}}(),rotateX:function(){var t=new Me(1,0,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateY:function(){var t=new Me(0,1,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateZ:function(){var t=new Me(0,0,1);return function(e){return this.rotateOnAxis(t,e)}}(),translateOnAxis:function(){var t=new Me;return function(e,i){return t.copy(e).applyQuaternion(this.quaternion),this.position.add(t.multiplyScalar(i)),this}}(),translateX:function(){var t=new Me(1,0,0);return function(e){return this.translateOnAxis(t,e)}}(),translateY:function(){var t=new Me(0,1,0);return function(e){return this.translateOnAxis(t,e)}}(),translateZ:function(){var t=new Me(0,0,1);return function(e){return this.translateOnAxis(t,e)}}(),localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var t=new Pe;return function(e){return e.applyMatrix4(t.getInverse(this.matrixWorld))}}(),lookAt:function(){var t=new Pe;return function(e){this.isCamera?t.lookAt(this.position,e,this.up):t.lookAt(e,this.position,this.up),this.quaternion.setFromRotationMatrix(t)}}(),add:function(t){var e=arguments,i=this;if(arguments.length>1){for(var r=0;r<arguments.length;r++)i.add(e[r]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,t.dispatchEvent({type:"added"}),this.children.push(t)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){var e=arguments,i=this;if(arguments.length>1){for(var r=0;r<arguments.length;r++)i.remove(e[r]);return this}var n=this.children.indexOf(t);return-1!==n&&(t.parent=null,t.dispatchEvent({type:"removed"}),this.children.splice(n,1)),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(var i=0,r=this.children.length;i<r;i++){var n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}},getWorldPosition:function(t){var e=t||new Me;return this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var t=new Me,e=new Me;return function(i){var r=i||new Ae;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,r,e),r}}(),getWorldRotation:function(){var t=new Ae;return function(e){var i=e||new Ni;return this.getWorldQuaternion(t),i.setFromQuaternion(t,this.rotation.order,!1)}}(),getWorldScale:function(){var t=new Me,e=new Ae;return function(i){var r=i||new Me;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,e,r),r}}(),getWorldDirection:function(){var t=new Ae;return function(e){var i=e||new Me;return this.getWorldQuaternion(t),i.set(0,0,1).applyQuaternion(t)}}(),raycast:function(){},traverse:function(t){t(this);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].updateMatrixWorld(t)},toJSON:function(t){var e=void 0===t||""===t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var r={};function n(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),r.matrix=this.matrix.toArray(),void 0!==this.geometry&&(r.geometry=n(t.geometries,this.geometry)),void 0!==this.material)if(Array.isArray(this.material)){for(var o=[],a=0,s=this.material.length;a<s;a++)o.push(n(t.materials,this.material[a]));r.material=o}else r.material=n(t.materials,this.material);if(this.children.length>0){r.children=[];for(a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(t).object)}if(e){var c=p(t.geometries),u=p(t.materials),h=p(t.textures),l=p(t.images);c.length>0&&(i.geometries=c),u.length>0&&(i.materials=u),h.length>0&&(i.textures=h),l.length>0&&(i.images=l)}return i.object=r,i;function p(t){var e=[];for(var i in t){var r=t[i];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){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;i<t.children.length;i++){var r=t.children[i];this.add(r.clone())}return this}}),Bi.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Bi,isCamera:!0,copy:function(t,e){return Fi.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this},getWorldDirection:function(){var t=new Ae;return function(e){var i=e||new Me;return this.getWorldQuaternion(t),i.set(0,0,-1).applyQuaternion(t)}}(),updateMatrixWorld:function(t){Fi.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),zi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:zi,isOrthographicCamera:!0,copy:function(t,e){return Bi.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,i,r,n,o){this.view={fullWidth:t,fullHeight:e,offsetX:i,offsetY:r,width:n,height:o},this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null,this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,n=i-t,o=i+t,a=r+e,s=r-e;if(null!==this.view){var c=this.zoom/(this.view.width/this.view.fullWidth),u=this.zoom/(this.view.height/this.view.fullHeight),h=(this.right-this.left)/this.view.width,l=(this.top-this.bottom)/this.view.height;o=(n+=h*(this.view.offsetX/c))+h*(this.view.width/c),s=(a-=l*(this.view.offsetY/u))-l*(this.view.height/u)}this.projectionMatrix.makeOrthographic(n,o,a,s,this.near,this.far)},toJSON:function(t){var e=Fi.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Ui.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Ui,isPerspectiveCamera:!0,copy:function(t,e){return Bi.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*ye.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*ye.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*ye.RAD2DEG*Math.atan(Math.tan(.5*ye.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,r,n,o){this.aspect=t/e,this.view={fullWidth:t,fullHeight:e,offsetX:i,offsetY:r,width:n,height:o},this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null,this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*ye.DEG2RAD*this.fov)/this.zoom,i=2*e,r=this.aspect*i,n=-.5*r,o=this.view;if(null!==o){var a=o.fullWidth,s=o.fullHeight;n+=o.offsetX*r/a,e-=o.offsetY*i/s,r*=o.width/a,i*=o.height/s}var c=this.filmOffset;0!==c&&(n+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,e,e-i,t,this.far)},toJSON:function(t){var e=Fi.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}),Object.assign(ji.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}});var Gi=0;function Vi(){return Gi++}function $i(){Object.defineProperty(this,"id",{value:Vi()}),this.uuid=ye.generateUUID(),this.name="",this.type="Geometry",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.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Hi(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=ye.generateUUID(),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Wi(t,e){Hi.call(this,new Uint16Array(t),e)}function Xi(t,e){Hi.call(this,new Uint32Array(t),e)}function qi(t,e){Hi.call(this,new Float32Array(t),e)}function Yi(){this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Zi(t){if(0===t.length)return-1/0;for(var e=t[0],i=1,r=t.length;i<r;++i)t[i]>e&&(e=t[i]);return e}function Ki(){Object.defineProperty(this,"id",{value:Vi()}),this.uuid=ye.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 Qi(t,e,i,r,n,o){$i.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new Ji(t,e,i,r,n,o)),this.mergeVertices()}function Ji(t,e,i,r,n,o){Ki.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:n,depthSegments:o};var a=this;r=Math.floor(r)||1,n=Math.floor(n)||1,o=Math.floor(o)||1;var s=[],c=[],u=[],h=[],l=0,p=0;function d(t,e,i,r,n,o,d,f,m,g,v){var y,b,x=o/m,_=d/g,w=o/2,S=d/2,A=f/2,M=m+1,P=g+1,T=0,E=0,C=new Me;for(b=0;b<P;b++){var I=b*_-S;for(y=0;y<M;y++){var R=y*x-w;C[t]=R*r,C[e]=I*n,C[i]=A,c.push(C.x,C.y,C.z),C[t]=0,C[e]=0,C[i]=f>0?1:-1,u.push(C.x,C.y,C.z),h.push(y/m),h.push(1-b/g),T+=1}}for(b=0;b<g;b++)for(y=0;y<m;y++){var L=l+y+M*b,O=l+y+M*(b+1),N=l+(y+1)+M*(b+1),D=l+(y+1)+M*b;s.push(L,O,D),s.push(O,N,D),E+=6}a.addGroup(p,E,v),p+=E,l+=T}d("z","y","x",-1,-1,i,e,t,o,n,0),d("z","y","x",1,-1,i,e,-t,o,n,1),d("x","z","y",1,1,t,i,e,r,o,2),d("x","z","y",1,-1,t,i,-e,r,o,3),d("x","y","z",1,-1,t,e,i,r,n,4),d("x","y","z",-1,-1,t,e,-i,r,n,5),this.setIndex(s),this.addAttribute("position",new qi(c,3)),this.addAttribute("normal",new qi(u,3)),this.addAttribute("uv",new qi(h,2))}function tr(t,e,i,r){$i.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new er(t,e,i,r)),this.mergeVertices()}function er(t,e,i,r){Ki.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r};var n,o,a=t/2,s=e/2,c=Math.floor(i)||1,u=Math.floor(r)||1,h=c+1,l=u+1,p=t/c,d=e/u,f=[],m=[],g=[],v=[];for(o=0;o<l;o++){var y=o*d-s;for(n=0;n<h;n++){var b=n*p-a;m.push(b,-y,0),g.push(0,0,1),v.push(n/c),v.push(1-o/u)}}for(o=0;o<u;o++)for(n=0;n<c;n++){var x=n+h*o,_=n+h*(o+1),w=n+1+h*(o+1),S=n+1+h*o;f.push(x,_,S),f.push(_,w,S)}this.setIndex(f),this.addAttribute("position",new qi(m,3)),this.addAttribute("normal",new qi(g,3)),this.addAttribute("uv",new qi(v,2))}function ir(t){Ai.call(this),this.type="MeshBasicMaterial",this.color=new mi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=at,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.lights=!1,this.setValues(t)}function rr(t,e){this.origin=void 0!==t?t:new Me,this.direction=void 0!==e?e:new Me}function nr(t,e){this.start=void 0!==t?t:new Me,this.end=void 0!==e?e:new Me}function or(t,e,i){this.a=void 0!==t?t:new Me,this.b=void 0!==e?e:new Me,this.c=void 0!==i?i:new Me}function ar(t,e){Fi.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Ki,this.material=void 0!==e?e:new ir({color:16777215*Math.random()}),this.drawMode=ae,this.updateMorphTargets()}function sr(t,e,i,r){var n,o,a,s,c=new mi(0),u=0;function h(t,i){e.buffers.color.setClear(t.r,t.g,t.b,i,r)}return{getClearColor:function(){return c},setClearColor:function(t,e){c.set(t),h(c,u=void 0!==e?e:1)},getClearAlpha:function(){return u},setClearAlpha:function(t){h(c,u=t)},render:function(e,r,l){var p=e.background;null===p?h(c,u):p&&p.isColor&&(h(p,1),l=!0),(t.autoClear||l)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),p&&p.isCubeTexture?(void 0===a&&(a=new Ui,s=new ar(new Ji(5,5,5),new Mi({uniforms:bi.cube.uniforms,vertexShader:bi.cube.vertexShader,fragmentShader:bi.cube.fragmentShader,side:S,depthTest:!1,depthWrite:!1,fog:!1}))),a.projectionMatrix.copy(r.projectionMatrix),a.matrixWorld.extractRotation(r.matrixWorld),a.matrixWorldInverse.getInverse(a.matrixWorld),s.material.uniforms.tCube.value=p,s.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,s.matrixWorld),i.update(s),t.renderBufferDirect(a,null,s.geometry,s.material,s,null)):p&&p.isTexture&&(void 0===n&&(n=new zi(-1,1,1,-1,0,1),o=new ar(new er(2,2),new ir({depthTest:!1,depthWrite:!1,fog:!1}))),o.material.map=p,i.update(o),t.renderBufferDirect(n,null,o.geometry,o.material,o,null))}}}function cr(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program&&e.program&&t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function ur(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function hr(){var t=[],e=-1,i=[],r=-1;return{opaque:t,transparent:i,init:function(){e=-1,r=-1},push:function(n,o,a,s,c){var u,h;a.transparent?(u=i,h=++r):(u=t,h=++e);var l=u[h];l?(l.id=n.id,l.object=n,l.geometry=o,l.material=a,l.program=a.program,l.renderOrder=n.renderOrder,l.z=s,l.group=c):(l={id:n.id,object:n,geometry:o,material:a,program:a.program,renderOrder:n.renderOrder,z:s,group:c},u.push(l))},finish:function(){t.length=e+1,i.length=r+1},sort:function(){t.sort(cr),i.sort(ur)}}}function lr(){var t={};return{get:function(e,i){var r=e.id+","+i.id,n=t[r];return void 0===n&&(n=new hr,t[r]=n),n},dispose:function(){t={}}}}function pr(t,e,i){var r,n,o;this.setMode=function(t){r=t},this.setIndex=function(t){n=t.type,o=t.bytesPerElement},this.render=function(e,a){t.drawElements(r,a,n,e*o),i.calls++,i.vertices+=a,r===t.TRIANGLES&&(i.faces+=a/3)},this.renderInstances=function(a,s,c){var u=e.get("ANGLE_instanced_arrays");null!==u?(u.drawElementsInstancedANGLE(r,c,n,s*o,a.maxInstancedCount),i.calls++,i.vertices+=c*a.maxInstancedCount,r===t.TRIANGLES&&(i.faces+=a.maxInstancedCount*c/3)):console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}function dr(t,e,i){var r;this.setMode=function(t){r=t},this.render=function(e,n){t.drawArrays(r,e,n),i.calls++,i.vertices+=n,r===t.TRIANGLES&&(i.faces+=n/3)},this.renderInstances=function(n,o,a){var s=e.get("ANGLE_instanced_arrays");if(null!==s){var c=n.attributes.position;c.isInterleavedBufferAttribute?(a=c.data.count,s.drawArraysInstancedANGLE(r,0,a,n.maxInstancedCount)):s.drawArraysInstancedANGLE(r,o,a,n.maxInstancedCount),i.calls++,i.vertices+=a*n.maxInstancedCount,r===t.TRIANGLES&&(i.faces+=n.maxInstancedCount*a/3)}else console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}function fr(t,e,i){var r={},n={};function o(t){var a=t.target,s=r[a.id];for(var c in null!==s.index&&e.remove(s.index),s.attributes)e.remove(s.attributes[c]);a.removeEventListener("dispose",o),delete r[a.id];var u=n[a.id];u&&(e.remove(u),delete n[a.id]),(u=n[s.id])&&(e.remove(u),delete n[s.id]),i.geometries--}return{get:function(t,e){var n=r[e.id];return n||(e.addEventListener("dispose",o),e.isBufferGeometry?n=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new Ki).setFromObject(t)),n=e._bufferGeometry),r[e.id]=n,i.geometries++,n)},update:function(i){var r=i.index,n=i.attributes;for(var o in null!==r&&e.update(r,t.ELEMENT_ARRAY_BUFFER),n)e.update(n[o],t.ARRAY_BUFFER);var a=i.morphAttributes;for(var o in a)for(var s=a[o],c=0,u=s.length;c<u;c++)e.update(s[c],t.ARRAY_BUFFER)},getWireframeAttribute:function(i){var r=n[i.id];if(r)return r;var o,a=[],s=i.index,c=i.attributes;if(null!==s)for(var u=0,h=(o=s.array).length;u<h;u+=3){var l=o[u+0],p=o[u+1],d=o[u+2];a.push(l,p,p,d,d,l)}else for(u=0,h=(o=c.position.array).length/3-1;u<h;u+=3){l=u+0,p=u+1,d=u+2;a.push(l,p,p,d,d,l)}return r=new(Zi(a)>65535?Xi:Wi)(a,1),e.update(r,t.ELEMENT_ARRAY_BUFFER),n[i.id]=r,r}}}function mr(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var i;switch(e.type){case"DirectionalLight":i={direction:new Me,color:new mi,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new be};break;case"SpotLight":i={position:new Me,direction:new Me,color:new mi,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new be};break;case"PointLight":i={position:new Me,color:new mi,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new be};break;case"HemisphereLight":i={direction:new Me,skyColor:new mi,groundColor:new mi};break;case"RectAreaLight":i={color:new mi,position:new Me,halfWidth:new Me,halfHeight:new Me}}return t[e.id]=i,i}}}function gr(t,e,i){var r={};return{update:function(t){var n=i.frame,o=t.geometry,a=e.get(t,o);return r[a.id]!==n&&(o.isGeometry&&a.updateFromObject(t),e.update(a),r[a.id]=n),a},clear:function(){r={}}}}function vr(t,e,i){var r=t.createShader(e);return t.shaderSource(r,i),t.compileShader(r),!1===t.getShaderParameter(r,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(r)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(r),function(t){for(var e=t.split("\n"),i=0;i<e.length;i++)e[i]=i+1+": "+e[i];return e.join("\n")}(i)),r}Object.assign($i.prototype,f.prototype,{isGeometry:!0,applyMatrix:function(t){for(var e=(new Ci).getNormalMatrix(t),i=0,r=this.vertices.length;i<r;i++){this.vertices[i].applyMatrix4(t)}for(i=0,r=this.faces.length;i<r;i++){var n=this.faces[i];n.normal.applyMatrix3(e).normalize();for(var o=0,a=n.vertexNormals.length;o<a;o++)n.vertexNormals[o].applyMatrix3(e).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(){var t=new Pe;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new Pe;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new Pe;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new Pe;return function(e,i,r){return t.makeTranslation(e,i,r),this.applyMatrix(t),this}}(),scale:function(){var t=new Pe;return function(e,i,r){return t.makeScale(e,i,r),this.applyMatrix(t),this}}(),lookAt:function(){var t=new Fi;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),fromBufferGeometry:function(t){var e=this,i=null!==t.index?t.index.array:void 0,r=t.attributes,n=r.position.array,o=void 0!==r.normal?r.normal.array:void 0,a=void 0!==r.color?r.color.array:void 0,s=void 0!==r.uv?r.uv.array:void 0,c=void 0!==r.uv2?r.uv2.array:void 0;void 0!==c&&(this.faceVertexUvs[1]=[]);for(var u=[],h=[],l=[],p=0,d=0;p<n.length;p+=3,d+=2)e.vertices.push(new Me(n[p],n[p+1],n[p+2])),void 0!==o&&u.push(new Me(o[p],o[p+1],o[p+2])),void 0!==a&&e.colors.push(new mi(a[p],a[p+1],a[p+2])),void 0!==s&&h.push(new be(s[d],s[d+1])),void 0!==c&&l.push(new be(c[d],c[d+1]));function f(t,i,r,n){var p=new ji(t,i,r,void 0!==o?[u[t].clone(),u[i].clone(),u[r].clone()]:[],void 0!==a?[e.colors[t].clone(),e.colors[i].clone(),e.colors[r].clone()]:[],n);e.faces.push(p),void 0!==s&&e.faceVertexUvs[0].push([h[t].clone(),h[i].clone(),h[r].clone()]),void 0!==c&&e.faceVertexUvs[1].push([l[t].clone(),l[i].clone(),l[r].clone()])}var m=t.groups;if(m.length>0)for(p=0;p<m.length;p++)for(var g=m[p],v=g.start,y=(d=v,v+g.count);d<y;d+=3)void 0!==i?f(i[d],i[d+1],i[d+2],g.materialIndex):f(d,d+1,d+2,g.materialIndex);else if(void 0!==i)for(p=0;p<i.length;p+=3)f(i[p],i[p+1],i[p+2]);else for(p=0;p<n.length/3;p+=3)f(p,p+1,p+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,e=this.boundingSphere.radius,i=0===e?1:1/e,r=new Pe;return r.set(i,0,0,-i*t.x,0,i,0,-i*t.y,0,0,i,-i*t.z,0,0,0,1),this.applyMatrix(r),this},computeFaceNormals:function(){for(var t=new Me,e=new Me,i=0,r=this.faces.length;i<r;i++){var n=this.faces[i],o=this.vertices[n.a],a=this.vertices[n.b],s=this.vertices[n.c];t.subVectors(s,a),e.subVectors(o,a),t.cross(e),t.normalize(),n.normal.copy(t)}},computeVertexNormals:function(t){var e,i,r,n,o,a;for(void 0===t&&(t=!0),a=new Array(this.vertices.length),e=0,i=this.vertices.length;e<i;e++)a[e]=new Me;if(t){var s,c,u,h=new Me,l=new Me;for(r=0,n=this.faces.length;r<n;r++)o=this.faces[r],s=this.vertices[o.a],c=this.vertices[o.b],u=this.vertices[o.c],h.subVectors(u,c),l.subVectors(s,c),h.cross(l),a[o.a].add(h),a[o.b].add(h),a[o.c].add(h)}else for(this.computeFaceNormals(),r=0,n=this.faces.length;r<n;r++)a[(o=this.faces[r]).a].add(o.normal),a[o.b].add(o.normal),a[o.c].add(o.normal);for(e=0,i=this.vertices.length;e<i;e++)a[e].normalize();for(r=0,n=this.faces.length;r<n;r++){var p=(o=this.faces[r]).vertexNormals;3===p.length?(p[0].copy(a[o.a]),p[1].copy(a[o.b]),p[2].copy(a[o.c])):(p[0]=a[o.a].clone(),p[1]=a[o.b].clone(),p[2]=a[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,i;for(this.computeFaceNormals(),t=0,e=this.faces.length;t<e;t++){var r=(i=this.faces[t]).vertexNormals;3===r.length?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,i,r,n;for(i=0,r=this.faces.length;i<r;i++)for((n=this.faces[i]).__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),t=0,e=n.vertexNormals.length;t<e;t++)n.__originalVertexNormals[t]?n.__originalVertexNormals[t].copy(n.vertexNormals[t]):n.__originalVertexNormals[t]=n.vertexNormals[t].clone();var o=new $i;for(o.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];var a=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(i=0,r=this.faces.length;i<r;i++)c=new Me,u={a:new Me,b:new Me,c:new Me},a.push(c),s.push(u)}var c,u,h=this.morphNormals[t];for(o.vertices=this.morphTargets[t].vertices,o.computeFaceNormals(),o.computeVertexNormals(),i=0,r=this.faces.length;i<r;i++)n=this.faces[i],c=h.faceNormals[i],u=h.vertexNormals[i],c.copy(n.normal),u.a.copy(n.vertexNormals[0]),u.b.copy(n.vertexNormals[1]),u.c.copy(n.vertexNormals[2])}for(i=0,r=this.faces.length;i<r;i++)(n=this.faces[i]).normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeLineDistances:function(){for(var t=0,e=this.vertices,i=0,r=e.length;i<r;i++)i>0&&(t+=e[i].distanceTo(e[i-1])),this.lineDistances[i]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ti),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ei),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,i){if(t&&t.isGeometry){var r,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===i&&(i=0),void 0!==e&&(r=(new Ci).getNormalMatrix(e));for(var d=0,f=a.length;d<f;d++){var m=a[d].clone();void 0!==e&&m.applyMatrix4(e),o.push(m)}for(d=0,f=p.length;d<f;d++)l.push(p[d].clone());for(d=0,f=c.length;d<f;d++){var g,v,y,b=c[d],x=b.vertexNormals,_=b.vertexColors;(g=new ji(b.a+n,b.b+n,b.c+n)).normal.copy(b.normal),void 0!==r&&g.normal.applyMatrix3(r).normalize();for(var w=0,S=x.length;w<S;w++)v=x[w].clone(),void 0!==r&&v.applyMatrix3(r).normalize(),g.vertexNormals.push(v);g.color.copy(b.color);for(w=0,S=_.length;w<S;w++)y=_[w],g.vertexColors.push(y.clone());g.materialIndex=b.materialIndex+i,s.push(g)}for(d=0,f=h.length;d<f;d++){var A=h[d],M=[];if(void 0!==A){for(w=0,S=A.length;w<S;w++)M.push(A[w].clone());u.push(M)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t)},mergeMesh:function(t){t&&t.isMesh?(t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t)},mergeVertices:function(){var t,e,i,r,n,o,a,s,c={},u=[],h=[],l=Math.pow(10,4);for(i=0,r=this.vertices.length;i<r;i++)t=this.vertices[i],void 0===c[e=Math.round(t.x*l)+"_"+Math.round(t.y*l)+"_"+Math.round(t.z*l)]?(c[e]=i,u.push(this.vertices[i]),h[i]=u.length-1):h[i]=h[c[e]];var p=[];for(i=0,r=this.faces.length;i<r;i++){(n=this.faces[i]).a=h[n.a],n.b=h[n.b],n.c=h[n.c],o=[n.a,n.b,n.c];for(var d=0;d<3;d++)if(o[d]===o[(d+1)%3]){p.push(i);break}}for(i=p.length-1;i>=0;i--){var f=p[i];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a<s;a++)this.faceVertexUvs[a].splice(f,1)}var m=this.vertices.length-u.length;return this.vertices=u,m},sortFacesByMaterialIndex:function(){for(var t=this.faces,e=t.length,i=0;i<e;i++)t[i]._id=i;t.sort(function(t,e){return t.materialIndex-e.materialIndex});var r,n,o=this.faceVertexUvs[0],a=this.faceVertexUvs[1];o&&o.length===e&&(r=[]),a&&a.length===e&&(n=[]);for(i=0;i<e;i++){var s=t[i]._id;r&&r.push(o[s]),n&&n.push(a[s])}r&&(this.faceVertexUvs[0]=r),n&&(this.faceVertexUvs[1]=n)},toJSON:function(){var t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}for(var r=[],n=0;n<this.vertices.length;n++){var o=this.vertices[n];r.push(o.x,o.y,o.z)}var a=[],s=[],c={},u=[],h={},l=[],p={};for(n=0;n<this.faces.length;n++){var d=this.faces[n],f=void 0!==this.faceVertexUvs[0][n],m=d.normal.length()>0,g=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=d.vertexColors.length>0,b=0;if(b=S(b,0,0),b=S(b,1,!0),b=S(b,2,!1),b=S(b,3,f),b=S(b,4,m),b=S(b,5,g),b=S(b,6,v),b=S(b,7,y),a.push(b),a.push(d.a,d.b,d.c),a.push(d.materialIndex),f){var x=this.faceVertexUvs[0][n];a.push(P(x[0]),P(x[1]),P(x[2]))}if(m&&a.push(A(d.normal)),g){var _=d.vertexNormals;a.push(A(_[0]),A(_[1]),A(_[2]))}if(v&&a.push(M(d.color)),y){var w=d.vertexColors;a.push(M(w[0]),M(w[1]),M(w[2]))}}function S(t,e,i){return i?t|1<<e:t&~(1<<e)}function A(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==c[e]?c[e]:(c[e]=s.length/3,s.push(t.x,t.y,t.z),c[e])}function M(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==h[e]?h[e]:(h[e]=u.length,u.push(t.getHex()),h[e])}function P(t){var e=t.x.toString()+t.y.toString();return void 0!==p[e]?p[e]:(p[e]=l.length/2,l.push(t.x,t.y),p[e])}return t.data={},t.data.vertices=r,t.data.normals=s,u.length>0&&(t.data.colors=u),l.length>0&&(t.data.uvs=[l]),t.data.faces=a,t},clone:function(){return(new $i).copy(this)},copy:function(t){var e,i,r,n,o,a;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 s=t.vertices;for(e=0,i=s.length;e<i;e++)this.vertices.push(s[e].clone());var c=t.colors;for(e=0,i=c.length;e<i;e++)this.colors.push(c[e].clone());var u=t.faces;for(e=0,i=u.length;e<i;e++)this.faces.push(u[e].clone());for(e=0,i=t.faceVertexUvs.length;e<i;e++){var h=t.faceVertexUvs[e];for(void 0===this.faceVertexUvs[e]&&(this.faceVertexUvs[e]=[]),r=0,n=h.length;r<n;r++){var l=h[r],p=[];for(o=0,a=l.length;o<a;o++){var d=l[o];p.push(d.clone())}this.faceVertexUvs[e].push(p)}}var f=t.morphTargets;for(e=0,i=f.length;e<i;e++){var m={};if(m.name=f[e].name,void 0!==f[e].vertices)for(m.vertices=[],r=0,n=f[e].vertices.length;r<n;r++)m.vertices.push(f[e].vertices[r].clone());if(void 0!==f[e].normals)for(m.normals=[],r=0,n=f[e].normals.length;r<n;r++)m.normals.push(f[e].normals[r].clone());this.morphTargets.push(m)}var g=t.morphNormals;for(e=0,i=g.length;e<i;e++){var v={};if(void 0!==g[e].vertexNormals)for(v.vertexNormals=[],r=0,n=g[e].vertexNormals.length;r<n;r++){var y=g[e].vertexNormals[r],b={};b.a=y.a.clone(),b.b=y.b.clone(),b.c=y.c.clone(),v.vertexNormals.push(b)}if(void 0!==g[e].faceNormals)for(v.faceNormals=[],r=0,n=g[e].faceNormals.length;r<n;r++)v.faceNormals.push(g[e].faceNormals[r].clone());this.morphNormals.push(v)}var x=t.skinWeights;for(e=0,i=x.length;e<i;e++)this.skinWeights.push(x[e].clone());var _=t.skinIndices;for(e=0,i=_.length;e<i;e++)this.skinIndices.push(_[e].clone());var w=t.lineDistances;for(e=0,i=w.length;e<i;e++)this.lineDistances.push(w[e]);var S=t.boundingBox;null!==S&&(this.boundingBox=S.clone());var A=t.boundingSphere;return null!==A&&(this.boundingSphere=A.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Hi.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Hi.prototype,{isBufferAttribute:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.itemSize:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(var r=0,n=this.itemSize;r<n;r++)this.array[t+r]=e.array[i+r];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),o=new mi),e[i++]=o.r,e[i++]=o.g,e[i++]=o.b}return this},copyIndicesArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];e[i++]=o.a,e[i++]=o.b,e[i++]=o.c}return this},copyVector2sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),o=new be),e[i++]=o.x,e[i++]=o.y}return this},copyVector3sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),o=new Me),e[i++]=o.x,e[i++]=o.y,e[i++]=o.z}return this},copyVector4sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),o=new we),e[i++]=o.x,e[i++]=o.y,e[i++]=o.z,e[i++]=o.w}return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=r,this},setXYZW:function(t,e,i,r,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=r,this.array[t+3]=n,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),Wi.prototype=Object.create(Hi.prototype),Wi.prototype.constructor=Wi,Xi.prototype=Object.create(Hi.prototype),Xi.prototype.constructor=Xi,qi.prototype=Object.create(Hi.prototype),qi.prototype.constructor=qi,Object.assign(Yi.prototype,{computeGroups:function(t){for(var e,i=[],r=void 0,n=t.faces,o=0;o<n.length;o++){var a=n[o];a.materialIndex!==r&&(r=a.materialIndex,void 0!==e&&(e.count=3*o-e.start,i.push(e)),e={start:3*o,materialIndex:r})}void 0!==e&&(e.count=3*o-e.start,i.push(e)),this.groups=i},fromGeometry:function(t){var e,i=t.faces,r=t.vertices,n=t.faceVertexUvs,o=n[0]&&n[0].length>0,a=n[1]&&n[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var u=0;u<c;u++)e[u]=[];this.morphTargets.position=e}var h,l=t.morphNormals,p=l.length;if(p>0){h=[];for(u=0;u<p;u++)h[u]=[];this.morphTargets.normal=h}var d=t.skinIndices,f=t.skinWeights,m=d.length===r.length,g=f.length===r.length;for(u=0;u<i.length;u++){var v=i[u];this.vertices.push(r[v.a],r[v.b],r[v.c]);var y=v.vertexNormals;if(3===y.length)this.normals.push(y[0],y[1],y[2]);else{var b=v.normal;this.normals.push(b,b,b)}var x,_=v.vertexColors;if(3===_.length)this.colors.push(_[0],_[1],_[2]);else{var w=v.color;this.colors.push(w,w,w)}if(!0===o)void 0!==(x=n[0][u])?this.uvs.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",u),this.uvs.push(new be,new be,new be));if(!0===a)void 0!==(x=n[1][u])?this.uvs2.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",u),this.uvs2.push(new be,new be,new be));for(var S=0;S<c;S++){var A=s[S].vertices;e[S].push(A[v.a],A[v.b],A[v.c])}for(S=0;S<p;S++){var M=l[S].vertexNormals[u];h[S].push(M.a,M.b,M.c)}m&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}}),Ki.MaxIndex=65535,Object.assign(Ki.prototype,f.prototype,{isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(Zi(t)>65535?Xi:Wi)(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 Hi(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,i){this.groups.push({start:t,count:e,materialIndex:void 0!==i?i: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 i=this.attributes.normal;void 0!==i&&((new Ci).getNormalMatrix(t).applyToBufferAttribute(i),i.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new Pe;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new Pe;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new Pe;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new Pe;return function(e,i,r){return t.makeTranslation(e,i,r),this.applyMatrix(t),this}}(),scale:function(){var t=new Pe;return function(e,i,r){return t.makeScale(e,i,r),this.applyMatrix(t),this}}(),lookAt:function(){var t=new Fi;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 i=new qi(3*e.vertices.length,3),r=new qi(3*e.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(e.vertices)),this.addAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var n=new qi(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,i=t.geometry;if(t.isMesh){var r=i.__directGeometry;if(!0===i.elementsNeedUpdate&&(r=void 0,i.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(i);r.verticesNeedUpdate=i.verticesNeedUpdate,r.normalsNeedUpdate=i.normalsNeedUpdate,r.colorsNeedUpdate=i.colorsNeedUpdate,r.uvsNeedUpdate=i.uvsNeedUpdate,r.groupsNeedUpdate=i.groupsNeedUpdate,i.verticesNeedUpdate=!1,i.normalsNeedUpdate=!1,i.colorsNeedUpdate=!1,i.uvsNeedUpdate=!1,i.groupsNeedUpdate=!1,i=r}return!0===i.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(i.vertices),e.needsUpdate=!0),i.verticesNeedUpdate=!1),!0===i.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(i.normals),e.needsUpdate=!0),i.normalsNeedUpdate=!1),!0===i.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(i.colors),e.needsUpdate=!0),i.colorsNeedUpdate=!1),i.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(i.uvs),e.needsUpdate=!0),i.uvsNeedUpdate=!1),i.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(i.lineDistances),e.needsUpdate=!0),i.lineDistancesNeedUpdate=!1),i.groupsNeedUpdate&&(i.computeGroups(t.geometry),this.groups=i.groups,i.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Yi).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new Hi(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var i=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Hi(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.addAttribute("color",new Hi(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var n=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Hi(n,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Hi(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Zi(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new Hi(a,1).copyIndicesArray(t.indices))}for(var s in this.groups=t.groups,t.morphTargets){for(var c=[],u=t.morphTargets[s],h=0,l=u.length;h<l;h++){var p=u[h],d=new qi(3*p.length,3);c.push(d.copyVector3sArray(p))}this.morphAttributes[s]=c}if(t.skinIndices.length>0){var f=new qi(4*t.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new qi(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.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 Ti);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 Ti,e=new Me;return function(){null===this.boundingSphere&&(this.boundingSphere=new Ei);var i=this.attributes.position;if(i){var r=this.boundingSphere.center;t.setFromBufferAttribute(i),t.getCenter(r);for(var n=0,o=0,a=i.count;o<a;o++)e.x=i.getX(o),e.y=i.getY(o),e.z=i.getZ(o),n=Math.max(n,r.distanceToSquared(e));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.attributes,i=this.groups;if(e.position){var r=e.position.array;if(void 0===e.normal)this.addAttribute("normal",new Hi(new Float32Array(r.length),3));else for(var n=e.normal.array,o=0,a=n.length;o<a;o++)n[o]=0;var s,c,u,h=e.normal.array,l=new Me,p=new Me,d=new Me,f=new Me,m=new Me;if(t){var g=t.array;0===i.length&&this.addGroup(0,g.length);for(var v=0,y=i.length;v<y;++v){var b=i[v],x=b.start;for(o=x,a=x+b.count;o<a;o+=3)s=3*g[o+0],c=3*g[o+1],u=3*g[o+2],l.fromArray(r,s),p.fromArray(r,c),d.fromArray(r,u),f.subVectors(d,p),m.subVectors(l,p),f.cross(m),h[s]+=f.x,h[s+1]+=f.y,h[s+2]+=f.z,h[c]+=f.x,h[c+1]+=f.y,h[c+2]+=f.z,h[u]+=f.x,h[u+1]+=f.y,h[u+2]+=f.z}}else for(o=0,a=r.length;o<a;o+=9)l.fromArray(r,o),p.fromArray(r,o+3),d.fromArray(r,o+6),f.subVectors(d,p),m.subVectors(l,p),f.cross(m),h[o]=f.x,h[o+1]=f.y,h[o+2]=f.z,h[o+3]=f.x,h[o+4]=f.y,h[o+5]=f.z,h[o+6]=f.x,h[o+7]=f.y,h[o+8]=f.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},merge:function(t,e){if(t&&t.isBufferGeometry){void 0===e&&(e=0);var i=this.attributes;for(var r in i)if(void 0!==t.attributes[r])for(var n=i[r].array,o=t.attributes[r],a=o.array,s=0,c=o.itemSize*e;s<a.length;s++,c++)n[c]=a[s];return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t)},normalizeNormals:function(){for(var t,e,i,r,n=this.attributes.normal,o=0,a=n.count;o<a;o++)t=n.getX(o),e=n.getY(o),i=n.getZ(o),r=1/Math.sqrt(t*t+e*e+i*i),n.setXYZ(o,t*r,e*r,i*r)},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new Ki,e=this.index.array,i=this.attributes;for(var r in i){for(var n=i[r],o=n.array,a=n.itemSize,s=new o.constructor(e.length*a),c=0,u=0,h=0,l=e.length;h<l;h++){c=e[h]*a;for(var p=0;p<a;p++)s[u++]=o[c++]}t.addAttribute(r,new Hi(s,a))}return t},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};var r=this.index;if(null!==r){var n=Array.prototype.slice.call(r.array);t.data.index={type:r.array.constructor.name,array:n}}var o=this.attributes;for(var i in o){var a=o[i];n=Array.prototype.slice.call(a.array);t.data.attributes[i]={itemSize:a.itemSize,type:a.array.constructor.name,array:n,normalized:a.normalized}}var s=this.groups;s.length>0&&(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 Ki).copy(this)},copy:function(t){var e,i,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var n=t.index;null!==n&&this.setIndex(n.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],u=s[e];for(i=0,r=u.length;i<r;i++)c.push(u[i].clone());this.morphAttributes[e]=c}var h=t.groups;for(i=0,r=h.length;i<r;i++){var l=h[i];this.addGroup(l.start,l.count,l.materialIndex)}var p=t.boundingBox;null!==p&&(this.boundingBox=p.clone());var d=t.boundingSphere;return null!==d&&(this.boundingSphere=d.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Qi.prototype=Object.create($i.prototype),Qi.prototype.constructor=Qi,Ji.prototype=Object.create(Ki.prototype),Ji.prototype.constructor=Ji,tr.prototype=Object.create($i.prototype),tr.prototype.constructor=tr,er.prototype=Object.create(Ki.prototype),er.prototype.constructor=er,ir.prototype=Object.create(Ai.prototype),ir.prototype.constructor=ir,ir.prototype.isMeshBasicMaterial=!0,ir.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},Object.assign(rr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new Me).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new Me;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var i=e||new Me;i.subVectors(t,this.origin);var r=i.dot(this.direction);return r<0?i.copy(this.origin):i.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new Me;return function(e){var i=t.subVectors(e,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(i).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new Me,e=new Me,i=new Me;return function(r,n,o,a){t.copy(r).add(n).multiplyScalar(.5),e.copy(n).sub(r).normalize(),i.copy(this.origin).sub(t);var s,c,u,h,l=.5*r.distanceTo(n),p=-this.direction.dot(e),d=i.dot(this.direction),f=-i.dot(e),m=i.lengthSq(),g=Math.abs(1-p*p);if(g>0)if(c=p*d-f,h=l*g,(s=p*f-d)>=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 Me;return function(e,i){t.subVectors(e.center,this.origin);var r=t.dot(this.direction),n=t.dot(t)-r*r,o=e.radius*e.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=r-a,c=r+a;return s<0&&c<0?null:s<0?this.at(c,i):this.at(s,i)}}(),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 i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null},intersectPlane:function(t,e){var i=this.distanceToPlane(t);return null===i?null:this.at(i,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 i,r,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?(i=(t.min.x-l.x)*c,r=(t.max.x-l.x)*c):(i=(t.max.x-l.x)*c,r=(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),i>o||n>r?null:((n>i||i!==i)&&(i=n),(o<r||r!==r)&&(r=o),h>=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),i>s||a>r?null:((a>i||i!==i)&&(i=a),(s<r||r!==r)&&(r=s),r<0?null:this.at(i>=0?i:r,e)))},intersectsBox:function(){var t=new Me;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new Me,e=new Me,i=new Me,r=new Me;return function(n,o,a,s,c){e.subVectors(o,n),i.subVectors(a,n),r.crossVectors(e,i);var u,h=this.direction.dot(r);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(i.crossVectors(t,i));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(r);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(nr.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 Me).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new Me).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 i=e||new Me;return this.delta(i).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new Me,e=new Me;return function(i,r){t.subVectors(i,this.start),e.subVectors(this.end,this.start);var n=e.dot(e),o=e.dot(t)/n;return r&&(o=ye.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,i){var r=this.closestPointToPointParameter(t,e),n=i||new Me;return this.delta(n).multiplyScalar(r).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(or,{normal:function(){var t=new Me;return function(e,i,r,n){var o=n||new Me;o.subVectors(r,i),t.subVectors(e,i),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 Me,e=new Me,i=new Me;return function(r,n,o,a,s){t.subVectors(a,n),e.subVectors(o,n),i.subVectors(r,n);var c=t.dot(t),u=t.dot(e),h=t.dot(i),l=e.dot(e),p=e.dot(i),d=c*l-u*u,f=s||new Me;if(0===d)return f.set(-2,-1,-1);var m=1/d,g=(l*h-u*p)*m,v=(c*p-u*h)*m;return f.set(1-g-v,v,g)}}(),containsPoint:function(){var t=new Me;return function(e,i,r,n){var o=or.barycoordFromPoint(e,i,r,n,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(or.prototype,{set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,r){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[r]),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 Me,e=new Me;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 Me).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return or.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new Ii).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return or.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return or.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new Ii,e=[new nr,new nr,new nr],i=new Me,r=new Me;return function(n,o){var a=o||new Me,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(n,i),!0===this.containsPoint(i))a.copy(i);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;c<e.length;c++){e[c].closestPointToPoint(i,!0,r);var u=i.distanceToSquared(r);u<s&&(s=u,a.copy(r))}}return a}}(),equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),ar.prototype=Object.assign(Object.create(Fi.prototype),{constructor:ar,isMesh:!0,setDrawMode:function(t){this.drawMode=t},copy:function(t){return Fi.prototype.copy.call(this,t),this.drawMode=t.drawMode,this},updateMorphTargets:function(){var t,e,i,r=this.geometry;if(r.isBufferGeometry){var n=r.morphAttributes,o=Object.keys(n);if(o.length>0){var a=n[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t<e;t++)i=a[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}else{var s=r.morphTargets;if(void 0!==s&&s.length>0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t<e;t++)i=s[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}},raycast:function(){var t=new Pe,e=new rr,i=new Ei,r=new Me,n=new Me,o=new Me,a=new Me,s=new Me,c=new Me,u=new be,h=new be,l=new be,p=new Me,d=new Me,f=new Me;function m(t,e,i,r,n,o,a){return or.barycoordFromPoint(t,e,i,r,p),n.multiplyScalar(p.x),o.multiplyScalar(p.y),a.multiplyScalar(p.z),n.add(o).add(a),n.clone()}function g(t,e,i,r,n,o,a){var s=t.material;if(null===(s.side===S?i.intersectTriangle(o,n,r,!0,a):i.intersectTriangle(r,n,o,s.side!==A,a)))return null;f.copy(a),f.applyMatrix4(t.matrixWorld);var c=e.ray.origin.distanceTo(f);return c<e.near||c>e.far?null:{distance:c,point:f.clone(),object:t}}function v(t,e,i,a,s,c,p,f){r.fromBufferAttribute(a,c),n.fromBufferAttribute(a,p),o.fromBufferAttribute(a,f);var v=g(t,e,i,r,n,o,d);return v&&(s&&(u.fromBufferAttribute(s,c),h.fromBufferAttribute(s,p),l.fromBufferAttribute(s,f),v.uv=m(d,r,n,o,u,h,l)),v.face=new ji(c,p,f,or.normal(r,n,o)),v.faceIndex=c),v}return function(p,f){var y,b=this.geometry,x=this.material,_=this.matrixWorld;if(void 0!==x&&(null===b.boundingSphere&&b.computeBoundingSphere(),i.copy(b.boundingSphere),i.applyMatrix4(_),!1!==p.ray.intersectsSphere(i)&&(t.getInverse(_),e.copy(p.ray).applyMatrix4(t),null===b.boundingBox||!1!==e.intersectsBox(b.boundingBox))))if(b.isBufferGeometry){var w,S,A,M,P,T=b.index,E=b.attributes.position,C=b.attributes.uv;if(null!==T)for(M=0,P=T.count;M<P;M+=3)w=T.getX(M),S=T.getX(M+1),A=T.getX(M+2),(y=v(this,p,e,E,C,w,S,A))&&(y.faceIndex=Math.floor(M/3),f.push(y));else for(M=0,P=E.count;M<P;M+=3)(y=v(this,p,e,E,C,w=M,S=M+1,A=M+2))&&(y.index=w,f.push(y))}else if(b.isGeometry){var I,R,L,O,N=Array.isArray(x),D=b.vertices,k=b.faces,F=b.faceVertexUvs[0];F.length>0&&(O=F);for(var B=0,z=k.length;B<z;B++){var U=k[B],j=N?x[U.materialIndex]:x;if(void 0!==j){if(I=D[U.a],R=D[U.b],L=D[U.c],!0===j.morphTargets){var G=b.morphTargets,V=this.morphTargetInfluences;r.set(0,0,0),n.set(0,0,0),o.set(0,0,0);for(var $=0,H=G.length;$<H;$++){var W=V[$];if(0!==W){var X=G[$].vertices;r.addScaledVector(a.subVectors(X[U.a],I),W),n.addScaledVector(s.subVectors(X[U.b],R),W),o.addScaledVector(c.subVectors(X[U.c],L),W)}}r.add(I),n.add(R),o.add(L),I=r,R=n,L=o}if(y=g(this,p,e,I,R,L,d)){if(O&&O[B]){var q=O[B];u.copy(q[0]),h.copy(q[1]),l.copy(q[2]),y.uv=m(d,I,R,L,u,h,l)}y.face=U,y.faceIndex=B,f.push(y)}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var yr=0;function br(t){switch(t){case ue:return["Linear","( value )"];case he:return["sRGB","( value )"];case pe:return["RGBE","( value )"];case de:return["RGBM","( value, 7.0 )"];case fe:return["RGBM","( value, 16.0 )"];case me:return["RGBD","( value, 256.0 )"];case le:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function xr(t,e){var i=br(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function _r(t,e){var i=br(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function wr(t,e){var i;switch(e){case ht:i="Linear";break;case lt:i="Reinhard";break;case pt:i="Uncharted2";break;case dt:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function Sr(t){return""!==t}function Ar(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function Mr(t){return t.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(t,e){var i=yi[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return Mr(i)})}function Pr(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,i,r){for(var n="",o=parseInt(e);o<parseInt(i);o++)n+=r.replace(/\[ i \]/g,"[ "+o+" ]");return n})}function Tr(t,e,i,r,n){var o=t.context,a=i.extensions,s=i.defines,c=r.vertexShader,u=r.fragmentShader,h="SHADOWMAP_TYPE_BASIC";n.shadowMapType===x?h="SHADOWMAP_TYPE_PCF":n.shadowMapType===_&&(h="SHADOWMAP_TYPE_PCF_SOFT");var l="ENVMAP_TYPE_CUBE",p="ENVMAP_MODE_REFLECTION",d="ENVMAP_BLENDING_MULTIPLY";if(n.envMap){switch(i.envMap.mapping){case ft:case mt:l="ENVMAP_TYPE_CUBE";break;case bt:case xt:l="ENVMAP_TYPE_CUBE_UV";break;case gt:case vt:l="ENVMAP_TYPE_EQUIREC";break;case yt:l="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case mt:case vt:p="ENVMAP_MODE_REFRACTION"}switch(i.combine){case at:d="ENVMAP_BLENDING_MULTIPLY";break;case st:d="ENVMAP_BLENDING_MIX";break;case ct:d="ENVMAP_BLENDING_ADD"}}var f,m,g=t.gammaFactor>0?t.gammaFactor:1,v=function(t,e,i){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Sr).join("\n")}(a,n,t.extensions),y=function(t){var e=[];for(var i in t){var r=t[i];!1!==r&&e.push("#define "+i+" "+r)}return e.join("\n")}(s),b=o.createProgram();i.isRawShaderMaterial?(f=[y,"\n"].filter(Sr).join("\n"),m=[v,y,"\n"].filter(Sr).join("\n")):(f=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.name,y,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.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(Sr).join("\n"),m=[v,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.name,y,n.alphaTest?"#define ALPHATEST "+n.alphaTest:"","#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+p:"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(n.numClippingPlanes-n.numClipIntersection),n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",n.envMap&&t.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",n.toneMapping!==ut?"#define TONE_MAPPING":"",n.toneMapping!==ut?yi.tonemapping_pars_fragment:"",n.toneMapping!==ut?wr("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?yi.encodings_pars_fragment:"",n.mapEncoding?xr("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?xr("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?xr("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?_r("linearToOutputTexel",n.outputEncoding):"",n.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Sr).join("\n")),c=Ar(c=Mr(c),n),u=Ar(u=Mr(u),n),i.isShaderMaterial||(c=Pr(c),u=Pr(u));var w=f+c,S=m+u,A=vr(o,o.VERTEX_SHADER,w),M=vr(o,o.FRAGMENT_SHADER,S);o.attachShader(b,A),o.attachShader(b,M),void 0!==i.index0AttributeName?o.bindAttribLocation(b,0,i.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(b,0,"position"),o.linkProgram(b);var P,T,E=o.getProgramInfoLog(b),C=o.getShaderInfoLog(A),I=o.getShaderInfoLog(M),R=!0,L=!0;return!1===o.getProgramParameter(b,o.LINK_STATUS)?(R=!1,console.error("THREE.WebGLProgram: shader error: ",o.getError(),"gl.VALIDATE_STATUS",o.getProgramParameter(b,o.VALIDATE_STATUS),"gl.getProgramInfoLog",E,C,I)):""!==E?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",E):""!==C&&""!==I||(L=!1),L&&(this.diagnostics={runnable:R,material:i,programLog:E,vertexShader:{log:C,prefix:f},fragmentShader:{log:I,prefix:m}}),o.deleteShader(A),o.deleteShader(M),this.getUniforms=function(){return void 0===P&&(P=new di(o,b,t)),P},this.getAttributes=function(){return void 0===T&&(T=function(t,e,i){for(var r={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o<n;o++){var a=t.getActiveAttrib(e,o).name;r[a]=t.getAttribLocation(e,a)}return r}(o,b)),T},this.destroy=function(){o.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=yr++,this.code=e,this.usedTimes=1,this.program=b,this.vertexShader=A,this.fragmentShader=M,this}function Er(t,e){var i=[],r={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},n=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];function o(t,e){var i;return t?t.isTexture?i=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),i=t.texture.encoding):i=ue,i===ue&&e&&(i=le),i}this.getParameters=function(i,n,a,s,c,u){var h=r[i.type],l=u.isSkinnedMesh?function(t){var i=t.skeleton.bones;if(e.floatVertexTextures)return 1024;var r=e.maxVertexUniforms,n=Math.floor((r-20)/4),o=Math.min(n,i.length);return o<i.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+i.length+" bones. This GPU supports "+o+"."),0):o}(u):0,p=t.getPrecision();null!==i.precision&&(p=e.getMaxPrecision(i.precision))!==i.precision&&console.warn("THREE.WebGLProgram.getParameters:",i.precision,"not supported, using",p,"instead.");var d=t.getRenderTarget();return{shaderID:h,precision:p,supportsVertexTextures:e.vertexTextures,outputEncoding:o(d?d.texture:null,t.gammaOutput),map:!!i.map,mapEncoding:o(i.map,t.gammaInput),envMap:!!i.envMap,envMapMode:i.envMap&&i.envMap.mapping,envMapEncoding:o(i.envMap,t.gammaInput),envMapCubeUV:!!i.envMap&&(i.envMap.mapping===bt||i.envMap.mapping===xt),lightMap:!!i.lightMap,aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,emissiveMapEncoding:o(i.emissiveMap,t.gammaInput),bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,alphaMap:!!i.alphaMap,gradientMap:!!i.gradientMap,combine:i.combine,vertexColors:i.vertexColors,fog:!!a,useFog:i.fog,fogExp:a&&a.isFogExp2,flatShading:i.shading===M,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:e.logarithmicDepthBuffer,skinning:i.skinning&&l>0,maxBones:l,useVertexTexture:e.floatVertexTextures,morphTargets:i.morphTargets,morphNormals:i.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numClippingPlanes:s,numClipIntersection:c,dithering:i.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&n.shadows.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===A,flipSided:i.side===S,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(e,i){var r=[];if(i.shaderID?r.push(i.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var o in e.defines)r.push(o),r.push(e.defines[o]);for(var a=0;a<n.length;a++)r.push(i[n[a]]);return r.push(e.onBeforeCompile.toString()),r.push(t.gammaOutput),r.join()},this.acquireProgram=function(e,r,n,o){for(var a,s=0,c=i.length;s<c;s++){var u=i[s];if(u.code===o){++(a=u).usedTimes;break}}return void 0===a&&(a=new Tr(t,o,e,r,n),i.push(a)),a},this.releaseProgram=function(t){if(0===--t.usedTimes){var e=i.indexOf(t);i[e]=i[i.length-1],i.pop(),t.destroy()}},this.programs=i}function Cr(t,e,i,r,n,o,a){var s="undefined"!==typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;function c(t,e){if(t.width>e||t.height>e){var i=e/Math.max(t.width,t.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(t.width*i),r.height=Math.floor(t.height*i),r.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+r.width+"x"+r.height,t),r}return t}function u(t){return ye.isPowerOfTwo(t.width)&&ye.isPowerOfTwo(t.height)}function h(t,e){return t.generateMipmaps&&e&&t.minFilter!==At&&t.minFilter!==Tt}function l(e){return e===At||e===Mt||e===Pt?t.NEAREST:t.LINEAR}function p(e){var i=e.target;i.removeEventListener("dispose",p),function(e){var i=r.get(e);if(e.image&&i.__image__webglTextureCube)t.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture)}r.remove(e)}(i),a.textures--}function d(e){var i=e.target;i.removeEventListener("dispose",d),function(e){var i=r.get(e),n=r.get(e.texture);if(!e)return;void 0!==n.__webglTexture&&t.deleteTexture(n.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(i.__webglFramebuffer[o]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[o]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer);r.remove(e.texture),r.remove(e)}(i),a.textures--}function f(e,l){var d=r.get(e);if(e.version>0&&d.__version!==e.version){var f=e.image;if(void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==f.complete)return void function(e,r,l){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),a.textures++);i.activeTexture(t.TEXTURE0+l),i.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment);var d=c(r.image,n.maxTextureSize);(function(t){return t.wrapS!==wt||t.wrapT!==wt||t.minFilter!==At&&t.minFilter!==Tt})(r)&&!1===u(d)&&(d=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=ye.nearestPowerOfTwo(t.width),e.height=ye.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}(d));var f=u(d),g=o(r.format),v=o(r.type);m(t.TEXTURE_2D,r,f);var y,b=r.mipmaps;if(r.isDepthTexture){var x=t.DEPTH_COMPONENT;if(r.type===kt){if(!s)throw new Error("Float Depth Texture only supported in WebGL2.0");x=t.DEPTH_COMPONENT32F}else s&&(x=t.DEPTH_COMPONENT16);r.format===Xt&&x===t.DEPTH_COMPONENT&&r.type!==Ot&&r.type!==Dt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Ot,v=o(r.type)),r.format===qt&&(x=t.DEPTH_STENCIL,r.type!==jt&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=jt,v=o(r.type))),i.texImage2D(t.TEXTURE_2D,0,x,d.width,d.height,0,g,v,null)}else if(r.isDataTexture)if(b.length>0&&f){for(var _=0,w=b.length;_<w;_++)y=b[_],i.texImage2D(t.TEXTURE_2D,_,g,y.width,y.height,0,g,v,y.data);r.generateMipmaps=!1}else i.texImage2D(t.TEXTURE_2D,0,g,d.width,d.height,0,g,v,d.data);else if(r.isCompressedTexture)for(_=0,w=b.length;_<w;_++)y=b[_],r.format!==$t&&r.format!==Vt?i.getCompressedTextureFormats().indexOf(g)>-1?i.compressedTexImage2D(t.TEXTURE_2D,_,g,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(t.TEXTURE_2D,_,g,y.width,y.height,0,g,v,y.data);else if(b.length>0&&f){for(_=0,w=b.length;_<w;_++)y=b[_],i.texImage2D(t.TEXTURE_2D,_,g,g,v,y);r.generateMipmaps=!1}else i.texImage2D(t.TEXTURE_2D,0,g,g,v,d);h(r,f)&&t.generateMipmap(t.TEXTURE_2D);e.__version=r.version,r.onUpdate&&r.onUpdate(r)}(d,e,l);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}i.activeTexture(t.TEXTURE0+l),i.bindTexture(t.TEXTURE_2D,d.__webglTexture)}function m(i,a,s){var c;if(s?(t.texParameteri(i,t.TEXTURE_WRAP_S,o(a.wrapS)),t.texParameteri(i,t.TEXTURE_WRAP_T,o(a.wrapT)),t.texParameteri(i,t.TEXTURE_MAG_FILTER,o(a.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,o(a.minFilter))):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS===wt&&a.wrapT===wt||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),t.texParameteri(i,t.TEXTURE_MAG_FILTER,l(a.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,l(a.minFilter)),a.minFilter!==At&&a.minFilter!==Tt&&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===kt&&null===e.get("OES_texture_float_linear"))return;if(a.type===Ft&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(t.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function g(e,n,a,s){var c=o(n.texture.format),u=o(n.texture.type);i.texImage2D(s,0,c,n.width,n.height,0,c,u,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,r.get(n.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function v(e,i){t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):i.depthBuffer&&i.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,i.width,i.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function y(e){var i=r.get(e),n=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),f(i.depthTexture,0);var n=r.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===Xt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,n,0);else{if(i.depthTexture.format!==qt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,n,0)}}(i.__webglFramebuffer,e)}else if(n){i.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer[o]),i.__webglDepthbuffer[o]=t.createRenderbuffer(),v(i.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),v(i.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(e,s){var l=r.get(e);if(6===e.image.length)if(e.version>0&&l.__version!==e.version){l.__image__webglTextureCube||(e.addEventListener("dispose",p),l.__image__webglTextureCube=t.createTexture(),a.textures++),i.activeTexture(t.TEXTURE0+s),i.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var d=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=d||f?f?e.image[v].image:e.image[v]:c(e.image[v],n.maxCubemapSize);var y=u(g[0]),b=o(e.format),x=o(e.type);m(t.TEXTURE_CUBE_MAP,e,y);for(v=0;v<6;v++)if(d)for(var _,w=g[v].mipmaps,S=0,A=w.length;S<A;S++)_=w[S],e.format!==$t&&e.format!==Vt?i.getCompressedTextureFormats().indexOf(b)>-1?i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,b,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,b,_.width,_.height,0,b,x,_.data);else f?i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b,g[v].width,g[v].height,0,b,x,g[v].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b,b,x,g[v]);h(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),l.__version=e.version,e.onUpdate&&e.onUpdate(e)}else i.activeTexture(t.TEXTURE0+s),i.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,n){i.activeTexture(t.TEXTURE0+n),i.bindTexture(t.TEXTURE_CUBE_MAP,r.get(e).__webglTexture)},this.setupRenderTarget=function(e){var n=r.get(e),o=r.get(e.texture);e.addEventListener("dispose",d),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,c=u(e);if(s){n.__webglFramebuffer=[];for(var l=0;l<6;l++)n.__webglFramebuffer[l]=t.createFramebuffer()}else n.__webglFramebuffer=t.createFramebuffer();if(s){i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,c);for(l=0;l<6;l++)g(n.__webglFramebuffer[l],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+l);h(e.texture,c)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),i.bindTexture(t.TEXTURE_CUBE_MAP,null)}else i.bindTexture(t.TEXTURE_2D,o.__webglTexture),m(t.TEXTURE_2D,e.texture,c),g(n.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),h(e.texture,c)&&t.generateMipmap(t.TEXTURE_2D),i.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&y(e)},this.updateRenderTargetMipmap=function(e){var n=e.texture;if(h(n,u(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=r.get(n).__webglTexture;i.bindTexture(o,a),t.generateMipmap(o),i.bindTexture(o,null)}}}function Ir(){var t={};return{get:function(e){var i=e.uuid,r=t[i];return void 0===r&&(r={},t[i]=r),r},remove:function(e){delete t[e.uuid]},clear:function(){t={}}}}function Rr(t,e,i){var r=new function(){var e=!1,i=new we,r=null,n=new we;return{setMask:function(i){r===i||e||(t.colorMask(i,i,i,i),r=i)},setLocked:function(t){e=t},setClear:function(e,r,o,a,s){!0===s&&(e*=a,r*=a,o*=a),i.set(e,r,o,a),!1===n.equals(i)&&(t.clearColor(e,r,o,a),n.copy(i))},reset:function(){e=!1,r=null,n.set(0,0,0,1)}}},n=new function(){var e=!1,i=null,r=null,n=null;return{setTest:function(e){e?W(t.DEPTH_TEST):X(t.DEPTH_TEST)},setMask:function(r){i===r||e||(t.depthMask(r),i=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case Q:t.depthFunc(t.NEVER);break;case J:t.depthFunc(t.ALWAYS);break;case tt:t.depthFunc(t.LESS);break;case et:t.depthFunc(t.LEQUAL);break;case it:t.depthFunc(t.EQUAL);break;case rt:t.depthFunc(t.GEQUAL);break;case nt:t.depthFunc(t.GREATER);break;case ot:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);r=e}},setLocked:function(t){e=t},setClear:function(e){n!==e&&(t.clearDepth(e),n=e)},reset:function(){e=!1,i=null,r=null,n=null}}},o=new function(){var e=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,u=null;return{setTest:function(e){e?W(t.STENCIL_TEST):X(t.STENCIL_TEST)},setMask:function(r){i===r||e||(t.stencilMask(r),i=r)},setFunc:function(e,i,a){r===e&&n===i&&o===a||(t.stencilFunc(e,i,a),r=e,n=i,o=a)},setOp:function(e,i,r){a===e&&s===i&&c===r||(t.stencilOp(e,i,r),a=e,s=i,c=r)},setLocked:function(t){e=t},setClear:function(e){u!==e&&(t.clearStencil(e),u=e)},reset:function(){e=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,u=null}}},a=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),c=new Uint8Array(a),u=new Uint8Array(a),h={},l=null,p=null,d=null,f=null,m=null,b=null,x=null,_=null,w=!1,M=null,P=null,T=null,E=null,C=null,k=null,F=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),B=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),z=parseFloat(B)>=1,U=null,j={},G=new we,V=new we;function $(e,i,r){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<r;a++)t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,n);return o}var H={};function W(e){!0!==h[e]&&(t.enable(e),h[e]=!0)}function X(e){!1!==h[e]&&(t.disable(e),h[e]=!1)}function q(e,r,n,o,a,s,c,u){e!==I?W(t.BLEND):X(t.BLEND),e===D||e===p&&u===w||(e===L?u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE)):e===O?u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_COLOR)):e===N?u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.SRC_COLOR)):u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)),p=e,w=u),e===D?(a=a||r,s=s||n,c=c||o,r===d&&a===b||(t.blendEquationSeparate(i(r),i(a)),d=r,b=a),n===f&&o===m&&s===x&&c===_||(t.blendFuncSeparate(i(n),i(o),i(s),i(c)),f=n,m=o,x=s,_=c)):(d=null,f=null,m=null,b=null,x=null,_=null)}function Y(e){M!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),M=e)}function Z(e){e!==g?(W(t.CULL_FACE),e!==P&&(e===v?t.cullFace(t.BACK):e===y?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):X(t.CULL_FACE),P=e}function K(e,i,r){e?(W(t.POLYGON_OFFSET_FILL),E===i&&C===r||(t.polygonOffset(i,r),E=i,C=r)):X(t.POLYGON_OFFSET_FILL)}function at(e){void 0===e&&(e=t.TEXTURE0+F-1),U!==e&&(t.activeTexture(e),U=e)}return H[t.TEXTURE_2D]=$(t.TEXTURE_2D,t.TEXTURE_2D,1),H[t.TEXTURE_CUBE_MAP]=$(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:r,depth:n,stencil:o},init:function(){r.setClear(0,0,0,1),n.setClear(1),o.setClear(0),W(t.DEPTH_TEST),n.setFunc(et),Y(!1),Z(v),W(t.CULL_FACE),W(t.BLEND),q(R)},initAttributes:function(){for(var t=0,e=s.length;t<e;t++)s[t]=0},enableAttribute:function(i){s[i]=1,0===c[i]&&(t.enableVertexAttribArray(i),c[i]=1),0!==u[i]&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(i,0),u[i]=0)},enableAttributeAndDivisor:function(i,r){s[i]=1,0===c[i]&&(t.enableVertexAttribArray(i),c[i]=1),u[i]!==r&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(i,r),u[i]=r)},disableUnusedAttributes:function(){for(var e=0,i=c.length;e!==i;++e)c[e]!==s[e]&&(t.disableVertexAttribArray(e),c[e]=0)},enable:W,disable:X,getCompressedTextureFormats:function(){if(null===l&&(l=[],e.get("WEBGL_compressed_texture_pvrtc")||e.get("WEBGL_compressed_texture_s3tc")||e.get("WEBGL_compressed_texture_etc1")))for(var i=t.getParameter(t.COMPRESSED_TEXTURE_FORMATS),r=0;r<i.length;r++)l.push(i[r]);return l},setBlending:q,setMaterial:function(e){e.side===A?X(t.CULL_FACE):W(t.CULL_FACE),Y(e.side===S),!0===e.transparent?q(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):q(I),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),r.setMask(e.colorWrite),K(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},setFlipSided:Y,setCullFace:Z,setLineWidth:function(e){e!==T&&(z&&t.lineWidth(e),T=e)},setPolygonOffset:K,getScissorTest:function(){return k},setScissorTest:function(e){k=e,e?W(t.SCISSOR_TEST):X(t.SCISSOR_TEST)},activeTexture:at,bindTexture:function(e,i){null===U&&at();var r=j[U];void 0===r&&(r={type:void 0,texture:void 0},j[U]=r),r.type===e&&r.texture===i||(t.bindTexture(e,i||H[e]),r.type=e,r.texture=i)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(e){!1===G.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),G.copy(e))},viewport:function(e){!1===V.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),V.copy(e))},reset:function(){for(var e=0;e<c.length;e++)1===c[e]&&(t.disableVertexAttribArray(e),c[e]=0);h={},l=null,U=null,j={},p=null,M=null,P=null,r.reset(),n.reset(),o.reset()}}}function Lr(t,e,i){var r;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=void 0!==i.precision?i.precision:"highp",a=n(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===i.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!==r)return r;var i=e.get("EXT_texture_filter_anisotropic");return r=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,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 Or(t){Ui.call(this),this.cameras=t||[]}function Nr(t){var e=this,i=null,r=null;"VRFrameData"in window&&(r=new window.VRFrameData);var n=new Pe,o=new Pe,a=new Pe,s=new Ui;s.bounds=new we(0,0,.5,1),s.layers.enable(1);var c=new Ui;c.bounds=new we(.5,0,.5,1),c.layers.enable(2);var u,h,l=new Or([s,c]);l.layers.enable(1),l.layers.enable(2),window.addEventListener("vrdisplaypresentchange",function(){if(i.isPresenting){var r=i.getEyeParameters("left"),n=r.renderWidth,o=r.renderHeight;h=t.getPixelRatio(),u=t.getSize(),t.setDrawingBufferSize(2*n,o,1)}else e.enabled&&t.setDrawingBufferSize(u.width,u.height,h)},!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(r);var e=r.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 u=i.stageParameters;if(this.standing&&u&&(o.fromArray(u.sittingToStandingTransform),a.getInverse(o),t.matrixWorld.multiply(o),t.matrixWorldInverse.multiply(a)),!1===i.isPresenting)return t;l.matrixWorld.copy(t.matrixWorld),l.matrixWorldInverse.copy(t.matrixWorldInverse),s.matrixWorldInverse.fromArray(r.leftViewMatrix),c.matrixWorldInverse.fromArray(r.rightViewMatrix),this.standing&&u&&(s.matrixWorldInverse.multiply(a),c.matrixWorldInverse.multiply(a));var h=t.parent;null!==h&&(n.getInverse(h.matrixWorld),s.matrixWorldInverse.multiply(n),c.matrixWorldInverse.multiply(n)),s.matrixWorld.getInverse(s.matrixWorldInverse),c.matrixWorld.getInverse(c.matrixWorldInverse),s.projectionMatrix.fromArray(r.leftProjectionMatrix),c.projectionMatrix.fromArray(r.rightProjectionMatrix),l.projectionMatrix.copy(s.projectionMatrix);var p=i.getLayers();if(p.length){var d=p[0];null!==d.leftBounds&&4===d.leftBounds.length&&s.bounds.fromArray(d.leftBounds),null!==d.rightBounds&&4===d.rightBounds.length&&c.bounds.fromArray(d.rightBounds)}return l},this.getStandingMatrix=function(){return o},this.submitFrame=function(){i&&i.isPresenting&&i.submitFrame()}}function Dr(t){var e={};return{get:function(i){if(void 0!==e[i])return e[i];var r;switch(i){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=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":r=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":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":r=t.getExtension("WEBGL_compressed_texture_etc1");break;default:r=t.getExtension(i)}return null===r&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),e[i]=r,r}}}function kr(){var t=this,e=null,i=0,r=!1,n=!1,o=new Ii,a=new Ci,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,i,r,n){var c=null!==e?e.length:0,u=null;if(0!==c){if(u=s.value,!0!==n||null===u){var h=r+4*c,l=i.matrixWorldInverse;a.getNormalMatrix(l),(null===u||u.length<h)&&(u=new Float32Array(h));for(var p=0,d=r;p!==c;++p,d+=4)o.copy(e[p]).applyMatrix4(l,a),o.normal.toArray(u,d),u[d+3]=o.constant}s.value=u,s.needsUpdate=!0}return t.numPlanes=c,u}this.uniform=s,this.numPlanes=0,this.numIntersection=0,this.init=function(t,n,o){var a=0!==t.length||n||0!==i||r;return r=n,e=u(t,o,0),i=t.length,a},this.beginShadows=function(){n=!0,u(null)},this.endShadows=function(){n=!1,c()},this.setState=function(t,o,a,h,l,p){if(!r||null===t||0===t.length||n&&!a)n?u(null):c();else{var d=n?0:i,f=4*d,m=l.clippingState||null;s.value=m,m=u(t,h,f,p);for(var g=0;g!==f;++g)m[g]=e[g];l.clippingState=m,this.numIntersection=o?this.numPlanes:0,this.numPlanes+=d}}}function Fr(t){console.log("THREE.WebGLRenderer",m);var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,n=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,c=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,u=[],h=null,l=new Float32Array(8),p=[],d=[];this.domElement=e,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=ht,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var f,g=this,v=null,y=null,x=null,_=-1,w="",S=null,A=null,P=new we,E=null,C=new we,I=0,R=e.width,L=e.height,O=1,N=new we(0,0,R,L),D=!1,Q=new we(0,0,R,L),J=new Ri,tt=new kr,et=!1,it=!1,rt=new Pe,nt=new Me,ot=new Pe,at=new Pe,st={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},ct={geometries:0,textures:0},ut={frame:0,calls:0,vertices:0,faces:0,points:0};this.info={render:ut,memory:ct,programs:null};try{var lt={alpha:r,depth:n,stencil:o,antialias:a,premultipliedAlpha:s,preserveDrawingBuffer:c};if(null===(f=i||e.getContext("webgl",lt)||e.getContext("experimental-webgl",lt)))throw null!==e.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===f.getShaderPrecisionFormat&&(f.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),e.addEventListener("webglcontextlost",xe,!1)}catch(Fe){console.error("THREE.WebGLRenderer: "+Fe)}var pt=new Dr(f);pt.get("WEBGL_depth_texture"),pt.get("OES_texture_float"),pt.get("OES_texture_float_linear"),pt.get("OES_texture_half_float"),pt.get("OES_texture_half_float_linear"),pt.get("OES_standard_derivatives"),pt.get("ANGLE_instanced_arrays"),pt.get("OES_element_index_uint")&&(Ki.MaxIndex=4294967296);var dt=new Lr(f,pt,t),ft=new Rr(f,pt,ke),mt=new Ir,gt=new Cr(f,pt,ft,mt,dt,ke,ct),vt=new Oi(f),yt=new fr(f,vt,ct),bt=new gr(f,yt,ut),xt=new Er(this,dt),ne=new mr,oe=new lr,ue=new sr(this,ft,bt,s),he=new Nr(this);this.info.programs=xt.programs;var le=new dr(f,pt,ut),pe=new pr(f,pt,ut);function de(){return null===y?O:1}function fe(){ft.init(),ft.scissor(P.copy(N).multiplyScalar(O)),ft.viewport(C.copy(Q).multiplyScalar(O))}function me(){v=null,S=null,w="",_=-1,ft.reset()}fe(),this.context=f,this.capabilities=dt,this.extensions=pt,this.properties=mt,this.renderLists=oe,this.state=ft,this.vr=he;var ge=new Li(this,st,bt,dt);this.shadowMap=ge;var ve=new wi(this,p),be=new _i(this,d);function xe(t){t.preventDefault(),me(),fe(),mt.clear(),bt.clear()}function _e(t){var e=t.target;e.removeEventListener("dispose",_e),function(t){Se(t),mt.remove(t)}(e)}function Se(t){var e=mt.get(t).program;t.program=void 0,void 0!==e&&xt.releaseProgram(e)}function Ae(t,e){return Math.abs(e[0])-Math.abs(t[0])}function Ee(t,e,i,r){for(var n=0,o=t.length;n<o;n++){var a=t[n],s=a.object,c=a.geometry,u=void 0===r?a.material:r,h=a.group;if(i.isArrayCamera){A=i;for(var l=i.cameras,p=0,d=l.length;p<d;p++){var f=l[p];if(s.layers.test(f.layers)){var m=f.bounds,v=m.x*R,y=m.y*L,b=m.z*R,x=m.w*L;g.setViewport(v,y,b,x),g.setScissor(v,y,b,x),g.setScissorTest(!0),Ce(s,e,f,c,u,h)}}}else A=null,Ce(s,e,i,c,u,h)}}function Ce(t,e,i,r,n,o){if(t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.onBeforeRender(g,e,i,r,n,o),t.isImmediateRenderObject){ft.setMaterial(n);var a=Re(i,e.fog,n,t);w="",function(t,e,i){t.render(function(t){g.renderBufferImmediate(t,e,i)})}(t,a,n)}else g.renderBufferDirect(i,e.fog,r,n,t,o);t.onAfterRender(g,e,i,r,n,o)}function Ie(t,e,i){var r=mt.get(t),n=xt.getParameters(t,st,e,tt.numPlanes,tt.numIntersection,i),o=xt.getProgramCode(t,n),a=r.program,s=!0;if(void 0===a)t.addEventListener("dispose",_e);else if(a.code!==o)Se(t);else{if(void 0!==n.shaderID)return;s=!1}if(s){if(n.shaderID){var c=bi[n.shaderID];r.shader={name:t.type,uniforms:vi.clone(c.uniforms),vertexShader:c.vertexShader,fragmentShader:c.fragmentShader}}else r.shader={name:t.type,uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};t.onBeforeCompile(r.shader),a=xt.acquireProgram(t,r.shader,n,o),r.program=a,t.program=a}var u=a.getAttributes();if(t.morphTargets){t.numSupportedMorphTargets=0;for(var h=0;h<g.maxMorphTargets;h++)u["morphTarget"+h]>=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(h=0;h<g.maxMorphNormals;h++)u["morphNormal"+h]>=0&&t.numSupportedMorphNormals++}var l=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=tt.numPlanes,r.numIntersection=tt.numIntersection,l.clippingPlanes=tt.uniform),r.fog=e,r.lightsHash=st.hash,t.lights&&(l.ambientLightColor.value=st.ambient,l.directionalLights.value=st.directional,l.spotLights.value=st.spot,l.rectAreaLights.value=st.rectArea,l.pointLights.value=st.point,l.hemisphereLights.value=st.hemi,l.directionalShadowMap.value=st.directionalShadowMap,l.directionalShadowMatrix.value=st.directionalShadowMatrix,l.spotShadowMap.value=st.spotShadowMap,l.spotShadowMatrix.value=st.spotShadowMatrix,l.pointShadowMap.value=st.pointShadowMap,l.pointShadowMatrix.value=st.pointShadowMatrix);var p=r.program.getUniforms(),d=di.seqWithValue(p.seq,l);r.uniformsList=d}function Re(t,e,i,r){I=0;var n=mt.get(i);if(et&&(it||t!==S)){var o=t===S&&i.id===_;tt.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,t,n,o)}!1===i.needsUpdate&&(void 0===n.program?i.needsUpdate=!0:i.fog&&n.fog!==e?i.needsUpdate=!0:i.lights&&n.lightsHash!==st.hash?i.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===tt.numPlanes&&n.numIntersection===tt.numIntersection||(i.needsUpdate=!0)),i.needsUpdate&&(Ie(i,e,r),i.needsUpdate=!1);var a,s,c=!1,u=!1,h=!1,l=n.program,p=l.getUniforms(),d=n.shader.uniforms;if(l.id!==v&&(f.useProgram(l.program),v=l.id,c=!0,u=!0,h=!0),i.id!==_&&(_=i.id,u=!0),c||t!==S){if(p.setValue(f,"projectionMatrix",t.projectionMatrix),dt.logarithmicDepthBuffer&&p.setValue(f,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),S!==(A||t)&&(S=A||t,u=!0,h=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var m=p.map.cameraPosition;void 0!==m&&m.setValue(f,nt.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&p.setValue(f,"viewMatrix",t.matrixWorldInverse)}if(i.skinning){p.setOptional(f,r,"bindMatrix"),p.setOptional(f,r,"bindMatrixInverse");var y=r.skeleton;if(y){var b=y.bones;if(dt.floatVertexTextures){if(void 0===y.boneTexture){var x=Math.sqrt(4*b.length);x=ye.nextPowerOfTwo(Math.ceil(x)),x=Math.max(x,4);var w=new Float32Array(x*x*4);w.set(y.boneMatrices);var M=new Te(w,x,x,$t,kt);y.boneMatrices=w,y.boneTexture=M,y.boneTextureSize=x}p.setValue(f,"boneTexture",y.boneTexture),p.setValue(f,"boneTextureSize",y.boneTextureSize)}else p.setOptional(f,y,"boneMatrices")}}return u&&(p.setValue(f,"toneMappingExposure",g.toneMappingExposure),p.setValue(f,"toneMappingWhitePoint",g.toneMappingWhitePoint),i.lights&&(s=h,(a=d).ambientLightColor.needsUpdate=s,a.directionalLights.needsUpdate=s,a.pointLights.needsUpdate=s,a.spotLights.needsUpdate=s,a.rectAreaLights.needsUpdate=s,a.hemisphereLights.needsUpdate=s),e&&i.fog&&function(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)}(d,e),(i.isMeshBasicMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshNormalMaterial||i.isMeshDepthMaterial)&&function(t,e){t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity);t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,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 i;e.map?i=e.map:e.specularMap?i=e.specularMap:e.displacementMap?i=e.displacementMap:e.normalMap?i=e.normalMap:e.bumpMap?i=e.bumpMap:e.roughnessMap?i=e.roughnessMap:e.metalnessMap?i=e.metalnessMap:e.alphaMap?i=e.alphaMap:e.emissiveMap&&(i=e.emissiveMap);if(void 0!==i){i.isWebGLRenderTarget&&(i=i.texture);var r=i.offset,n=i.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}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}(d,i),i.isLineBasicMaterial?Le(d,i):i.isLineDashedMaterial?(Le(d,i),function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(d,i)):i.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*O,t.scale.value=.5*L,t.map.value=e.map,null!==e.map){var i=e.map.offset,r=e.map.repeat;t.offsetRepeat.value.set(i.x,i.y,r.x,r.y)}}(d,i):i.isMeshLambertMaterial?function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(d,i):i.isMeshToonMaterial?function(t,e){Oe(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(d,i):i.isMeshPhongMaterial?Oe(d,i):i.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,Ne(t,e)}(d,i):i.isMeshStandardMaterial?Ne(d,i):i.isMeshDepthMaterial?i.displacementMap&&(d.displacementMap.value=i.displacementMap,d.displacementScale.value=i.displacementScale,d.displacementBias.value=i.displacementBias):i.isMeshNormalMaterial&&function(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)}(d,i),void 0!==d.ltcMat&&(d.ltcMat.value=gi.LTC_MAT_TEXTURE),void 0!==d.ltcMag&&(d.ltcMag.value=gi.LTC_MAG_TEXTURE),di.upload(f,n.uniformsList,d,g)),p.setValue(f,"modelViewMatrix",r.modelViewMatrix),p.setValue(f,"normalMatrix",r.normalMatrix),p.setValue(f,"modelMatrix",r.matrixWorld),l}function Le(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function Oe(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 Ne(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 De(t,e){var i,r,n,o,a,s,c,u,h=0,l=0,p=0,d=e.matrixWorldInverse,f=0,m=0,g=0,v=0,y=0;for(i=0,r=t.length;i<r;i++)if(a=(n=t[i]).color,s=n.intensity,c=n.distance,u=n.shadow&&n.shadow.map?n.shadow.map.texture:null,n.isAmbientLight)h+=a.r*s,l+=a.g*s,p+=a.b*s;else if(n.isDirectionalLight){(b=ne.get(n)).color.copy(n.color).multiplyScalar(n.intensity),b.direction.setFromMatrixPosition(n.matrixWorld),nt.setFromMatrixPosition(n.target.matrixWorld),b.direction.sub(nt),b.direction.transformDirection(d),b.shadow=n.castShadow,n.castShadow&&(o=n.shadow,b.shadowBias=o.bias,b.shadowRadius=o.radius,b.shadowMapSize=o.mapSize),st.directionalShadowMap[f]=u,st.directionalShadowMatrix[f]=n.shadow.matrix,st.directional[f]=b,f++}else if(n.isSpotLight){(b=ne.get(n)).position.setFromMatrixPosition(n.matrixWorld),b.position.applyMatrix4(d),b.color.copy(a).multiplyScalar(s),b.distance=c,b.direction.setFromMatrixPosition(n.matrixWorld),nt.setFromMatrixPosition(n.target.matrixWorld),b.direction.sub(nt),b.direction.transformDirection(d),b.coneCos=Math.cos(n.angle),b.penumbraCos=Math.cos(n.angle*(1-n.penumbra)),b.decay=0===n.distance?0:n.decay,b.shadow=n.castShadow,n.castShadow&&(o=n.shadow,b.shadowBias=o.bias,b.shadowRadius=o.radius,b.shadowMapSize=o.mapSize),st.spotShadowMap[g]=u,st.spotShadowMatrix[g]=n.shadow.matrix,st.spot[g]=b,g++}else if(n.isRectAreaLight){(b=ne.get(n)).color.copy(a).multiplyScalar(s/(n.width*n.height)),b.position.setFromMatrixPosition(n.matrixWorld),b.position.applyMatrix4(d),at.identity(),ot.copy(n.matrixWorld),ot.premultiply(d),at.extractRotation(ot),b.halfWidth.set(.5*n.width,0,0),b.halfHeight.set(0,.5*n.height,0),b.halfWidth.applyMatrix4(at),b.halfHeight.applyMatrix4(at),st.rectArea[v]=b,v++}else if(n.isPointLight){(b=ne.get(n)).position.setFromMatrixPosition(n.matrixWorld),b.position.applyMatrix4(d),b.color.copy(n.color).multiplyScalar(n.intensity),b.distance=n.distance,b.decay=0===n.distance?0:n.decay,b.shadow=n.castShadow,n.castShadow&&(o=n.shadow,b.shadowBias=o.bias,b.shadowRadius=o.radius,b.shadowMapSize=o.mapSize),st.pointShadowMap[m]=u,st.pointShadowMatrix[m]=n.shadow.matrix,st.point[m]=b,m++}else if(n.isHemisphereLight){var b;(b=ne.get(n)).direction.setFromMatrixPosition(n.matrixWorld),b.direction.transformDirection(d),b.direction.normalize(),b.skyColor.copy(n.color).multiplyScalar(s),b.groundColor.copy(n.groundColor).multiplyScalar(s),st.hemi[y]=b,y++}st.ambient[0]=h,st.ambient[1]=l,st.ambient[2]=p,st.directional.length=f,st.spot.length=g,st.rectArea.length=v,st.point.length=m,st.hemi.length=y,st.hash=f+","+m+","+g+","+v+","+y+","+st.shadows.length}function ke(t){var e;if(t===_t)return f.REPEAT;if(t===wt)return f.CLAMP_TO_EDGE;if(t===St)return f.MIRRORED_REPEAT;if(t===At)return f.NEAREST;if(t===Mt)return f.NEAREST_MIPMAP_NEAREST;if(t===Pt)return f.NEAREST_MIPMAP_LINEAR;if(t===Tt)return f.LINEAR;if(t===Et)return f.LINEAR_MIPMAP_NEAREST;if(t===Ct)return f.LINEAR_MIPMAP_LINEAR;if(t===It)return f.UNSIGNED_BYTE;if(t===Bt)return f.UNSIGNED_SHORT_4_4_4_4;if(t===zt)return f.UNSIGNED_SHORT_5_5_5_1;if(t===Ut)return f.UNSIGNED_SHORT_5_6_5;if(t===Rt)return f.BYTE;if(t===Lt)return f.SHORT;if(t===Ot)return f.UNSIGNED_SHORT;if(t===Nt)return f.INT;if(t===Dt)return f.UNSIGNED_INT;if(t===kt)return f.FLOAT;if(t===Ft&&null!==(e=pt.get("OES_texture_half_float")))return e.HALF_FLOAT_OES;if(t===Gt)return f.ALPHA;if(t===Vt)return f.RGB;if(t===$t)return f.RGBA;if(t===Ht)return f.LUMINANCE;if(t===Wt)return f.LUMINANCE_ALPHA;if(t===Xt)return f.DEPTH_COMPONENT;if(t===qt)return f.DEPTH_STENCIL;if(t===k)return f.FUNC_ADD;if(t===F)return f.FUNC_SUBTRACT;if(t===B)return f.FUNC_REVERSE_SUBTRACT;if(t===j)return f.ZERO;if(t===G)return f.ONE;if(t===V)return f.SRC_COLOR;if(t===$)return f.ONE_MINUS_SRC_COLOR;if(t===H)return f.SRC_ALPHA;if(t===W)return f.ONE_MINUS_SRC_ALPHA;if(t===X)return f.DST_ALPHA;if(t===q)return f.ONE_MINUS_DST_ALPHA;if(t===Y)return f.DST_COLOR;if(t===Z)return f.ONE_MINUS_DST_COLOR;if(t===K)return f.SRC_ALPHA_SATURATE;if((t===Yt||t===Zt||t===Kt||t===Qt)&&null!==(e=pt.get("WEBGL_compressed_texture_s3tc"))){if(t===Yt)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===Zt)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===Kt)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===Qt)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===Jt||t===te||t===ee||t===ie)&&null!==(e=pt.get("WEBGL_compressed_texture_pvrtc"))){if(t===Jt)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===te)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===ee)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===ie)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===re&&null!==(e=pt.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((t===z||t===U)&&null!==(e=pt.get("EXT_blend_minmax"))){if(t===z)return e.MIN_EXT;if(t===U)return e.MAX_EXT}return t===jt&&null!==(e=pt.get("WEBGL_depth_texture"))?e.UNSIGNED_INT_24_8_WEBGL:0}this.getContext=function(){return f},this.getContextAttributes=function(){return f.getContextAttributes()},this.forceContextLoss=function(){var t=pt.get("WEBGL_lose_context");t&&t.loseContext()},this.getMaxAnisotropy=function(){return dt.getMaxAnisotropy()},this.getPrecision=function(){return dt.precision},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(R,L,!1))},this.getSize=function(){return{width:R,height:L}},this.setSize=function(t,i,r){var n=he.getDevice();n&&n.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(R=t,L=i,e.width=t*O,e.height=i*O,!1!==r&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(){return{width:R*O,height:L*O}},this.setDrawingBufferSize=function(t,i,r){R=t,L=i,O=r,e.width=t*r,e.height=i*r,this.setViewport(0,0,t,i)},this.setViewport=function(t,e,i,r){Q.set(t,L-e-r,i,r),ft.viewport(C.copy(Q).multiplyScalar(O))},this.setScissor=function(t,e,i,r){N.set(t,L-e-r,i,r),ft.scissor(P.copy(N).multiplyScalar(O))},this.setScissorTest=function(t){ft.setScissorTest(D=t)},this.getClearColor=ue.getClearColor,this.setClearColor=ue.setClearColor,this.getClearAlpha=ue.getClearAlpha,this.setClearAlpha=ue.setClearAlpha,this.clear=function(t,e,i){var r=0;(void 0===t||t)&&(r|=f.COLOR_BUFFER_BIT),(void 0===e||e)&&(r|=f.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=f.STENCIL_BUFFER_BIT),f.clear(r)},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,i,r){this.setRenderTarget(t),this.clear(e,i,r)},this.resetGLState=me,this.dispose=function(){e.removeEventListener("webglcontextlost",xe,!1),oe.dispose()},this.renderBufferImmediate=function(t,e,i){ft.initAttributes();var r=mt.get(t);t.hasPositions&&!r.position&&(r.position=f.createBuffer()),t.hasNormals&&!r.normal&&(r.normal=f.createBuffer()),t.hasUvs&&!r.uv&&(r.uv=f.createBuffer()),t.hasColors&&!r.color&&(r.color=f.createBuffer());var n=e.getAttributes();if(t.hasPositions&&(f.bindBuffer(f.ARRAY_BUFFER,r.position),f.bufferData(f.ARRAY_BUFFER,t.positionArray,f.DYNAMIC_DRAW),ft.enableAttribute(n.position),f.vertexAttribPointer(n.position,3,f.FLOAT,!1,0,0)),t.hasNormals){if(f.bindBuffer(f.ARRAY_BUFFER,r.normal),!i.isMeshPhongMaterial&&!i.isMeshStandardMaterial&&!i.isMeshNormalMaterial&&i.shading===M)for(var o=0,a=3*t.count;o<a;o+=9){var s=t.normalArray,c=(s[o+0]+s[o+3]+s[o+6])/3,u=(s[o+1]+s[o+4]+s[o+7])/3,h=(s[o+2]+s[o+5]+s[o+8])/3;s[o+0]=c,s[o+1]=u,s[o+2]=h,s[o+3]=c,s[o+4]=u,s[o+5]=h,s[o+6]=c,s[o+7]=u,s[o+8]=h}f.bufferData(f.ARRAY_BUFFER,t.normalArray,f.DYNAMIC_DRAW),ft.enableAttribute(n.normal),f.vertexAttribPointer(n.normal,3,f.FLOAT,!1,0,0)}t.hasUvs&&i.map&&(f.bindBuffer(f.ARRAY_BUFFER,r.uv),f.bufferData(f.ARRAY_BUFFER,t.uvArray,f.DYNAMIC_DRAW),ft.enableAttribute(n.uv),f.vertexAttribPointer(vt.uv,2,f.FLOAT,!1,0,0)),t.hasColors&&i.vertexColors!==T&&(f.bindBuffer(f.ARRAY_BUFFER,r.color),f.bufferData(f.ARRAY_BUFFER,t.colorArray,f.DYNAMIC_DRAW),ft.enableAttribute(n.color),f.vertexAttribPointer(n.color,3,f.FLOAT,!1,0,0)),ft.disableUnusedAttributes(),f.drawArrays(f.TRIANGLES,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,i,r,n,o){ft.setMaterial(r);var a=Re(t,e,r,n),s=i.id+"_"+a.id+"_"+(!0===r.wireframe),c=!1;s!==w&&(w=s,c=!0);var u=n.morphTargetInfluences;if(void 0!==u){for(var h=[],p=0,d=u.length;p<d;p++){var m=u[p];h.push([m,p])}h.sort(Ae),h.length>8&&(h.length=8);var g=i.morphAttributes;for(p=0,d=h.length;p<d;p++){m=h[p];if(l[p]=m[0],0!==m[0]){var v=m[1];!0===r.morphTargets&&g.position&&i.addAttribute("morphTarget"+p,g.position[v]),!0===r.morphNormals&&g.normal&&i.addAttribute("morphNormal"+p,g.normal[v])}else!0===r.morphTargets&&i.removeAttribute("morphTarget"+p),!0===r.morphNormals&&i.removeAttribute("morphNormal"+p)}p=h.length;for(var y=l.length;p<y;p++)l[p]=0;a.getUniforms().setValue(f,"morphTargetInfluences",l),c=!0}v=i.index;var b,x=i.attributes.position,_=1;!0===r.wireframe&&(v=yt.getWireframeAttribute(i),_=2);var S=le;null!==v&&(b=vt.get(v),(S=pe).setIndex(b)),c&&(!function(t,e,i,r){if(i&&i.isInstancedBufferGeometry&&null===pt.get("ANGLE_instanced_arrays"))return void console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");void 0===r&&(r=0);ft.initAttributes();var n=i.attributes,o=e.getAttributes(),a=t.defaultAttributeValues;for(var s in o){var c=o[s];if(c>=0){var u=n[s];if(void 0!==u){var h=u.normalized,l=u.itemSize,p=vt.get(u),d=p.buffer,m=p.type,g=p.bytesPerElement;if(u.isInterleavedBufferAttribute){var v=u.data,y=v.stride,b=u.offset;v&&v.isInstancedInterleavedBuffer?(ft.enableAttributeAndDivisor(c,v.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=v.meshPerAttribute*v.count)):ft.enableAttribute(c),f.bindBuffer(f.ARRAY_BUFFER,d),f.vertexAttribPointer(c,l,m,h,y*g,(r*y+b)*g)}else u.isInstancedBufferAttribute?(ft.enableAttributeAndDivisor(c,u.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=u.meshPerAttribute*u.count)):ft.enableAttribute(c),f.bindBuffer(f.ARRAY_BUFFER,d),f.vertexAttribPointer(c,l,m,h,0,r*l*g)}else if(void 0!==a){var x=a[s];if(void 0!==x)switch(x.length){case 2:f.vertexAttrib2fv(c,x);break;case 3:f.vertexAttrib3fv(c,x);break;case 4:f.vertexAttrib4fv(c,x);break;default:f.vertexAttrib1fv(c,x)}}}}ft.disableUnusedAttributes()}(r,a,i),null!==v&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,b.buffer));var A=0;null!==v?A=v.count:void 0!==x&&(A=x.count);var M=i.drawRange.start*_,P=i.drawRange.count*_,T=null!==o?o.start*_:0,E=null!==o?o.count*_:1/0,C=Math.max(M,T),I=Math.min(A,M+P,T+E)-1,R=Math.max(0,I-C+1);if(0!==R){if(n.isMesh)if(!0===r.wireframe)ft.setLineWidth(r.wireframeLinewidth*de()),S.setMode(f.LINES);else switch(n.drawMode){case ae:S.setMode(f.TRIANGLES);break;case se:S.setMode(f.TRIANGLE_STRIP);break;case ce:S.setMode(f.TRIANGLE_FAN)}else if(n.isLine){var L=r.linewidth;void 0===L&&(L=1),ft.setLineWidth(L*de()),n.isLineSegments?S.setMode(f.LINES):n.isLineLoop?S.setMode(f.LINE_LOOP):S.setMode(f.LINE_STRIP)}else n.isPoints&&S.setMode(f.POINTS);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&S.renderInstances(i,C,R):S.render(C,R)}},this.compile=function(t,e){u=[],t.traverse(function(t){t.isLight&&u.push(t)}),De(u,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var i=0;i<e.material.length;i++)Ie(e.material[i],t.fog,e);else Ie(e.material,t.fog,e)})},this.animate=function(t){(he.getDevice()||window).requestAnimationFrame(function e(){t(),(he.getDevice()||window).requestAnimationFrame(e)})},this.render=function(t,e,i,r){if(e&&e.isCamera){w="",_=-1,S=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),he.enabled&&(e=he.getCamera(e)),rt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),J.setFromMatrix(rt),u.length=0,p.length=0,d.length=0,it=this.localClippingEnabled,et=tt.init(this.clippingPlanes,it,e),(h=oe.get(t,e)).init(),function t(e,i,r){if(!e.visible)return;var n=e.layers.test(i.layers);if(n)if(e.isLight)u.push(e);else if(e.isSprite)e.frustumCulled&&!J.intersectsSprite(e)||p.push(e);else if(e.isLensFlare)d.push(e);else if(e.isImmediateRenderObject)r&&nt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(rt),h.push(e,null,e.material,nt.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||J.intersectsObject(e))){r&&nt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(rt);var o=bt.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,c=0,l=s.length;c<l;c++){var f=s[c],m=a[f.materialIndex];m&&m.visible&&h.push(e,o,m,nt.z,f)}else a.visible&&h.push(e,o,a,nt.z,null)}var g=e.children;for(c=0,l=g.length;c<l;c++)t(g[c],i,r)}(t,e,g.sortObjects),h.finish(),!0===g.sortObjects&&h.sort(),et&&tt.beginShadows(),function(t){for(var e=0,i=0,r=t.length;i<r;i++){var n=t[i];n.castShadow&&(st.shadows[e]=n,e++)}st.shadows.length=e}(u),ge.render(t,e),De(u,e),et&&tt.endShadows(),ut.frame++,ut.calls=0,ut.vertices=0,ut.faces=0,ut.points=0,void 0===i&&(i=null),this.setRenderTarget(i),ue.render(t,e,r);var n=h.opaque,o=h.transparent;if(t.overrideMaterial){var a=t.overrideMaterial;n.length&&Ee(n,t,e,a),o.length&&Ee(o,t,e,a)}else n.length&&Ee(n,t,e),o.length&&Ee(o,t,e);ve.render(t,e),be.render(t,e,C),i&&gt.updateRenderTargetMipmap(i),ft.buffers.depth.setTest(!0),ft.buffers.depth.setMask(!0),ft.buffers.color.setMask(!0),e.isArrayCamera&&g.setScissorTest(!1),he.enabled&&he.submitFrame()}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFaceCulling=function(t,e){ft.setCullFace(t),ft.setFlipSided(e===b)},this.allocTextureUnit=function(){var t=I;return t>=dt.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+dt.maxTextures),I+=1,t},this.setTexture2D=function(){var t=!1;return function(e,i){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),gt.setTexture2D(e,i)}}(),this.setTexture=function(){var t=!1;return function(e,i){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),gt.setTexture2D(e,i)}}(),this.setTextureCube=function(){var t=!1;return function(e,i){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?gt.setTextureCube(e,i):gt.setTextureCubeDynamic(e,i)}}(),this.getRenderTarget=function(){return y},this.setRenderTarget=function(t){y=t,t&&void 0===mt.get(t).__webglFramebuffer&&gt.setupRenderTarget(t);var e,i=t&&t.isWebGLRenderTargetCube;if(t){var r=mt.get(t);e=i?r.__webglFramebuffer[t.activeCubeFace]:r.__webglFramebuffer,P.copy(t.scissor),E=t.scissorTest,C.copy(t.viewport)}else e=null,P.copy(N).multiplyScalar(O),E=D,C.copy(Q).multiplyScalar(O);if(x!==e&&(f.bindFramebuffer(f.FRAMEBUFFER,e),x=e),ft.scissor(P),ft.setScissorTest(E),ft.viewport(C),i){var n=mt.get(t.texture);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,n.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,i,r,n,o){if(t&&t.isWebGLRenderTarget){var a=mt.get(t).__webglFramebuffer;if(a){var s=!1;a!==x&&(f.bindFramebuffer(f.FRAMEBUFFER,a),s=!0);try{var c=t.texture,u=c.format,h=c.type;if(u!==$t&&ke(u)!==f.getParameter(f.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(h!==It&&ke(h)!==f.getParameter(f.IMPLEMENTATION_COLOR_READ_TYPE)&&(h!==kt||!pt.get("OES_texture_float")&&!pt.get("WEBGL_color_buffer_float"))&&(h!==Ft||!pt.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-r&&i>=0&&i<=t.height-n&&f.readPixels(e,i,r,n,ke(u),ke(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&f.bindFramebuffer(f.FRAMEBUFFER,x)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function Br(t,e){this.name="",this.color=new mi(t),this.density=void 0!==e?e:25e-5}function zr(t,e,i){this.name="",this.color=new mi(t),this.near=void 0!==e?e:1,this.far=void 0!==i?i:1e3}function Ur(){Fi.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function jr(t,e,i,r,n){Fi.call(this),this.lensFlares=[],this.positionScreen=new Me,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,i,r,n)}function Gr(t){Ai.call(this),this.type="SpriteMaterial",this.color=new mi(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Vr(t){Fi.call(this),this.type="Sprite",this.material=void 0!==t?t:new Gr}function $r(){Fi.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Hr(t,e){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,r=this.bones.length;i<r;i++)this.boneInverses.push(new Pe)}}function Wr(){Fi.call(this),this.type="Bone"}function Xr(t,e){ar.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Pe,this.bindMatrixInverse=new Pe;var i=new Hr(this.initBones());this.bind(i,this.matrixWorld),this.normalizeSkinWeights()}function qr(t){Ai.call(this),this.type="LineBasicMaterial",this.color=new mi(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(t)}function Yr(t,e,i){if(1===i)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new Zr(t,e);Fi.call(this),this.type="Line",this.geometry=void 0!==t?t:new Ki,this.material=void 0!==e?e:new qr({color:16777215*Math.random()})}function Zr(t,e){Yr.call(this,t,e),this.type="LineSegments"}function Kr(t,e){Yr.call(this,t,e),this.type="LineLoop"}function Qr(t){Ai.call(this),this.type="PointsMaterial",this.color=new mi(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.lights=!1,this.setValues(t)}function Jr(t,e){Fi.call(this),this.type="Points",this.geometry=void 0!==t?t:new Ki,this.material=void 0!==e?e:new Qr({color:16777215*Math.random()})}function tn(){Fi.call(this),this.type="Group"}function en(t,e,i,r,n,o,a,s,c,u,h,l){_e.call(this,null,o,a,s,c,u,r,n,h,l),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function rn(t,e,i,r,n,o,a,s,c){_e.call(this,t,e,i,r,n,o,a,s,c),this.needsUpdate=!0}function nn(t){Ki.call(this),this.type="WireframeGeometry";var e,i,r,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,r=m.length;e<r;e++){var g=m[e];for(i=0;i<3;i++)s=g[f[i]],c=g[f[(i+1)%3]],p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[u=p[0]+","+p[1]]&&(d[u]={index1:p[0],index2:p[1]})}for(u in d)a=d[u],h=t.vertices[a.index1],l.push(h.x,h.y,h.z),h=t.vertices[a.index2],l.push(h.x,h.y,h.z)}else if(t&&t.isBufferGeometry){var v,y,b,x,_,w,S;if(h=new Me,null!==t.index){for(v=t.attributes.position,y=t.index,0===(b=t.groups).length&&(b=[{start:0,count:y.count,materialIndex:0}]),n=0,o=b.length;n<o;++n)for(e=_=(x=b[n]).start,r=_+x.count;e<r;e+=3)for(i=0;i<3;i++)s=y.getX(e+i),c=y.getX(e+(i+1)%3),p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[u=p[0]+","+p[1]]&&(d[u]={index1:p[0],index2:p[1]});for(u in d)a=d[u],h.fromBufferAttribute(v,a.index1),l.push(h.x,h.y,h.z),h.fromBufferAttribute(v,a.index2),l.push(h.x,h.y,h.z)}else for(e=0,r=(v=t.attributes.position).count/3;e<r;e++)for(i=0;i<3;i++)w=3*e+i,h.fromBufferAttribute(v,w),l.push(h.x,h.y,h.z),S=3*e+(i+1)%3,h.fromBufferAttribute(v,S),l.push(h.x,h.y,h.z)}this.addAttribute("position",new qi(l,3))}function on(t,e,i){$i.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i},this.fromBufferGeometry(new an(t,e,i)),this.mergeVertices()}function an(t,e,i){Ki.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:i};var r,n,o=[],a=[],s=[],c=[],u=new Me,h=new Me,l=new Me,p=new Me,d=new Me,f=e+1;for(r=0;r<=i;r++){var m=r/i;for(n=0;n<=e;n++){var g=n/e;h=t(g,m,h),a.push(h.x,h.y,h.z),g-1e-5>=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(r=0;r<i;r++)for(n=0;n<e;n++){var v=r*f+n,y=r*f+n+1,b=(r+1)*f+n+1,x=(r+1)*f+n;o.push(v,y,x),o.push(y,b,x)}this.setIndex(o),this.addAttribute("position",new qi(a,3)),this.addAttribute("normal",new qi(s,3)),this.addAttribute("uv",new qi(c,2))}function sn(t,e,i,r){$i.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},this.fromBufferGeometry(new cn(t,e,i,r)),this.mergeVertices()}function cn(t,e,i,r){Ki.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},i=i||1;var n=[],o=[];function a(t,e,i,r){var n,o,a=Math.pow(2,r),c=[];for(n=0;n<=a;n++){c[n]=[];var u=t.clone().lerp(i,n/a),h=e.clone().lerp(i,n/a),l=a-n;for(o=0;o<=l;o++)c[n][o]=0===o&&n===a?u:u.clone().lerp(h,o/l)}for(n=0;n<a;n++)for(o=0;o<2*(a-n)-1;o++){var p=Math.floor(o/2);o%2===0?(s(c[n][p+1]),s(c[n+1][p]),s(c[n][p])):(s(c[n][p+1]),s(c[n+1][p+1]),s(c[n+1][p]))}}function s(t){n.push(t.x,t.y,t.z)}function c(e,i){var r=3*e;i.x=t[r+0],i.y=t[r+1],i.z=t[r+2]}function u(t,e,i,r){r<0&&1===t.x&&(o[e]=t.x-1),0===i.x&&0===i.z&&(o[e]=r/2/Math.PI+.5)}function h(t){return Math.atan2(t.z,-t.x)}!function(t){for(var i=new Me,r=new Me,n=new Me,o=0;o<e.length;o+=3)c(e[o+0],i),c(e[o+1],r),c(e[o+2],n),a(i,r,n,t)}(r=r||0),function(t){for(var e=new Me,i=0;i<n.length;i+=3)e.x=n[i+0],e.y=n[i+1],e.z=n[i+2],e.normalize().multiplyScalar(t),n[i+0]=e.x,n[i+1]=e.y,n[i+2]=e.z}(i),function(){for(var t=new Me,e=0;e<n.length;e+=3){t.x=n[e+0],t.y=n[e+1],t.z=n[e+2];var i=h(t)/2/Math.PI+.5,r=(a=t,Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5);o.push(i,1-r)}var a;(function(){for(var t=new Me,e=new Me,i=new Me,r=new Me,a=new be,s=new be,c=new be,l=0,p=0;l<n.length;l+=9,p+=6){t.set(n[l+0],n[l+1],n[l+2]),e.set(n[l+3],n[l+4],n[l+5]),i.set(n[l+6],n[l+7],n[l+8]),a.set(o[p+0],o[p+1]),s.set(o[p+2],o[p+3]),c.set(o[p+4],o[p+5]),r.copy(t).add(e).add(i).divideScalar(3);var d=h(r);u(a,p+0,t,d),u(s,p+2,e,d),u(c,p+4,i,d)}})(),function(){for(var t=0;t<o.length;t+=6){var e=o[t+0],i=o[t+2],r=o[t+4],n=Math.max(e,i,r),a=Math.min(e,i,r);n>.9&&a<.1&&(e<.2&&(o[t+0]+=1),i<.2&&(o[t+2]+=1),r<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new qi(n,3)),this.addAttribute("normal",new qi(n.slice(),3)),this.addAttribute("uv",new qi(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function un(t,e){$i.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new hn(t,e)),this.mergeVertices()}function hn(t,e){cn.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ln(t,e){$i.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new pn(t,e)),this.mergeVertices()}function pn(t,e){cn.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function dn(t,e){$i.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new fn(t,e)),this.mergeVertices()}function fn(t,e){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];cn.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function mn(t,e){$i.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new gn(t,e)),this.mergeVertices()}function gn(t,e){var i=(1+Math.sqrt(5))/2,r=1/i,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];cn.call(this,n,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function vn(t,e,i,r,n,o){$i.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new yn(t,e,i,r,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function yn(t,e,i,r,n){Ki.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:n},e=e||64,i=i||1,r=r||8,n=n||!1;var o=t.computeFrenetFrames(e,n);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,c=new Me,u=new Me,h=new be,l=[],p=[],d=[],f=[];function m(n){var a=t.getPointAt(n/e),h=o.normals[n],d=o.binormals[n];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);u.x=g*h.x+m*d.x,u.y=g*h.y+m*d.y,u.z=g*h.z+m*d.z,u.normalize(),p.push(u.x,u.y,u.z),c.x=a.x+i*u.x,c.y=a.y+i*u.y,c.z=a.z+i*u.z,l.push(c.x,c.y,c.z)}}!function(){for(a=0;a<e;a++)m(a);m(!1===n?e:0),function(){for(a=0;a<=e;a++)for(s=0;s<=r;s++)h.x=a/e,h.y=s/r,d.push(h.x,h.y)}(),function(){for(s=1;s<=e;s++)for(a=1;a<=r;a++){var t=(r+1)*(s-1)+(a-1),i=(r+1)*s+(a-1),n=(r+1)*s+a,o=(r+1)*(s-1)+a;f.push(t,i,o),f.push(i,n,o)}}()}(),this.setIndex(f),this.addAttribute("position",new qi(l,3)),this.addAttribute("normal",new qi(p,3)),this.addAttribute("uv",new qi(d,2))}function bn(t,e,i,r,n,o,a){$i.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:n,q:o},void 0!==a&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new xn(t,e,i,r,n,o)),this.mergeVertices()}function xn(t,e,i,r,n,o){Ki.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:n,q:o},t=t||100,e=e||40,i=Math.floor(i)||64,r=Math.floor(r)||8,n=n||2,o=o||3;var a,s,c=[],u=[],h=[],l=[],p=new Me,d=new Me,f=new Me,m=new Me,g=new Me,v=new Me,y=new Me;for(a=0;a<=i;++a){var b=a/i*n*Math.PI*2;for(T(b,n,o,t,f),T(b+.01,n,o,t,m),v.subVectors(m,f),y.addVectors(m,f),g.crossVectors(v,y),y.crossVectors(g,v),g.normalize(),y.normalize(),s=0;s<=r;++s){var x=s/r*Math.PI*2,_=-e*Math.cos(x),w=e*Math.sin(x);p.x=f.x+(_*y.x+w*g.x),p.y=f.y+(_*y.y+w*g.y),p.z=f.z+(_*y.z+w*g.z),u.push(p.x,p.y,p.z),d.subVectors(p,f).normalize(),h.push(d.x,d.y,d.z),l.push(a/i),l.push(s/r)}}for(s=1;s<=i;s++)for(a=1;a<=r;a++){var S=(r+1)*(s-1)+(a-1),A=(r+1)*s+(a-1),M=(r+1)*s+a,P=(r+1)*(s-1)+a;c.push(S,A,P),c.push(A,M,P)}function T(t,e,i,r,n){var o=Math.cos(t),a=Math.sin(t),s=i/e*t,c=Math.cos(s);n.x=r*(2+c)*.5*o,n.y=r*(2+c)*a*.5,n.z=r*Math.sin(s)*.5}this.setIndex(c),this.addAttribute("position",new qi(u,3)),this.addAttribute("normal",new qi(h,3)),this.addAttribute("uv",new qi(l,2))}function _n(t,e,i,r,n){$i.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:n},this.fromBufferGeometry(new wn(t,e,i,r,n)),this.mergeVertices()}function wn(t,e,i,r,n){Ki.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:n},t=t||100,e=e||40,i=Math.floor(i)||8,r=Math.floor(r)||6,n=n||2*Math.PI;var o,a,s=[],c=[],u=[],h=[],l=new Me,p=new Me,d=new Me;for(o=0;o<=i;o++)for(a=0;a<=r;a++){var f=a/r*n,m=o/i*Math.PI*2;p.x=(t+e*Math.cos(m))*Math.cos(f),p.y=(t+e*Math.cos(m))*Math.sin(f),p.z=e*Math.sin(m),c.push(p.x,p.y,p.z),l.x=t*Math.cos(f),l.y=t*Math.sin(f),d.subVectors(p,l).normalize(),u.push(d.x,d.y,d.z),h.push(a/r),h.push(o/i)}for(o=1;o<=i;o++)for(a=1;a<=r;a++){var g=(r+1)*o+a-1,v=(r+1)*(o-1)+a-1,y=(r+1)*(o-1)+a,b=(r+1)*o+a;s.push(g,v,b),s.push(v,y,b)}this.setIndex(s),this.addAttribute("position",new qi(c,3)),this.addAttribute("normal",new qi(u,3)),this.addAttribute("uv",new qi(h,2))}Or.prototype=Object.assign(Object.create(Ui.prototype),{constructor:Or,isArrayCamera:!0}),Br.prototype.isFogExp2=!0,Br.prototype.clone=function(){return new Br(this.color.getHex(),this.density)},Br.prototype.toJSON=function(t){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},zr.prototype.isFog=!0,zr.prototype.clone=function(){return new zr(this.color.getHex(),this.near,this.far)},zr.prototype.toJSON=function(t){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},Ur.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Ur,copy:function(t,e){return Fi.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},toJSON:function(t){var e=Fi.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}),jr.prototype=Object.assign(Object.create(Fi.prototype),{constructor:jr,isLensFlare:!0,copy:function(t){Fi.prototype.copy.call(this,t),this.positionScreen.copy(t.positionScreen),this.customUpdateCallback=t.customUpdateCallback;for(var e=0,i=t.lensFlares.length;e<i;e++)this.lensFlares.push(t.lensFlares[e]);return this},add:function(t,e,i,r,n,o){void 0===e&&(e=-1),void 0===i&&(i=0),void 0===o&&(o=1),void 0===n&&(n=new mi(16777215)),void 0===r&&(r=R),i=Math.min(i,Math.max(0,i)),this.lensFlares.push({texture:t,size:e,distance:i,x:0,y:0,z:0,scale:1,rotation:0,opacity:o,color:n,blending:r})},updateLensFlares:function(){var t,e,i=this.lensFlares.length,r=2*-this.positionScreen.x,n=2*-this.positionScreen.y;for(t=0;t<i;t++)(e=this.lensFlares[t]).x=this.positionScreen.x+r*e.distance,e.y=this.positionScreen.y+n*e.distance,e.wantedRotation=e.x*Math.PI*.25,e.rotation+=.25*(e.wantedRotation-e.rotation)}}),Gr.prototype=Object.create(Ai.prototype),Gr.prototype.constructor=Gr,Gr.prototype.isSpriteMaterial=!0,Gr.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.rotation=t.rotation,this},Vr.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Vr,isSprite:!0,raycast:function(){var t=new Me,e=new Me,i=new Me;return function(r,n){e.setFromMatrixPosition(this.matrixWorld),r.ray.closestPointToPoint(e,t),i.setFromMatrixScale(this.matrixWorld);var o=i.x*i.y/4;if(!(e.distanceToSquared(t)>o)){var a=r.ray.origin.distanceTo(t);a<r.near||a>r.far||n.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),$r.prototype=Object.assign(Object.create(Fi.prototype),{constructor:$r,copy:function(t){Fi.prototype.copy.call(this,t,!1);for(var e=t.levels,i=0,r=e.length;i<r;i++){var n=e[i];this.addLevel(n.object.clone(),n.distance)}return this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var i=this.levels,r=0;r<i.length&&!(e<i[r].distance);r++);i.splice(r,0,{distance:e,object:t}),this.add(t)},getObjectForDistance:function(t){for(var e=this.levels,i=1,r=e.length;i<r&&!(t<e[i].distance);i++);return e[i-1].object},raycast:function(){var t=new Me;return function(e,i){t.setFromMatrixPosition(this.matrixWorld);var r=e.ray.origin.distanceTo(t);this.getObjectForDistance(r).raycast(e,i)}}(),update:function(){var t=new Me,e=new Me;return function(i){var r=this.levels;if(r.length>1){t.setFromMatrixPosition(i.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var n=t.distanceTo(e);r[0].object.visible=!0;for(var o=1,a=r.length;o<a&&n>=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;o<a;o++)r[o].object.visible=!1}}}(),toJSON:function(t){var e=Fi.prototype.toJSON.call(this,t);e.object.levels=[];for(var i=this.levels,r=0,n=i.length;r<n;r++){var o=i[r];e.object.levels.push({object:o.object.uuid,distance:o.distance})}return e}}),Object.assign(Hr.prototype,{calculateInverses:function(){this.boneInverses=[];for(var t=0,e=this.bones.length;t<e;t++){var i=new Pe;this.bones[t]&&i.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(i)}},pose:function(){var t,e,i;for(e=0,i=this.bones.length;e<i;e++)(t=this.bones[e])&&t.matrixWorld.getInverse(this.boneInverses[e]);for(e=0,i=this.bones.length;e<i;e++)(t=this.bones[e])&&(t.parent&&t.parent.isBone?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},update:function(){var t=new Pe,e=new Pe;return function(){for(var i=this.bones,r=this.boneInverses,n=this.boneMatrices,o=this.boneTexture,a=0,s=i.length;a<s;a++){var c=i[a]?i[a].matrixWorld:e;t.multiplyMatrices(c,r[a]),t.toArray(n,16*a)}void 0!==o&&(o.needsUpdate=!0)}}(),clone:function(){return new Hr(this.bones,this.boneInverses)}}),Wr.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Wr,isBone:!0}),Xr.prototype=Object.assign(Object.create(ar.prototype),{constructor:Xr,isSkinnedMesh:!0,initBones:function(){var t,e,i,r,n=[];if(this.geometry&&void 0!==this.geometry.bones){for(i=0,r=this.geometry.bones.length;i<r;i++)e=this.geometry.bones[i],t=new Wr,n.push(t),t.name=e.name,t.position.fromArray(e.pos),t.quaternion.fromArray(e.rotq),void 0!==e.scl&&t.scale.fromArray(e.scl);for(i=0,r=this.geometry.bones.length;i<r;i++)-1!==(e=this.geometry.bones[i]).parent&&null!==e.parent&&void 0!==n[e.parent]?n[e.parent].add(n[i]):this.add(n[i])}return this.updateMatrixWorld(!0),n},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var t,e;if(this.geometry&&this.geometry.isGeometry)for(e=0;e<this.geometry.skinWeights.length;e++){var i=this.geometry.skinWeights[e];(t=1/i.lengthManhattan())!==1/0?i.multiplyScalar(t):i.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){var r=new we,n=this.geometry.attributes.skinWeight;for(e=0;e<n.count;e++)r.x=n.getX(e),r.y=n.getY(e),r.z=n.getZ(e),r.w=n.getW(e),(t=1/r.lengthManhattan())!==1/0?r.multiplyScalar(t):r.set(1,0,0,0),n.setXYZW(e,r.x,r.y,r.z,r.w)}},updateMatrixWorld:function(t){ar.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),qr.prototype=Object.create(Ai.prototype),qr.prototype.constructor=qr,qr.prototype.isLineBasicMaterial=!0,qr.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this},Yr.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Yr,isLine:!0,raycast:function(){var t=new Pe,e=new rr,i=new Ei;return function(r,n){var o=r.linePrecision,a=o*o,s=this.geometry,c=this.matrixWorld;if(null===s.boundingSphere&&s.computeBoundingSphere(),i.copy(s.boundingSphere),i.applyMatrix4(c),!1!==r.ray.intersectsSphere(i)){t.getInverse(c),e.copy(r.ray).applyMatrix4(t);var u=new Me,h=new Me,l=new Me,p=new Me,d=this&&this.isLineSegments?2:1;if(s.isBufferGeometry){var f=s.index,m=s.attributes.position.array;if(null!==f)for(var g=f.array,v=0,y=g.length-1;v<y;v+=d){var b=g[v],x=g[v+1];if(u.fromArray(m,3*b),h.fromArray(m,3*x),!(e.distanceSqToSegment(u,h,p,l)>a))p.applyMatrix4(this.matrixWorld),(S=r.ray.origin.distanceTo(p))<r.near||S>r.far||n.push({distance:S,point:l.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}else for(v=0,y=m.length/3-1;v<y;v+=d){if(u.fromArray(m,3*v),h.fromArray(m,3*v+3),!(e.distanceSqToSegment(u,h,p,l)>a))p.applyMatrix4(this.matrixWorld),(S=r.ray.origin.distanceTo(p))<r.near||S>r.far||n.push({distance:S,point:l.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var _=s.vertices,w=_.length;for(v=0;v<w-1;v+=d){var S;if(!(e.distanceSqToSegment(_[v],_[v+1],p,l)>a))p.applyMatrix4(this.matrixWorld),(S=r.ray.origin.distanceTo(p))<r.near||S>r.far||n.push({distance:S,point:l.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Zr.prototype=Object.assign(Object.create(Yr.prototype),{constructor:Zr,isLineSegments:!0}),Kr.prototype=Object.assign(Object.create(Yr.prototype),{constructor:Kr,isLineLoop:!0}),Qr.prototype=Object.create(Ai.prototype),Qr.prototype.constructor=Qr,Qr.prototype.isPointsMaterial=!0,Qr.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Jr.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Jr,isPoints:!0,raycast:function(){var t=new Pe,e=new rr,i=new Ei;return function(r,n){var o=this,a=this.geometry,s=this.matrixWorld,c=r.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),i.copy(a.boundingSphere),i.applyMatrix4(s),i.radius+=c,!1!==r.ray.intersectsSphere(i)){t.getInverse(s),e.copy(r.ray).applyMatrix4(t);var u=c/((this.scale.x+this.scale.y+this.scale.z)/3),h=u*u,l=new Me;if(a.isBufferGeometry){var p=a.index,d=a.attributes.position.array;if(null!==p)for(var f=p.array,m=0,g=f.length;m<g;m++){var v=f[m];l.fromArray(d,3*v),x(l,v)}else{m=0;for(var y=d.length/3;m<y;m++)l.fromArray(d,3*m),x(l,m)}}else{var b=a.vertices;for(m=0,y=b.length;m<y;m++)x(b[m],m)}}function x(t,i){var a=e.distanceSqToPoint(t);if(a<h){var c=e.closestPointToPoint(t);c.applyMatrix4(s);var u=r.ray.origin.distanceTo(c);if(u<r.near||u>r.far)return;n.push({distance:u,distanceToRay:Math.sqrt(a),point:c.clone(),index:i,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),tn.prototype=Object.assign(Object.create(Fi.prototype),{constructor:tn}),en.prototype=Object.create(_e.prototype),en.prototype.constructor=en,en.prototype.isCompressedTexture=!0,rn.prototype=Object.create(_e.prototype),rn.prototype.constructor=rn,nn.prototype=Object.create(Ki.prototype),nn.prototype.constructor=nn,on.prototype=Object.create($i.prototype),on.prototype.constructor=on,an.prototype=Object.create(Ki.prototype),an.prototype.constructor=an,sn.prototype=Object.create($i.prototype),sn.prototype.constructor=sn,cn.prototype=Object.create(Ki.prototype),cn.prototype.constructor=cn,un.prototype=Object.create($i.prototype),un.prototype.constructor=un,hn.prototype=Object.create(cn.prototype),hn.prototype.constructor=hn,ln.prototype=Object.create($i.prototype),ln.prototype.constructor=ln,pn.prototype=Object.create(cn.prototype),pn.prototype.constructor=pn,dn.prototype=Object.create($i.prototype),dn.prototype.constructor=dn,fn.prototype=Object.create(cn.prototype),fn.prototype.constructor=fn,mn.prototype=Object.create($i.prototype),mn.prototype.constructor=mn,gn.prototype=Object.create(cn.prototype),gn.prototype.constructor=gn,vn.prototype=Object.create($i.prototype),vn.prototype.constructor=vn,yn.prototype=Object.create(Ki.prototype),yn.prototype.constructor=yn,bn.prototype=Object.create($i.prototype),bn.prototype.constructor=bn,xn.prototype=Object.create(Ki.prototype),xn.prototype.constructor=xn,_n.prototype=Object.create($i.prototype),_n.prototype.constructor=_n,wn.prototype=Object.create(Ki.prototype),wn.prototype.constructor=wn;var Sn={area:function(t){for(var e=t.length,i=0,r=e-1,n=0;n<e;r=n++)i+=t[r].x*t[n].y-t[n].x*t[r].y;return.5*i},triangulate:function(){function t(t,e,i,r,n,o){var a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w;if(s=t[o[e]].x,c=t[o[e]].y,u=t[o[i]].x,h=t[o[i]].y,l=t[o[r]].x,(u-s)*((p=t[o[r]].y)-c)-(h-c)*(l-s)<=0)return!1;for(m=l-u,g=p-h,v=s-l,y=c-p,b=u-s,x=h-c,a=0;a<n;a++)if(d=t[o[a]].x,f=t[o[a]].y,!(d===s&&f===c||d===u&&f===h||d===l&&f===p)&&(_=b*(f-c)-x*(d-s),w=v*(f-p)-y*(d-l),m*(f-h)-g*(d-u)>=-Number.EPSILON&&w>=-Number.EPSILON&&_>=-Number.EPSILON))return!1;return!0}return function(e,i){var r=e.length;if(r<3)return null;var n,o,a,s=[],c=[],u=[];if(Sn.area(e)>0)for(o=0;o<r;o++)c[o]=o;else for(o=0;o<r;o++)c[o]=r-1-o;var h=r,l=2*h;for(o=h-1;h>2;){if(l--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?u:s;if(h<=(n=o)&&(n=0),h<=(o=n+1)&&(o=0),h<=(a=o+1)&&(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;g<h;m++,g++)c[m]=c[g];l=2*--h}}return i?u:s}}(),triangulateShape:function(t,e){function i(t){var e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function r(t,e,i){return t.x!==e.x?t.x<e.x?t.x<=i.x&&i.x<=e.x:e.x<=i.x&&i.x<=t.x:t.y<e.y?t.y<=i.y&&i.y<=e.y:e.y<=i.y&&i.y<=t.y}function n(t,e,i,n,o){var a=e.x-t.x,s=e.y-t.y,c=n.x-i.x,u=n.y-i.y,h=t.x-i.x,l=t.y-i.y,p=s*c-a*u,d=s*h-a*l;if(Math.abs(p)>Number.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||d<p)return[];if((f=u*h-c*l)>0||f<p)return[]}if(0===f)return!o||0!==d&&d!==p?[t]:[];if(f===p)return!o||0!==d&&d!==p?[e]:[];if(0===d)return[i];if(d===p)return[n];var m=f/p;return[{x:t.x+m*a,y:t.y+m*s}]}if(0!==d||u*h!==c*l)return[];var g,v,y,b,x,_,w,S,A=0===a&&0===s,M=0===c&&0===u;return A&&M?t.x!==i.x||t.y!==i.y?[]:[t]:A?r(i,n,t)?[t]:[]:M?r(t,e,i)?[i]:[]:(0!==a?(t.x<e.x?(g=t,y=t.x,v=e,b=e.x):(g=e,y=e.x,v=t,b=t.x),i.x<n.x?(x=i,w=i.x,_=n,S=n.x):(x=n,w=n.x,_=i,S=i.x)):(t.y<e.y?(g=t,y=t.y,v=e,b=e.y):(g=e,y=e.y,v=t,b=t.y),i.y<n.y?(x=i,w=i.y,_=n,S=n.y):(x=n,w=n.y,_=i,S=i.y)),y<=w?b<w?[]:b===w?o?[]:[x]:b<=S?[x,v]:[x,_]:y>S?[]:y===S?o?[]:[g]:b<=S?[g,v]:[g,_])}function o(t,e,i,r){var n=e.x-t.x,o=e.y-t.y,a=i.x-t.x,s=i.y-t.y,c=r.x-t.x,u=r.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}i(t),e.forEach(i);for(var a,s,c,u,h,l,p={},d=t.concat(),f=0,m=e.length;f<m;f++)Array.prototype.push.apply(d,e[f]);for(a=0,s=d.length;a<s;a++)void 0!==p[h=d[a].x+":"+d[a].y]&&console.warn("THREE.ShapeUtils: Duplicate point",h,a),p[h]=a;var g=function(t,e){var i,r=t.concat();function a(t,e){var n=r.length-1,a=t-1;a<0&&(a=n);var s=t+1;s>n&&(s=0);var c=o(r[t],r[a],r[s],i[e]);if(!c)return!1;var u=i.length-1,h=e-1;h<0&&(h=u);var l=e+1;return l>u&&(l=0),!!(c=o(i[e],i[h],i[l],r[t]))}function s(t,e){var i,o;for(i=0;i<r.length;i++)if(o=i+1,o%=r.length,n(t,e,r[i],r[o],!0).length>0)return!0;return!1}var c=[];function u(t,i){var r,o,a,s;for(r=0;r<c.length;r++)for(o=e[c[r]],a=0;a<o.length;a++)if(s=a+1,s%=o.length,n(t,i,o[a],o[s],!0).length>0)return!0;return!1}for(var h,l,p,d,f,m,g,v,y,b,x=[],_=0,w=e.length;_<w;_++)c.push(_);for(var S=0,A=2*c.length;c.length>0;){if(--A<0){console.log("Infinite Loop! Holes left:"+c.length+", Probably Hole outside Shape!");break}for(l=S;l<r.length;l++){p=r[l],h=-1;for(_=0;_<c.length;_++)if(f=c[_],void 0===x[m=p.x+":"+p.y+":"+f]){i=e[f];for(var M=0;M<i.length;M++)if(d=i[M],a(l,M)&&!s(p,d)&&!u(p,d)){h=M,c.splice(_,1),g=r.slice(0,l+1),v=r.slice(l),y=i.slice(h),b=i.slice(0,h+1),r=g.concat(y).concat(b).concat(v),S=l;break}if(h>=0)break;x[m]=!0}if(h>=0)break}}return r}(t,e),v=Sn.triangulate(g,!1);for(a=0,s=v.length;a<s;a++)for(u=v[a],c=0;c<3;c++)void 0!==(l=p[h=u[c].x+":"+u[c].y])&&(u[c]=l);return v.concat()},isClockWise:function(t){return Sn.area(t)<0}};function An(t,e){$i.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new Mn(t,e)),this.mergeVertices()}function Mn(t,e){"undefined"!==typeof t&&(Ki.call(this),this.type="ExtrudeBufferGeometry",t=Array.isArray(t)?t:[t],this.addShapeList(t,e),this.computeVertexNormals())}function Pn(t,e){$i.call(this),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new Tn(t,e)),this.mergeVertices()}function Tn(t,e){var i=(e=e||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new $i;var r=i.generateShapes(t,e.size,e.curveSegments);e.amount=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),Mn.call(this,r,e),this.type="TextBufferGeometry"}function En(t,e,i,r,n,o,a){$i.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new Cn(t,e,i,r,n,o,a)),this.mergeVertices()}function Cn(t,e,i,r,n,o,a){Ki.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:a},t=t||50,e=Math.max(3,Math.floor(e)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var s,c,u=(o=void 0!==o?o:0)+(a=void 0!==a?a:Math.PI),h=0,l=[],p=new Me,d=new Me,f=[],m=[],g=[],v=[];for(c=0;c<=i;c++){var y=[],b=c/i;for(s=0;s<=e;s++){var x=s/e;p.x=-t*Math.cos(r+x*n)*Math.sin(o+b*a),p.y=t*Math.cos(o+b*a),p.z=t*Math.sin(r+x*n)*Math.sin(o+b*a),m.push(p.x,p.y,p.z),d.set(p.x,p.y,p.z).normalize(),g.push(d.x,d.y,d.z),v.push(x,1-b),y.push(h++)}l.push(y)}for(c=0;c<i;c++)for(s=0;s<e;s++){var _=l[c][s+1],w=l[c][s],S=l[c+1][s],A=l[c+1][s+1];(0!==c||o>0)&&f.push(_,w,A),(c!==i-1||u<Math.PI)&&f.push(w,S,A)}this.setIndex(f),this.addAttribute("position",new qi(m,3)),this.addAttribute("normal",new qi(g,3)),this.addAttribute("uv",new qi(v,2))}function In(t,e,i,r,n,o){$i.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},this.fromBufferGeometry(new Rn(t,e,i,r,n,o)),this.mergeVertices()}function Rn(t,e,i,r,n,o){Ki.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},t=t||20,e=e||50,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,i=void 0!==i?Math.max(3,i):8;var a,s,c,u=[],h=[],l=[],p=[],d=t,f=(e-t)/(r=void 0!==r?Math.max(1,r):1),m=new Me,g=new be;for(s=0;s<=r;s++){for(c=0;c<=i;c++)a=n+c/i*o,m.x=d*Math.cos(a),m.y=d*Math.sin(a),h.push(m.x,m.y,m.z),l.push(0,0,1),g.x=(m.x/e+1)/2,g.y=(m.y/e+1)/2,p.push(g.x,g.y);d+=f}for(s=0;s<r;s++){var v=s*(i+1);for(c=0;c<i;c++){var y=a=c+v,b=a+i+1,x=a+i+2,_=a+1;u.push(y,b,_),u.push(b,x,_)}}this.setIndex(u),this.addAttribute("position",new qi(h,3)),this.addAttribute("normal",new qi(l,3)),this.addAttribute("uv",new qi(p,2))}function Ln(t,e,i,r){$i.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},this.fromBufferGeometry(new On(t,e,i,r)),this.mergeVertices()}function On(t,e,i,r){Ki.call(this),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},e=Math.floor(e)||12,i=i||0,r=r||2*Math.PI,r=ye.clamp(r,0,2*Math.PI);var n,o,a,s=[],c=[],u=[],h=1/e,l=new Me,p=new be;for(o=0;o<=e;o++){var d=i+o*h*r,f=Math.sin(d),m=Math.cos(d);for(a=0;a<=t.length-1;a++)l.x=t[a].x*f,l.y=t[a].y,l.z=t[a].x*m,c.push(l.x,l.y,l.z),p.x=o/e,p.y=a/(t.length-1),u.push(p.x,p.y)}for(o=0;o<e;o++)for(a=0;a<t.length-1;a++){var g=n=a+o*t.length,v=n+t.length,y=n+t.length+1,b=n+1;s.push(g,v,b),s.push(v,y,b)}if(this.setIndex(s),this.addAttribute("position",new qi(c,3)),this.addAttribute("uv",new qi(u,2)),this.computeVertexNormals(),r===2*Math.PI){var x=this.attributes.normal.array,_=new Me,w=new Me,S=new Me;for(n=e*t.length*3,o=0,a=0;o<t.length;o++,a+=3)_.x=x[a+0],_.y=x[a+1],_.z=x[a+2],w.x=x[n+a+0],w.y=x[n+a+1],w.z=x[n+a+2],S.addVectors(_,w).normalize(),x[a+0]=x[n+a+0]=S.x,x[a+1]=x[n+a+1]=S.y,x[a+2]=x[n+a+2]=S.z}}function Nn(t,e){$i.call(this),this.type="ShapeGeometry","object"===typeof e&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new Dn(t,e)),this.mergeVertices()}function Dn(t,e){Ki.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:e},e=e||12;var i=[],r=[],n=[],o=[],a=0,s=0;if(!1===Array.isArray(t))u(t);else for(var c=0;c<t.length;c++)u(t[c]),this.addGroup(a,s,c),a+=s,s=0;function u(t){var a,c,u,h=r.length/3,l=t.extractPoints(e),p=l.shape,d=l.holes;if(!1===Sn.isClockWise(p))for(p=p.reverse(),a=0,c=d.length;a<c;a++)u=d[a],!0===Sn.isClockWise(u)&&(d[a]=u.reverse());var f=Sn.triangulateShape(p,d);for(a=0,c=d.length;a<c;a++)u=d[a],p=p.concat(u);for(a=0,c=p.length;a<c;a++){var m=p[a];r.push(m.x,m.y,0),n.push(0,0,1),o.push(m.x,m.y)}for(a=0,c=f.length;a<c;a++){var g=f[a],v=g[0]+h,y=g[1]+h,b=g[2]+h;i.push(v,y,b),s+=3}}this.setIndex(i),this.addAttribute("position",new qi(r,3)),this.addAttribute("normal",new qi(n,3)),this.addAttribute("uv",new qi(o,2))}function kn(t,e){Ki.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1;var i,r,n,o,a=[],s=Math.cos(ye.DEG2RAD*e),c=[0,0],u={},h=["a","b","c"];t.isBufferGeometry?(o=new $i).fromBufferGeometry(t):o=t.clone(),o.mergeVertices(),o.computeFaceNormals();for(var l=o.vertices,p=o.faces,d=0,f=p.length;d<f;d++)for(var m=p[d],g=0;g<3;g++)i=m[h[g]],r=m[h[(g+1)%3]],c[0]=Math.min(i,r),c[1]=Math.max(i,r),void 0===u[n=c[0]+","+c[1]]?u[n]={index1:c[0],index2:c[1],face1:d,face2:void 0}:u[n].face2=d;for(n in u){var v=u[n];if(void 0===v.face2||p[v.face1].normal.dot(p[v.face2].normal)<=s){var y=l[v.index1];a.push(y.x,y.y,y.z),y=l[v.index2],a.push(y.x,y.y,y.z)}}this.addAttribute("position",new qi(a,3))}function Fn(t,e,i,r,n,o,a,s){$i.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new Bn(t,e,i,r,n,o,a,s)),this.mergeVertices()}function Bn(t,e,i,r,n,o,a,s){Ki.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s};var c=this;t=void 0!==t?t:20,e=void 0!==e?e:20,i=void 0!==i?i:100,r=Math.floor(r)||8,n=Math.floor(n)||1,o=void 0!==o&&o,a=void 0!==a?a:0,s=void 0!==s?s:2*Math.PI;var u=[],h=[],l=[],p=[],d=0,f=[],m=i/2,g=0;function v(i){var n,o,f,v=new be,y=new Me,b=0,x=!0===i?t:e,_=!0===i?1:-1;for(o=d,n=1;n<=r;n++)h.push(0,m*_,0),l.push(0,_,0),p.push(.5,.5),d++;for(f=d,n=0;n<=r;n++){var w=n/r*s+a,S=Math.cos(w),A=Math.sin(w);y.x=x*A,y.y=m*_,y.z=x*S,h.push(y.x,y.y,y.z),l.push(0,_,0),v.x=.5*S+.5,v.y=.5*A*_+.5,p.push(v.x,v.y),d++}for(n=0;n<r;n++){var M=o+n,P=f+n;!0===i?u.push(P,P+1,M):u.push(P+1,P,M),b+=3}c.addGroup(g,b,!0===i?1:2),g+=b}!function(){var o,v,y=new Me,b=new Me,x=0,_=(e-t)/i;for(v=0;v<=n;v++){var w=[],S=v/n,A=S*(e-t)+t;for(o=0;o<=r;o++){var M=o/r,P=M*s+a,T=Math.sin(P),E=Math.cos(P);b.x=A*T,b.y=-S*i+m,b.z=A*E,h.push(b.x,b.y,b.z),y.set(T,_,E).normalize(),l.push(y.x,y.y,y.z),p.push(M,1-S),w.push(d++)}f.push(w)}for(o=0;o<r;o++)for(v=0;v<n;v++){var C=f[v][o],I=f[v+1][o],R=f[v+1][o+1],L=f[v][o+1];u.push(C,I,L),u.push(I,R,L),x+=6}c.addGroup(g,x,0),g+=x}(),!1===o&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.addAttribute("position",new qi(h,3)),this.addAttribute("normal",new qi(l,3)),this.addAttribute("uv",new qi(p,2))}function zn(t,e,i,r,n,o,a){Fn.call(this,0,t,e,i,r,n,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function Un(t,e,i,r,n,o,a){Bn.call(this,0,t,e,i,r,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function jn(t,e,i,r){$i.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new Gn(t,e,i,r)),this.mergeVertices()}function Gn(t,e,i,r){Ki.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},t=t||50,e=void 0!==e?Math.max(3,e):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,o,a=[],s=[],c=[],u=[],h=new Me,l=new be;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 p=i+o/e*r;h.x=t*Math.cos(p),h.y=t*Math.sin(p),s.push(h.x,h.y,h.z),c.push(0,0,1),l.x=(s[n]/t+1)/2,l.y=(s[n+1]/t+1)/2,u.push(l.x,l.y)}for(n=1;n<=e;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new qi(s,3)),this.addAttribute("normal",new qi(c,3)),this.addAttribute("uv",new qi(u,2))}An.prototype=Object.create($i.prototype),An.prototype.constructor=An,Mn.prototype=Object.create(Ki.prototype),Mn.prototype.constructor=Mn,Mn.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],i=this.getAttribute("uv"),r=i?Array.prototype.slice.call(i.array):[],n=this.index;return{position:e,uv:r,index:n?Array.prototype.slice.call(n.array):[]}},Mn.prototype.addShapeList=function(t,e){var i=t.length;e.arrays=this.getArrays();for(var r=0;r<i;r++){var n=t[r];this.addShape(n,e)}this.setIndex(e.arrays.index),this.addAttribute("position",new qi(e.arrays.position,3)),this.addAttribute("uv",new qi(e.arrays.uv,2))},Mn.prototype.addShape=function(t,e){var i,r,n,o,a,s,c,u,h=e.arrays?e.arrays:this.getArrays(),l=h.position,p=h.index,d=h.uv,f=[],m=void 0!==e.amount?e.amount:100,g=void 0!==e.bevelThickness?e.bevelThickness:6,v=void 0!==e.bevelSize?e.bevelSize:g-2,y=void 0!==e.bevelSegments?e.bevelSegments:3,b=void 0===e.bevelEnabled||e.bevelEnabled,x=void 0!==e.curveSegments?e.curveSegments:12,_=void 0!==e.steps?e.steps:1,w=e.extrudePath,S=!1,A=void 0!==e.UVGenerator?e.UVGenerator:An.WorldUVGenerator;w&&(i=w.getSpacedPoints(_),S=!0,b=!1,r=void 0!==e.frames?e.frames:w.computeFrenetFrames(_,!1),n=new Me,o=new Me,a=new Me),b||(y=0,g=0,v=0);var M=this,P=t.extractPoints(x),T=P.shape,E=P.holes;if(!Sn.isClockWise(T))for(T=T.reverse(),c=0,u=E.length;c<u;c++)s=E[c],Sn.isClockWise(s)&&(E[c]=s.reverse());var C=Sn.triangulateShape(T,E),I=T;for(c=0,u=E.length;c<u;c++)s=E[c],T=T.concat(s);function R(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}var L,O,N,D,k,F,B=T.length,z=C.length;function U(t,e,i){var r,n,o,a=t.x-e.x,s=t.y-e.y,c=i.x-t.x,u=i.y-t.y,h=a*a+s*s,l=a*u-s*c;if(Math.abs(l)>Number.EPSILON){var p=Math.sqrt(h),d=Math.sqrt(c*c+u*u),f=e.x-s/p,m=e.y+a/p,g=((i.x-u/d-f)*u-(i.y+c/d-m)*c)/(a*u-s*c),v=(r=f+a*g-t.x)*r+(n=m+s*g-t.y)*n;if(v<=2)return new be(r,n);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?c>Number.EPSILON&&(y=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(u)&&(y=!0),y?(r=-s,n=a,o=Math.sqrt(h)):(r=a,n=s,o=Math.sqrt(h/2))}return new be(r/o,n/o)}for(var j=[],G=0,V=I.length,$=V-1,H=G+1;G<V;G++,$++,H++)$===V&&($=0),H===V&&(H=0),j[G]=U(I[G],I[$],I[H]);var W,X,q=[],Y=j.concat();for(c=0,u=E.length;c<u;c++){for(s=E[c],W=[],G=0,$=(V=s.length)-1,H=G+1;G<V;G++,$++,H++)$===V&&($=0),H===V&&(H=0),W[G]=U(s[G],s[$],s[H]);q.push(W),Y=Y.concat(W)}for(L=0;L<y;L++){for(N=L/y,D=g*Math.cos(N*Math.PI/2),O=v*Math.sin(N*Math.PI/2),G=0,V=I.length;G<V;G++)K((k=R(I[G],j[G],O)).x,k.y,-D);for(c=0,u=E.length;c<u;c++)for(s=E[c],W=q[c],G=0,V=s.length;G<V;G++)K((k=R(s[G],W[G],O)).x,k.y,-D)}for(O=v,G=0;G<B;G++)k=b?R(T[G],Y[G],O):T[G],S?(o.copy(r.normals[0]).multiplyScalar(k.x),n.copy(r.binormals[0]).multiplyScalar(k.y),a.copy(i[0]).add(o).add(n),K(a.x,a.y,a.z)):K(k.x,k.y,0);for(X=1;X<=_;X++)for(G=0;G<B;G++)k=b?R(T[G],Y[G],O):T[G],S?(o.copy(r.normals[X]).multiplyScalar(k.x),n.copy(r.binormals[X]).multiplyScalar(k.y),a.copy(i[X]).add(o).add(n),K(a.x,a.y,a.z)):K(k.x,k.y,m/_*X);for(L=y-1;L>=0;L--){for(N=L/y,D=g*Math.cos(N*Math.PI/2),O=v*Math.sin(N*Math.PI/2),G=0,V=I.length;G<V;G++)K((k=R(I[G],j[G],O)).x,k.y,m+D);for(c=0,u=E.length;c<u;c++)for(s=E[c],W=q[c],G=0,V=s.length;G<V;G++)k=R(s[G],W[G],O),S?K(k.x,k.y+i[_-1].y,i[_-1].x+D):K(k.x,k.y,m+D)}function Z(t,e){var i,r;for(G=t.length;--G>=0;){i=G,(r=G-1)<0&&(r=t.length-1);var n=0,o=_+2*y;for(n=0;n<o;n++){var a=B*n,s=B*(n+1);J(e+i+a,e+r+a,e+r+s,e+i+s,t,n,o,i,r)}}}function K(t,e,i){f.push(t),f.push(e),f.push(i)}function Q(t,e,i){tt(t),tt(e),tt(i);var r=l.length/3,n=A.generateTopUV(M,l,r-3,r-2,r-1);et(n[0]),et(n[1]),et(n[2])}function J(t,e,i,r,n,o,a,s,c){tt(t),tt(e),tt(r),tt(e),tt(i),tt(r);var u=l.length/3,h=A.generateSideWallUV(M,l,u-6,u-3,u-2,u-1);et(h[0]),et(h[1]),et(h[3]),et(h[1]),et(h[2]),et(h[3])}function tt(t){p.push(l.length/3),l.push(f[3*t+0]),l.push(f[3*t+1]),l.push(f[3*t+2])}function et(t){d.push(t.x),d.push(t.y)}!function(){var t=l.length/3;if(b){var i=0,r=B*i;for(G=0;G<z;G++)Q((F=C[G])[2]+r,F[1]+r,F[0]+r);for(r=B*(i=_+2*y),G=0;G<z;G++)Q((F=C[G])[0]+r,F[1]+r,F[2]+r)}else{for(G=0;G<z;G++)Q((F=C[G])[2],F[1],F[0]);for(G=0;G<z;G++)Q((F=C[G])[0]+B*_,F[1]+B*_,F[2]+B*_)}M.addGroup(t,l.length/3-t,void 0!==e.material?e.material:0)}(),function(){var t=l.length/3,i=0;for(Z(I,i),i+=I.length,c=0,u=E.length;c<u;c++)Z(s=E[c],i),i+=s.length;M.addGroup(t,l.length/3-t,void 0!==e.extrudeMaterial?e.extrudeMaterial:1)}(),e.arrays||(this.setIndex(p),this.addAttribute("position",new qi(l,3)),this.addAttribute("uv",new qi(e.arrays.uv,2)))},An.WorldUVGenerator={generateTopUV:function(t,e,i,r,n){var o=e[3*i],a=e[3*i+1],s=e[3*r],c=e[3*r+1],u=e[3*n],h=e[3*n+1];return[new be(o,a),new be(s,c),new be(u,h)]},generateSideWallUV:function(t,e,i,r,n,o){var a=e[3*i],s=e[3*i+1],c=e[3*i+2],u=e[3*r],h=e[3*r+1],l=e[3*r+2],p=e[3*n],d=e[3*n+1],f=e[3*n+2],m=e[3*o],g=e[3*o+1],v=e[3*o+2];return Math.abs(s-h)<.01?[new be(a,1-c),new be(u,1-l),new be(p,1-f),new be(m,1-v)]:[new be(s,1-c),new be(h,1-l),new be(d,1-f),new be(g,1-v)]}},Pn.prototype=Object.create($i.prototype),Pn.prototype.constructor=Pn,Tn.prototype=Object.create(Mn.prototype),Tn.prototype.constructor=Tn,En.prototype=Object.create($i.prototype),En.prototype.constructor=En,Cn.prototype=Object.create(Ki.prototype),Cn.prototype.constructor=Cn,In.prototype=Object.create($i.prototype),In.prototype.constructor=In,Rn.prototype=Object.create(Ki.prototype),Rn.prototype.constructor=Rn,Ln.prototype=Object.create($i.prototype),Ln.prototype.constructor=Ln,On.prototype=Object.create(Ki.prototype),On.prototype.constructor=On,Nn.prototype=Object.create($i.prototype),Nn.prototype.constructor=Nn,Dn.prototype=Object.create(Ki.prototype),Dn.prototype.constructor=Dn,kn.prototype=Object.create(Ki.prototype),kn.prototype.constructor=kn,Fn.prototype=Object.create($i.prototype),Fn.prototype.constructor=Fn,Bn.prototype=Object.create(Ki.prototype),Bn.prototype.constructor=Bn,zn.prototype=Object.create(Fn.prototype),zn.prototype.constructor=zn,Un.prototype=Object.create(Bn.prototype),Un.prototype.constructor=Un,jn.prototype=Object.create($i.prototype),jn.prototype.constructor=jn,Gn.prototype=Object.create(Ki.prototype),Gn.prototype.constructor=Gn;var Vn=Object.freeze({WireframeGeometry:nn,ParametricGeometry:on,ParametricBufferGeometry:an,TetrahedronGeometry:un,TetrahedronBufferGeometry:hn,OctahedronGeometry:ln,OctahedronBufferGeometry:pn,IcosahedronGeometry:dn,IcosahedronBufferGeometry:fn,DodecahedronGeometry:mn,DodecahedronBufferGeometry:gn,PolyhedronGeometry:sn,PolyhedronBufferGeometry:cn,TubeGeometry:vn,TubeBufferGeometry:yn,TorusKnotGeometry:bn,TorusKnotBufferGeometry:xn,TorusGeometry:_n,TorusBufferGeometry:wn,TextGeometry:Pn,TextBufferGeometry:Tn,SphereGeometry:En,SphereBufferGeometry:Cn,RingGeometry:In,RingBufferGeometry:Rn,PlaneGeometry:tr,PlaneBufferGeometry:er,LatheGeometry:Ln,LatheBufferGeometry:On,ShapeGeometry:Nn,ShapeBufferGeometry:Dn,ExtrudeGeometry:An,ExtrudeBufferGeometry:Mn,EdgesGeometry:kn,ConeGeometry:zn,ConeBufferGeometry:Un,CylinderGeometry:Fn,CylinderBufferGeometry:Bn,CircleGeometry:jn,CircleBufferGeometry:Gn,BoxGeometry:Qi,BoxBufferGeometry:Ji});function $n(t){Mi.call(this,{uniforms:vi.merge([gi.lights,{opacity:{value:1}}]),vertexShader:yi.shadow_vert,fragmentShader:yi.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}}}),this.setValues(t)}function Hn(t){Mi.call(this,t),this.type="RawShaderMaterial"}function Wn(t){Ai.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new mi(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 mi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new be(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 Xn(t){Wn.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function qn(t){Ai.call(this),this.type="MeshPhongMaterial",this.color=new mi(16777215),this.specular=new mi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=at,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 Yn(t){qn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Zn(t){Ai.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new be(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 Kn(t){Ai.call(this),this.type="MeshLambertMaterial",this.color=new mi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=at,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 Qn(t){Ai.call(this),this.type="LineDashedMaterial",this.color=new mi(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(t)}$n.prototype=Object.create(Mi.prototype),$n.prototype.constructor=$n,$n.prototype.isShadowMaterial=!0,Hn.prototype=Object.create(Mi.prototype),Hn.prototype.constructor=Hn,Hn.prototype.isRawShaderMaterial=!0,Wn.prototype=Object.create(Ai.prototype),Wn.prototype.constructor=Wn,Wn.prototype.isMeshStandardMaterial=!0,Wn.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Xn.prototype=Object.create(Wn.prototype),Xn.prototype.constructor=Xn,Xn.prototype.isMeshPhysicalMaterial=!0,Xn.prototype.copy=function(t){return Wn.prototype.copy.call(this,t),this.defines={PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearCoat=t.clearCoat,this.clearCoatRoughness=t.clearCoatRoughness,this},qn.prototype=Object.create(Ai.prototype),qn.prototype.constructor=qn,qn.prototype.isMeshPhongMaterial=!0,qn.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Yn.prototype=Object.create(qn.prototype),Yn.prototype.constructor=Yn,Yn.prototype.isMeshToonMaterial=!0,Yn.prototype.copy=function(t){return qn.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Zn.prototype=Object.create(Ai.prototype),Zn.prototype.constructor=Zn,Zn.prototype.isMeshNormalMaterial=!0,Zn.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Kn.prototype=Object.create(Ai.prototype),Kn.prototype.constructor=Kn,Kn.prototype.isMeshLambertMaterial=!0,Kn.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Qn.prototype=Object.create(Ai.prototype),Qn.prototype.constructor=Qn,Qn.prototype.isLineDashedMaterial=!0,Qn.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Jn=Object.freeze({ShadowMaterial:$n,SpriteMaterial:Gr,RawShaderMaterial:Hn,ShaderMaterial:Mi,PointsMaterial:Qr,MeshPhysicalMaterial:Xn,MeshStandardMaterial:Wn,MeshPhongMaterial:qn,MeshToonMaterial:Yn,MeshNormalMaterial:Zn,MeshLambertMaterial:Kn,MeshDepthMaterial:Pi,MeshBasicMaterial:ir,LineDashedMaterial:Qn,LineBasicMaterial:qr,Material:Ai}),to={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function eo(t,e,i){var r=this,n=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){a++,!1===n&&void 0!==r.onStart&&r.onStart(t,o,a),n=!0},this.itemEnd=function(t){o++,void 0!==r.onProgress&&r.onProgress(t,o,a),o===a&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)}}var io=new eo;function ro(t){this.manager=void 0!==t?t:io}function no(t){this.manager=void 0!==t?t:io}function oo(t){this.manager=void 0!==t?t:io}function ao(t,e){Fi.call(this),this.type="Light",this.color=new mi(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function so(t,e,i){ao.call(this,t,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(Fi.DefaultUp),this.updateMatrix(),this.groundColor=new mi(e)}function co(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new be(512,512),this.map=null,this.matrix=new Pe}function uo(){co.call(this,new Ui(50,1,.5,500))}function ho(t,e,i,r,n,o){ao.call(this,t,e),this.type="SpotLight",this.position.copy(Fi.DefaultUp),this.updateMatrix(),this.target=new Fi,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new uo}function lo(t,e,i,r){ao.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!==i?i:0,this.decay=void 0!==r?r:1,this.shadow=new co(new Ui(90,1,.5,500))}function po(){co.call(this,new zi(-5,5,5,-5,.5,500))}function fo(t,e){ao.call(this,t,e),this.type="DirectionalLight",this.position.copy(Fi.DefaultUp),this.updateMatrix(),this.target=new Fi,this.shadow=new po}function mo(t,e){ao.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function go(t,e,i,r){ao.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==i?i:10,this.height=void 0!==r?r:10}Object.assign(ro.prototype,{load:function(t,e,i,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var n=this,o=to.get(t);if(void 0!==o)return n.manager.itemStart(t),setTimeout(function(){e&&e(o),n.manager.itemEnd(t)},0),o;var a=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(a){var s=a[1],c=!!a[2],u=a[3];u=window.decodeURIComponent(u),c&&(u=window.atob(u));try{var h,l=(this.responseType||"").toLowerCase();switch(l){case"arraybuffer":case"blob":h=new ArrayBuffer(u.length);for(var p=new Uint8Array(h),d=0;d<u.length;d++)p[d]=u.charCodeAt(d);"blob"===l&&(h=new Blob([h],{type:s}));break;case"document":var f=new DOMParser;h=f.parseFromString(u,s);break;case"json":h=JSON.parse(u);break;default:h=u}window.setTimeout(function(){e&&e(h),n.manager.itemEnd(t)},0)}catch(v){window.setTimeout(function(){r&&r(v),n.manager.itemEnd(t),n.manager.itemError(t)},0)}}else{var m=new XMLHttpRequest;for(var g in m.open("GET",t,!0),m.addEventListener("load",function(i){var o=i.target.response;to.add(t,o),200===this.status?(e&&e(o),n.manager.itemEnd(t)):0===this.status?(console.warn("THREE.FileLoader: HTTP Status 0 received."),e&&e(o),n.manager.itemEnd(t)):(r&&r(i),n.manager.itemEnd(t),n.manager.itemError(t))},!1),void 0!==i&&m.addEventListener("progress",function(t){i(t)},!1),m.addEventListener("error",function(e){r&&r(e),n.manager.itemEnd(t),n.manager.itemError(t)},!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)m.setRequestHeader(g,this.requestHeader[g]);m.send(null)}return n.manager.itemStart(t),m},setPath:function(t){return this.path=t,this},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),Object.assign(function(t){this.manager=void 0!==t?t:io,this._parser=null}.prototype,{load:function(t,e,i,r){var n=this,o=[],a=new en;a.image=o;var s=new ro(this.manager);function c(c){s.load(t[c],function(t){var i=n._parser(t,!0);o[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},6===(u+=1)&&(1===i.mipmapCount&&(a.minFilter=Tt),a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,r)}if(s.setPath(this.path),s.setResponseType("arraybuffer"),Array.isArray(t))for(var u=0,h=0,l=t.length;h<l;++h)c(h);else s.load(t,function(t){var i=n._parser(t,!0);if(i.isCubemap)for(var r=i.mipmaps.length/i.mipmapCount,s=0;s<r;s++){o[s]={mipmaps:[]};for(var c=0;c<i.mipmapCount;c++)o[s].mipmaps.push(i.mipmaps[s*i.mipmapCount+c]),o[s].format=i.format,o[s].width=i.width,o[s].height=i.height}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=Tt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,r);return a},setPath:function(t){return this.path=t,this}}),Object.assign(function(t){this.manager=void 0!==t?t:io,this._parser=null}.prototype,{load:function(t,e,i,r){var n=this,o=new Te,a=new ro(this.manager);return a.setResponseType("arraybuffer"),a.load(t,function(t){var i=n._parser(t);i&&(void 0!==i.image?o.image=i.image:void 0!==i.data&&(o.image.width=i.width,o.image.height=i.height,o.image.data=i.data),o.wrapS=void 0!==i.wrapS?i.wrapS:wt,o.wrapT=void 0!==i.wrapT?i.wrapT:wt,o.magFilter=void 0!==i.magFilter?i.magFilter:Tt,o.minFilter=void 0!==i.minFilter?i.minFilter:Ct,o.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.format&&(o.format=i.format),void 0!==i.type&&(o.type=i.type),void 0!==i.mipmaps&&(o.mipmaps=i.mipmaps),1===i.mipmapCount&&(o.minFilter=Tt),o.needsUpdate=!0,e&&e(o,i))},i,r),o}}),Object.assign(no.prototype,{load:function(t,e,i,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var n=this,o=to.get(t);if(void 0!==o)return n.manager.itemStart(t),setTimeout(function(){e&&e(o),n.manager.itemEnd(t)},0),o;var a=document.createElementNS("http://www.w3.org/1999/xhtml","img");return a.addEventListener("load",function(){to.add(t,this),e&&e(this),n.manager.itemEnd(t)},!1),a.addEventListener("error",function(e){r&&r(e),n.manager.itemEnd(t),n.manager.itemError(t)},!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),n.manager.itemStart(t),a.src=t,a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(function(t){this.manager=void 0!==t?t:io}.prototype,{load:function(t,e,i,r){var n=new Ee,o=new no(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);var a=0;function s(i){o.load(t[i],function(t){n.images[i]=t,6===++a&&(n.needsUpdate=!0,e&&e(n))},void 0,r)}for(var c=0;c<t.length;++c)s(c);return n},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(oo.prototype,{load:function(t,e,i,r){var n=new no(this.manager);n.setCrossOrigin(this.crossOrigin),n.setPath(this.path);var o=new _e;return o.image=n.load(t,function(){var i=t.search(/\.(jpg|jpeg)$/)>0||0===t.search(/^data\:image\/jpeg/);o.format=i?Vt:$t,o.needsUpdate=!0,void 0!==e&&e(o)},i,r),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),ao.prototype=Object.assign(Object.create(Fi.prototype),{constructor:ao,isLight:!0,copy:function(t){return Fi.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Fi.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}}),so.prototype=Object.assign(Object.create(ao.prototype),{constructor:so,isHemisphereLight:!0,copy:function(t){return ao.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(co.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}}),uo.prototype=Object.assign(Object.create(co.prototype),{constructor:uo,isSpotLightShadow:!0,update:function(t){var e=this.camera,i=2*ye.RAD2DEG*t.angle,r=this.mapSize.width/this.mapSize.height,n=t.distance||e.far;i===e.fov&&r===e.aspect&&n===e.far||(e.fov=i,e.aspect=r,e.far=n,e.updateProjectionMatrix())}}),ho.prototype=Object.assign(Object.create(ao.prototype),{constructor:ho,isSpotLight:!0,copy:function(t){return ao.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}}),lo.prototype=Object.assign(Object.create(ao.prototype),{constructor:lo,isPointLight:!0,copy:function(t){return ao.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),po.prototype=Object.assign(Object.create(co.prototype),{constructor:po}),fo.prototype=Object.assign(Object.create(ao.prototype),{constructor:fo,isDirectionalLight:!0,copy:function(t){return ao.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),mo.prototype=Object.assign(Object.create(ao.prototype),{constructor:mo,isAmbientLight:!0}),go.prototype=Object.assign(Object.create(ao.prototype),{constructor:go,isRectAreaLight:!0,copy:function(t){return ao.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=ao.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var vo,yo={arraySlice:function(t,e,i){return yo.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&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,i=new Array(e),r=0;r!==e;++r)i[r]=r;return i.sort(function(e,i){return t[e]-t[i]}),i},sortedArray:function(t,e,i){for(var r=t.length,n=new t.constructor(r),o=0,a=0;a!==r;++o)for(var s=i[o]*e,c=0;c!==e;++c)n[a++]=t[s+c];return n},flattenJSON:function(t,e,i,r){for(var n=1,o=t[0];void 0!==o&&void 0===o[r];)o=t[n++];if(void 0!==o){var a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(e.push(o.time),i.push.apply(i,a)),o=t[n++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(e.push(o.time),a.toArray(i,i.length)),o=t[n++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(e.push(o.time),i.push(a)),o=t[n++]}while(void 0!==o)}}};function bo(t,e,i,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function xo(t,e,i,r){bo.call(this,t,e,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function _o(t,e,i,r){bo.call(this,t,e,i,r)}function wo(t,e,i,r){bo.call(this,t,e,i,r)}function So(t,e,i,r){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=yo.convertArray(e,this.TimeBufferType),this.values=yo.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()}function Ao(t,e,i,r){So.call(this,t,e,i,r)}function Mo(t,e,i,r){bo.call(this,t,e,i,r)}function Po(t,e,i,r){So.call(this,t,e,i,r)}function To(t,e,i,r){So.call(this,t,e,i,r)}function Eo(t,e,i,r){So.call(this,t,e,i,r)}function Co(t,e,i){So.call(this,t,e,i)}function Io(t,e,i,r){So.call(this,t,e,i,r)}function Ro(t,e,i,r){So.apply(this,arguments)}function Lo(t,e,i){this.name=t,this.tracks=i,this.duration=void 0!==e?e:-1,this.uuid=ye.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Oo(t){this.manager=void 0!==t?t:io,this.textures={}}function No(t){this.manager=void 0!==t?t:io}Object.assign(bo.prototype,{evaluate:function(t){var e=this.parameterPositions,i=this._cachedIndex,r=e[i],n=e[i-1];t:{e:{var o;i:{r:if(!(t<r)){for(var a=i+2;;){if(void 0===r){if(t<n)break r;return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,t,n)}if(i===a)break;if(n=r,t<(r=e[++i]))break e}o=e.length;break i}if(t>=n)break t;var s=e[1];t<s&&(i=2,n=s);for(a=i-2;;){if(void 0===n)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(i===a)break;if(r=n,t>=(n=e[--i-1]))break e}o=i,i=0}for(;i<o;){var c=i+o>>>1;t<e[c]?o=c:i=c+1}if(r=e[i],void 0===(n=e[i-1]))return this._cachedIndex=0,this.beforeStart_(0,t,r);if(void 0===r)return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,n,t)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,t,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=t*r,o=0;o!==r;++o)e[o]=i[n+o];return e},interpolate_:function(t,e,i,r){throw new Error("call to abstract method")},intervalChanged_:function(t,e,i){}}),Object.assign(bo.prototype,{beforeStart_:bo.prototype.copySampleValue_,afterEnd_:bo.prototype.copySampleValue_}),xo.prototype=Object.assign(Object.create(bo.prototype),{constructor:xo,DefaultSettings_:{endingStart:oe,endingEnd:oe},intervalChanged_:function(t,e,i){var r=this.parameterPositions,n=t-2,o=t+1,a=r[n],s=r[o];if(void 0===a)switch(this.getSettings_().endingStart){case 2401:n=t,a=2*e-i;break;case 2402:a=e+r[n=r.length-2]-r[n+1];break;default:n=t,a=i}if(void 0===s)switch(this.getSettings_().endingEnd){case 2401:o=t,s=2*i-e;break;case 2402:o=1,s=i+r[1]-r[0];break;default:o=t-1,s=e}var c=.5*(i-e),u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(s-i),this._offsetPrev=n*u,this._offsetNext=o*u},interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,u=this._offsetPrev,h=this._offsetNext,l=this._weightPrev,p=this._weightNext,d=(i-e)/(r-e),f=d*d,m=f*d,g=-l*m+2*l*f-l*d,v=(1+l)*m+(-1.5-2*l)*f+(-.5+l)*d+1,y=(-1-p)*m+(1.5+p)*f+.5*d,b=p*m-p*f,x=0;x!==a;++x)n[x]=g*o[u+x]+v*o[c+x]+y*o[s+x]+b*o[h+x];return n}}),_o.prototype=Object.assign(Object.create(bo.prototype),{constructor:_o,interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,u=(i-e)/(r-e),h=1-u,l=0;l!==a;++l)n[l]=o[c+l]*h+o[s+l]*u;return n}}),wo.prototype=Object.assign(Object.create(bo.prototype),{constructor:wo,interpolate_:function(t,e,i,r){return this.copySampleValue_(t-1)}}),vo={TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(t){return new wo(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new _o(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new xo(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth}if(void 0!==e)this.createInterpolant=e;else{var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}console.warn("THREE.KeyframeTrackPrototype:",i)}},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,i=0,r=e.length;i!==r;++i)e[i]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,i=0,r=e.length;i!==r;++i)e[i]*=t;return this},trim:function(t,e){for(var i=this.times,r=i.length,n=0,o=r-1;n!==r&&i[n]<t;)++n;for(;-1!==o&&i[o]>e;)--o;if(++o,0!==n||o!==r){n>=o&&(n=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=yo.arraySlice(i,n,o),this.values=yo.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),t=!1);var i=this.times,r=this.values,n=i.length;0===n&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),t=!1);for(var o=null,a=0;a!==n;a++){var s=i[a];if("number"===typeof s&&isNaN(s)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",this,a,s),t=!1;break}if(null!==o&&o>s){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",this,a,s,o),t=!1;break}o=s}if(void 0!==r&&yo.isTypedArray(r)){a=0;for(var c=r.length;a!==c;++a){var u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",this,a,u),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,o=t.length-1,a=1;a<o;++a){var s=!1,c=t[a];if(c!==t[a+1]&&(1!==a||c!==c[0]))if(r)s=!0;else for(var u=a*i,h=u-i,l=u+i,p=0;p!==i;++p){var d=e[u+p];if(d!==e[h+p]||d!==e[l+p]){s=!0;break}}if(s){if(a!==n){t[n]=t[a];var f=a*i,m=n*i;for(p=0;p!==i;++p)e[m+p]=e[f+p]}++n}}if(o>0){t[n]=t[o];for(f=o*i,m=n*i,p=0;p!==i;++p)e[m+p]=e[f+p];++n}return n!==t.length&&(this.times=yo.arraySlice(t,0,n),this.values=yo.arraySlice(e,0,n*i)),this}},Ao.prototype=Object.assign(Object.create(vo),{constructor:Ao,ValueTypeName:"vector"}),Mo.prototype=Object.assign(Object.create(bo.prototype),{constructor:Mo,interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(i-e)/(r-e),u=s+a;s!==u;s+=4)Ae.slerpFlat(n,0,o,s-a,o,s,c);return n}}),Po.prototype=Object.assign(Object.create(vo),{constructor:Po,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new Mo(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),To.prototype=Object.assign(Object.create(vo),{constructor:To,ValueTypeName:"number"}),Eo.prototype=Object.assign(Object.create(vo),{constructor:Eo,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Co.prototype=Object.assign(Object.create(vo),{constructor:Co,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Io.prototype=Object.assign(Object.create(vo),{constructor:Io,ValueTypeName:"color"}),Ro.prototype=vo,vo.constructor=Ro,Object.assign(Ro,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Ro._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var i=[],r=[];yo.flattenJSON(t.keys,i,r,"value"),t.times=i,t.values=r}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,i=t.constructor;if(void 0!==i.toJSON)e=i.toJSON(t);else{e={name:t.name,times:yo.convertArray(t.times,Array),values:yo.convertArray(t.values,Array)};var r=t.getInterpolation();r!==t.DefaultInterpolation&&(e.interpolation=r)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return To;case"vector":case"vector2":case"vector3":case"vector4":return Ao;case"color":return Io;case"quaternion":return Po;case"bool":case"boolean":return Co;case"string":return Eo}throw new Error("Unsupported typeName: "+t)}}),Object.assign(Lo,{parse:function(t){for(var e=[],i=t.tracks,r=1/(t.fps||1),n=0,o=i.length;n!==o;++n)e.push(Ro.parse(i[n]).scale(r));return new Lo(t.name,t.duration,e)},toJSON:function(t){for(var e=[],i=t.tracks,r={name:t.name,duration:t.duration,tracks:e},n=0,o=i.length;n!==o;++n)e.push(Ro.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(t,e,i,r){for(var n=e.length,o=[],a=0;a<n;a++){var s=[],c=[];s.push((a+n-1)%n,a,(a+1)%n),c.push(0,1,0);var u=yo.getKeyframeOrder(s);s=yo.sortedArray(s,1,u),c=yo.sortedArray(c,1,u),r||0!==s[0]||(s.push(n),c.push(c[0])),o.push(new To(".morphTargetInfluences["+e[a].name+"]",s,c).scale(1/i))}return new Lo(t,-1,o)},findByName:function(t,e){var i=t;if(!Array.isArray(t)){var r=t;i=r.geometry&&r.geometry.animations||r.animations}for(var n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null},CreateClipsFromMorphTargetSequences:function(t,e,i){for(var r={},n=/^([\w-]*?)([\d]+)$/,o=0,a=t.length;o<a;o++){var s=t[o],c=s.name.match(n);if(c&&c.length>1){var u=r[l=c[1]];u||(r[l]=u=[]),u.push(s)}}var h=[];for(var l in r)h.push(Lo.CreateFromMorphTargetSequence(l,r[l],e,i));return h},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(t,e,i,r,n){if(0!==i.length){var o=[],a=[];yo.flattenJSON(i,o,a,r),0!==o.length&&n.push(new t(e,o,a))}},r=[],n=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c<s.length;c++){var u=s[c].keys;if(u&&0!==u.length)if(u[0].morphTargets){for(var h={},l=0;l<u.length;l++)if(u[l].morphTargets)for(var p=0;p<u[l].morphTargets.length;p++)h[u[l].morphTargets[p]]=-1;for(var d in h){var f=[],m=[];for(p=0;p!==u[l].morphTargets.length;++p){var g=u[l];f.push(g.time),m.push(g.morphTarget===d?1:0)}r.push(new To(".morphTargetInfluence["+d+"]",f,m))}o=h.length*(a||1)}else{var v=".bones["+e[c].name+"]";i(Ao,v+".position",u,"pos",r),i(Po,v+".quaternion",u,"rot",r),i(Ao,v+".scale",u,"scl",r)}}return 0===r.length?null:new Lo(n,o,r)}}),Object.assign(Lo.prototype,{resetDuration:function(){for(var t=0,e=0,i=this.tracks.length;e!==i;++e){var r=this.tracks[e];t=Math.max(t,r.times[r.times.length-1])}this.duration=t},trim:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},optimize:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}}),Object.assign(Oo.prototype,{load:function(t,e,i,r){var n=this;new ro(n.manager).load(t,function(t){e(n.parse(JSON.parse(t)))},i,r)},setTextures:function(t){this.textures=t},parse:function(t){var e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}var r=new Jn[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&r.specular.setHex(t.specular),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearCoat&&(r.clearCoat=t.clearCoat),void 0!==t.clearCoatRoughness&&(r.clearCoatRoughness=t.clearCoatRoughness),void 0!==t.uniforms&&(r.uniforms=t.uniforms),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.vertexColors&&(r.vertexColors=t.vertexColors),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.shading&&(r.shading=t.shading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.side&&(r.side=t.side),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.skinning&&(r.skinning=t.skinning),void 0!==t.morphTargets&&(r.morphTargets=t.morphTargets),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=i(t.map)),void 0!==t.alphaMap&&(r.alphaMap=i(t.alphaMap),r.transparent=!0),void 0!==t.bumpMap&&(r.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=i(t.normalMap)),void 0!==t.normalScale){var n=t.normalScale;!1===Array.isArray(n)&&(n=[n,n]),r.normalScale=(new be).fromArray(n)}return void 0!==t.displacementMap&&(r.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=i(t.specularMap)),void 0!==t.envMap&&(r.envMap=i(t.envMap)),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.lightMap&&(r.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=i(t.gradientMap)),r}}),Object.assign(No.prototype,{load:function(t,e,i,r){var n=this;new ro(n.manager).load(t,function(t){e(n.parse(JSON.parse(t)))},i,r)},parse:function(t){var e=new Ki,i=t.data.index;if(void 0!==i){var r=new Do[i.type](i.array);e.setIndex(new Hi(r,1))}var n=t.data.attributes;for(var o in n){var a=n[o];r=new Do[a.type](a.array);e.addAttribute(o,new Hi(r,a.itemSize,a.normalized))}var s=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==s)for(var c=0,u=s.length;c!==u;++c){var h=s[c];e.addGroup(h.start,h.count,h.materialIndex)}var l=t.data.boundingSphere;if(void 0!==l){var p=new Me;void 0!==l.center&&p.fromArray(l.center),e.boundingSphere=new Ei(p,l.radius)}return e}});var Do={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!==typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ko(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function Fo(t){"boolean"===typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:io,this.withCredentials=!1}ko.Handlers={handlers:[],add:function(t,e){this.handlers.push(t,e)},get:function(t){for(var e=this.handlers,i=0,r=e.length;i<r;i+=2){var n=e[i],o=e[i+1];if(n.test(t))return o}return null}},Object.assign(ko.prototype,{crossOrigin:void 0,extractUrlBase:function(t){var e=t.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},initMaterials:function(t,e,i){for(var r=[],n=0;n<t.length;++n)r[n]=this.createMaterial(t[n],e,i);return r},createMaterial:function(){var t={NoBlending:I,NormalBlending:R,AdditiveBlending:L,SubtractiveBlending:O,MultiplyBlending:N,CustomBlending:D},e=new mi,i=new oo,r=new Oo;return function(n,o,a){var s={};function c(t,e,r,n,c){var u,h=o+t,l=ko.Handlers.get(h);null!==l?u=l.load(h):(i.setCrossOrigin(a),u=i.load(h)),void 0!==e&&(u.repeat.fromArray(e),1!==e[0]&&(u.wrapS=_t),1!==e[1]&&(u.wrapT=_t)),void 0!==r&&u.offset.fromArray(r),void 0!==n&&("repeat"===n[0]&&(u.wrapS=_t),"mirror"===n[0]&&(u.wrapS=St),"repeat"===n[1]&&(u.wrapT=_t),"mirror"===n[1]&&(u.wrapT=St)),void 0!==c&&(u.anisotropy=c);var p=ye.generateUUID();return s[p]=u,p}var u={uuid:ye.generateUUID(),type:"MeshLambertMaterial"};for(var h in n){var l=n[h];switch(h){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":u.name=l;break;case"blending":u.blending=t[l];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",h,"is no longer supported.");break;case"colorDiffuse":u.color=e.fromArray(l).getHex();break;case"colorSpecular":u.specular=e.fromArray(l).getHex();break;case"colorEmissive":u.emissive=e.fromArray(l).getHex();break;case"specularCoef":u.shininess=l;break;case"shading":"basic"===l.toLowerCase()&&(u.type="MeshBasicMaterial"),"phong"===l.toLowerCase()&&(u.type="MeshPhongMaterial"),"standard"===l.toLowerCase()&&(u.type="MeshStandardMaterial");break;case"mapDiffuse":u.map=c(l,n.mapDiffuseRepeat,n.mapDiffuseOffset,n.mapDiffuseWrap,n.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":u.emissiveMap=c(l,n.mapEmissiveRepeat,n.mapEmissiveOffset,n.mapEmissiveWrap,n.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":u.lightMap=c(l,n.mapLightRepeat,n.mapLightOffset,n.mapLightWrap,n.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":u.aoMap=c(l,n.mapAORepeat,n.mapAOOffset,n.mapAOWrap,n.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":u.bumpMap=c(l,n.mapBumpRepeat,n.mapBumpOffset,n.mapBumpWrap,n.mapBumpAnisotropy);break;case"mapBumpScale":u.bumpScale=l;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":u.normalMap=c(l,n.mapNormalRepeat,n.mapNormalOffset,n.mapNormalWrap,n.mapNormalAnisotropy);break;case"mapNormalFactor":u.normalScale=[l,l];break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":u.specularMap=c(l,n.mapSpecularRepeat,n.mapSpecularOffset,n.mapSpecularWrap,n.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":u.metalnessMap=c(l,n.mapMetalnessRepeat,n.mapMetalnessOffset,n.mapMetalnessWrap,n.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":u.roughnessMap=c(l,n.mapRoughnessRepeat,n.mapRoughnessOffset,n.mapRoughnessWrap,n.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":u.alphaMap=c(l,n.mapAlphaRepeat,n.mapAlphaOffset,n.mapAlphaWrap,n.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":u.side=S;break;case"doubleSided":u.side=A;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),u.opacity=l;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":u[h]=l;break;case"vertexColors":!0===l&&(u.vertexColors=C),"face"===l&&(u.vertexColors=E);break;default:console.error("THREE.Loader.createMaterial: Unsupported",h,l)}}return"MeshBasicMaterial"===u.type&&delete u.emissive,"MeshPhongMaterial"!==u.type&&delete u.specular,u.opacity<1&&(u.transparent=!0),r.setTextures(s),r.parse(u)}}()}),Object.assign(Fo.prototype,{load:function(t,e,i,r){var n=this,o=this.texturePath&&"string"===typeof this.texturePath?this.texturePath:ko.prototype.extractUrlBase(t),a=new ro(this.manager);a.setWithCredentials(this.withCredentials),a.load(t,function(i){var r=JSON.parse(i),a=r.metadata;if(void 0!==a){var s=a.type;if(void 0!==s){if("object"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.ObjectLoader instead.");if("scene"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.SceneLoader instead.")}}var c=n.parse(r,o);e(c.geometry,c.materials)},i,r)},setTexturePath:function(t){this.texturePath=t},parse:function(){return function(t,e){void 0!==t.data&&(t=t.data),void 0!==t.scale?t.scale=1/t.scale:t.scale=1;var i=new $i;return function(t,e){function i(t,e){return t&1<<e}var r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E=t.faces,C=t.vertices,I=t.normals,R=t.colors,L=t.scale,O=0;if(void 0!==t.uvs){for(r=0;r<t.uvs.length;r++)t.uvs[r].length&&O++;for(r=0;r<O;r++)e.faceVertexUvs[r]=[]}for(a=0,s=C.length;a<s;)(x=new Me).x=C[a++]*L,x.y=C[a++]*L,x.z=C[a++]*L,e.vertices.push(x);for(a=0,s=E.length;a<s;)if(d=i(p=E[a++],0),f=i(p,1),m=i(p,3),g=i(p,4),v=i(p,5),y=i(p,6),b=i(p,7),d){if((w=new ji).a=E[a],w.b=E[a+1],w.c=E[a+3],(S=new ji).a=E[a+1],S.b=E[a+2],S.c=E[a+3],a+=4,f&&(l=E[a++],w.materialIndex=l,S.materialIndex=l),o=e.faces.length,m)for(r=0;r<O;r++)for(P=t.uvs[r],e.faceVertexUvs[r][o]=[],e.faceVertexUvs[r][o+1]=[],n=0;n<4;n++)T=new be(P[2*(h=E[a++])],P[2*h+1]),2!==n&&e.faceVertexUvs[r][o].push(T),0!==n&&e.faceVertexUvs[r][o+1].push(T);if(g&&(u=3*E[a++],w.normal.set(I[u++],I[u++],I[u]),S.normal.copy(w.normal)),v)for(r=0;r<4;r++)u=3*E[a++],M=new Me(I[u++],I[u++],I[u]),2!==r&&w.vertexNormals.push(M),0!==r&&S.vertexNormals.push(M);if(y&&(A=R[c=E[a++]],w.color.setHex(A),S.color.setHex(A)),b)for(r=0;r<4;r++)A=R[c=E[a++]],2!==r&&w.vertexColors.push(new mi(A)),0!==r&&S.vertexColors.push(new mi(A));e.faces.push(w),e.faces.push(S)}else{if((_=new ji).a=E[a++],_.b=E[a++],_.c=E[a++],f&&(l=E[a++],_.materialIndex=l),o=e.faces.length,m)for(r=0;r<O;r++)for(P=t.uvs[r],e.faceVertexUvs[r][o]=[],n=0;n<3;n++)T=new be(P[2*(h=E[a++])],P[2*h+1]),e.faceVertexUvs[r][o].push(T);if(g&&(u=3*E[a++],_.normal.set(I[u++],I[u++],I[u])),v)for(r=0;r<3;r++)u=3*E[a++],M=new Me(I[u++],I[u++],I[u]),_.vertexNormals.push(M);if(y&&(c=E[a++],_.color.setHex(R[c])),b)for(r=0;r<3;r++)c=E[a++],_.vertexColors.push(new mi(R[c]));e.faces.push(_)}}(t,i),function(t,e){var i=void 0!==t.influencesPerVertex?t.influencesPerVertex:2;if(t.skinWeights)for(var r=0,n=t.skinWeights.length;r<n;r+=i){var o=t.skinWeights[r],a=i>1?t.skinWeights[r+1]:0,s=i>2?t.skinWeights[r+2]:0,c=i>3?t.skinWeights[r+3]:0;e.skinWeights.push(new we(o,a,s,c))}if(t.skinIndices)for(r=0,n=t.skinIndices.length;r<n;r+=i){var u=t.skinIndices[r],h=i>1?t.skinIndices[r+1]:0,l=i>2?t.skinIndices[r+2]:0,p=i>3?t.skinIndices[r+3]:0;e.skinIndices.push(new we(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.")}(t,i),function(t,e){var i=t.scale;if(void 0!==t.morphTargets)for(var r=0,n=t.morphTargets.length;r<n;r++){e.morphTargets[r]={},e.morphTargets[r].name=t.morphTargets[r].name,e.morphTargets[r].vertices=[];for(var o=e.morphTargets[r].vertices,a=t.morphTargets[r].vertices,s=0,c=a.length;s<c;s+=3){var u=new Me;u.x=a[s]*i,u.y=a[s+1]*i,u.z=a[s+2]*i,o.push(u)}}if(void 0!==t.morphColors&&t.morphColors.length>0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var h=e.faces,l=t.morphColors[0].colors;for(r=0,n=h.length;r<n;r++)h[r].color.fromArray(l,3*r)}}(t,i),function(t,e){var i=[],r=[];void 0!==t.animation&&r.push(t.animation),void 0!==t.animations&&(t.animations.length?r=r.concat(t.animations):r.push(t.animations));for(var n=0;n<r.length;n++){var o=Lo.parseAnimation(r[n],e.bones);o&&i.push(o)}if(e.morphTargets){var a=Lo.CreateClipsFromMorphTargetSequences(e.morphTargets,10);i=i.concat(a)}i.length>0&&(e.animations=i)}(t,i),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:i}:{geometry:i,materials:ko.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(function(t){this.manager=void 0!==t?t:io,this.texturePath=""}.prototype,{load:function(t,e,i,r){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var n=this;new ro(n.manager).load(t,function(i){var o=null;try{o=JSON.parse(i)}catch(s){return void 0!==r&&r(s),void console.error("THREE:ObjectLoader: Can't parse "+t+".",s.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.")},i,r)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var i=this.parseGeometries(t.geometries),r=this.parseImages(t.images,function(){void 0!==e&&e(a)}),n=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,n),a=this.parseObject(t.object,i,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={};if(void 0!==t)for(var i=new Fo,r=new No,n=0,o=t.length;n<o;n++){var a,s=t[n];switch(s.type){case"PlaneGeometry":case"PlaneBufferGeometry":a=new Vn[s.type](s.width,s.height,s.widthSegments,s.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":a=new Vn[s.type](s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":a=new Vn[s.type](s.radius,s.segments,s.thetaStart,s.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":a=new Vn[s.type](s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":a=new Vn[s.type](s.radius,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":a=new Vn[s.type](s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength);break;case"DodecahedronGeometry":case"IcosahedronGeometry":case"OctahedronGeometry":case"TetrahedronGeometry":a=new Vn[s.type](s.radius,s.detail);break;case"RingGeometry":case"RingBufferGeometry":a=new Vn[s.type](s.innerRadius,s.outerRadius,s.thetaSegments,s.phiSegments,s.thetaStart,s.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":a=new Vn[s.type](s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":a=new Vn[s.type](s.radius,s.tube,s.tubularSegments,s.radialSegments,s.p,s.q);break;case"LatheGeometry":case"LatheBufferGeometry":a=new Vn[s.type](s.points,s.segments,s.phiStart,s.phiLength);break;case"BufferGeometry":a=r.parse(s);break;case"Geometry":a=i.parse(s,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+s.type+'"');continue}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),e[s.uuid]=a}return e},parseMaterials:function(t,e){var i={};if(void 0!==t){var r=new Oo;r.setTextures(e);for(var n=0,o=t.length;n<o;n++){var a=t[n];if("MultiMaterial"===a.type){for(var s=[],c=0;c<a.materials.length;c++)s.push(r.parse(a.materials[c]));i[a.uuid]=s}else i[a.uuid]=r.parse(a)}}return i},parseAnimations:function(t){for(var e=[],i=0;i<t.length;i++){var r=Lo.parse(t[i]);e.push(r)}return e},parseImages:function(t,e){var i=this,r={};function n(t){return i.manager.itemStart(t),o.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemEnd(t),i.manager.itemError(t)})}if(void 0!==t&&t.length>0){var o=new no(new eo(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a<s;a++){var c=t[a],u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c.url)?c.url:i.texturePath+c.url;r[c.uuid]=n(u)}}return r},parseTextures:function(t,e){function i(t,e){return"number"===typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var r={};if(void 0!==t)for(var n=0,o=t.length;n<o;n++){var a=t[n];void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===e[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image);var s=new _e(e[a.image]);s.needsUpdate=!0,s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.mapping&&(s.mapping=i(a.mapping,Bo)),void 0!==a.offset&&s.offset.fromArray(a.offset),void 0!==a.repeat&&s.repeat.fromArray(a.repeat),void 0!==a.wrap&&(s.wrapS=i(a.wrap[0],zo),s.wrapT=i(a.wrap[1],zo)),void 0!==a.minFilter&&(s.minFilter=i(a.minFilter,Uo)),void 0!==a.magFilter&&(s.magFilter=i(a.magFilter,Uo)),void 0!==a.anisotropy&&(s.anisotropy=a.anisotropy),void 0!==a.flipY&&(s.flipY=a.flipY),r[a.uuid]=s}return r},parseObject:function(){var t=new Pe;return function(e,i,r){var n;function o(t){return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),i[t]}function a(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],i=0,n=t.length;i<n;i++){var o=t[i];void 0===r[o]&&console.warn("THREE.ObjectLoader: Undefined material",o),e.push(r[o])}return e}return void 0===r[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),r[t]}}switch(e.type){case"Scene":n=new Ur,void 0!==e.background&&Number.isInteger(e.background)&&(n.background=new mi(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?n.fog=new zr(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(n.fog=new Br(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":n=new Ui(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(n.focus=e.focus),void 0!==e.zoom&&(n.zoom=e.zoom),void 0!==e.filmGauge&&(n.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(n.filmOffset=e.filmOffset),void 0!==e.view&&(n.view=Object.assign({},e.view));break;case"OrthographicCamera":n=new zi(e.left,e.right,e.top,e.bottom,e.near,e.far);break;case"AmbientLight":n=new mo(e.color,e.intensity);break;case"DirectionalLight":n=new fo(e.color,e.intensity);break;case"PointLight":n=new lo(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":n=new go(e.color,e.intensity,e.width,e.height);break;case"SpotLight":n=new ho(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":n=new so(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var s=o(e.geometry),c=a(e.material);n=s.bones&&s.bones.length>0?new Xr(s,c):new ar(s,c);break;case"LOD":n=new $r;break;case"Line":n=new Yr(o(e.geometry),a(e.material),e.mode);break;case"LineLoop":n=new Kr(o(e.geometry),a(e.material));break;case"LineSegments":n=new Zr(o(e.geometry),a(e.material));break;case"PointCloud":case"Points":n=new Jr(o(e.geometry),a(e.material));break;case"Sprite":n=new Vr(a(e.material));break;case"Group":n=new tn;break;default:n=new Fi}if(n.uuid=e.uuid,void 0!==e.name&&(n.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(n.position,n.quaternion,n.scale)):(void 0!==e.position&&n.position.fromArray(e.position),void 0!==e.rotation&&n.rotation.fromArray(e.rotation),void 0!==e.quaternion&&n.quaternion.fromArray(e.quaternion),void 0!==e.scale&&n.scale.fromArray(e.scale)),void 0!==e.castShadow&&(n.castShadow=e.castShadow),void 0!==e.receiveShadow&&(n.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(n.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(n.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&n.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(n.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.children)for(var u in e.children)n.add(this.parseObject(e.children[u],i,r));if("LOD"===e.type)for(var h=e.levels,l=0;l<h.length;l++){var p=h[l];void 0!==(u=n.getObjectByProperty("uuid",p.object))&&n.addLevel(u,p.distance)}return n}}()});var Bo={UVMapping:300,CubeReflectionMapping:ft,CubeRefractionMapping:mt,EquirectangularReflectionMapping:gt,EquirectangularRefractionMapping:vt,SphericalReflectionMapping:yt,CubeUVReflectionMapping:bt,CubeUVRefractionMapping:xt},zo={RepeatWrapping:_t,ClampToEdgeWrapping:wt,MirroredRepeatWrapping:St},Uo={NearestFilter:At,NearestMipMapNearestFilter:Mt,NearestMipMapLinearFilter:Pt,LinearFilter:Tt,LinearMipMapNearestFilter:Et,LinearMipMapLinearFilter:Ct};function jo(t,e,i,r,n){var o=.5*(r-e),a=.5*(n-i),s=t*t;return(2*i-2*r+o+a)*(t*s)+(-3*i+3*r-2*o-a)*s+o*t+i}function Go(t,e,i,r){return function(t,e){var i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,r)}function Vo(t,e,i,r,n){return function(t,e){var i=1-t;return i*i*i*e}(t,e)+function(t,e){var i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,r)+function(t,e){return t*t*t*e}(t,n)}function $o(){this.arcLengthDivisions=200}function Ho(t,e){$o.call(this),this.v1=t,this.v2=e}function Wo(){$o.call(this),this.curves=[],this.autoClose=!1}function Xo(t,e,i,r,n,o,a,s){$o.call(this),this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function qo(t){$o.call(this),this.points=void 0===t?[]:t}function Yo(t,e,i,r){$o.call(this),this.v0=t,this.v1=e,this.v2=i,this.v3=r}function Zo(t,e,i){$o.call(this),this.v0=t,this.v1=e,this.v2=i}Object.assign($o.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t){var e=this.getUtoTmapping(t);return this.getPoint(e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i,r=[],n=this.getPoint(0),o=0;for(r.push(0),i=1;i<=t;i++)o+=(e=this.getPoint(i/t)).distanceTo(n),r.push(o),n=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var i,r=this.getLengths(),n=0,o=r.length;i=e||t*r[o-1];for(var a,s=0,c=o-1;s<=c;)if((a=r[n=Math.floor(s+(c-s)/2)]-i)<0)s=n+1;else{if(!(a>0)){c=n;break}c=n-1}if(r[n=c]===i)return n/(o-1);var u=r[n];return(n+(i-u)/(r[n+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);var r=this.getPoint(e);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var i,r,n,o=new Me,a=[],s=[],c=[],u=new Me,h=new Pe;for(i=0;i<=t;i++)r=i/t,a[i]=this.getTangentAt(r),a[i].normalize();s[0]=new Me,c[0]=new Me;var l=Number.MAX_VALUE,p=Math.abs(a[0].x),d=Math.abs(a[0].y),f=Math.abs(a[0].z);for(p<=l&&(l=p,o.set(1,0,0)),d<=l&&(l=d,o.set(0,1,0)),f<=l&&o.set(0,0,1),u.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],u),c[0].crossVectors(a[0],s[0]),i=1;i<=t;i++)s[i]=s[i-1].clone(),c[i]=c[i-1].clone(),u.crossVectors(a[i-1],a[i]),u.length()>Number.EPSILON&&(u.normalize(),n=Math.acos(ye.clamp(a[i-1].dot(a[i]),-1,1)),s[i].applyMatrix4(h.makeRotationAxis(u,n))),c[i].crossVectors(a[i],s[i]);if(!0===e)for(n=Math.acos(ye.clamp(s[0].dot(s[t]),-1,1)),n/=t,a[0].dot(u.crossVectors(s[0],s[t]))>0&&(n=-n),i=1;i<=t;i++)s[i].applyMatrix4(h.makeRotationAxis(a[i],n*i)),c[i].crossVectors(a[i],s[i]);return{tangents:a,normals:s,binormals:c}}}),Ho.prototype=Object.create($o.prototype),Ho.prototype.constructor=Ho,Ho.prototype.isLineCurve=!0,Ho.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},Ho.prototype.getPointAt=function(t){return this.getPoint(t)},Ho.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},Wo.prototype=Object.assign(Object.create($o.prototype),{constructor:Wo,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 Ho(e,t))},getPoint:function(t){for(var e=t*this.getLength(),i=this.getCurveLengths(),r=0;r<i.length;){if(i[r]>=e){var n=i[r]-e,o=this.curves[r],a=o.getLength(),s=0===a?0:1-n/a;return o.getPointAt(s)}r++}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(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,i=0,r=this.curves.length;i<r;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;for(var e,i=[],r=0,n=this.curves;r<n.length;r++)for(var o=n[r],a=o&&o.isEllipseCurve?2*t:o&&o.isLineCurve?1:o&&o.isSplineCurve?t*o.points.length:t,s=o.getPoints(a),c=0;c<s.length;c++){var u=s[c];e&&e.equals(u)||(i.push(u),e=u)}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},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 $i,i=0,r=t.length;i<r;i++){var n=t[i];e.vertices.push(new Me(n.x,n.y,n.z||0))}return e}}),Xo.prototype=Object.create($o.prototype),Xo.prototype.constructor=Xo,Xo.prototype.isEllipseCurve=!0,Xo.prototype.getPoint=function(t){for(var e=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)<Number.EPSILON;i<0;)i+=e;for(;i>e;)i-=e;i<Number.EPSILON&&(i=r?0:e),!0!==this.aClockwise||r||(i===e?i=-e:i-=e);var n=this.aStartAngle+t*i,o=this.aX+this.xRadius*Math.cos(n),a=this.aY+this.yRadius*Math.sin(n);if(0!==this.aRotation){var s=Math.cos(this.aRotation),c=Math.sin(this.aRotation),u=o-this.aX,h=a-this.aY;o=u*s-h*c+this.aX,a=u*c+h*s+this.aY}return new be(o,a)},qo.prototype=Object.create($o.prototype),qo.prototype.constructor=qo,qo.prototype.isSplineCurve=!0,qo.prototype.getPoint=function(t){var e=this.points,i=(e.length-1)*t,r=Math.floor(i),n=i-r,o=e[0===r?r:r-1],a=e[r],s=e[r>e.length-2?e.length-1:r+1],c=e[r>e.length-3?e.length-1:r+2];return new be(jo(n,o.x,a.x,s.x,c.x),jo(n,o.y,a.y,s.y,c.y))},Yo.prototype=Object.create($o.prototype),Yo.prototype.constructor=Yo,Yo.prototype.getPoint=function(t){var e=this.v0,i=this.v1,r=this.v2,n=this.v3;return new be(Vo(t,e.x,i.x,r.x,n.x),Vo(t,e.y,i.y,r.y,n.y))},Zo.prototype=Object.create($o.prototype),Zo.prototype.constructor=Zo,Zo.prototype.getPoint=function(t){var e=this.v0,i=this.v1,r=this.v2;return new be(Go(t,e.x,i.x,r.x),Go(t,e.y,i.y,r.y))};var Ko,Qo=Object.assign(Object.create(Wo.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y)},moveTo:function(t,e){this.currentPoint.set(t,e)},lineTo:function(t,e){var i=new Ho(this.currentPoint.clone(),new be(t,e));this.curves.push(i),this.currentPoint.set(t,e)},quadraticCurveTo:function(t,e,i,r){var n=new Zo(this.currentPoint.clone(),new be(t,e),new be(i,r));this.curves.push(n),this.currentPoint.set(i,r)},bezierCurveTo:function(t,e,i,r,n,o){var a=new Yo(this.currentPoint.clone(),new be(t,e),new be(i,r),new be(n,o));this.curves.push(a),this.currentPoint.set(n,o)},splineThru:function(t){var e=new qo([this.currentPoint.clone()].concat(t));this.curves.push(e),this.currentPoint.copy(t[t.length-1])},arc:function(t,e,i,r,n,o){var a=this.currentPoint.x,s=this.currentPoint.y;this.absarc(t+a,e+s,i,r,n,o)},absarc:function(t,e,i,r,n,o){this.absellipse(t,e,i,i,r,n,o)},ellipse:function(t,e,i,r,n,o,a,s){var c=this.currentPoint.x,u=this.currentPoint.y;this.absellipse(t+c,e+u,i,r,n,o,a,s)},absellipse:function(t,e,i,r,n,o,a,s){var c=new Xo(t,e,i,r,n,o,a,s);if(this.curves.length>0){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)}});function Jo(t){Wo.call(this),this.currentPoint=new be,t&&this.fromPoints(t)}function ta(){Jo.apply(this,arguments),this.holes=[]}function ea(){this.subPaths=[],this.currentPath=null}function ia(t){this.data=t}Jo.prototype=Qo,Qo.constructor=Jo,ta.prototype=Object.assign(Object.create(Qo),{constructor:ta,getPointsHoles:function(t){for(var e=[],i=0,r=this.holes.length;i<r;i++)e[i]=this.holes[i].getPoints(t);return e},extractAllPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},extractPoints:function(t){return this.extractAllPoints(t)}}),Object.assign(ea.prototype,{moveTo:function(t,e){this.currentPath=new Jo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e)},lineTo:function(t,e){this.currentPath.lineTo(t,e)},quadraticCurveTo:function(t,e,i,r){this.currentPath.quadraticCurveTo(t,e,i,r)},bezierCurveTo:function(t,e,i,r,n,o){this.currentPath.bezierCurveTo(t,e,i,r,n,o)},splineThru:function(t){this.currentPath.splineThru(t)},toShapes:function(t,e){function i(t){for(var e=[],i=0,r=t.length;i<r;i++){var n=t[i],o=new ta;o.curves=n.curves,e.push(o)}return e}function r(t,e){for(var i=e.length,r=!1,n=i-1,o=0;o<i;n=o++){var a=e[n],s=e[o],c=s.x-a.x,u=s.y-a.y;if(Math.abs(u)>Number.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[n],u=-u),t.y<a.y||t.y>s.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;r=!r}}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 r}var n=Sn.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return i(o);var a,s,c,u=[];if(1===o.length)return s=o[0],(c=new ta).curves=s.curves,u.push(c),u;var h=!n(o[0].getPoints());h=t?!h:h;var l,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v<y;v++)a=n(l=(s=o[v]).getPoints()),(a=t?!a:a)?(!h&&f[g]&&g++,f[g]={s:new ta,p:l},f[g].s.curves=s.curves,h&&g++,m[g]=[]):m[g].push({h:s,p:l[0]});if(!f[0])return i(o);if(f.length>1){for(var b=!1,x=[],_=0,w=f.length;_<w;_++)d[_]=[];for(_=0,w=f.length;_<w;_++)for(var S=m[_],A=0;A<S.length;A++){for(var M=S[A],P=!0,T=0;T<f.length;T++)r(M.p,f[T].p)&&(_!==T&&x.push({froms:_,tos:T,hole:A}),P?(P=!1,d[T].push(M)):b=!0);P&&d[_].push(M)}x.length>0&&(b||(m=d))}v=0;for(var E=f.length;v<E;v++){c=f[v].s,u.push(c);for(var C=0,I=(p=m[v]).length;C<I;C++)c.holes.push(p[C].h)}return u}}),Object.assign(ia.prototype,{isFont:!0,generateShapes:function(t,e,i){function r(t,e,r,o){var a=n.glyphs[t]||n.glyphs["?"];if(a){var s,c,u,h,l,p,d,f,m,g,v,y=new ea,b=[];if(a.o)for(var x=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),_=0,w=x.length;_<w;){switch(x[_++]){case"m":s=x[_++]*e+r,c=x[_++]*e+o,y.moveTo(s,c);break;case"l":s=x[_++]*e+r,c=x[_++]*e+o,y.lineTo(s,c);break;case"q":if(u=x[_++]*e+r,h=x[_++]*e+o,d=x[_++]*e+r,f=x[_++]*e+o,y.quadraticCurveTo(d,f,u,h),v=b[b.length-1]){l=v.x,p=v.y;for(var S=1;S<=i;S++){Go(A=S/i,l,d,u),Go(A,p,f,h)}}break;case"b":if(u=x[_++]*e+r,h=x[_++]*e+o,d=x[_++]*e+r,f=x[_++]*e+o,m=x[_++]*e+r,g=x[_++]*e+o,y.bezierCurveTo(d,f,m,g,u,h),v=b[b.length-1]){l=v.x,p=v.y;for(S=1;S<=i;S++){var A;Vo(A=S/i,l,d,m,u),Vo(A,p,f,g,h)}}}}return{offsetX:a.ha*e,path:y}}}void 0===e&&(e=100),void 0===i&&(i=4);for(var n=this.data,o=function(t){for(var i=String(t).split(""),o=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*o,s=0,c=0,u=[],h=0;h<i.length;h++){var l=i[h];if("\n"===l)s=0,c-=a;else{var p=r(l,o,s,c);s+=p.offsetX,u.push(p.path)}}return u}(t),a=[],s=0,c=o.length;s<c;s++)Array.prototype.push.apply(a,o[s].toShapes());return a}}),Object.assign(function(t){this.manager=void 0!==t?t:io}.prototype,{load:function(t,e,i,r){var n=this;new ro(this.manager).load(t,function(t){var i;try{i=JSON.parse(t)}catch(o){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}var r=n.parse(i);e&&e(r)},i,r)},parse:function(t){return new ia(t)}});var ra={getContext:function(){return void 0===Ko&&(Ko=new(window.AudioContext||window.webkitAudioContext)),Ko},setContext:function(t){Ko=t}};function na(t){this.manager=void 0!==t?t:io}function oa(){Fi.call(this),this.type="AudioListener",this.context=ra.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function aa(t){Fi.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 sa(t){aa.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function ca(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 ua(t,e,i){this.binding=t,this.valueSize=i;var r,n=Float64Array;switch(e){case"quaternion":r=this._slerp;break;case"string":case"bool":n=Array,r=this._select;break;default:r=this._lerp}this.buffer=new n(4*i),this._mixBufferRegion=r,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function ha(t,e,i){var r=i||la.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function la(t,e,i){this.path=e,this.parsedPath=i||la.parseTrackName(e),this.node=la.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function pa(t,e,i){this._mixer=t,this._clip=e,this._localRoot=i||null;for(var r=e.tracks,n=r.length,o=new Array(n),a={endingStart:oe,endingEnd:oe},s=0;s!==n;++s){var c=r[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=ne,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 da(t){"string"===typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function fa(){Ki.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function ma(t,e,i,r){this.uuid=ye.generateUUID(),this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===r}function ga(t,e){this.uuid=ye.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 va(t,e,i){ga.call(this,t,e),this.meshPerAttribute=i||1}function ya(t,e,i){Hi.call(this,t,e),this.meshPerAttribute=i||1}function ba(t,e){return t.distance-e.distance}function xa(t,e,i,r){if(!1!==t.visible&&(t.raycast(e,i),!0===r))for(var n=t.children,o=0,a=n.length;o<a;o++)xa(n[o],e,i,!0)}function _a(t,e,i,r){this.object=t,this.size=void 0!==e?e:1;var n=void 0!==i?i:16711680,o=void 0!==r?r:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=3*s.faces.length:s&&s.isBufferGeometry&&(a=s.attributes.normal.count);var c=new Ki,u=new qi(2*a*3,3);c.addAttribute("position",u),Zr.call(this,c,new qr({color:n,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function wa(t){for(var e=function t(e){var i=[];e&&e.isBone&&i.push(e);for(var r=0;r<e.children.length;r++)i.push.apply(i,t(e.children[r]));return i}(t),i=new Ki,r=[],n=[],o=new mi(0,0,1),a=new mi(0,1,0),s=0;s<e.length;s++){var c=e[s];c.parent&&c.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(o.r,o.g,o.b),n.push(a.r,a.g,a.b))}i.addAttribute("position",new qi(r,3)),i.addAttribute("color",new qi(n,3));var u=new qr({vertexColors:C,depthTest:!1,depthWrite:!1,transparent:!0});Zr.call(this,i,u),this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.onBeforeRender()}function Sa(t,e){Fi.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;var i=new pn(e);i.rotateY(.5*Math.PI);var r=new ir({vertexColors:C,wireframe:!0}),n=i.getAttribute("position"),o=new Float32Array(3*n.count);i.addAttribute("color",new Hi(o,3)),this.add(new ar(i,r)),this.update()}function Aa(t,e,i,r){this.object=t,this.size=void 0!==e?e:1;var n=void 0!==i?i:16776960,o=void 0!==r?r:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=s.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var c=new Ki,u=new qi(2*a*3,3);c.addAttribute("position",u),Zr.call(this,c,new qr({color:n,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function Ma(t){var e=new Ki,i=new qr({color:16777215,vertexColors:E}),r=[],n=[],o={},a=new mi(16755200),s=new mi(16711680),c=new mi(43775),u=new mi(16777215),h=new mi(3355443);function l(t,e,i){p(t,i),p(e,i)}function p(t,e){r.push(0,0,0),n.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(r.length/3-1)}l("n1","n2",a),l("n2","n4",a),l("n4","n3",a),l("n3","n1",a),l("f1","f2",a),l("f2","f4",a),l("f4","f3",a),l("f3","f1",a),l("n1","f1",a),l("n2","f2",a),l("n3","f3",a),l("n4","f4",a),l("p","n1",s),l("p","n2",s),l("p","n3",s),l("p","n4",s),l("u1","u2",c),l("u2","u3",c),l("u3","u1",c),l("c","t",u),l("p","c",h),l("cn1","cn2",h),l("cn3","cn4",h),l("cf1","cf2",h),l("cf3","cf4",h),e.addAttribute("position",new qi(r,3)),e.addAttribute("color",new qi(n,3)),Zr.call(this,e,i),this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}function Pa(){var t=0,e=0,i=0,r=0;function n(n,o,a,s){t=n,e=a,i=-3*n+3*o-2*a-s,r=2*n-2*o+a+s}return{initCatmullRom:function(t,e,i,r,o){n(e,i,o*(i-t),o*(r-e))},initNonuniformCatmullRom:function(t,e,i,r,o,a,s){var c=(e-t)/o-(i-t)/(o+a)+(i-e)/a,u=(i-e)/a-(r-e)/(a+s)+(r-i)/s;n(e,i,c*=a,u*=a)},calc:function(n){var o=n*n;return t+e*n+i*o+r*(o*n)}}}Object.assign(na.prototype,{load:function(t,e,i,r){var n=new ro(this.manager);n.setResponseType("arraybuffer"),n.load(t,function(t){ra.getContext().decodeAudioData(t,function(t){e(t)})},i,r)}}),Object.assign(function(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ui,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ui,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}.prototype,{update:function(){var t,e,i,r,n,o,a,s,c=new Pe,u=new Pe;return function(h){if(t!==this||e!==h.focus||i!==h.fov||r!==h.aspect*this.aspect||n!==h.near||o!==h.far||a!==h.zoom||s!==this.eyeSep){t=this,e=h.focus,i=h.fov,r=h.aspect*this.aspect,n=h.near,o=h.far,a=h.zoom;var l,p,d=h.projectionMatrix.clone(),f=(s=this.eyeSep/2)*n/e,m=n*Math.tan(ye.DEG2RAD*i*.5)/a;u.elements[12]=-s,c.elements[12]=s,l=-m*r+f,p=m*r+f,d.elements[0]=2*n/(p-l),d.elements[8]=(p+l)/(p-l),this.cameraL.projectionMatrix.copy(d),l=-m*r-f,p=m*r-f,d.elements[0]=2*n/(p-l),d.elements[8]=(p+l)/(p-l),this.cameraR.projectionMatrix.copy(d)}this.cameraL.matrixWorld.copy(h.matrixWorld).multiply(u),this.cameraR.matrixWorld.copy(h.matrixWorld).multiply(c)}}()}),oa.prototype=Object.assign(Object.create(Fi.prototype),{constructor:oa,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)},getFilter:function(){return this.filter},setFilter:function(t){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination)},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(t){this.gain.gain.value=t},updateMatrixWorld:function(){var t=new Me,e=new Ae,i=new Me,r=new Me;return function(n){Fi.prototype.updateMatrixWorld.call(this,n);var o=this.context.listener,a=this.up;this.matrixWorld.decompose(t,e,i),r.set(0,0,-1).applyQuaternion(e),o.positionX?(o.positionX.setValueAtTime(t.x,this.context.currentTime),o.positionY.setValueAtTime(t.y,this.context.currentTime),o.positionZ.setValueAtTime(t.z,this.context.currentTime),o.forwardX.setValueAtTime(r.x,this.context.currentTime),o.forwardY.setValueAtTime(r.y,this.context.currentTime),o.forwardZ.setValueAtTime(r.z,this.context.currentTime),o.upX.setValueAtTime(a.x,this.context.currentTime),o.upY.setValueAtTime(a.y,this.context.currentTime),o.upZ.setValueAtTime(a.z,this.context.currentTime)):(o.setPosition(t.x,t.y,t.z),o.setOrientation(r.x,r.y,r.z,a.x,a.y,a.z))}}()}),aa.prototype=Object.assign(Object.create(Fi.prototype),{constructor:aa,getOutput:function(){return this.gain},setNodeSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},setBuffer:function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.onended=this.onEnded.bind(this),t.playbackRate.setValueAtTime(this.playbackRate,this.startTime),t.start(0,this.startTime),this.isPlaying=!0,this.source=t,this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.startTime=this.context.currentTime,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.startTime=0,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(t){return t||(t=[]),!0===this.isPlaying?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(t){return this.setFilters(t?[t]:[])},setPlaybackRate:function(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this;console.warn("THREE.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},getVolume:function(){return this.gain.gain.value},setVolume:function(t){return this.gain.gain.value=t,this}}),sa.prototype=Object.assign(Object.create(aa.prototype),{constructor:sa,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(t){this.panner.refDistance=t},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(t){this.panner.rolloffFactor=t},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(t){this.panner.distanceModel=t},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(t){this.panner.maxDistance=t},updateMatrixWorld:function(){var t=new Me;return function(e){Fi.prototype.updateMatrixWorld.call(this,e),t.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(t.x,t.y,t.z)}}()}),Object.assign(ca.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var t=0,e=this.getFrequencyData(),i=0;i<e.length;i++)t+=e[i];return t/e.length}}),Object.assign(ua.prototype,{accumulate:function(t,e){var i=this.buffer,r=this.valueSize,n=t*r+r,o=this.cumulativeWeight;if(0===o){for(var a=0;a!==r;++a)i[n+a]=i[a];o=e}else{var s=e/(o+=e);this._mixBufferRegion(i,n,0,s,r)}this.cumulativeWeight=o},apply:function(t){var e=this.valueSize,i=this.buffer,r=t*e+e,n=this.cumulativeWeight,o=this.binding;if(this.cumulativeWeight=0,n<1){var a=3*e;this._mixBufferRegion(i,r,a,1-n,e)}for(var s=e,c=e+e;s!==c;++s)if(i[s]!==i[s+e]){o.setValue(i,r);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,i=this.valueSize,r=3*i;t.getValue(e,r);for(var n=i,o=r;n!==o;++n)e[n]=e[r+n%i];this.cumulativeWeight=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_select:function(t,e,i,r,n){if(r>=.5)for(var o=0;o!==n;++o)t[e+o]=t[i+o]},_slerp:function(t,e,i,r){Ae.slerpFlat(t,e,t,e,t,i,r)},_lerp:function(t,e,i,r,n){for(var o=1-r,a=0;a!==n;++a){var s=e+a;t[s]=t[s]*o+t[i+a]*r}}}),Object.assign(ha.prototype,{getValue:function(t,e){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(t,e)},setValue:function(t,e){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(la,{Composite:ha,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new la.Composite(t,e,i):new la(t,e,i)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),e=["material","materials","bones"];return function(i){var r=t.exec(i);if(!r)throw new Error("PropertyBinding: Cannot parse trackName: "+i);var n={nodeName:r[2],objectName:r[3],objectIndex:r[4],propertyName:r[5],propertyIndex:r[6]},o=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==o&&-1!==o){var a=n.nodeName.substring(o+1);-1!==e.indexOf(a)&&(n.nodeName=n.nodeName.substring(0,o),n.objectName=a)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+i);return n}}(),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var i=function(t){for(var i=0;i<t.bones.length;i++){var r=t.bones[i];if(r.name===e)return r}return null}(t.skeleton);if(i)return i}if(t.children){var r=function t(i){for(var r=0;r<i.length;r++){var n=i[r];if(n.name===e||n.uuid===e)return n;var o=t(n.children);if(o)return o}return null}(t.children);if(r)return r}return null}}),Object.assign(la.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)t[e++]=i[r]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.node[this.propertyName]=t[e]},function(t,e){this.node[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.node[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++]},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,i=e.objectName,r=e.propertyName,n=e.propertyIndex;if(t||(t=la.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(i){var o=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(var a=0;a<t.length;a++)if(t[a].name===o){o=a;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==o){if(void 0===t[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[o]}}var s=t[r];if(void 0!==s){var c=this.Versioning.None;void 0!==t.needsUpdate?(c=this.Versioning.NeedsUpdate,this.targetObject=t):void 0!==t.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=t);var u=this.BindingType.Direct;if(void 0!==n){if("morphTargetInfluences"===r){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(a=0;a<this.node.geometry.morphAttributes.position.length;a++)if(t.geometry.morphAttributes.position[a].name===n){n=a;break}}else{if(!t.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(a=0;a<this.node.geometry.morphTargets.length;a++)if(t.geometry.morphTargets[a].name===n){n=a;break}}}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=n}else void 0!==s.fromArray&&void 0!==s.toArray?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][c]}else{var h=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",t)}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(la.prototype,{_getValue_unbound:la.prototype.getValue,_setValue_unbound:la.prototype.setValue}),Object.assign(function(t){var e=arguments;this.uuid=ye.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var i={};this._indicesByUUID=i;for(var r=0,n=arguments.length;r!==n;++r)i[e[r].uuid]=r;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}}}.prototype,{isAnimationObjectGroup:!0,add:function(t){for(var e=arguments,i=this._objects,r=i.length,n=this.nCachedObjects_,o=this._indicesByUUID,a=this._paths,s=this._parsedPaths,c=this._bindings,u=c.length,h=0,l=arguments.length;h!==l;++h){var p=e[h],d=p.uuid,f=o[d],m=void 0;if(void 0===f){f=r++,o[d]=f,i.push(p);for(var g=0,v=u;g!==v;++g)c[g].push(new la(p,a[g],s[g]))}else if(f<n){m=i[f];var y=--n,b=i[y];o[b.uuid]=f,i[f]=b,o[d]=y,i[y]=p;for(g=0,v=u;g!==v;++g){var x=c[g],_=x[y],w=x[f];x[f]=_,void 0===w&&(w=new la(p,a[g],s[g])),x[y]=w}}else i[f]!==m&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=n},remove:function(t){for(var e=arguments,i=this._objects,r=this.nCachedObjects_,n=this._indicesByUUID,o=this._bindings,a=o.length,s=0,c=arguments.length;s!==c;++s){var u=e[s],h=u.uuid,l=n[h];if(void 0!==l&&l>=r){var p=r++,d=i[p];n[d.uuid]=l,i[l]=d,n[h]=p,i[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_=r},uncache:function(t){for(var e=arguments,i=this._objects,r=i.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],l=h.uuid,p=o[l];if(void 0!==p)if(delete o[l],p<n){var d=--n,f=i[d],m=i[x=--r];o[f.uuid]=p,i[p]=f,o[m.uuid]=d,i[d]=m,i.pop();for(var g=0,v=s;g!==v;++g){var y=(_=a[g])[d],b=_[x];_[p]=y,_[d]=b,_.pop()}}else{var x;o[(m=i[x=--r]).uuid]=p,i[p]=m,i.pop();for(g=0,v=s;g!==v;++g){var _;(_=a[g])[p]=_[x],_.pop()}}}this.nCachedObjects_=n},subscribe_:function(t,e){var i=this._bindingsIndicesByPath,r=i[t],n=this._bindings;if(void 0!==r)return n[r];var o=this._paths,a=this._parsedPaths,s=this._objects,c=s.length,u=this.nCachedObjects_,h=new Array(c);r=n.length,i[t]=r,o.push(t),a.push(e),n.push(h);for(var l=u,p=s.length;l!==p;++l){var d=s[l];h[l]=new la(d,t,e)}return h},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){var r=this._paths,n=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];e[t[a]]=i,o[i]=s,o.pop(),n[i]=n[a],n.pop(),r[i]=r[a],r.pop()}}}),Object.assign(pa.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(t){return this._startTime=t,this},setLoop:function(t,e){return this.loop=t,this.repetitions=e,this},setEffectiveWeight:function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(t){return this._scheduleFading(t,0,1)},fadeOut:function(t){return this._scheduleFading(t,1,0)},crossFadeFrom:function(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){var r=this._clip.duration,n=t._clip.duration,o=n/r,a=r/n;t.warp(1,o,e),this.warp(a,1,e)}return this},crossFadeTo:function(t,e,i){return t.crossFadeFrom(this,e,i)},stopFading:function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},setEffectiveTimeScale:function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},syncWith:function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},halt:function(t){return this.warp(this._effectiveTimeScale,0,t)},warp:function(t,e,i){var r=this._mixer,n=r.time,o=this._timeScaleInterpolant,a=this.timeScale;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,c=o.sampleValues;return s[0]=n,s[1]=n+i,c[0]=t/a,c[1]=e/a,this},stopWarping:function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(t,e,i,r){if(this.enabled){var n=this._startTime;if(null!==n){var o=(t-n)*i;if(o<0||0===i)return;this._startTime=null,e=i*o}e*=this._updateTimeScale(t);var a=this._updateTime(e),s=this._updateWeight(t);if(s>0)for(var c=this._interpolants,u=this._propertyBindings,h=0,l=c.length;h!==l;++h)c[h].evaluate(a),u[h].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(t)[0];e*=r,t>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)e*=i.evaluate(t)[0],t>i.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 i=this._clip.duration,r=this.loop,n=this._loopCount;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=i)e=i;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===r;if(-1===n&&(t>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=i||e<0){var a=Math.floor(e/i);e-=i*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?i: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,i-e}return this.time=e,e},_setEndings:function(t,e,i){var r=this._interpolantSettings;i?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=t?this.zeroSlopeAtStart?2401:oe:2402,r.endingEnd=e?this.zeroSlopeAtEnd?2401:oe:2402)},_scheduleFading:function(t,e,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=e,a[1]=n+t,s[1]=i,this}}),Object.assign(function(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}.prototype,f.prototype,{_bindAction:function(t,e){var i=t._localRoot||this._root,r=t._clip.tracks,n=r.length,o=t._propertyBindings,a=t._interpolants,s=i.uuid,c=this._bindingsByRootAndName,u=c[s];void 0===u&&(u={},c[s]=u);for(var h=0;h!==n;++h){var l=r[h],p=l.name,d=u[p];if(void 0!==d)o[h]=d;else{if(void 0!==(d=o[h])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=e&&e._propertyBindings[h].binding.parsedPath;++(d=new ua(la.create(i,p,f),l.ValueTypeName,l.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),o[h]=d}a[h].resultBuffer=d.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,e)}for(var n=t._propertyBindings,o=0,a=n.length;o!==a;++o){var s=n[o];0===s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,i=0,r=e.length;i!==r;++i){var n=e[i];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}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<this._nActiveActions},_addInactiveAction:function(t,e,i){var r=this._actions,n=this._actionsByClip,o=n[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,n[e]=o;else{var a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[i]=t},_removeInactiveAction:function(t){var e=this._actions,i=e[e.length-1],r=t._cacheIndex;i._cacheIndex=r,e[r]=i,e.pop(),t._cacheIndex=null;var n=t._clip.uuid,o=this._actionsByClip,a=o[n],s=a.knownActions,c=s[s.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,s[u]=c,s.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete o[n],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=t._propertyBindings,i=0,r=e.length;i!==r;++i){var n=e[i];0===--n.referenceCount&&this._removeInactiveBinding(n)}},_lendAction:function(t){var e=this._actions,i=t._cacheIndex,r=this._nActiveActions++,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_takeBackAction:function(t){var e=this._actions,i=t._cacheIndex,r=--this._nActiveActions,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_addInactiveBinding:function(t,e,i){var r=this._bindingsByRootAndName,n=r[e],o=this._bindings;void 0===n&&(n={},r[e]=n),n[i]=t,t._cacheIndex=o.length,o.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,i=t.binding,r=i.rootNode.uuid,n=i.path,o=this._bindingsByRootAndName,a=o[r],s=e[e.length-1],c=t._cacheIndex;s._cacheIndex=c,e[c]=s,e.pop(),delete a[n];t:{for(var u in a)break t;delete o[r]}},_lendBinding:function(t){var e=this._bindings,i=t._cacheIndex,r=this._nActiveBindings++,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_takeBackBinding:function(t){var e=this._bindings,i=t._cacheIndex,r=--this._nActiveBindings,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,i=t[e];return void 0===i&&((i=new _o(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=i),i},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,i=t.__cacheIndex,r=--this._nActiveControlInterpolants,n=e[r];t.__cacheIndex=r,e[r]=t,n.__cacheIndex=i,e[i]=n},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e){var i=e||this._root,r=i.uuid,n="string"===typeof t?Lo.findByName(i,t):t,o=null!==n?n.uuid:t,a=this._actionsByClip[o],s=null;if(void 0!==a){var c=a.actionByRoot[r];if(void 0!==c)return c;s=a.knownActions[0],null===n&&(n=s._clip)}if(null===n)return null;var u=new pa(this,n,e);return this._bindAction(u,s),this._addInactiveAction(u,o,r),u},existingAction:function(t,e){var i=e||this._root,r=i.uuid,n="string"===typeof t?Lo.findByName(i,t):t,o=n?n.uuid:t,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[r]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,i=this._bindings,r=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var n=0;n!==e;++n)t[n].reset();for(n=0;n!==r;++n)i[n].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,i=this._nActiveActions,r=this.time+=t,n=Math.sign(t),o=this._accuIndex^=1,a=0;a!==i;++a){e[a]._update(r,t,n,o)}var s=this._bindings,c=this._nActiveBindings;for(a=0;a!==c;++a)s[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,i=t.uuid,r=this._actionsByClip,n=r[i];if(void 0!==n){for(var o=n.knownActions,a=0,s=o.length;a!==s;++a){var c=o[a];this._deactivateAction(c);var u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}},uncacheRoot:function(t){var e=t.uuid,i=this._actionsByClip;for(var r in i){var n=i[r].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}var o=this._bindingsByRootAndName[e];if(void 0!==o)for(var a in o){var s=o[a];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(t,e){var i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}),da.prototype.clone=function(){return new da(void 0===this.value.clone?this.value:this.value.clone())},fa.prototype=Object.assign(Object.create(Ki.prototype),{constructor:fa,isInstancedBufferGeometry:!0,addGroup:function(t,e,i){this.groups.push({start:t,count:e,materialIndex:i})},copy:function(t){var e=t.index;null!==e&&this.setIndex(e.clone());var i=t.attributes;for(var r in i){var n=i[r];this.addAttribute(r,n.clone())}for(var o=t.groups,a=0,s=o.length;a<s;a++){var c=o[a];this.addGroup(c.start,c.count,c.materialIndex)}return this}}),Object.defineProperties(ma.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(ma.prototype,{isInterleavedBufferAttribute:!0,setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=r,this},setXYZW:function(t,e,i,r,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=r,this.data.array[t+3]=n,this}}),Object.defineProperty(ga.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ga.prototype,{isInterleavedBuffer:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.stride:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){t*=this.stride,i*=e.stride;for(var r=0,n=this.stride;r<n;r++)this.array[t+r]=e.array[i+r];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}}),va.prototype=Object.assign(Object.create(ga.prototype),{constructor:va,isInstancedInterleavedBuffer:!0,copy:function(t){return ga.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),ya.prototype=Object.assign(Object.create(Hi.prototype),{constructor:ya,isInstancedBufferAttribute:!0,copy:function(t){return Hi.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Object.assign(function(t,e,i,r){this.ray=new rr(t,e),this.near=i||0,this.far=r||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}}})}.prototype,{linePrecision:1,set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize()):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e){var i=[];return xa(t,this,i,e),i.sort(ba),i},intersectObjects:function(t,e){var i=[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),i;for(var r=0,n=t.length;r<n;r++)xa(t[r],this,i,e);return i.sort(ba),i}}),Object.assign(function(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}.prototype,{start:function(){this.startTime=("undefined"===typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"===typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(t){return this.radius=t.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(ye.clamp(t.y/this.radius,-1,1))),this}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.theta=e,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.radius=Math.sqrt(t.x*t.x+t.z*t.z),this.theta=Math.atan2(t.x,t.z),this.y=t.y,this}}),_a.prototype=Object.create(Zr.prototype),_a.prototype.constructor=_a,_a.prototype.update=function(){var t=new Me,e=new Me,i=new Ci;return function(){var r=["a","b","c"];this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);var n=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,u=0,h=0,l=c.length;h<l;h++)for(var p=c[h],d=0,f=p.vertexNormals.length;d<f;d++){var m=s[p[r[d]]],g=p.vertexNormals[d];t.copy(m).applyMatrix4(n),e.copy(g).applyMatrix3(i).normalize().multiplyScalar(this.size).add(t),o.setXYZ(u,t.x,t.y,t.z),u+=1,o.setXYZ(u,e.x,e.y,e.z),u+=1}else if(a&&a.isBufferGeometry){var v=a.attributes.position,y=a.attributes.normal;for(u=0,d=0,f=v.count;d<f;d++)t.set(v.getX(d),v.getY(d),v.getZ(d)).applyMatrix4(n),e.set(y.getX(d),y.getY(d),y.getZ(d)),e.applyMatrix3(i).normalize().multiplyScalar(this.size).add(t),o.setXYZ(u,t.x,t.y,t.z),u+=1,o.setXYZ(u,e.x,e.y,e.z),u+=1}o.needsUpdate=!0}}(),wa.prototype=Object.create(Zr.prototype),wa.prototype.constructor=wa,wa.prototype.onBeforeRender=function(){var t=new Me,e=new Pe,i=new Pe;return function(){var r=this.bones,n=this.geometry,o=n.getAttribute("position");i.getInverse(this.root.matrixWorld);for(var a=0,s=0;a<r.length;a++){var c=r[a];c.parent&&c.parent.isBone&&(e.multiplyMatrices(i,c.matrixWorld),t.setFromMatrixPosition(e),o.setXYZ(s,t.x,t.y,t.z),e.multiplyMatrices(i,c.parent.matrixWorld),t.setFromMatrixPosition(e),o.setXYZ(s+1,t.x,t.y,t.z),s+=2)}n.getAttribute("position").needsUpdate=!0}}(),Sa.prototype=Object.create(Fi.prototype),Sa.prototype.constructor=Sa,Sa.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},Sa.prototype.update=function(){var t=new Me,e=new mi,i=new mi;return function(){var r=this.children[0],n=r.geometry.getAttribute("color");e.copy(this.light.color),i.copy(this.light.groundColor);for(var o=0,a=n.count;o<a;o++){var s=o<a/2?e:i;n.setXYZ(o,s.r,s.g,s.b)}r.lookAt(t.setFromMatrixPosition(this.light.matrixWorld).negate()),n.needsUpdate=!0}}(),Aa.prototype=Object.create(Zr.prototype),Aa.prototype.constructor=Aa,Aa.prototype.update=function(){var t=new Me,e=new Me,i=new Ci;return function(){this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);for(var r=this.object.matrixWorld,n=this.geometry.attributes.position,o=this.object.geometry,a=o.vertices,s=o.faces,c=0,u=0,h=s.length;u<h;u++){var l=s[u],p=l.normal;t.copy(a[l.a]).add(a[l.b]).add(a[l.c]).divideScalar(3).applyMatrix4(r),e.copy(p).applyMatrix3(i).normalize().multiplyScalar(this.size).add(t),n.setXYZ(c,t.x,t.y,t.z),c+=1,n.setXYZ(c,e.x,e.y,e.z),c+=1}n.needsUpdate=!0}}(),Ma.prototype=Object.create(Zr.prototype),Ma.prototype.constructor=Ma,Ma.prototype.update=function(){var t,e,i=new Me,r=new Bi;function n(n,o,a,s){i.set(o,a,s).unproject(r);var c=e[n];if(void 0!==c)for(var u=t.getAttribute("position"),h=0,l=c.length;h<l;h++)u.setXYZ(c[h],i.x,i.y,i.z)}return function(){t=this.geometry,e=this.pointMap;r.projectionMatrix.copy(this.camera.projectionMatrix),n("c",0,0,-1),n("t",0,0,1),n("n1",-1,-1,-1),n("n2",1,-1,-1),n("n3",-1,1,-1),n("n4",1,1,-1),n("f1",-1,-1,1),n("f2",1,-1,1),n("f3",-1,1,1),n("f4",1,1,1),n("u1",.7,1.1,-1),n("u2",-.7,1.1,-1),n("u3",0,2,-1),n("cf1",-1,0,1),n("cf2",1,0,1),n("cf3",0,-1,1),n("cf4",0,1,1),n("cn1",-1,0,-1),n("cn2",1,0,-1),n("cn3",0,-1,-1),n("cn4",0,1,-1),t.getAttribute("position").needsUpdate=!0}}();var Ta=new Me,Ea=new Pa,Ca=new Pa,Ia=new Pa;function Ra(t){$o.call(this),t.length<2&&console.warn("THREE.CatmullRomCurve3: Points array needs at least two entries."),this.points=t||[],this.closed=!1}function La(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Ra.call(this,t),this.type="catmullrom"}function Oa(t,e){return void 0!==t?t:e}function Na(){var t=window.location.protocol;return null===t.match(/http(s)?:/gi)?"http:":t}function Da(){if("undefined"===typeof window)return!1;var t=window.navigator.userAgent;return/Opera|OPR/.test(t)?"Opera":/Chrome/i.test(t)?"Chrome":/Firefox/i.test(t)?"Firefox":/Mobile(\/.*)? Safari/i.test(t)?"Mobile Safari":/MSIE/i.test(t)?"Internet Explorer":!!/Safari/i.test(t)&&"Safari"}function ka(t){var e,i,r,n=(e="undefined"!==typeof window&&t instanceof window.File||"undefined"!==typeof window&&t instanceof window.Blob?t.name||"":t).lastIndexOf("?"),o=(e=e.substring(0,-1===n?e.length:n)).replace(/^.*[\\\/]/,""),a=o.substring(0,o.lastIndexOf(".")),s=o.split("."),c=s.length>1?s.pop().toLowerCase():"",u=e.match(/^(.+):\/\/(.+)$/);u&&(r=u[1].toLowerCase(),e=u[2]);var h=e.substring(0,e.lastIndexOf("/")+1);if(["gz"].includes(c)){i=c;var l=e.length-c.length-1;c=e.substr(0,l).split(".").pop().toLowerCase();var p=a.length-c.length-1;a=a.substr(0,p)}else i=!1;return{path:e,name:o,ext:c,base:a,dir:h,compressed:i,protocol:r,src:t}}function Fa(t,e){return t<e?-1:t>e?1:0}function Ba(t,e,i){void 0===i&&(i=Fa);for(var r=0,n=t.length-1;r<=n;){var o=r+n>>1,a=i(e,t[o]);if(a>0)r=o+1;else{if(!(a<0))return o;n=o-1}}return-r-1}function za(t,e,i){var r=function(t,e){var i=t.length-1;if(t[i]<e)return-1;for(var r=0;r<=i;){var n=r+i>>1;t[n]>=e?i=n-1:r=n+1}return i+1}(t,e),n=function(t,e){if(t[0]>e)return-1;for(var i=0,r=t.length-1;i<=r;){var n=i+r>>1;t[n]>e?r=n-1:i=n+1}return i-1}(t,i);return-1===r||-1===n||r>n?0:n-r+1}function Ua(t){return t.sort().filter(function(t,e,i){return 0===e||t!==i[e-1]})}function ja(t){if(t.length>28672){for(var e=[],i=0;i<t.length;i+=28672)e.push(String.fromCharCode.apply(null,t.subarray(i,i+28672)));return e.join("")}return String.fromCharCode.apply(null,t)}function Ga(t,e){switch(t){case"int8":return new Int8Array(e);case"int16":return new Int16Array(e);case"int32":return new Int32Array(e);case"uint8":return new Uint8Array(e);case"uint16":return new Uint16Array(e);case"uint32":return new Uint32Array(e);case"float32":return new Float32Array(e);default:throw new Error("arrayType unknown: "+t)}}function Va(t,e){return new(e>65535?Uint32Array:Uint16Array)(t)}function $a(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function Ha(t){return $a(t,Me)}function Wa(t){return $a(t,Pe)}function Xa(t){return $a(t,Ae)}function qa(t){return e=t,i=Float32Array,e instanceof i?e:new i(e);var e,i}function Ya(t){return Oa(t,"").toString().toLowerCase()}Ra.prototype=Object.create($o.prototype),Ra.prototype.constructor=Ra,Ra.prototype.getPoint=function(t){var e,i,r,n,o=this.points,a=o.length,s=(a-(this.closed?0:1))*t,c=Math.floor(s),u=s-c;if(this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o.length)+1)*o.length:0===u&&c===a-1&&(c=a-2,u=1),this.closed||c>0?e=o[(c-1)%a]:(Ta.subVectors(o[0],o[1]).add(o[0]),e=Ta),i=o[c%a],r=o[(c+1)%a],this.closed||c+2<a?n=o[(c+2)%a]:(Ta.subVectors(o[a-1],o[a-2]).add(o[a-1]),n=Ta),void 0===this.type||"centripetal"===this.type||"chordal"===this.type){var h="chordal"===this.type?.5:.25,l=Math.pow(e.distanceToSquared(i),h),p=Math.pow(i.distanceToSquared(r),h),d=Math.pow(r.distanceToSquared(n),h);p<1e-4&&(p=1),l<1e-4&&(l=p),d<1e-4&&(d=p),Ea.initNonuniformCatmullRom(e.x,i.x,r.x,n.x,l,p,d),Ca.initNonuniformCatmullRom(e.y,i.y,r.y,n.y,l,p,d),Ia.initNonuniformCatmullRom(e.z,i.z,r.z,n.z,l,p,d)}else if("catmullrom"===this.type){var f=void 0!==this.tension?this.tension:.5;Ea.initCatmullRom(e.x,i.x,r.x,n.x,f),Ca.initCatmullRom(e.y,i.y,r.y,n.y,f),Ia.initCatmullRom(e.z,i.z,r.z,n.z,f)}return new Me(Ea.calc(u),Ca.calc(u),Ia.calc(u))},$o.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create($o.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},La.prototype=Object.create(Ra.prototype),Object.assign(La.prototype,{initFromArray:function(t){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(t){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(t){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),wa.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(xi.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(Ti.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),nr.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},ye.random16=function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},Object.assign(Ci.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(t){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(t,e,i){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(t,e,i){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(Pe.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){var t;return function(){return void 0===t&&(t=new Me),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),t.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(t){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(t,e,i){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(t,e,i){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,i,r,n,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,i,n,o)}}),Ii.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Ae.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(rr.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(ta.prototype,{extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new An(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Nn(this,t)}}),Object.assign(be.prototype,{fromAttribute:function(t,e,i){return console.error("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)}}),Object.assign(Me.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,i){return console.error("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)}}),Object.assign(we.prototype,{fromAttribute:function(t,e,i){return console.error("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)}}),$i.prototype.computeTangents=function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},Object.assign(Fi.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)}}),Object.defineProperties(Fi.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties($r.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Hr.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Object.defineProperty($o.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),Ui.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(ao.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Hi.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}}}),Object.assign(Ki.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addDrawCall:function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}),Object.defineProperties(Ki.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(da.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Ai.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new mi}}}),Object.defineProperties(qn.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Mi.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(Fr.prototype,{getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}}),Object.defineProperties(Fr.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace."),this.shadowMap.cullFace=t}}}),Object.defineProperties(Li.prototype,{cullFace:{get:function(){return this.renderReverseSided?y:v},set:function(t){var e=t!==v;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+e+"."),this.renderReverseSided=e}}}),Object.defineProperties(Se.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),aa.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new na).load(t,function(t){e.setBuffer(t)}),this},ca.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()};var Za=function(t){this.name=t,this._dict={}},Ka={names:{}};function Qa(t){return Ua(function t(e){var i=e;return e.forEach(function(e){e.__deps&&Array.prototype.push.apply(i,t(e.__deps))}),i}(t)).map(function(t){return t.toString()}).join("\n\n\n")}function Ja(t){var e=t.data.__name,i=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!==i&&(t.__postId=i);try{self.postMessage(t,e)}catch(r){console.error("self.postMessage:",r),self.postMessage(t)}})}}function ts(t,e){var i="'use strict';\n\n"+Qa(e);return i+="\n\n\nself.func = "+t.toString()+";",i+="\n\n\nself.onmessage = "+Ja.toString()+";",new window.Blob([i],{type:"application/javascript"})}Za.prototype.add=function(t,e){this._dict[Ya(t)]=e},Za.prototype.get=function(t){return this._dict[Ya(t)]},Ka.names.get=function(){return Object.keys(this._dict)},Object.defineProperties(Za.prototype,Ka);var es=function(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}};function is(t){return.01745*t}function rs(t){return 57.29578*t}es.prototype.add=function(t,e,i){this._funcDict[t]=e,this._depsDict[t]=i},es.prototype.get=function(t){return this._blobDict[t]||(this._blobDict[t]=ts(this._funcDict[t],this._depsDict[t])),this._blobDict[t]};var ns,os,as,ss,cs,us,hs,ls,ps,ds,fs,ms,gs,vs,ys,bs,xs,_s,ws,Ss,As,Ms,Ps,Ts,Es,Cs,Is,Rs,Ls,Os,Ns,Ds,ks,Fs,Bs,zs,Us,js,Gs,Vs,$s,Hs,Ws,Xs,qs,Ys,Zs,Ks,Qs,Js,tc,ec,ic,rc,nc,oc,ac,sc,cc,uc,hc,lc,pc,dc,fc,mc,gc,vc,yc,bc,xc,_c,wc,Sc,Ac,Mc,Pc,Tc,Ec="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Cc=new Array(36);function Ic(){for(var t,e=0,i=0;i<36;i++)8===i||13===i||18===i||23===i?Cc[i]="-":14===i?Cc[i]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Cc[i]=Ec[19===i?3&t|8:t]);return Cc.join("")}function Rc(t,e,i){return Math.max(e,Math.min(i,t))}function Lc(t){return Rc(t,0,100)}function Oc(t,e,i){return t+(e-t)*i}function Nc(t,e,i,r,n,o){var a=(i-t)*o,s=(r-e)*o,c=n*n;return(2*e-2*i+a+s)*(n*c)+(-3*e+3*i-2*a-s)*c+a*n+e}function Dc(t,e,i){return(i=function(t){return Rc(t,0,1)}(function(t,e,i){return(t-e)/(i-e)}(i,t,e)))*i*(3-2*i)}var kc=[].slice;Sc=function(){var t,e,i,r,n;for(t={},r=0,e=(n="Boolean Number String Function Array Date RegExp Undefined Null".split(" ")).length;r<e;r++)i=n[r],t["[object "+i+"]"]=i.toLowerCase();return function(e){var i;return i=Object.prototype.toString.call(e),t[i]||"object"}}(),qs=function(t,e,i){return null==e&&(e=0),null==i&&(i=1),t<e&&(t=e),t>i&&(t=i),t},Ac=function(t){return t.length>=3?[].slice.call(t):t[0]},Ss=function(t){var e,i;for(t._clipped=!1,t._unclipped=t.slice(0),e=i=0;i<3;e=++i)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},ss=Math.PI,yc=Math.round,Ms=Math.cos,Is=Math.floor,ic=Math.pow,Ys=Math.log,xc=Math.sin,_c=Math.sqrt,gs=Math.atan2,Qs=Math.max,ms=Math.abs,hs=2*ss,cs=ss/3,os=ss/180,us=180/ss,fs=[],(ws=function(){return arguments[0]instanceof ns?arguments[0]:function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,arguments,function(){})}).version="1.3.3",ds={},ls=[],ps=!1,ns=function(){function t(){var t,e,i,r,n,o,a,s,c,u=arguments;for(o=this,e=[],s=0,r=arguments.length;s<r;s++)null!=(t=u[s])&&e.push(t);if(a=e[e.length-1],null!=ds[a])o._rgb=Ss(ds[a](Ac(e.slice(0,-1))));else{for(ps||(ls=ls.sort(function(t,e){return e.p-t.p}),ps=!0),c=0,n=ls.length;c<n&&!(a=(i=ls[c]).test.apply(i,e));c++);a&&(o._rgb=Ss(ds[a].apply(ds,e)))}null==o._rgb&&console.warn("unknown format: "+e),null==o._rgb&&(o._rgb=[0,0,0]),3===o._rgb.length&&o._rgb.push(1)}return t.prototype.toString=function(){return this.hex()},t}(),ws._input=ds,ws.brewer=xs={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},function(){var t,e;for(t in e=[],xs)e.push(xs[t.toLowerCase()]=xs[t])}(),ws.colors=Mc={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},Vs=function(){var t,e,i,r,n,o,a;return r=(e=Ac(arguments))[0],t=e[1],i=e[2],o=(r+16)/116,n=isNaN(t)?o:o+t/500,a=isNaN(i)?o:o-i/200,o=as.Yn*$s(o),n=as.Xn*$s(n),a=as.Zn*$s(a),[Tc(3.2404542*n-1.5371385*o-.4985314*a),Tc(-.969266*n+1.8760108*o+.041556*a),i=Tc(.0556434*n-.2040259*o+1.0572252*a),e.length>3?e[3]:1]},Tc=function(t){return 255*(t<=.00304?12.92*t:1.055*ic(t,1/2.4)-.055)},$s=function(t){return t>as.t1?t*t*t:as.t2*(t-as.t0)},as={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},hc=function(){var t,e,i,r,n,o,a;return i=(r=Ac(arguments))[0],e=r[1],t=r[2],o=(n=mc(i,e,t))[0],[116*(a=n[1])-16,500*(o-a),200*(a-n[2])]},gc=function(t){return(t/=255)<=.04045?t/12.92:ic((t+.055)/1.055,2.4)},Pc=function(t){return t>as.t3?ic(t,1/3):t/as.t2+as.t0},mc=function(){var t,e,i,r;return i=(r=Ac(arguments))[0],e=r[1],t=r[2],i=gc(i),e=gc(e),t=gc(t),[Pc((.4124564*i+.3575761*e+.1804375*t)/as.Xn),Pc((.2126729*i+.7151522*e+.072175*t)/as.Yn),Pc((.0193339*i+.119192*e+.9503041*t)/as.Zn)]},ws.lab=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["lab"]),function(){})},ds.lab=Vs,ns.prototype.lab=function(){return hc(this._rgb)},vs=function(t){var e,i,r,n,o,a,s,c,u,h,l;return 2===(t=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(ws(n));return r}()).length?(u=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(n.lab());return r}(),o=u[0],a=u[1],e=function(t){var e,i;return i=function(){var i,r;for(r=[],e=i=0;i<=2;e=++i)r.push(o[e]+t*(a[e]-o[e]));return r}(),ws.lab.apply(ws,i)}):3===t.length?(h=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(n.lab());return r}(),o=h[0],a=h[1],s=h[2],e=function(t){var e,i;return i=function(){var i,r;for(r=[],e=i=0;i<=2;e=++i)r.push((1-t)*(1-t)*o[e]+2*(1-t)*t*a[e]+t*t*s[e]);return r}(),ws.lab.apply(ws,i)}):4===t.length?(l=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(n.lab());return r}(),o=l[0],a=l[1],s=l[2],c=l[3],e=function(t){var e,i;return i=function(){var i,r;for(r=[],e=i=0;i<=2;e=++i)r.push((1-t)*(1-t)*(1-t)*o[e]+3*(1-t)*(1-t)*t*a[e]+3*(1-t)*t*t*s[e]+t*t*t*c[e]);return r}(),ws.lab.apply(ws,i)}):5===t.length&&(i=vs(t.slice(0,3)),r=vs(t.slice(2,5)),e=function(t){return t<.5?i(2*t):r(2*(t-.5))}),e},ws.bezier=function(t){var e;return(e=vs(t)).scale=function(){return ws.scale(e)},e},ws.cubehelix=function(t,e,i,r,n){var o,a,s;return null==t&&(t=300),null==e&&(e=-1.5),null==i&&(i=1),null==r&&(r=1),null==n&&(n=[0,1]),o=0,"array"===Sc(n)?a=n[1]-n[0]:(a=0,n=[n,n]),(s=function(s){var c,u,h,l,p;return c=hs*((t+120)/360+e*s),l=ic(n[0]+a*s,r),u=(0!==o?i[0]+s*o:i)*l*(1-l)/2,h=Ms(c),p=xc(c),ws(Ss([255*(l+u*(-.14861*h+1.78277*p)),255*(l+u*(-.29227*h-.90649*p)),255*(l+u*(1.97294*h))]))}).start=function(e){return null==e?t:(t=e,s)},s.rotations=function(t){return null==t?e:(e=t,s)},s.gamma=function(t){return null==t?r:(r=t,s)},s.hue=function(t){return null==t?i:("array"===Sc(i=t)?0===(o=i[1]-i[0])&&(i=i[1]):o=0,s)},s.lightness=function(t){return null==t?n:("array"===Sc(t)?(n=t,a=t[1]-t[0]):(n=[t,t],a=0),s)},s.scale=function(){return ws.scale(s)},s.hue(i),s},ws.random=function(){var t,e;for("0123456789abcdef",t="#",e=0;e<6;++e)t+="0123456789abcdef".charAt(Is(16*Math.random()));return new ns(t)},ws.average=function(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f;for(u in null==e&&(e="rgb"),h=t.length,o=[],a=0,s=0,d=(c=(t=t.map(function(t){return ws(t)})).splice(0,1)[0]).get(e))d[u]=d[u]||0,o.push(isNaN(d[u])?0:1),"h"!==e.charAt(u)||isNaN(d[u])||(i=d[u]/180*ss,a+=Ms(i),s+=xc(i));for(r=c.alpha(),p=0,l=t.length;p<l;p++)for(u in f=(n=t[p]).get(e),r+=n.alpha(),d)isNaN(f[u])||(d[u]+=f[u],o[u]+=1,"h"===e.charAt(u)&&(i=d[u]/180*ss,a+=Ms(i),s+=xc(i)));for(u in d)if(d[u]=d[u]/o[u],"h"===e.charAt(u)){for(i=gs(s/o[u],a/o[u])/ss*180;i<0;)i+=360;for(;i>=360;)i-=360;d[u]=i}return ws(d,e).alpha(r/h)},ds.rgb=function(){var t,e,i,r;for(t in i=[],e=Ac(arguments))r=e[t],i.push(r);return i},ws.rgb=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["rgb"]),function(){})},ns.prototype.rgb=function(t){return null==t&&(t=!0),t?this._rgb.map(Math.round).slice(0,3):this._rgb.slice(0,3)},ns.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)},ls.push({p:3,test:function(t){var e;return e=Ac(arguments),"array"===Sc(e)&&3===e.length?"rgb":4===e.length&&"number"===Sc(e[3])&&e[3]>=0&&e[3]<=1?"rgb":void 0}}),Ls=function(t){var e,i;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]),[(i=parseInt(t,16))>>16,i>>8&255,255&i,1];if(t.match(/^#?([A-Fa-f0-9]{8})$/))return 9===t.length&&(t=t.substr(1)),[(i=parseInt(t,16))>>24&255,i>>16&255,i>>8&255,yc((255&i)/255*100)/100];if(null!=ds.css&&(e=ds.css(t)))return e;throw"unknown color: "+t},ac=function(t,e){var i,r,n,o,a,s;return null==e&&(e="rgb"),a=t[0],n=t[1],r=t[2],i=t[3],a=Math.round(a),n=Math.round(n),r=Math.round(r),s=(s="000000"+(a<<16|n<<8|r).toString(16)).substr(s.length-6),o=(o="0"+yc(255*i).toString(16)).substr(o.length-2),"#"+function(){switch(e.toLowerCase()){case"rgba":return s+o;case"argb":return o+s;default:return s}}()},ds.hex=function(t){return Ls(t)},ws.hex=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["hex"]),function(){})},ns.prototype.hex=function(t){return null==t&&(t="rgb"),ac(this._rgb,t)},ls.push({p:4,test:function(t){if(1===arguments.length&&"string"===Sc(t))return"hex"}}),Ds=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d;if(n=(t=Ac(arguments))[0],h=t[1],a=t[2],0===h)c=r=e=255*a;else{for(i=[0,0,0],l=2*a-(p=a<.5?a*(1+h):a+h-a*h),(d=[0,0,0])[0]=(n/=360)+1/3,d[1]=n,d[2]=n-1/3,o=s=0;s<=2;o=++s)d[o]<0&&(d[o]+=1),d[o]>1&&(d[o]-=1),6*d[o]<1?i[o]=l+6*(p-l)*d[o]:2*d[o]<1?i[o]=p:3*d[o]<2?i[o]=l+(p-l)*(2/3-d[o])*6:i[o]=l;c=(u=[yc(255*i[0]),yc(255*i[1]),yc(255*i[2])])[0],r=u[1],e=u[2]}return t.length>3?[c,r,e,t[3]]:[c,r,e]},cc=function(t,e,i){var r,n,o,a,s;return void 0!==t&&t.length>=3&&(t=(a=t)[0],e=a[1],i=a[2]),t/=255,e/=255,i/=255,o=Math.min(t,e,i),n=((Qs=Math.max(t,e,i))+o)/2,Qs===o?(s=0,r=Number.NaN):s=n<.5?(Qs-o)/(Qs+o):(Qs-o)/(2-Qs-o),t===Qs?r=(e-i)/(Qs-o):e===Qs?r=2+(i-t)/(Qs-o):i===Qs&&(r=4+(t-e)/(Qs-o)),(r*=60)<0&&(r+=360),[r,s,n]},ws.hsl=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["hsl"]),function(){})},ds.hsl=Ds,ns.prototype.hsl=function(){return cc(this._rgb)},ks=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v;if(n=(t=Ac(arguments))[0],m=t[1],v=t[2],v*=255,0===m)c=r=e=v;else switch(360===n&&(n=0),n>360&&(n-=360),n<0&&(n+=360),a=v*(1-m),s=v*(1-m*(i=(n/=60)-(o=Is(n)))),g=v*(1-m*(1-i)),o){case 0:c=(u=[v,g,a])[0],r=u[1],e=u[2];break;case 1:c=(h=[s,v,a])[0],r=h[1],e=h[2];break;case 2:c=(l=[a,v,g])[0],r=l[1],e=l[2];break;case 3:c=(p=[a,s,v])[0],r=p[1],e=p[2];break;case 4:c=(d=[g,a,v])[0],r=d[1],e=d[2];break;case 5:c=(f=[v,a,s])[0],r=f[1],e=f[2]}return[c,r,e,t.length>3?t[3]:1]},uc=function(){var t,e,i,r,n,o,a,s,c;return o=(a=Ac(arguments))[0],i=a[1],t=a[2],n=Math.min(o,i,t),e=(Qs=Math.max(o,i,t))-n,c=Qs/255,0===Qs?(r=Number.NaN,s=0):(s=e/Qs,o===Qs&&(r=(i-t)/e),i===Qs&&(r=2+(t-o)/e),t===Qs&&(r=4+(o-i)/e),(r*=60)<0&&(r+=360)),[r,s,c]},ws.hsv=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["hsv"]),function(){})},ds.hsv=ks,ns.prototype.hsv=function(){return uc(this._rgb)},tc=function(t){return"number"===Sc(t)&&t>=0&&t<=16777215?[t>>16,t>>8&255,255&t,1]:(console.warn("unknown num color: "+t),[0,0,0,1])},dc=function(){var t;return((t=Ac(arguments))[0]<<16)+(t[1]<<8)+t[2]},ws.num=function(t){return new ns(t,"num")},ns.prototype.num=function(t){return null==t&&(t="rgb"),dc(this._rgb,t)},ds.num=tc,ls.push({p:1,test:function(t){if(1===arguments.length&&"number"===Sc(t)&&t>=0&&t<=16777215)return"num"}}),Rs=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b;if(s=(i=Ac(arguments))[0],n=i[1],e=i[2],a=a/100*255,t=255*(n/=100),0===n)l=a=r=e;else switch(360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360),h=(u=e*(1-n))+t*(1-(o=(s/=60)-(c=Is(s)))),y=u+t*o,b=u+t,c){case 0:l=(p=[b,y,u])[0],a=p[1],r=p[2];break;case 1:l=(d=[h,b,u])[0],a=d[1],r=d[2];break;case 2:l=(f=[u,b,y])[0],a=f[1],r=f[2];break;case 3:l=(m=[u,h,b])[0],a=m[1],r=m[2];break;case 4:l=(g=[y,u,b])[0],a=g[1],r=g[2];break;case 5:l=(v=[b,u,h])[0],a=v[1],r=v[2]}return[l,a,r,i.length>3?i[3]:1]},oc=function(){var t,e,i,r,n,o,a,s,c;return s=(c=Ac(arguments))[0],n=c[1],e=c[2],a=Math.min(s,n,e),i=100*(r=(Qs=Math.max(s,n,e))-a)/255,t=a/(255-r)*100,0===r?o=Number.NaN:(s===Qs&&(o=(n-e)/r),n===Qs&&(o=2+(e-s)/r),e===Qs&&(o=4+(s-n)/r),(o*=60)<0&&(o+=360)),[o,i,t]},ws.hcg=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["hcg"]),function(){})},ds.hcg=Rs,ns.prototype.hcg=function(){return oc(this._rgb)},Ps=function(t){var e,i,r,n,o,a,s,c;if(t=t.toLowerCase(),null!=ws.colors&&ws.colors[t])return Ls(ws.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]=yc(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=i=0;i<=2;n=++i)s[n]=yc(2.55*s[n]);s[3]=+s[3]}else(o=t.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((r=o.slice(1,4))[1]*=.01,r[2]*=.01,(s=Ds(r))[3]=1):(o=t.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((r=o.slice(1,4))[1]*=.01,r[2]*=.01,(s=Ds(r))[3]=+o[4]);return s},nc=function(t){var e;return"rgb"===(e=t[3]<1?"rgba":"rgb")?e+"("+t.slice(0,3).map(yc).join(",")+")":"rgba"===e?e+"("+t.slice(0,3).map(yc).join(",")+","+t[3]+")":void 0},vc=function(t){return yc(100*t)/100},Ns=function(t,e){var i;return i=e<1?"hsla":"hsl",t[0]=vc(t[0]||0),t[1]=vc(100*t[1])+"%",t[2]=vc(100*t[2])+"%","hsla"===i&&(t[3]=e),i+"("+t.join(",")+")"},ds.css=function(t){return Ps(t)},ws.css=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["css"]),function(){})},ns.prototype.css=function(t){return null==t&&(t="rgb"),"rgb"===t.slice(0,3)?nc(this._rgb):"hsl"===t.slice(0,3)?Ns(this.hsl(),this.alpha()):void 0},ds.named=function(t){return Ls(Mc[t])},ls.push({p:5,test:function(t){if(1===arguments.length&&null!=Mc[t])return"named"}}),ns.prototype.name=function(t){var e,i;for(i in arguments.length&&(Mc[t]&&(this._rgb=Ls(Mc[t])),this._rgb[3]=1),e=this.hex(),Mc)if(e===Mc[i])return i;return e},Hs=function(){var t,e,i,r;return i=(r=Ac(arguments))[0],t=r[1],e=r[2],[i,Ms(e*=os)*t,xc(e)*t]},Ws=function(){var t,e,i,r,n,o,a,s,c;return a=(i=Ac(arguments))[0],n=i[1],o=i[2],t=(s=Hs(a,n,o))[0],e=s[1],r=s[2],[(c=Vs(t,e,r))[0],c[1],r=c[2],i.length>3?i[3]:1]},Gs=function(){var t,e,i,r,n,o;return n=(o=Ac(arguments))[0],t=o[1],e=o[2],i=_c(t*t+e*e),r=(gs(e,t)*us+360)%360,0===yc(1e4*i)&&(r=Number.NaN),[n,i,r]},lc=function(){var t,e,i,r,n,o,a;return n=(o=Ac(arguments))[0],i=o[1],e=o[2],r=(a=hc(n,i,e))[0],t=a[1],e=a[2],Gs(r,t,e)},ws.lch=function(){var t;return t=Ac(arguments),new ns(t,"lch")},ws.hcl=function(){var t;return t=Ac(arguments),new ns(t,"hcl")},ds.lch=Ws,ds.hcl=function(){var t,e,i,r;return e=(r=Ac(arguments))[0],t=r[1],i=r[2],Ws([i,t,e])},ns.prototype.lch=function(){return lc(this._rgb)},ns.prototype.hcl=function(){return lc(this._rgb).reverse()},rc=function(t){var e,i,r,n,o,a;return null==t&&(t="rgb"),o=(a=Ac(arguments))[0],r=a[1],e=a[2],r/=255,e/=255,[(1-(o/=255)-(n=1-Math.max(o,Math.max(r,e))))*(i=n<1?1/(1-n):0),(1-r-n)*i,(1-e-n)*i,n]},As=function(){var t,e,i,r,n,o;return i=(e=Ac(arguments))[0],n=e[1],o=e[2],r=e[3],t=e.length>4?e[4]:1,1===r?[0,0,0,t]:[i>=1?0:255*(1-i)*(1-r),n>=1?0:255*(1-n)*(1-r),o>=1?0:255*(1-o)*(1-r),t]},ds.cmyk=function(){return As(Ac(arguments))},ws.cmyk=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["cmyk"]),function(){})},ns.prototype.cmyk=function(){return rc(this._rgb)},ds.gl=function(){var t,e,i,r,n;for(r=function(){var t,i;for(e in i=[],t=Ac(arguments))n=t[e],i.push(n);return i}.apply(this,arguments),t=i=0;i<=2;t=++i)r[t]*=255;return r},ws.gl=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["gl"]),function(){})},ns.prototype.gl=function(){var t;return[(t=this._rgb)[0]/255,t[1]/255,t[2]/255,t[3]]},pc=function(t,e,i){var r;return t=(r=Ac(arguments))[0],e=r[1],i=r[2],.2126*(t=Zs(t))+.7152*(e=Zs(e))+.0722*(i=Zs(i))},Zs=function(t){return(t/=255)<=.03928?t/12.92:ic((t+.055)/1.055,2.4)},fs=[],Fs=function(t,e,i,r){var n,o,a,s;for(null==i&&(i=.5),null==r&&(r="rgb"),"object"!==Sc(t)&&(t=ws(t)),"object"!==Sc(e)&&(e=ws(e)),a=0,o=fs.length;a<o;a++)if(r===(n=fs[a])[0]){s=n[1](t,e,i,r);break}if(null==s)throw"color mode "+r+" is not supported";return s.alpha(t.alpha()+i*(e.alpha()-t.alpha()))},ws.interpolate=Fs,ns.prototype.interpolate=function(t,e,i){return Fs(this,t,e,i)},ws.mix=Fs,ns.prototype.mix=ns.prototype.interpolate,js=function(t,e,i,r){var n,o;return n=t._rgb,o=e._rgb,new ns(n[0]+i*(o[0]-n[0]),n[1]+i*(o[1]-n[1]),n[2]+i*(o[2]-n[2]),r)},fs.push(["rgb",js]),ns.prototype.luminance=function(t,e){var i,r,n,o;return null==e&&(e="rgb"),arguments.length?(0===t?this._rgb=[0,0,0,this._rgb[3]]:1===t?this._rgb=[255,255,255,this._rgb[3]]:(r=1e-7,n=20,o=function(i,a){var s,c;return s=(c=i.interpolate(a,.5,e)).luminance(),Math.abs(t-s)<r||!n--?c:s>t?o(i,c):o(c,a)},i=pc(this._rgb),this._rgb=(i>t?o(ws("black"),this):o(this,ws("white"))).rgba()),this):pc(this._rgb)},wc=function(t){var e,i,r,n;return(n=t/100)<66?(r=255,i=-155.25485562709179-.44596950469579133*(i=n-2)+104.49216199393888*Ys(i),e=n<20?0:.8274096064007395*(e=n-10)-254.76935184120902+115.67994401066147*Ys(e)):(r=351.97690566805693+.114206453784165*(r=n-55)-40.25366309332127*Ys(r),i=325.4494125711974+.07943456536662342*(i=n-50)-28.0852963507957*Ys(i),e=255),[r,i,e]},fc=function(){var t,e,i,r,n,o,a,s;for(n=(o=Ac(arguments))[0],o[1],t=o[2],r=1e3,i=4e4,e=.4;i-r>e;)(a=wc(s=.5*(i+r)))[2]/a[0]>=t/n?i=s:r=s;return yc(s)},ws.temperature=ws.kelvin=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["temperature"]),function(){})},ds.temperature=ds.kelvin=ds.K=wc,ns.prototype.temperature=function(){return fc(this._rgb)},ns.prototype.kelvin=ns.prototype.temperature,ws.contrast=function(t,e){var i,r,n,o;return"string"!==(n=Sc(t))&&"number"!==n||(t=new ns(t)),"string"!==(o=Sc(e))&&"number"!==o||(e=new ns(e)),(i=t.luminance())>(r=e.luminance())?(i+.05)/(r+.05):(r+.05)/(i+.05)},ws.distance=function(t,e,i){var r,n,o,a,s,c,u;for(n in null==i&&(i="lab"),"string"!==(s=Sc(t))&&"number"!==s||(t=new ns(t)),"string"!==(c=Sc(e))&&"number"!==c||(e=new ns(e)),o=t.get(i),a=e.get(i),u=0,o)u+=(r=(o[n]||0)-(a[n]||0))*r;return Math.sqrt(u)},ws.deltaE=function(t,e,i,r){var n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T;for(null==i&&(i=1),null==r&&(r=1),"string"!==(y=Sc(t))&&"number"!==y||(t=new ns(t)),"string"!==(b=Sc(e))&&"number"!==b||(e=new ns(e)),n=(x=t.lab())[0],a=x[1],c=x[2],o=(_=e.lab())[0],s=_[1],u=_[2],h=_c(a*a+c*c),l=_c(s*s+u*u),S=n<16?.511:.040975*n/(1+.01765*n),w=.0638*h/(1+.0131*h)+.638,v=h<1e-6?0:180*gs(c,a)/ss;v<0;)v+=360;for(;v>=360;)v-=360;return A=v>=164&&v<=345?.56+ms(.2*Ms(ss*(v+168)/180)):.36+ms(.4*Ms(ss*(v+35)/180)),g=_c((p=h*h*h*h)/(p+1900)),_c((M=(n-o)/(i*S))*M+(P=(m=h-l)/(r*w))*P+((d=a-s)*d+(f=c-u)*f-m*m)/((T=w*(g*A+1-g))*T))},ns.prototype.get=function(t){var e,i,r,n,o;return this,r=(n=t.split("."))[0],e=n[1],o=this[r](),e?(i=r.indexOf(e))>-1?o[i]:console.warn("unknown channel "+e+" in mode "+r):o},ns.prototype.set=function(t,e){var i,r,n,o,a;if(this,n=(o=t.split("."))[0],i=o[1])if(a=this[n](),(r=n.indexOf(i))>-1)if("string"===Sc(e))switch(e.charAt(0)){case"+":case"-":a[r]+=+e;break;case"*":a[r]*=+e.substr(1);break;case"/":a[r]/=+e.substr(1);break;default:a[r]=+e}else a[r]=e;else console.warn("unknown channel "+i+" in mode "+n);else a=e;return ws(a,n).alpha(this.alpha())},ns.prototype.clipped=function(){return this._rgb._clipped||!1},ns.prototype.alpha=function(t){return arguments.length?ws.rgb([this._rgb[0],this._rgb[1],this._rgb[2],t]):this._rgb[3]},ns.prototype.darken=function(t){var e;return null==t&&(t=1),this,(e=this.lab())[0]-=as.Kn*t,ws.lab(e).alpha(this.alpha())},ns.prototype.brighten=function(t){return null==t&&(t=1),this.darken(-t)},ns.prototype.darker=ns.prototype.darken,ns.prototype.brighter=ns.prototype.brighten,ns.prototype.saturate=function(t){var e;return null==t&&(t=1),this,(e=this.lch())[1]+=t*as.Kn,e[1]<0&&(e[1]=0),ws.lch(e).alpha(this.alpha())},ns.prototype.desaturate=function(t){return null==t&&(t=1),this.saturate(-t)},ns.prototype.premultiply=function(){var t,e;return e=this.rgb(),t=this.alpha(),ws(e[0]*t,e[1]*t,e[2]*t,t)},Js=function(t,e){return t*e/255},Ts=function(t,e){return t>e?e:t},Xs=function(t,e){return t>e?t:e},bc=function(t,e){return 255*(1-(1-t/255)*(1-e/255))},ec=function(t,e){return e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255))},_s=function(t,e){return 255*(1-(1-e/255)/(t/255))},Es=function(t,e){return 255===t?255:(t=e/255*255/(1-t/255))>255?255:t},(ys=function(t,e,i){if(!ys[i])throw"unknown blend mode "+i;return ys[i](t,e)}).normal=(bs=function(t){return function(e,i){var r,n;return r=ws(i).rgb(),n=ws(e).rgb(),ws(t(r,n),"rgb")}})((Cs=function(t){return function(e,i){var r,n,o;for(o=[],r=n=0;n<=3;r=++n)o[r]=t(e[r],i[r]);return o}})(function(t,e){return t})),ys.multiply=bs(Cs(Js)),ys.screen=bs(Cs(bc)),ys.overlay=bs(Cs(ec)),ys.darken=bs(Cs(Ts)),ys.lighten=bs(Cs(Xs)),ys.dodge=bs(Cs(Es)),ys.burn=bs(Cs(_s)),ws.blend=ys,ws.analyze=function(t){var e,i,r,n;for(r={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},i=0,e=t.length;i<e;i++)null==(n=t[i])||isNaN(n)||(r.values.push(n),r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.count+=1);return r.domain=[r.min,r.max],r.limits=function(t,e){return ws.limits(r,t,e)},r},ws.scale=function(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_;return u="rgb",h=ws("#ccc"),f=0,!1,a=[0,1],d=[],p=[0,0],i=!1,n=[],l=!1,c=0,s=1,o=!1,r={},m=!0,x=function(t){var e,i,r,o,a,s;if(null==t&&(t=["#fff","#000"]),null!=t&&"string"===Sc(t)&&null!=ws.brewer&&(t=ws.brewer[t]||ws.brewer[t.toLowerCase()]||t),"array"===Sc(t)){for(e=r=0,o=(t=t.slice(0)).length-1;0<=o?r<=o:r>=o;e=0<=o?++r:--r)i=t[e],"string"===Sc(i)&&(t[e]=ws(i));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,r;if(null!=i){for(r=i.length-1,e=0;e<r&&t>=i[e];)e++;return e-1}return 0},_=function(t){return t},function(t){var e,r,n,o,a;return a=t,i.length>2&&(o=i.length-1,e=v(t),n=i[0]+(i[1]-i[0])*(0+.5*f),r=i[o-1]+(i[o]-i[o-1])*(1-.5*f),a=c+(i[e]+.5*(i[e+1]-i[e])-n)/(r-n)*(s-c)),a},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:i&&i.length>2?(b=v(t)/(i.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&&r[l])o=r[l];else{if("array"===Sc(n))for(a=f=0,y=d.length-1;0<=y?f<=y:f>=y;a=0<=y?++f:--f){if(b<=(g=d[a])){o=n[a];break}if(b>=g&&a===d.length-1){o=n[a];break}if(b>g&&b<d[a+1]){b=(b-g)/(d[a+1]-g),o=ws.interpolate(n[a],n[a+1],b,u);break}}else"function"===Sc(n)&&(o=n(b));m&&(r[l]=o)}return o},b=function(){return r={}},x(t),(g=function(t){var e;return e=ws(y(t)),l&&e[l]?e[l]():e}).classes=function(t){var e;return null!=t?("array"===Sc(t)?(i=t,a=[t[0],t[t.length-1]]):(e=ws.analyze(a),i=0===t?[e.min,e.max]:ws.limits(e,"e",t)),g):i},g.domain=function(t){var e,i,r,o,u,h,l;if(!arguments.length)return a;if(c=t[0],s=t[t.length-1],d=[],r=n.length,t.length===r&&c!==s)for(u=0,o=t.length;u<o;u++)i=t[u],d.push((i-c)/(s-c));else for(e=l=0,h=r-1;0<=h?l<=h:l>=h;e=0<=h?++l:--l)d.push(e/(r-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,i,r,n,o,a,s,c,u;for(e=y(0,!0).lab()[0],i=y(1,!0).lab()[0],s=e>i,r=y(t,!0).lab()[0],n=r-(o=e+(i-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)),r=y(t,!0).lab()[0],n=r-o;return t}:function(t){return t},g},g.padding=function(t){return null!=t?("number"===Sc(t)&&(t=[t,t]),p=t,g):p},g.colors=function(e,r){var o,s,c,u,h,l,p;if(null==r&&(r="hex"),0===arguments.length)return n.map(function(t){return t[r]()});if(e)return 1===e?g(.5)[r]():(s=a[0],o=a[1]-s,function(){h=[];for(var t=0;0<=e?t<e:t>e;0<=e?t++:t--)h.push(t);return h}.apply(this).map(function(t){return g(s+t/(e-1)*o)[r]()}));if(t=[],l=[],i&&i.length>2)for(c=p=1,u=i.length;1<=u?p<u:p>u;c=1<=u?++p:--p)l.push(.5*(i[c-1]+i[c]));else l=a;return l.map(function(t){return g(t)[r]()})},g.cache=function(t){return null!=t?m=t:m},g},null==ws.scales&&(ws.scales={}),ws.scales.cool=function(){return ws.scale([ws.hsl(180,1,.9),ws.hsl(250,.7,.4)])},ws.scales.hot=function(){return ws.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},ws.analyze=function(t,e,i){var r,n,o,a,s,c;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==i&&(i=function(){return!0}),r=function(t){null==t||isNaN(t)||(s.values.push(t),s.sum+=t,t<s.min&&(s.min=t),t>s.max&&(s.max=t),s.count+=1)},c=function(t,n){if(i(t,n))return null!=e&&"function"===Sc(e)?r(e(t)):null!=e&&"string"===Sc(e)||"number"===Sc(e)?r(t[e]):r(t)},"array"===Sc(t))for(a=0,o=t.length;a<o;a++)c(t[a]);else for(n in t)c(t[n],n);return s.domain=[s.min,s.max],s.limits=function(t,e){return ws.limits(s,t,e)},s},ws.limits=function(t,e,i){var r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I,R,L,O,N,D,k,F,B,z,U,j,G,V,$,H,W,X,q,Y,Z,K,Q,J,tt,et,it,rt;if(null==e&&(e="equal"),null==i&&(i=7),"array"===Sc(t)&&(t=ws.analyze(t)),T=t.min,Qs=t.max,t.sum,it=t.values.sort(function(t,e){return t-e}),1===i)return[T,Qs];if(M=[],"c"===e.substr(0,1)&&(M.push(T),M.push(Qs)),"e"===e.substr(0,1)){for(M.push(T),w=O=1,F=i-1;1<=F?O<=F:O>=F;w=1<=F?++O:--O)M.push(T+w/i*(Qs-T));M.push(Qs)}else if("l"===e.substr(0,1)){if(T<=0)throw"Logarithmic scales are only possible for values > 0";for(E=Math.LOG10E*Ys(T),P=Math.LOG10E*Ys(Qs),M.push(T),w=rt=1,B=i-1;1<=B?rt<=B:rt>=B;w=1<=B?++rt:--rt)M.push(ic(10,E+w/i*(P-E)));M.push(Qs)}else if("q"===e.substr(0,1)){for(M.push(T),w=r=1,$=i-1;1<=$?r<=$:r>=$;w=1<=$?++r:--r)N=(it.length-1)*w/i,(D=Is(N))===N?M.push(it[D]):(k=N-D,M.push(it[D]*(1-k)+it[D+1]*k));M.push(Qs)}else if("k"===e.substr(0,1)){for(I=it.length,g=new Array(I),x=new Array(i),Q=!0,R=0,y=null,(y=[]).push(T),w=n=1,H=i-1;1<=H?n<=H:n>=H;w=1<=H?++n:--n)y.push(T+w/i*(Qs-T));for(y.push(Qs);Q;){for(S=o=0,W=i-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=it[w],C=Number.MAX_VALUE,S=s=0,q=i-1;0<=q?s<=q:s>=q;S=0<=q?++s:--s)(_=ms(y[S]-et))<C&&(C=_,v=S);x[v]++,g[w]=v}for(L=new Array(i),S=c=0,Y=i-1;0<=Y?c<=Y:c>=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]=it[w]:L[b]+=it[w];for(S=h=0,K=i-1;0<=K?h<=K:h>=K;S=0<=K?++h:--h)L[S]*=1/x[S];for(Q=!1,S=l=0,z=i-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=i-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(it[w]);for(J=[],S=f=0,G=i-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},Os=function(t,e,i){var r,n,o,a;return t=(r=Ac(arguments))[0],e=r[1],i=r[2],isNaN(t)&&(t=0),(t/=360)<1/3?o=1-((n=(1-e)/3)+(a=(1+e*Ms(hs*t)/Ms(cs-hs*t))/3)):t<2/3?n=1-((a=(1-e)/3)+(o=(1+e*Ms(hs*(t-=1/3))/Ms(cs-hs*t))/3)):a=1-((o=(1-e)/3)+(n=(1+e*Ms(hs*(t-=2/3))/Ms(cs-hs*t))/3)),[255*(a=qs(i*a*3)),255*(o=qs(i*o*3)),255*(n=qs(i*n*3)),r.length>3?r[3]:1]},sc=function(){var t,e,i,r,n,o,a;return n=(o=Ac(arguments))[0],e=o[1],t=o[2],hs=2*Math.PI,n/=255,e/=255,t/=255,0===(a=1-Math.min(n,e,t)/(r=(n+e+t)/3))?i=0:(i=(n-e+(n-t))/2,i/=Math.sqrt((n-e)*(n-e)+(n-t)*(e-t)),i=Math.acos(i),t>e&&(i=hs-i),i/=hs),[360*i,a,r]},ws.hsi=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(ns,kc.call(arguments).concat(["hsi"]),function(){})},ds.hsi=Os,ns.prototype.hsi=function(){return sc(this._rgb)},Bs=function(t,e,i,r){var n,o,a,s,c,u,h,l,p,d;return"hsl"===r?(p=t.hsl(),d=e.hsl()):"hsv"===r?(p=t.hsv(),d=e.hsv()):"hcg"===r?(p=t.hcg(),d=e.hcg()):"hsi"===r?(p=t.hsi(),d=e.hsi()):"lch"!==r&&"hcl"!==r||(r="hcl",p=t.hcl(),d=e.hcl()),"h"===r.substr(0,1)&&(o=p[0],h=p[1],s=p[2],a=d[0],l=d[1],c=d[2]),isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?n=Number.NaN:(n=a,1!==s&&0!==s||"hsv"===r||(u=l)):(n=o,1!==c&&0!==c||"hsv"===r||(u=h)):n=o+i*(a>o&&a-o>180?a-(o+360):a<o&&o-a>180?a+360-o:a-o),null==u&&(u=h+i*(l-h)),ws[r](n,u,s+i*(c-s))},Us=function(t,e,i,r){var n,o;return n=t.num(),o=e.num(),ws.num(n+(o-n)*i,"num")},(fs=fs.concat(function(){var t,e,i,r;for(r=[],e=0,t=(i=["hsv","hsl","hsi","hcl","lch","hcg"]).length;e<t;e++)Ks=i[e],r.push([Ks,Bs]);return r}())).push(["num",Us]),zs=function(t,e,i,r){var n,o;return n=t.lab(),o=e.lab(),new ns(n[0]+i*(o[0]-n[0]),n[1]+i*(o[1]-n[1]),n[2]+i*(o[2]-n[2]),r)},fs.push(["lab",zs]);var Fc=ws,Bc=function(t){var e=t||{};this.scale=Oa(e.scale,"uniform"),this.mode=Oa(e.mode,"hcl"),this.domain=Oa(e.domain,[0,1]),this.value=new mi(Oa(e.value,16777215)).getHex(),this.reverse=Oa(e.reverse,!1),this.structure=e.structure,this.volume=e.volume,this.surface=e.surface,this.structure&&(this.atomProxy=this.structure.getAtomProxy())};function zc(t,e,i,r,n){this._listener=e,this._isOnce=i,this.context=r,this._signal=t,this._priority=n||0}function Uc(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 jc(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){jc.prototype.dispatch.apply(t,arguments)}}Bc.prototype.getScale=function(t){var e=t||{},i=Oa(e.scale,this.scale);"rainbow"===i?i=["red","orange","yellow","green","blue"]:"rwb"===i&&(i=["red","white","blue"]);var r=Oa(e.domain,this.domain);return this.reverse&&(r=r.slice().reverse()),Fc.scale(i).mode(Oa(e.mode,this.mode)).domain(r).out("num")},Bc.prototype.colorToArray=function(t,e,i){return void 0===e&&(e=[]),void 0===i&&(i=0),e[i+0]=(t>>16&255)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(255&t)/255,e},Bc.prototype.atomColorToArray=function(t,e,i){return this.colorToArray(this.atomColor(t),e,i)},Bc.prototype.bondColor=function(t,e){return this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)},Bc.prototype.bondColorToArray=function(t,e,i,r){return this.colorToArray(this.bondColor(t,e),i,r)},Bc.prototype.volumeColorToArray=function(t,e,i){return this.colorToArray(this.volumeColor(t),e,i)},Bc.prototype.positionColorToArray=function(t,e,i){return this.colorToArray(this.positionColor(t),e,i)},zc.prototype={active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,i),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+"]"}},jc.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,e,i,r){var n,o=this._indexOfListener(t,i);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 zc(this,t,e,i,r),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 i,r=this._bindings.length;r--;)if((i=this._bindings[r])._listener===t&&i.context===e)return r;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){return Uc(t,"add"),this._registerListener(t,!1,e,i)},addOnce:function(t,e,i){return Uc(t,"addOnce"),this._registerListener(t,!0,e,i)},remove:function(t,e){Uc(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(){for(var t=this._bindings.length;t--;)this._bindings[t]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(t){if(this.active){var e,i=Array.prototype.slice.call(arguments),r=this._bindings.length;if(this.memorize&&(this._prevParams=i),r){e=this._bindings.slice(),this._shouldPropagate=!0;do{r--}while(e[r]&&this._shouldPropagate&&!1!==e[r].execute(i))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var Gc={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},Vc=["*","","ALL"],$c=[Gc.BACKBONE,Gc.SIDECHAIN,Gc.BONDED,Gc.RING],Hc=[Gc.POLYMER,Gc.WATER],Wc=["ALA","GLY","SER"],Xc=["CYS","SER","THR"],qc=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Yc=["PHE","TRP","TYR","HIS"],Zc=["ASN","GLN"],Kc=["ASP","GLU"],Qc=["ARG","HIS","LYS"],Jc=["ARG","ASP","GLU","HIS","LYS"],tu=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],eu=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],iu=["HIS","PHE","PRO","TRP","TYR"],ru=["ALA","GLY","ILE","LEU","VAL"];function nu(t,e){if(void 0===e.atomname&&void 0===e.element&&void 0===e.altloc&&void 0===e.atomindex&&void 0===e.keyword&&void 0===e.inscode&&void 0===e.resname&&void 0===e.sstruc&&void 0===e.resno&&void 0===e.chainname&&void 0===e.model)return-1;if(void 0!==e.keyword){if(e.keyword===Gc.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===Gc.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===Gc.BONDED&&!t.isBonded())return!1;if(e.keyword===Gc.RING&&!t.isRing())return!1;if(e.keyword===Gc.HETERO&&!t.isHetero())return!1;if(e.keyword===Gc.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Gc.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Gc.RNA&&!t.isRna())return!1;if(e.keyword===Gc.DNA&&!t.isDna())return!1;if(e.keyword===Gc.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Gc.WATER&&!t.isWater())return!1;if(e.keyword===Gc.HELIX&&!t.isHelix())return!1;if(e.keyword===Gc.SHEET&&!t.isSheet())return!1;if(e.keyword===Gc.TURN&&!t.isTurn())return!1;if(e.keyword===Gc.ION&&!t.isIon())return!1;if(e.keyword===Gc.SACCHARIDE&&!t.isSaccharide())return!1}if(void 0!==e.atomname&&e.atomname!==t.atomname)return!1;if(void 0!==e.element&&e.element!==t.element)return!1;if(void 0!==e.altloc&&e.altloc!==t.altloc)return!1;if(void 0!==e.atomindex&&Ba(e.atomindex,t.index)<0)return!1;if(void 0!==e.resname)if(Array.isArray(e.resname)){if(!e.resname.includes(t.resname))return!1}else if(e.resname!==t.resname)return!1;if(void 0!==e.sstruc&&e.sstruc!==t.sstruc)return!1;if(void 0!==e.resno)if(Array.isArray(e.resno)&&2===e.resno.length){if(e.resno[0]>t.resno||e.resno[1]<t.resno)return!1}else if(e.resno!==t.resno)return!1;return(void 0===e.inscode||e.inscode===t.inscode)&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function ou(t,e){if(void 0===e.resname&&void 0===e.resno&&void 0===e.inscode&&void 0===e.sstruc&&void 0===e.model&&void 0===e.chainname&&void 0===e.atomindex&&(void 0===e.keyword||$c.includes(e.keyword)))return-1;if(void 0!==e.keyword){if(e.keyword===Gc.HETERO&&!t.isHetero())return!1;if(e.keyword===Gc.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Gc.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Gc.RNA&&!t.isRna())return!1;if(e.keyword===Gc.DNA&&!t.isDna())return!1;if(e.keyword===Gc.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Gc.WATER&&!t.isWater())return!1;if(e.keyword===Gc.HELIX&&!t.isHelix())return!1;if(e.keyword===Gc.SHEET&&!t.isSheet())return!1;if(e.keyword===Gc.TURN&&!t.isTurn())return!1;if(e.keyword===Gc.ION&&!t.isIon())return!1;if(e.keyword===Gc.SACCHARIDE&&!t.isSaccharide())return!1}if(void 0!==e.atomindex&&0===za(e.atomindex,t.atomOffset,t.atomEnd))return!1;if(void 0!==e.resname)if(Array.isArray(e.resname)){if(!e.resname.includes(t.resname))return!1}else if(e.resname!==t.resname)return!1;if(void 0!==e.sstruc&&e.sstruc!==t.sstruc)return!1;if(void 0!==e.resno)if(Array.isArray(e.resno)&&2===e.resno.length){if(e.resno[0]>t.resno||e.resno[1]<t.resno)return!1}else if(e.resno!==t.resno)return!1;return(void 0===e.inscode||e.inscode===t.inscode)&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function au(t,e){if(void 0===e.chainname&&void 0===e.model&&void 0===e.atomindex&&(void 0===e.keyword||!Hc.includes(e.keyword)||!t.entity))return-1;if(void 0!==e.keyword){if(e.keyword===Gc.POLYMER&&!t.entity.isPolymer())return!1;if(e.keyword===Gc.WATER&&!t.entity.isWater())return!1}return(void 0===e.atomindex||0!==za(e.atomindex,t.atomOffset,t.atomEnd))&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function su(t,e){return void 0===e.model&&void 0===e.atomindex?-1:(void 0===e.atomindex||0!==za(e.atomindex,t.atomOffset,t.atomEnd))&&(void 0===e.model||e.model===t.index)}var cu=function(t){this.signals={stringChanged:new jc},this.setString(t)},uu={type:{}};uu.type.get=function(){return"selection"},cu.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.parse(t)}catch(i){this.selection={error:i.message}}this.string=t,this.test=this.makeAtomTest(),this.residueTest=this.makeResidueTest(),this.chainTest=this.makeChainTest(),this.modelTest=this.makeModelTest(),this.atomOnlyTest=this.makeAtomTest(!0),this.residueOnlyTest=this.makeResidueTest(!0),this.chainOnlyTest=this.makeChainTest(!0),this.modelOnlyTest=this.makeModelTest(!0),e||this.signals.stringChanged.dispatch(this.string)}},cu.prototype.parse=function(t){var e=this;if(this.selection={operator:void 0,rules:[]},t){var i,r,n=this.selection,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){i={operator:t,rules:[]},void 0===n?(n=i,e.selection=i):(n.rules.push(i),o.push(n),n=i)},u=function(t){r=n,void 0===(n=o.pop())&&(c(t),h(r))},h=function(t){n.rules.push(t)},l=0;l<s.length;++l){var p=s[l],d=p.toUpperCase();if("("!==p)if(")"!==p){if(a>0)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=Gc[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===Vc.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 P=p.substr(1).split(","),T=0,E=P.length;T<E;++T)P[T]=parseInt(P[T]);P.sort(function(t,e){return t-e}),h({atomindex:P})}else h({keyword:Gc.ALL});else h({operator:"AND",rules:[{operator:"OR",rules:[{keyword:Gc.HETERO},{negate:!0,operator:void 0,rules:[{keyword:Gc.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:Gc.WATER},{keyword:Gc.ION}]}]}]});else h({operator:"OR",rules:[{keyword:Gc.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:Gc.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:Gc.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"C5'"},{atomname:"C5*"}]}]}]});else h({resname:ru});else h({resname:iu});else h({resname:eu});else h({resname:tu});else h({resname:Jc});else h({resname:Qc});else h({resname:Kc});else h({resname:Zc});else h({resname:Yc});else h({resname:qc});else h({resname:Xc});else h({resname:Wc});else h({element:"H"});else h({keyword:f})}else a=1,c(),n.negate=!0;else"AND"===n.operator?u("OR"):n.operator="OR";else if("OR"===n.operator){var C=n.rules.pop();c("AND"),h(C)}else n.operator="AND"}else u(),n.negate&&u();else a=!1,c()}void 0===this.selection.operator&&1===this.selection.rules.length&&this.selection.rules[0].hasOwnProperty("operator")&&(this.selection=this.selection.rules[0])}},cu.prototype._makeTest=function(t,e){if(void 0===e&&(e=this.selection),null===e)return!1;if(e.error)return!1;var i=e.rules.length;if(0===i)return!1;for(var r=!e.negate,n=!!e.negate,o=[],a=0;a<i;++a){var s=e.rules[a];s.hasOwnProperty("operator")&&(o[a]=this._makeTest(t,s))}return function(a){for(var s="AND"===e.operator,c=!1,u=0;u<i;++u){var h=e.rules[u],l=void 0;if(h.hasOwnProperty("operator")){if(-1===(l=o[u]?o[u](a):-1)){c=!0;continue}if(!0===l){if(s)continue;return r}if(s)return n}else{if(h.keyword===Gc.ALL){if(s)continue;return r}if(-1!==(l=t(a,h))){if(!0===l){if(s)continue;return r}if(s)return n}else c=!0}}return c?-1:s?r:n}},cu.prototype._filter=function(t,e){if(void 0===e&&(e=this.selection),e.error)return e;var i=e.rules.length;if(0===i)return e;var r={operator:e.operator,rules:[]};e.hasOwnProperty("negate")&&(r.negate=e.negate);for(var n=0;n<i;++n){var o=e.rules[n];if(o.hasOwnProperty("operator")){var a=this._filter(t,o);null!==a&&r.rules.push(a)}else t(o)||r.rules.push(o)}return r.rules.length>0?e:null},cu.prototype.makeAtomTest=function(t){var e;return e=t?this._filter(function(t){return void 0!==t.keyword&&!$c.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))}):this.selection,this._makeTest(nu,e)},cu.prototype.makeResidueTest=function(t){var e;return e=t?this._filter(function(t){return!(void 0===t.keyword||!$c.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))}):this.selection,this._makeTest(ou,e)},cu.prototype.makeChainTest=function(t){var e;return e=t?this._filter(function(t){return void 0!==t.keyword&&!Hc.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))))))}):this.selection,this._makeTest(au,e)},cu.prototype.makeModelTest=function(t){var e;return e=t?this._filter(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)))))))}):this.selection,this._makeTest(su,e)},Object.defineProperties(cu.prototype,uu);var hu=function(t){function e(e){var i=this;t.call(this,e);var r=e.dataList||[];this.colormakerList=[],this.selectionList=[],r.forEach(function(t){var e=t[0],r=t[1],n=t[2];void 0===n&&(n={}),Su.hasScheme(e)?Object.assign(n,{scheme:e,structure:i.structure}):Object.assign(n,{scheme:"uniform",value:new mi(e).getHex()}),i.colormakerList.push(Su.getScheme(n)),i.selectionList.push(new cu(r))})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){for(var e=0,i=this.selectionList.length;e<i;++e)if(this.selectionList[e].test(t))return this.colormakerList[e].atomColor(t);return 16777215},e}(Bc),lu={"":"",OrRd:"[S] Orange-Red",PuBu:"[S] Purple-Blue",BuPu:"[S] Blue-Purple",Oranges:"[S] Oranges",BuGn:"[S] Blue-Green",YlOrBr:"[S] Yellow-Orange-Brown",YlGn:"[S] Yellow-Green",Reds:"[S] Reds",RdPu:"[S] Red-Purple",Greens:"[S] Greens",YlGnBu:"[S] Yellow-Green-Blue",Purples:"[S] Purples",GnBu:"[S] Green-Blue",Greys:"[S] Greys",YlOrRd:"[S] Yellow-Orange-Red",PuRd:"[S] Purple-Red",Blues:"[S] Blues",PuBuGn:"[S] Purple-Blue-Green",Viridis:"[D] Viridis",Spectral:"[D] Spectral",RdYlGn:"[D] Red-Yellow-Green",RdBu:"[D] Red-Blue",PiYG:"[D] Pink-Yellowgreen",PRGn:"[D] Purplered-Green",RdYlBu:"[D] Red-Yellow-Blue",BrBG:"[D] Brown-Bluegreen",RdGy:"[D] Red-Grey",PuOr:"[D] Purple-Orange",Set1:"[Q] Set1",Set2:"[Q] Set2",Set3:"[Q] Set3",Dark2:"[Q] Dark2",Paired:"[Q] Paired",Pastel1:"[Q] Pastel1",Pastel2:"[Q] Pastel2",Accent:"[Q] Accent",rainbow:"[?] Rainbow",rwb:"[?] Red-White-Blue"},pu={"":"",rgb:"Red Green Blue",hsv:"Hue Saturation Value",hsl:"Hue Saturation Lightness",hsi:"Hue Saturation Intensity",lab:"CIE L*a*b*",hcl:"Hue Chroma Lightness"},du=function(){this.schemes={},this.userSchemes={}};du.prototype.getScheme=function(t){var e=(t||{}).scheme||"";return new(e in this.schemes?this.schemes[e]:e in this.userSchemes?this.userSchemes[e]:Bc)(t)},du.prototype.getSchemes=function(){var t={};return Object.keys(this.schemes).forEach(function(e){t[e]=e}),Object.keys(this.userSchemes).forEach(function(e){t[e]=e.split("|")[1]}),t},du.prototype.getScales=function(){return lu},du.prototype.getModes=function(){return pu},du.prototype.add=function(t,e){this.schemes[t]=e},du.prototype.addScheme=function(t,e){return t instanceof Bc||(t=this._createScheme(t,e)),this._addUserScheme(t,e)},du.prototype._addUserScheme=function(t,e){e=e||"";var i=Ic()+"|"+e;return this.userSchemes[i]=t,i},du.prototype.removeScheme=function(t){delete this.userSchemes[t]},du.prototype._createScheme=function(t,e){var i=function(i){Bc.call(this,i),this.label=e||"",t.call(this,i)};return(i.prototype=Bc.prototype).constructor=Bc,i},du.prototype.addSelectionScheme=function(t,e){var i=function(e){function i(i){e.call(this,Object.assign({dataList:t},i))}return e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i,i}(hu);return this._addUserScheme(i,e)},du.prototype.hasScheme=function(t){return t in this.schemes||t in this.userSchemes};var fu=Da(),mu="undefined"!==typeof window&&"undefined"!==typeof window.orientation,gu=!1;var vu=!1;var yu,bu={log:Function.prototype.bind.call(console.log,console),info:Function.prototype.bind.call(console.info,console),warn:Function.prototype.bind.call(console.warn,console),error:Function.prototype.bind.call(console.error,console),time:Function.prototype.bind.call(console.time,console),timeEnd:Function.prototype.bind.call(console.timeEnd,console)},xu=!!(yu=function(t){if("undefined"!==typeof window){var e=new RegExp(t+"=([^&#=]*)").exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}}("debug"))&&("string"!==typeof yu||/^1|true|t|yes|y$/i.test(yu));var _u='

Your browser/graphics card does not seem to support <a target="_blank" href="https://en.wikipedia.org/wiki/WebGL">WebGL</a>.

Find out how to get it <a target="_blank" href="http://get.webgl.org/">here</a>.

',wu=new es,Su=new du,Au=new Za("datasource"),Mu=new Za("representatation"),Pu=new Za("parser"),Tu=new Za("shader"),Eu=new Za("decompressor"),Cu=new Za("component"),Iu=function(t,e){var i=e||{};this.compressed=Oa(i.compressed,!1),this.binary=Oa(i.binary,!1),this.json=Oa(i.json,!1),this.xml=Oa(i.xml,!1),this.src=t,this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.__srcName&&(this[this.__srcName]=t)},Ru={type:{},__srcName:{}};Ru.type.get=function(){return""},Ru.__srcName.get=function(){},Iu.prototype.isBinary=function(){return this.binary||this.compressed},Iu.prototype.onload=function(){},Iu.prototype.onprogress=function(){},Iu.prototype.onerror=function(){},Iu.prototype.read=function(){var t=this;return new Promise(function(e,i){try{t._read(function(i){var r=Eu.get(t.compressed);t.compressed&&r?t.data=r(i):((t.binary||t.compressed)&&i instanceof ArrayBuffer&&(i=new Uint8Array(i)),t.data=i),e(t.data)})}catch(r){i(r)}})},Iu.prototype._read=function(t){t(this.src)},Iu.prototype._chunk=function(t,e){return e=Math.min(this.data.length,e),0===t&&this.data.length===e?this.data:this.isBinary()?this.data.subarray(t,e):this.data.substring(t,e)},Iu.prototype.chunk=function(t){var e=t+this.chunkSize;return this._chunk(t,e)},Iu.prototype.peekLines=function(t){var e,i=this.data,r=i.length,n=this.isBinary()?this.newline.charCodeAt(0):this.newline,o=0;for(e=0;e<r&&(i[e]===n&&++o,o!==t);++e);var a=this._chunk(0,e+1);return this.chunkToLines(a,"",e>r).lines},Iu.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},Iu.prototype.asText=function(){return this.isBinary()?ja(this.data):this.data},Iu.prototype.chunkToLines=function(t,e,i){var r=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(r),partialLine:""};var n=[],o=this.isBinary()?ja(t):t,a=o.lastIndexOf(r);if(-1===a)e+=o;else{var s=e+o.substr(0,a);n=n.concat(s.split(r)),e=a===o.length-r.length?"":o.substr(a+r.length)}return i&&""!==e&&n.push(e),{lines:n,partialLine:e}},Iu.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},Iu.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,i=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=i.partialLine,i.lines}},Iu.prototype.eachChunk=function(t){for(var e=this.chunkSize,i=this.data.length,r=this.chunkCount(),n=0;n<i;n+=e){t(this.chunk(n),Math.round(n/e),r)}},Iu.prototype.eachChunkOfLines=function(t){var e=this;this.eachChunk(function(i,r,n){var o=r===n+1,a=e.chunkToLines(i,e.__partialLine,o);e.__partialLine=a.partialLine,t(a.lines,r,n)})},Iu.prototype.dispose=function(){delete this.src,this.__srcName&&delete this[this.__srcName]},Object.defineProperties(Iu.prototype,Ru);var Lu=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__srcName:{}};return i.type.get=function(){return"file"},i.__srcName.get=function(){return"file"},e.prototype._read=function(t){var e,i,r=this;"function"===typeof importScripts?(e=new window.FileReaderSync,i=this.binary||this.compressed?e.readAsArrayBuffer(this.file):e.readAsText(this.file),t(i)):((e=new window.FileReader).onload=function(e){t(e.target.result)},"function"===typeof this.onprogress&&(e.onprogress=function(t){r.onprogress(t)}),"function"===typeof this.onerror&&(e.onerror=function(t){r.onerror(t)}),this.binary||this.compressed?e.readAsArrayBuffer(this.file):e.readAsText(this.file))},Object.defineProperties(e.prototype,i),e}(Iu),Ou=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__srcName:{}};return i.type.get=function(){return"network"},i.__srcName.get=function(){return"url"},e.prototype._read=function(t){var e=this.src;"function"===typeof importScripts&&"../"===e.substr(0,3)&&(e="../"+e);var i=new window.XMLHttpRequest;i.open("GET",e,!0),i.addEventListener("load",function(){if(200!==i.status&&304!==i.status&&0!==i.status)throw"function"===typeof this.onerror&&this.onerror(i.status),new Error("NetworkStreamer._read: status code "+i.status);try{t(i.response)}catch(e){this.onerror(e)}}.bind(this),!1),"function"===typeof this.onerror&&i.addEventListener("error",function(t){this.onerror(t)}.bind(this),!1),this.isBinary()?i.responseType="arraybuffer":this.json?i.responseType="json":this.xml?i.responseType="document":i.responseType="text",i.send(null)},Object.defineProperties(e.prototype,i),e}(Iu),Nu=["mmtf","dcd","mrc","ccp4","map","dsn6","brix","dxbin"],Du=["json"],ku=["xml","validation"],Fu=function(t,e){var i=Object.assign({},e),r=Nu.includes(i.ext);this.compressed=Oa(i.compressed,!1),this.binary=Oa(i.binary,r),this.name=Oa(i.name,""),this.ext=Oa(i.ext,""),this.dir=Oa(i.dir,""),this.path=Oa(i.path,""),this.protocol=Oa(i.protocol,""),this.params=e;var n={compressed:this.compressed,binary:this.binary,json:Du.includes(this.ext),xml:ku.includes(this.ext)};"undefined"!==typeof File&&t instanceof window.File||"undefined"!==typeof Blob&&t instanceof window.Blob?this.streamer=new Lu(t,n):this.streamer=new Ou(t,n),"function"===typeof i.onProgress&&(this.streamer.onprogress=i.onprogress)};Fu.prototype.load=function(){return Promise.reject(new Error("not implemented"))};var Bu=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.load=function(){return new(Pu.get(this.ext))(this.streamer,this.params).parse()},e}(Fu),zu=function(t,e,i){this.signals={elementAdded:new jc,elementRemoved:new jc,nameChanged:new jc},this.name=e,this.path=i,this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","panel","__name__","__path__","__dir__",t)}catch(r){bu.error("Script compilation failed",r),this.fn=function(){}}},Uu={type:{}};Uu.type.get=function(){return"Script"},zu.prototype.call=function(t){var e=this,i={add:function(){this.signals.elementAdded.dispatch(arguments)}.bind(this),remove:function(){this.signals.elementRemoved.dispatch(arguments)}.bind(this),setName:function(t){this.signals.nameChanged.dispatch(t)}.bind(this)};return new Promise(function(r,n){var o=[t,i,e.name,e.path,e.dir];try{e.fn.apply(null,o),r()}catch(a){bu.error("Script.fn",a),n(a)}})},Object.defineProperties(zu.prototype,Uu);var ju=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.load=function(){var t=this;return this.streamer.read().then(function(){return new zu(t.streamer.asText(),t.name,t.path)})},e}(Fu),Gu=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.load=function(){var t,e=this;return t=this.protocol?this.protocol+"://"+this.dir:this.dir,this.streamer.read().then(function(){var i=JSON.parse(e.streamer.asText()),r=[];return i.files.map(function(e){r.push(Vu(t+e,{ext:"text",useWorker:!1}))}),Promise.all(r).then(function(t){var r=t.reduce(function(t,e){return t+"\n\n"+e.data},"");return r+=i.source||"",new zu(r,e.name,e.path)})})},e}(Fu);function Vu(t,e){var i,r=Object.assign(function(t){var e=ka(t),i=Au.get(e.protocol);return i&&!(e=ka(i.getUrl(e.src))).ext&&i.getExt&&(e.ext=i.getExt(t)),e}(t),e);return Pu.names.includes(r.ext)?i=Bu:["ngl","js"].includes(r.ext)?i=ju:"plugin"===r.ext&&(i=Gu),i?new i(r.src,r).load():Promise.reject(new Error("autoLoad: ext '"+r.ext+"' unknown"))}var $u={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/bcdiefguxX/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function Hu(){var t=arguments[0],e=Hu.cache;return e[t]&&e.hasOwnProperty(t)||(e[t]=Hu.parse(t)),Hu.format.call(null,e[t],arguments)}function Wu(t){return"number"===typeof t?"number":"string"===typeof t?"string":Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}Hu.format=function(t,e){var i,r,n,o,a,s,c,u=1,h=t.length,l="",p=[],d=!0,f="";for(r=0;r<h;r++)if("string"===(l=Wu(t[r])))p[p.length]=t[r];else if("array"===l){if((o=t[r])[2])for(i=e[u],n=0;n<o[2].length;n++){if(!i.hasOwnProperty(o[2][n]))throw new Error(Hu('[sprintf] property "%s" does not exist',o[2][n]));i=i[o[2][n]]}else i=o[1]?e[o[1]]:e[u++];if($u.not_type.test(o[8])&&$u.not_primitive.test(o[8])&&"function"==Wu(i)&&(i=i()),$u.numeric_arg.test(o[8])&&"number"!=Wu(i)&&isNaN(i))throw new TypeError(Hu("[sprintf] expecting number but found %s",Wu(i)));switch($u.number.test(o[8])&&(d=i>=0),o[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,o[6]?parseInt(o[6]):0);break;case"e":i=o[7]?parseFloat(i).toExponential(o[7]):parseFloat(i).toExponential();break;case"f":i=o[7]?parseFloat(i).toFixed(o[7]):parseFloat(i);break;case"g":i=o[7]?parseFloat(i).toPrecision(o[7]):parseFloat(i);break;case"o":i=i.toString(8);break;case"s":i=String(i),i=o[7]?i.substring(0,o[7]):i;break;case"t":i=String(!!i),i=o[7]?i.substring(0,o[7]):i;break;case"T":i=Wu(i),i=o[7]?i.substring(0,o[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=o[7]?i.substring(0,o[7]):i;break;case"x":i=parseInt(i,10).toString(16);break;case"X":i=parseInt(i,10).toString(16).toUpperCase()}$u.json.test(o[8])?p[p.length]=i:(!$u.number.test(o[8])||d&&!o[3]?f="":(f=d?"+":"-",i=i.toString().replace($u.sign,"")),s=o[4]?"0"===o[4]?"0":o[4].charAt(1):" ",c=o[6]-(f+i).length,a=o[6]&&c>0?qu(s,c):"",p[p.length]=o[5]?f+i+a:"0"===s?f+a+i:a+f+i)}return p.join("")},Hu.cache={},Hu.parse=function(t){for(var e=t,i=[],r=[],n=0;e;){if(null!==(i=$u.text.exec(e)))r[r.length]=i[0];else if(null!==(i=$u.modulo.exec(e)))r[r.length]="%";else{if(null===(i=$u.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(i[2]){n|=1;var o=[],a=i[2],s=[];if(null===(s=$u.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o[o.length]=s[1];""!==(a=a.substring(s[0].length));)if(null!==(s=$u.key_access.exec(a)))o[o.length]=s[1];else{if(null===(s=$u.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o[o.length]=s[1]}i[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r[r.length]=i}e=e.substring(i[0].length)}return r};var Xu={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," "," "," "," "," "," "," "],_:["","_","__","___","____","_____","______","_______"]};function qu(t,e){return e>=0&&e<=7&&Xu[t]?Xu[t][e]:Array(e+1).join(t)}var Yu=function(){this.count=0,this.signals={countChanged:new jc}};function Zu(){this.signals={updated:new jc},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}Yu.prototype.clear=function(){this.change(-this.count)},Yu.prototype.change=function(t){this.count+=t,this.signals.countChanged.dispatch(t,this.count),this.count<0&&bu.warn("Counter.count below zero",this.count)},Yu.prototype.increment=function(){this.change(1)},Yu.prototype.decrement=function(){this.change(-1)},Yu.prototype.listen=function(t){this.change(t.count),t.signals.countChanged.add(this.change,this)},Yu.prototype.unlisten=function(t){var e=t.signals.countChanged;e.has(this.change,this)&&e.remove(this.change,this)},Yu.prototype.onZeroOnce=function(t,e){if(0===this.count)t.call(e,0,0);else{this.signals.countChanged.add(function i(){0===this.count&&(this.signals.countChanged.remove(i,this),t.apply(e,arguments))},this)}},Yu.prototype.dispose=function(){this.clear(),this.signals.countChanged.dispose()},Tu.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),Tu.add("shader/BasicLine.frag","uniform vec3 uColor;\n#include common\n#include fog_pars_fragment\nvoid main(){\ngl_FragColor = vec4( uColor, 1.0 );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"),Tu.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),Tu.add("shader/Quad.frag","varying vec2 vUv;\nuniform sampler2D tForeground;\nuniform float scale;\nvoid main() {\nvec4 foreground = texture2D( tForeground, vUv );\ngl_FragColor = foreground * scale;\n}"),Zu.prototype={update:function(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()},begin:function(){this.startTime=window.performance.now(),this.lastFrames=this.frames},end:function(){var t=window.performance.now();return this.count+=1,this.frames+=1,this.lastDuration=t-this.startTime,this.minDuration=Math.min(this.minDuration,this.lastDuration),this.maxDuration=Math.max(this.maxDuration,this.lastDuration),this.avgDuration-=this.avgDuration/30,this.avgDuration+=this.lastDuration/30,t>this.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t}},Tu.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"),Tu.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"),Tu.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}"),Tu.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"),Tu.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip )\ndiscard;\n#endif"),Tu.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"),Tu.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"),Tu.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),Tu.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 Ku=/^(?!\/\/)\s*#include\s+(\S+)/gim,Qu={};function Ju(t,e){e=e||{};var i=t+"|";for(var r in e)i+=r+":"+e[r];if(!Qu[i]){var n=function(t){if(void 0===t)return"";var e=[];for(var i in t){var r=t[i];!1!==r&&e.push("#define "+i+" "+r)}return e.join("\n")+"\n"}(e),o=Tu.get("shader/"+t);if(!o)throw new Error("empty shader, '"+t+"'");o=o.replace(Ku,function(t,e){var i="shader/chunk/"+e+".glsl";return Tu.get(i)||yi[e]||""}),Qu[i]=n+o}return Qu[i]}if("undefined"!==typeof window&&window.WebGLRenderingContext){var th=window.WebGLRenderingContext.prototype,eh=th.getShaderParameter;th.getShaderParameter=function(){return!xu||eh.apply(this,arguments)};var ih=th.getShaderInfoLog;th.getShaderInfoLog=function(){return xu?ih.apply(this,arguments):""};var rh=th.getProgramParameter;th.getProgramParameter=function(t,e){return!xu&&e===th.LINK_STATUS||rh.apply(this,arguments)};var nh=th.getProgramInfoLog;th.getProgramInfoLog=function(){return xu?nh.apply(this,arguments):""}}var oh=[[[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]]];function ah(t,e,i,r){var n=r||{},o=void 0!==n.factor?n.factor:2,a=void 0!==n.antialias&&n.antialias,s=n.onProgress,c=n.onFinish;a&&(o*=2);var u=o*o,h=document.createElement("canvas"),l=i.width,p=i.height;a?(h.width=l*o/2,h.height=p*o/2):(h.width=l*o,h.height=p*o);var d=h.getContext("2d"),f=i.sampleLevel;function m(e){var r=e%o,n=Math.floor(e/o),c=r*l,h=n*p;i.camera.setViewOffset(l*o,p*o,c,h,l,p),i.render(),a?d.drawImage(t.domElement,Math.floor(c/2),Math.floor(h/2),Math.ceil(l/2),Math.ceil(p/2)):d.drawImage(t.domElement,Math.floor(c),Math.floor(h),Math.ceil(l),Math.ceil(p)),"function"===typeof s&&s(e+1,u,!1)}function g(){i.setSampling(f),i.camera.view=null,"function"===typeof c&&c(u+1,u,!1)}i.setSampling(-1),this.render=function(){for(var t=0;t<=u;++t)t===u?g():m(t)},this.renderAsync=function(){var t=0;function e(){t===u?g():m(t),t+=1}for(var i=0;i<=u;++i)setTimeout(e,0,i)},this.canvas=h}oh.forEach(function(t){t.forEach(function(t){t[0]*=.0625,t[1]*=.0625})}),ah.prototype.constructor=ah;var sh=2*Math.PI;function ch(t,e,i,r,n){i=i||1,r=r||0;var o,a,s=n?n.length:t.length/i,c=0,u=0;if(n)for(a=0;a<s;++a)o=(t[n[a]*i+r]+e)%e/e*sh-Math.PI,c+=Math.cos(o),u+=Math.sin(o);else for(a=r;a<s;a+=i)o=(t[a]+e)%e/e*sh-Math.PI,c+=Math.cos(o),u+=Math.sin(o);return c/=s,u/=s,(Math.atan2(u,c)+Math.PI)/sh*e}function uh(t,e,i,r){var n=t.length;i=i||new Float32Array(n),r=r||0;for(var o=0;o<n;o+=3)i[r+o+0]=(t[o+0]+e[o+0])/2,i[r+o+1]=(t[o+1]+e[o+1])/2,i[r+o+2]=(t[o+2]+e[o+2])/2;return i}function hh(t,e,i){for(var r=i||new Float32Array(t),n=0;n<t;++n)r[n]=e;return r}function lh(t,e,i,r,n){for(var o,a=n||new Float32Array(3*t),s=0;s<t;++s)a[(o=3*s)+0]=e,a[o+1]=i,a[o+2]=r;return a}function ph(t){for(var e=new Float32Array(t),i=0;i<t;++i)e[i]=i;return e}function dh(t,e,i,r){void 0===i&&(i=0);for(var n=r||new Float32Array(t*e),o=0;o<t;++o)for(var a=i+o*e,s=0;s<e;++s)n[a+s]=o;return n}function fh(t,e,i,r,n){for(var o=0;o<n;++o)e[r+o]=t[i+o]}function mh(t,e,i,r){fh(t,t,e,i,r)}new Float32Array(4),new Float32Array(4);function gh(t){for(var e=t.length,i=0,r=0;r<e;++r)i+=t[r];return i}function vh(t,e){var i=e||{},r=Oa(i.trim,!1),n=Oa(i.factor,1),o=Oa(i.antialias,!1),a=Oa(i.transparent,!1),s=t.renderer,c=t.camera,u=s.getClearAlpha(),h=s.getClearColor();function l(e){var i=n;o&&(i*=2),e&&(i=1/i),t.scene.traverse(function(t){var e=t.material;e&&e.linewidth&&(e.linewidth*=i),e&&e.uniforms&&e.uniforms.size&&void 0===e.uniforms.size.__seen&&(e.uniforms.size.value*=i,e.uniforms.size.__seen=!0)}),t.scene.traverse(function(t){var e=t.material;e&&e.uniforms&&e.uniforms.size&&delete e.uniforms.size.__seen})}function p(t){if(r){var e=h;return function(t,e,i,r,n){var o,a,s,c,u=t.height,h=t.width,l=t.getContext("2d").getImageData(0,0,h,u).data;for(s=!1,a=0;a<u;a++){for(o=0;o<h;o++)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var p=a;for(s=!1,o=0;o<h;o++){for(a=0;a<u;a++)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var d=o;for(s=!1,a=u-1;a>=0;a--){for(o=h-1;o>=0;o--)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||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(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||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}(t,a?0:255*e.r,a?0:255*e.g,a?0:255*e.b,a?0:255)}return t}function d(t,e,r){"function"===typeof i.onProgress&&i.onProgress(t,e,r)}return new Promise(function(e){var i=new ah(s,c,t,{factor:n,antialias:o,onProgress:d,onFinish:function(r,n){p(i.canvas).toBlob(function(i){s.setClearAlpha(u),l(!0),t.requestRender(),d(n,n,!0),e(i)},"image/png")}});s.setClearAlpha(a?0:1),l(),i.renderAsync()})}var yh=new Me,bh=new Pe,xh=new Pe;var _h=new Pe,wh=new Pe;var Sh=new Float32Array(4),Ah=new Uint8Array(4),Mh=new Pe;function Ph(t,e,i,r,n){var o=n.uniforms,a=[];if(o.objectId&&(o.objectId.value=gu?this.id:this.id/255,a.push("objectId")),(o.modelViewMatrixInverse||o.modelViewMatrixInverseTranspose||o.modelViewProjectionMatrix||o.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),o.modelViewMatrixInverse&&(o.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),a.push("modelViewMatrixInverse")),o.modelViewMatrixInverseTranspose&&(o.modelViewMatrixInverse?o.modelViewMatrixInverseTranspose.value.copy(o.modelViewMatrixInverse.value).transpose():o.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),a.push("modelViewMatrixInverseTranspose")),o.modelViewProjectionMatrix&&(i.updateProjectionMatrix(),o.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),a.push("modelViewProjectionMatrix")),o.modelViewProjectionMatrixInverse&&(o.modelViewProjectionMatrix?(Mh.copy(o.modelViewProjectionMatrix.value),o.modelViewProjectionMatrixInverse.value.getInverse(Mh)):(i.updateProjectionMatrix(),Mh.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.modelViewProjectionMatrixInverse.value.getInverse(Mh)),a.push("modelViewProjectionMatrixInverse")),a.length){var s=t.properties.get(n);if(s.program){var c=t.getContext(),u=s.program;c.useProgram(u.program);var h=u.getUniforms();a.forEach(function(t){h.setValue(c,t,o[t].value)})}}}function Th(t){var e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I,R,O,N,D,k={ticked:new jc};if((e="string"===typeof t?document.getElementById(t):t instanceof window.Element?t:document.createElement("div"))===document.body)i=window.innerWidth||1,r=window.innerHeight||1;else{var F=e.getBoundingClientRect();i=F.width||1,r=F.height||1}if(l={fogColor:new mi(0),fogNear:50,fogFar:100,backgroundColor:new mi(0),cameraType:"perspective",cameraFov:40,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,lightColor:new mi(14540253),lightIntensity:1,ambientColor:new mi(14540253),ambientIntensity:.2,sampleLevel:0},p=new Zu,function(){var t=new Me(0,0,0);(d=new Ui(l.cameraFov,i/r)).position.z=l.cameraZ,d.lookAt(t),(f=new zi(i/-2,i/2,r/2,r/-2)).position.z=l.cameraZ,f.lookAt(t),m="orthographic"===l.cameraType?f:d;m.updateProjectionMatrix()}(),V(),!1===function(){var t=window.devicePixelRatio;try{M=new Fr({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(a){return e.innerHTML=_u,!1}M.setPixelRatio(t),M.setSize(i,r),M.autoClear=!1,M.sortObjects=!0,function(t){vu=t}(M.extensions.get("EXT_frag_depth")),M.extensions.get("OES_element_index_uint"),function(t){gu=t}(M.extensions.get("OES_texture_float")&&M.extensions.get("WEBGL_color_buffer_float")||"Chrome"===fu&&M.extensions.get("OES_texture_float")),e.appendChild(M.domElement);var n=i*t,o=r*t;M.extensions.get("OES_texture_float"),P=M.extensions.get("OES_texture_half_float"),M.extensions.get("WEBGL_color_buffer_float"),(T=new Se(n,o,{minFilter:At,magFilter:At,stencilBuffer:!1,format:$t,type:gu?kt:It})).texture.generateMipmaps=!1,E=new Se(n,o,{minFilter:Tt,magFilter:Tt,format:$t}),C=new Se(n,o,{minFilter:At,magFilter:At,format:$t,type:mu?It:P?Ft:gu?kt:It}),R=new Mi({uniforms:I={tForeground:{type:"t",value:null},scale:{type:"f",value:1}},vertexShader:Ju("Quad.vert"),fragmentShader:Ju("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:L,depthTest:!1,depthWrite:!1}),O=new zi(-1,1,1,-1,0,1),N=(new Ur).add(new ar(new tr(2,2),R))}())return this.container=e,void bu.error("Viewer: could not initialize renderer");var B=new Ti,z=new Me,U=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),i=new Ki;i.setIndex(new Hi(t,1)),i.addAttribute("position",new Hi(e,3));var r=new Mi({uniforms:{uColor:{value:new mi("skyblue")}},vertexShader:Ju("BasicLine.vert"),fragmentShader:Ju("BasicLine.frag"),linewidth:2});D=new Zr(i,r),A.add(D)}(),Y(),q();var j=new Me,G={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};function V(){g||(g=new Ur),(b=new tn).name="rotationGroup",g.add(b),(x=new tn).name="translationGroup",b.add(x),(_=new tn).name="modelGroup",x.add(_),(w=new tn).name="pickingGroup",x.add(w),(S=new tn).name="backgroundGroup",x.add(S),(A=new tn).name="helperGroup",x.add(A),g.fog=new zr,v=new ho(l.lightColor,l.lightIntensity),g.add(v),y=new mo(l.ambientLight,l.ambientIntensity),g.add(y)}function $(){var t=D.geometry.attributes.position,e=t.array,i=B.min,r=B.max;e[0]=r.x,e[1]=r.y,e[2]=r.z,e[3]=i.x,e[4]=r.y,e[5]=r.z,e[6]=i.x,e[7]=i.y,e[8]=r.z,e[9]=r.x,e[10]=i.y,e[11]=r.z,e[12]=r.x,e[13]=r.y,e[14]=i.z,e[15]=i.x,e[16]=r.y,e[17]=i.z,e[18]=i.x,e[19]=i.y,e[20]=i.z,e[21]=r.x,e[22]=i.y,e[23]=i.z,t.needsUpdate=!0,B.isEmpty()||D.geometry.computeBoundingSphere()}function H(t,e){function i(r){r instanceof tn?r.children.forEach(i):(r.userData.buffer=t,r.userData.instance=e,r.onBeforeRender=Ph)}var r=t.getMesh();e&&r.applyMatrix(e.matrix),i(r),t.group.add(r);var n=t.getWireframeMesh();if(e&&(n.matrix.copy(r.matrix),n.position.copy(r.position),n.quaternion.copy(r.quaternion),n.scale.copy(r.scale)),i(n),t.wireframeGroup.add(n),t.pickable){var o=t.getPickingMesh();e&&(o.matrix.copy(r.matrix),o.position.copy(r.position),o.quaternion.copy(r.quaternion),o.scale.copy(r.scale)),i(o),t.pickingGroup.add(o)}e?W(t.geometry,t.matrix,e.matrix):W(t.geometry,t.matrix)}function W(t,e,i){function r(t,e,i){t.boundingBox||t.computeBoundingBox();var r=t.boundingBox.clone();e&&r.applyMatrix4(e),i&&r.applyMatrix4(i),r.min.equals(r.max)&&r.expandByScalar(5),B.union(r)}function n(t){var e,i;void 0!==t.geometry&&(t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(i=t.userData.instance.matrix),r(t.geometry,e,i))}t?r(t,e,i):(B.makeEmpty(),_.traverse(n),S.traverse(n)),B.getSize(z),U=z.length()}function X(){var t=i*r*4,e=gu?new Float32Array(t):new Uint8Array(t);return rt(!0),M.readRenderTargetPixels(T,0,0,i,r,e),e}function q(t,e,i){var r=l;void 0!==t&&r.fogColor.set(t),void 0!==e&&(r.fogNear=e),void 0!==i&&(r.fogFar=i),Q()}function Y(t){var e=l;t&&e.backgroundColor.set(t),q(e.backgroundColor),M.setClearColor(e.backgroundColor,0),M.domElement.style.backgroundColor=e.backgroundColor.getStyle(),Q()}function Z(t,e){i=t||1,r=e||1,d.aspect=i/r,f.left=-i/2,f.right=i/2,f.top=r/2,f.bottom=-r/2,m.updateProjectionMatrix();var n=window.devicePixelRatio;M.setPixelRatio(n),M.setSize(i,r);var o=i*n,a=r*n;T.setSize(o,a),E.setSize(o,a),C.setSize(o,a),Q()}function K(t){var e=G.memory,i=G.render;if(t)e.programs=0,e.geometries=0,e.textures=0,i.calls=0,i.vertices=0,i.faces=0,i.points=0;else{var r=M.info,n=r.memory,o=r.render;e.programs=n.programs,e.geometries=n.geometries,e.textures=n.textures,i.calls+=o.calls,i.vertices+=o.vertices,i.faces+=o.faces,i.points+=o.points}}function Q(){o||(window.performance.now()-p.startTime>22&&(p.begin(),s=!1),o=!0,window.requestAnimationFrame(function(){rt(),p.update()}))}function J(){var t=is(d.fov),e=2*Math.tan(t/2)*-m.position.z;f.zoom=r/e}function tt(){m.updateMatrix(),m.updateMatrixWorld(!0),m.matrixWorldInverse.getInverse(m.matrixWorld),m.updateProjectionMatrix(),function(t,e,i,r,n){var o=i.getSize().height,a=i.getPixelRatio(),s="OrthographicCamera"===e.type;_h.getInverse(e.projectionMatrix),wh.copy(e.projectionMatrix).transpose(),t.traverse(function(t){var e=t.material;if(e){var i=t.material.uniforms;if(i){if(e.clipNear){var c=(50-e.clipNear)/50,u=r-n*c;i.nearClip.value=u}i.canvasHeight&&(i.canvasHeight.value=o),i.pixelRatio&&(i.pixelRatio.value=a),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(_h),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(wh),i.ortho&&(i.ortho.value=s)}}})}(g,m,M,u,h),function(t,e){t.traverseVisible(function(t){if(t instanceof Jr&&t.sortParticles){var i=t.geometry.attributes,r=i.position.count;if(0!==r){var n,o,a,s,c,u,h;bh.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),xh.multiplyMatrices(e.projectionMatrix,bh),t.userData.sortData?(n=t.userData.sortData,a=n.__zArray,o=n.__sortArray,s=n.__cmpFn):(a=new Float32Array(r),o=new Uint32Array(r),n={__zArray:a,__sortArray:o,__cmpFn:s=function(t,e){var i=a[t],r=a[e];return i>r?1:i<r?-1:0}},t.userData.sortData=n);for(var l=0;l<r;++l)yh.fromArray(i.position.array,3*l),yh.applyMatrix4(xh),a[l]=-yh.z,o[l]=l;for(var p in function(t,e,i,r){e=e||function(t,e){return t>e?1:t<e?-1:0};var n,o,a=[],s=-1,c=i=i||0,u=r=(r||t.length)-1,h=0,l=0;function p(e,i){l=t[e],t[e]=t[i],t[i]=l}for(;;)if(u-c<=25){for(o=c+1;o<=u;++o){for(h=t[o],n=o-1;n>=c&&e(t[n],h)>0;)t[n+1]=t[n],--n;t[n+1]=h}if(-1===s)break;u=a[s--],c=a[s--]}else{for(o=u,p(c+u>>1,n=c+1),e(t[c],t[u])>0&&p(c,u),e(t[n],t[u])>0&&p(n,u),e(t[c],t[n])>0&&p(c,n),h=t[n];;){do{n++}while(e(t[n],h)<0);do{o--}while(e(t[o],h)>0);if(o<n)break;p(n,o)}t[c+1]=t[o],t[o]=h,u-n+1>=o-c?(a[++s]=n,a[++s]=u,u=o-1):(a[++s]=c,a[++s]=o-1,c=n)}}(o,s),i){var d=i[p],f=d.array,m=d.itemSize;n[p]||(n[p]=new Float32Array(m*r)),h=n[p],n[p]=f;for(var g=0;g<r;++g){c=o[g];for(var v=0;v<m;++v)u=c*m+v,h[g*m+v]=f[u]}i[p].array=h,i[p].needsUpdate=!0}}}})}(g,m)}function et(t,e,i,r){_.visible=t,w.visible=e,S.visible=i,A.visible=r}function it(t){t?M.clearTarget(t):M.clear(),et(!1,!1,!0,!1),M.render(g,m,t),t?M.clearTarget(t,!1,!0,!1):M.clearDepth(),K(),et(!0,!1,!1,xu),M.render(g,m,t),K()}function rt(t){n?bu.warn("tried to call 'render' from within 'render'"):(n=!0,function(){var t=l;(u=j.copy(m.position).length())||(m.position.set(0,0,t.cameraZ),u=Math.abs(t.cameraZ)),h=Math.max(10,.5*U),((h+=B.getCenter(j).length())===1/0||h===-1/0||isNaN(h))&&(h=50);var e=(50-t.clipNear)/50,i=-(50-t.clipFar)/50;m.near=u-h*e,m.far=u+h*i;var r=(50-t.fogNear)/50,n=-(50-t.fogFar)/50,o=g.fog;o.color.set(t.fogColor),o.near=u-h*r,o.far=u+h*n,"PerspectiveCamera"===m.type?(m.near=Math.max(.1,t.clipDist,m.near),m.far=Math.max(1,m.far),o.near=Math.max(.1,o.near),o.far=Math.max(1,o.far)):"OrthographicCamera"===m.type&&0===t.clipNear&&t.clipDist>0&&u+m.zoom>2*-t.clipDist&&(m.near+=m.zoom+t.clipDist)}(),tt(),j.copy(m.position).setLength(100*U),v.position.copy(m.position).add(j),v.color.set(l.lightColor),v.intensity=l.lightIntensity,y.color.set(l.ambientColor),y.intensity=l.ambientIntensity,K(!0),t?a||(M.clearTarget(T),et(!1,!0,!1,!1),M.render(g,m,T),K(),M.setRenderTarget(null)):c>0?function(){var t=oh[Math.max(0,Math.min(c,5))],e=1/t.length;I.tForeground.value=E.texture;for(var i=E.width,r=E.height,n=0;n<t.length;++n){var o=t[n];m.setViewOffset(i,r,o[0],o[1],i,r),tt();var a=e;a+=1/32*((n+.5)/t.length-.5),I.scale.value=a,it(E),M.render(N,O,C,0===n)}I.scale.value=1,I.tForeground.value=C.texture,M.render(N,O,null,!0),m.view=null}():it(),a=t,n=!1,o=!1)}this.container=e,this.stats=p,this.signals=k,this.rotationGroup=b,this.translationGroup=x,this.add=function(t,e){e?e.forEach(function(e){H(t,e)}):H(t),t.background?(S.add(t.group),S.add(t.wireframeGroup)):(_.add(t.group),_.add(t.wireframeGroup)),t.pickable&&w.add(t.pickingGroup),xu&&$()},this.remove=function(t){x.children.forEach(function(e){e.remove(t.group),e.remove(t.wireframeGroup)}),t.pickable&&w.remove(t.pickingGroup),W(),xu&&$()},this.clear=function(){bu.log("scene cleared"),g.remove(b),V(),M.clear()},this.getPickingPixels=X,this.getImage=function(t){return new Promise(function(e){if(t){var n=i*r*4,o=X();if(gu){for(var a=new Uint8Array(n),s=0;s<n;++s)a[s]=Math.round(255*o[s]);o=a}var c=document.createElement("canvas");c.width=i,c.height=r;var u=c.getContext("2d"),h=u.getImageData(0,0,i,r);h.data.set(o),u.putImageData(h,0,0),c.toBlob(e,"image/png")}else M.domElement.toBlob(e,"image/png")})},this.makeImage=function(t){return vh(this,t)},this.setLight=function(t,e,i,r){var n=l;void 0!==t&&n.lightColor.set(t),void 0!==e&&(n.lightIntensity=e),void 0!==i&&n.ambientColor.set(i),void 0!==r&&(n.ambientIntensity=r),Q()},this.setFog=q,this.setBackground=Y,this.setSampling=function(t){void 0!==t&&(l.sampleLevel=t,c=t),Q()},this.setCamera=function(t,e){var i=l;t&&(i.cameraType=t),e&&(i.cameraFov=e),"orthographic"===i.cameraType?m!==f&&((m=f).position.copy(d.position),m.up.copy(d.up),J()):m!==d&&((m=d).position.copy(f.position),m.up.copy(f.up)),d.fov=i.cameraFov,m.updateProjectionMatrix(),Q()},this.setClip=function(t,e,i){var r=l;void 0!==t&&(r.clipNear=t),void 0!==e&&(r.clipFar=e),void 0!==i&&(r.clipDist=i),Q()},this.setSize=Z,this.handleResize=function(){if(e===document.body)Z(window.innerWidth,window.innerHeight);else{var t=e.getBoundingClientRect();Z(t.width,t.height)}},this.pick=function(t,e){var i,r,n;t*=window.devicePixelRatio,e*=window.devicePixelRatio;var o=gu?Sh:Ah;rt(!0),M.readRenderTargetPixels(T,t,e,1,1,o),i=gu?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=w.getObjectById(a);return s&&(r=s.userData.instance,n=s.userData.buffer.picking),{pid:i,instance:r,picker:n}},this.requestRender=Q,this.render=rt,this.animate=function t(){if(k.ticked.dispatch(p),window.performance.now()-p.startTime>500&&!s&&c<3&&-1!==c){var e=c;c=3,o=!0,rt(),s=!0,c=e,xu&&bu.log("rendered still frame")}window.requestAnimationFrame(t)},this.updateZoom=J,this.updateHelper=$,this.renderer=M,this.scene=g,this.perspectiveCamera=d,this.boundingBox=B,this.updateBoundingBox=function(){W(),xu&&$()},Object.defineProperties(this,{camera:{get:function(){return m}},width:{get:function(){return i}},height:{get:function(){return r}},sampleLevel:{get:function(){return c}}})}Th.prototype.constructor=Th;function Eh(t){var e=t.touches[0].pageX-t.touches[1].pageX,i=t.touches[0].pageY-t.touches[1].pageY;return Math.sqrt(e*e+i*i)}var Ch=function(t,e){this.signals={moved:new jc,scrolled:new jc,dragged:new jc,dropped:new jc,clicked:new jc,hovered:new jc};var i=Object.assign({},e);this.hoverTimeout=Oa(i.hoverTimeout,50),this.handleScroll=Oa(i.handleScroll,!0),this.domElement=t,this.position=new be,this.prevPosition=new be,this.down=new be,this.canvasPosition=new be,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)},Ih={key:{}};Ih.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},Ch.prototype.setParameters=function(t){var e=Object.assign({},t);this.hoverTimeout=Oa(e.hoverTimeout,this.hoverTimeout)},Ch.prototype._listen=function(){if(window.performance.now()-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement)){this.hovering=!0;var t=this.canvasPosition;this.signals.hovered.dispatch(t.x,t.y)}window.requestAnimationFrame(this._listen)},Ch.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var i=0;i=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail/3:-t.deltaY/(t.deltaMode?.33:30),this.signals.scrolled.dispatch(i),setTimeout(function(){e.scrolled=!0},this.hoverTimeout)}},Ch.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,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,i),this.pressed&&this.signals.dragged.dispatch(e,i)},Ch.prototype._onMousedown=function(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=function(t){if("object"===typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<<e-1}else if("button"in t){var i=t.button;if(1===i)return 4;if(2===i)return 2;if(i>=0)return 1<<i}}return 0}(t),this.pressed=!0,this._setCanvasPosition(t))},Ch.prototype._onMouseup=function(t){t.target===this.domElement&&t.preventDefault(),this._setKeys(t);var e=this.canvasPosition;this.signals.clicked.dispatch(e.x,e.y),this.which=void 0,this.buttons=void 0,this.pressed=void 0},Ch.prototype._onContextmenu=function(t){t.target===this.domElement&&t.preventDefault()},Ch.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=Eh(t)}},Ch.prototype._onTouchend=function(t){t.target===this.domElement&&t.preventDefault(),this.pressed=!1},Ch.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=void 0,this.buttons=void 0,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,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,i),this.pressed&&this.signals.dragged.dispatch(e,i);break;case 2:this.which=3,this.buttons=2;var r=Eh(t),n=r-this.lastTouchDistance;if(this.lastTouchDistance=r,Math.abs(n)>1)this.signals.scrolled.dispatch(n/2);else{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);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)}}},Ch.prototype._distance=function(){return this.position.distanceTo(this.down)},Ch.prototype._setCanvasPosition=function(t){var e,i,r=this.domElement.getBoundingClientRect();"offsetX"in t&&"offsetY"in t?(e=t.offsetX,i=t.offsetY):(e=t.clientX-r.left,i=t.clientY-r.top),this.canvasPosition.set(e,r.height-i)},Ch.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},Ch.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(Ch.prototype,Ih);var Rh=new Pe,Lh=new Pe,Oh=new Pe,Nh=new Me,Dh=new Ae,kh=new Pe,Fh=new Me,Bh=function(t,e){var i=e||{};this.rotateSpeed=Oa(i.rotateSpeed,2),this.zoomSpeed=Oa(i.zoomSpeed,1.2),this.panSpeed=Oa(i.panSpeed,1),this.stage=t,this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},zh={component:{}};zh.component.get=function(){return this.stage.transformComponent},Bh.prototype._setPanVector=function(t,e){var i,r=this.viewer.camera;if("OrthographicCamera"===r.type)i=1/r.zoom;else{var n=is(r.fov);i=-2*r.position.z*Math.tan(n/2)/this.viewer.height}Fh.set(t,e,0),Fh.multiplyScalar(this.panSpeed*i)},Bh.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},Bh.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},Bh.prototype.pan=function(t,e){this._setPanVector(t,e),kh.getInverse(this.viewer.rotationGroup.matrix),Fh.applyMatrix4(kh),this.controls.translate(Fh)},Bh.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),kh.extractRotation(this.component.transform),kh.premultiply(this.viewer.rotationGroup.matrix),kh.getInverse(kh),Fh.applyMatrix4(kh),this.component.position.add(Fh),this.component.updateMatrix())},Bh.prototype.rotate=function(t,e){var i=this._getRotateXY(t,e),r=i[0],n=i[1];Rh.makeRotationX(n),Lh.makeRotationY(r),Rh.multiply(Lh),this.controls.applyMatrix(Rh)},Bh.prototype.rotateComponent=function(t,e){if(this.component){var i=this._getRotateXY(t,e),r=i[0],n=i[1];Oh.extractRotation(this.component.transform),Oh.premultiply(this.viewer.rotationGroup.matrix),Oh.getInverse(Oh),Nh.set(1,0,0),Nh.applyMatrix4(Oh),Rh.makeRotationAxis(Nh,n),Nh.set(0,1,0),Nh.applyMatrix4(Oh),Lh.makeRotationAxis(Nh,r),Rh.multiply(Lh),Dh.setFromRotationMatrix(Rh),this.component.quaternion.premultiply(Dh),this.component.updateMatrix()}},Object.defineProperties(Bh.prototype,zh);var Uh=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},jh={type:{},altKey:{},ctrlKey:{},metaKey:{},shiftKey:{},canvasPosition:{},component:{},object:{},position:{},closestBondAtom:{},arrow:{},atom:{},axes:{},bond:{},cone:{},clash:{},contact:{},cylinder:{},distance:{},ellipsoid:{},mesh:{},slice:{},sphere:{},surface:{},unitcell:{},unknown:{},volume:{}};jh.type.get=function(){return this.picker.type},jh.altKey.get=function(){return this.mouse.altKey},jh.ctrlKey.get=function(){return this.mouse.ctrlKey},jh.metaKey.get=function(){return this.mouse.metaKey},jh.shiftKey.get=function(){return this.mouse.shiftKey},jh.canvasPosition.get=function(){return this.mouse.canvasPosition},jh.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},jh.object.get=function(){return this.picker.getObject(this.pid)},jh.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},jh.closestBondAtom.get=function(){if("bond"===this.type){var t,e,i,r=this.bond,n=this.controls,o=this.canvasPosition,a=n.getPositionOnCanvas(r.atom1),s=n.getPositionOnCanvas(r.atom2);return e=a,i=s,(t=o).distanceTo(e)<t.distanceTo(i)?r.atom1:r.atom2}},jh.arrow.get=function(){return this._objectIfType("arrow")},jh.atom.get=function(){return this._objectIfType("atom")},jh.axes.get=function(){return this._objectIfType("axes")},jh.bond.get=function(){return this._objectIfType("bond")},jh.cone.get=function(){return this._objectIfType("cone")},jh.clash.get=function(){return this._objectIfType("clash")},jh.contact.get=function(){return this._objectIfType("contact")},jh.cylinder.get=function(){return this._objectIfType("cylinder")},jh.distance.get=function(){return this._objectIfType("distance")},jh.ellipsoid.get=function(){return this._objectIfType("ellipsoid")},jh.mesh.get=function(){return this._objectIfType("mesh")},jh.slice.get=function(){return this._objectIfType("slice")},jh.sphere.get=function(){return this._objectIfType("sphere")},jh.surface.get=function(){return this._objectIfType("surface")},jh.unitcell.get=function(){return this._objectIfType("unitcell")},jh.unknown.get=function(){return this._objectIfType("unknown")},jh.volume.get=function(){return this._objectIfType("volume")},Uh.prototype._objectIfType=function(t){return this.type===t?this.object:void 0},Uh.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.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.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.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(Uh.prototype,jh);var Gh=function(t){this.stage=t,this.viewer=t.viewer};Gh.prototype.pick=function(t,e){var i=this.viewer.pick(t,e);if(i.picker&&"ignore"!==i.picker.type&&void 0!==i.pid){var r=i.picker.array;if(!(r&&i.pid>=r.length))return new Uh(i,this.stage);console.error("pid >= picker.array.length")}};var Vh=new Ae,$h=new Me,Hh=new Me,Wh=new Me,Xh=new Me,qh=new Pe,Yh=new Me,Zh=new Pe,Kh=function(t){this.stage=t,this.viewer=t.viewer,this.signals={changed:new jc}},Qh={position:{},rotation:{}};Qh.position.get=function(){return this.viewer.translationGroup.position},Qh.rotation.get=function(){return this.viewer.rotationGroup.quaternion},Kh.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},Kh.prototype.getPositionOnCanvas=function(t,e){var i=$a(e,be),r=this.viewer;return Wh.copy(t).add(r.translationGroup.position).applyMatrix4(r.rotationGroup.matrix).project(r.camera),i.set((Wh.x+1)*r.width/2,(Wh.y+1)*r.height/2)},Kh.prototype.getOrientation=function(t){var e=Wa(t);e.copy(this.viewer.rotationGroup.matrix);var i=-this.viewer.camera.position.z;return e.scale(Xh.set(i,i,i)),e.setPosition(this.viewer.translationGroup.position),e},Kh.prototype.orient=function(t){Wa(t).decompose($h,Vh,Hh);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(Vh),e.translationGroup.position.copy($h),e.camera.position.z=-Hh.z,e.updateZoom(),this.changed()},Kh.prototype.translate=function(t){this.viewer.translationGroup.position.add(Ha(t)),this.changed()},Kh.prototype.center=function(t){this.viewer.translationGroup.position.copy(Ha(t)).negate(),this.changed()},Kh.prototype.zoom=function(t){this.distance(this.viewer.camera.position.z*(1-t))},Kh.prototype.distance=function(t){this.viewer.camera.position.z=t,this.viewer.updateZoom(),this.changed()},Kh.prototype.spin=function(t,e){qh.getInverse(this.viewer.rotationGroup.matrix),Yh.copy(Ha(t)).applyMatrix4(qh),this.viewer.rotationGroup.rotateOnAxis(Yh,e),this.changed()},Kh.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(Xa(t)),this.changed()},Kh.prototype.align=function(t){Zh.getInverse(Wa(t)),this.viewer.rotationGroup.setRotationFromMatrix(Zh),this.changed()},Kh.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix(Wa(t)),this.changed()},Object.defineProperties(Kh.prototype,Qh);var Jh=function(t,e){for(var i,r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];this.duration=Oa(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=[],(i=this)._init.apply(i,r)},tl={done:{},paused:{}};tl.done.get=function(){return 1===this.alpha},tl.paused.get=function(){return this._paused},Jh.prototype._init=function(){},Jh.prototype._tick=function(){},Jh.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Dc(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach(function(t){return t()}),this.done},Jh.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},Jh.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},Jh.prototype.toggle=function(){this._paused?this.resume():this.pause()},Jh.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(Jh.prototype,tl);var el=function(t){function e(e){for(var i=[],r=arguments.length-1;r-- >0;)i[r]=arguments[r+1];t.apply(this,[Oa(e,1/0)].concat(i))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){Array.isArray(t)?this.axis=(new Me).fromArray(t):this.axis=Oa(t,new Me(0,1,0)),this.angle=Oa(e,.01)},e.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},e}(Jh),il=function(t){function e(e){for(var i=[],r=arguments.length-1;r-- >0;)i[r]=arguments[r+1];t.apply(this,[Oa(e,1/0)].concat(i))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,i){Array.isArray(t)?this.axis=(new Me).fromArray(t):this.axis=Oa(t,new Me(0,1,0)),this.angleStep=Oa(e,.01),this.angleEnd=Oa(i,.2),this.angleSum=0,this.direction=1},e.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=Dc(0,1,Math.abs(this.angleSum)/this.angleEnd),i=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,i*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},e}(Jh),rl=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.moveFrom=Ha(Oa(t,new Me)),this.moveTo=Ha(Oa(e,new Me))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(Jh),nl=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(Oc(this.zoomFrom,this.zoomTo,this.alpha))},e}(Jh),ol=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=Xa(t),this.rotateTo=Xa(e),this._currentRotation=new Ae},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(Jh),al=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,i){this.valueFrom=t,this.valueTo=e,this.callback=i},e.prototype._tick=function(){this.callback(Oc(this.valueFrom,this.valueTo,this.alpha))},e}(Jh),sl=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(Jh),cl=function(t){this._list=t||[],this._resolveList=[]},ul={done:{}};ul.done.get=function(){return this._list.every(function(t){return t.done})},cl.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(cl.prototype,ul);var hl=function(t){this.stage=t,this.viewer=t.viewer,this.controls=t.viewerControls,this.animationList=[],this.finishedList=[]},ll={paused:{}};ll.paused.get=function(){return this.animationList.every(function(t){return t.paused})},hl.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},hl.prototype.remove=function(t){var e=this.animationList,i=e.indexOf(t);i>-1&&e.splice(i,1)},hl.prototype.run=function(t){for(var e=this.finishedList,i=this.animationList,r=i.length,n=0;n<r;++n){var o=i[n];o.tick(t)&&e.push(o)}var a=e.length;if(a){for(var s=0;s<a;++s)this.remove(e[s]);e.length=0}},hl.prototype.spin=function(t,e,i){return this.add(new el(i,this.controls,t,e))},hl.prototype.rock=function(t,e,i,r){return this.add(new il(r,this.controls,t,e,i))},hl.prototype.rotate=function(t,e){var i=this.viewer.rotationGroup.quaternion.clone();return this.add(new ol(e,this.controls,i,t))},hl.prototype.move=function(t,e){var i=this.controls.position.clone().negate();return this.add(new rl(e,this.controls,i,t))},hl.prototype.zoom=function(t,e){var i=this.viewer.camera.position.z;return this.add(new nl(e,this.controls,i,t))},hl.prototype.zoomMove=function(t,e,i){return new cl([this.move(t,i),this.zoom(e,i)])},hl.prototype.orient=function(t,e){var i=new Me,r=new Ae,n=new Me;return Wa(t).decompose(i,r,n),new cl([this.move(i.negate(),e),this.rotate(r,e),this.zoom(-n.x,e)])},hl.prototype.value=function(t,e,i,r){return this.add(new al(r,this.controls,t,e,i))},hl.prototype.timeout=function(t,e){return this.add(new sl(e,this.controls,t))},hl.prototype.spinComponent=function(t,e,i,r){return this.add(new el(r,t.controls,e,i))},hl.prototype.rockComponent=function(t,e,i,r,n){return this.add(new il(n,t.controls,e,i,r))},hl.prototype.moveComponent=function(t,e,i){var r=t.controls.position.clone().negate();return this.add(new rl(i,t.controls,r,e))},hl.prototype.pause=function(){this.animationList.forEach(function(t){return t.pause()})},hl.prototype.resume=function(){this.animationList.forEach(function(t){return t.resume()})},hl.prototype.toggle=function(){this.paused?this.resume():this.pause()},hl.prototype.clear=function(){this.animationList.length=0},hl.prototype.dispose=function(){this.clear()},Object.defineProperties(hl.prototype,ll);var pl=function(){};pl.zoomScroll=function(t,e){t.trackballControls.zoom(e)},pl.clipNearScroll=function(t,e){var i=t.getParameters();t.setParameters({clipNear:i.clipNear+e/10})},pl.focusScroll=function(t,e){var i=2*t.getParameters().clipNear,r=Math.sign(e)*function(t,e,i){if(t>e)return t;var r=t/e;return((2*i-e)*r+(2*e-3*i))*r*r+i}((100-i)/10,5,.2);t.setFocus(i+r)},pl.isolevelScroll=function(t,e){var i=Math.sign(e)/5;t.eachRepresentation(function(t){if("surface"===t.repr.type){var e=t.getParameters().isolevel;t.setParameters({isolevel:e+i})}},"volume")},pl.panDrag=function(t,e,i){t.trackballControls.pan(e,i)},pl.rotateDrag=function(t,e,i){t.trackballControls.rotate(e,i)},pl.zoomDrag=function(t,e,i){t.trackballControls.zoom((e+i)/-2)},pl.zoomFocusDrag=function(t,e,i){t.trackballControls.zoom((e+i)/-2);var r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))};var dl={default:[["scroll",pl.zoomScroll],["scroll-ctrl",pl.clipNearScroll],["scroll-shift",pl.focusScroll],["scroll-alt",pl.isolevelScroll],["drag-right",pl.panDrag],["drag-left",pl.rotateDrag],["drag-middle",pl.zoomDrag],["drag-shift-right",pl.zoomDrag],["drag-left+right",pl.zoomDrag],["drag-ctrl-right",pl.panComponentDrag=function(t,e,i){t.trackballControls.panComponent(e,i)}],["drag-ctrl-left",pl.rotateComponentDrag=function(t,e,i){t.trackballControls.rotateComponent(e,i)}],["clickPick-middle",pl.movePick=function(t,e){e&&t.animationControls.move(e.position.clone())}],["hoverPick",pl.tooltipPick=function(t,e){var i=t.tooltip;if(t.getParameters().tooltip&&e){var r=e.mouse.position;i.innerText=e.getLabel(),i.style.bottom=window.innerHeight-r.y+3+"px",i.style.left=r.x+3+"px",i.style.display="block"}else i.style.display="none"}]],pymol:[["drag-left",pl.rotateDrag],["drag-middle",pl.panDrag],["drag-right",pl.zoomDrag],["drag-shift-right",pl.focusScroll],["clickPick-ctrl+shift-middle",pl.movePick],["hoverPick",pl.tooltipPick]],coot:[["scroll",pl.isolevelScroll],["drag-left",pl.rotateDrag],["drag-middle",pl.panDrag],["drag-ctrl-left",pl.panDrag],["drag-right",pl.zoomFocusDrag],["drag-ctrl-right",pl.focusScroll],["clickPick-middle",pl.movePick],["hoverPick",pl.tooltipPick]]};function fl(t){var e=t.split(/[-+]/),i="";e.includes("scroll")&&(i="scroll"),e.includes("drag")&&(i="drag"),e.includes("click")&&(i="click"),e.includes("hover")&&(i="hover"),e.includes("clickPick")&&(i="clickPick"),e.includes("hoverPick")&&(i="hoverPick");var r=0;e.includes("alt")&&(r+=1),e.includes("ctrl")&&(r+=2),e.includes("meta")&&(r+=4),e.includes("shift")&&(r+=8);var n=0;return e.includes("left")&&(n+=1),e.includes("right")&&(n+=2),e.includes("middle")&&(n+=4),[i,r,n]}var ml=function(t,e){var i=e||{};this.stage=t,this.mouse=t.mouseObserver,this.actionList=[],this.preset(i.preset||"default")};ml.prototype.run=function(t){for(var e=this,i=[],r=arguments.length-1;r-- >0;)i[r]=arguments[r+1];var n=this.mouse.key||0,o=this.mouse.buttons||0;this.actionList.forEach(function(r){r.type===t&&r.key===n&&r.button===o&&r.callback.apply(r,[e.stage].concat(i))})},ml.prototype.add=function(t,e){var i=fl(t),r=i[0],n=i[1],o=i[2];this.actionList.push({type:r,key:n,button:o,callback:e})},ml.prototype.remove=function(t,e){var i=t.includes("*"),r=fl(t),n=r[0],o=r[1],a=r[2],s=this.actionList.filter(function(t){return!((t.type===n||i&&""===n)&&(t.key===o||i&&0===o)&&(t.button===a||i&&0===a)&&(t.callback===e||void 0===e))});this.actionList=s},ml.prototype.preset=function(t){var e=this;this.clear(),(dl[t]||[]).forEach(function(t){var i;(i=e).add.apply(i,t)})},ml.prototype.clear=function(){this.actionList.length=0};var gl=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)};gl.prototype._onClick=function(t,e){var i=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)},gl.prototype._onHover=function(t,e){var i=this.stage.pickingControls.pick(t,e);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)},gl.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var vl=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)};vl.prototype._onMove=function(){this.stage.tooltip.style.display="none"},vl.prototype._onScroll=function(t){this.controls.run("scroll",t)},vl.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},vl.prototype._onClick=function(t,e){this.controls.run("click",t,e)},vl.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},vl.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 yl=function(t){this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};yl.prototype._onTick=function(t){this.animationControls.run(t)},yl.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var bl=function(t){this.stage=t,this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),document.addEventListener("keydown",this._onKeydown),document.addEventListener("keyup",this._onKeyup),document.addEventListener("keypress",this._onKeypress)};bl.prototype._onKeydown=function(){},bl.prototype._onKeyup=function(){},bl.prototype._onKeypress=function(t){switch(t.keyCode){case 73:case 105:this.stage.toggleSpin();break;case 75:case 107:this.stage.toggleRock();break;case 80:case 112:this.stage.animationControls.toggle()}},bl.prototype.dispose=function(){document.removeEventListener("keydown",this._onKeypress),document.removeEventListener("keyup",this._onKeypress),document.removeEventListener("keypress",this._onKeypress)};var xl=function(t,e,i,r){var n=r||{};this.offsetX=Oa(n.offsetX,0),this.offsetY=Oa(n.offsetY,0),this.visible=Oa(n.visible,!0),this.component=t,this.stage=t.stage,this.viewer=this.stage.viewer,this.position=e,this._viewerPosition=new Me,this._updateViewerPosition(),this._canvasPosition=new Me,this._cameraPosition=new Me,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(i),this.updateVisibility(),this.viewer.signals.ticked.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};xl.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)},xl.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},xl.prototype.getVisibility=function(){return this.visible&&this.component.visible},xl.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},xl.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},xl.prototype._update=function(){if(this.getVisibility()){var t=this.element.style,e=this._canvasPosition,i=this._viewerPosition,r=this._clientRect;this._cameraPosition.copy(i).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-Dc(this.viewer.scene.fog.near,this.viewer.scene.fog.far,this._cameraPosition.length()),this.stage.viewerControls.getPositionOnCanvas(i,e),t.bottom=this.offsetX+e.y+r.height/2+"px",t.left=this.offsetY+e.x-r.width/2+"px")}},xl.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 _l=new Pe,wl=new Me,Sl=new Ae,Al=function(t){this.component=t,this.stage=t.stage,this.viewer=t.stage.viewer,this.signals={changed:new jc}},Ml={position:{},rotation:{}};function Pl(t){var e,i=t.length,r=t.length/3,n=0,o=0,a=0;for(e=0;e<i;e+=3)n+=t[e+0],o+=t[e+1],a+=t[e+2];return new Me(n/r,o/r,a/r)}function Tl(t,e,i){return i?t.sub(i).projectOnVector(e).add(i):t.projectOnVector(e),t}function El(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],h=t[s+1],l=t[s+2];u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),u>n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return[Ll([e,i,r]),Ll([n,o,a])]}function Cl(t,e){for(var i=0,r=e.length;i<r;i+=3){var n=e[i],o=e[i+1],a=e[i+2];e[i]=t[0]*n+t[4]*o+t[8]*a+t[12],e[i+1]=t[1]*n+t[5]*o+t[9]*a+t[13],e[i+2]=t[2]*n+t[6]*o+t[10]*a+t[14]}}function Il(t,e){for(var i=0,r=e.length;i<r;i+=3){var n=e[i],o=e[i+1],a=e[i+2];e[i]=t[0]*n+t[3]*o+t[6]*a,e[i+1]=t[1]*n+t[4]*o+t[7]*a,e[i+2]=t[2]*n+t[5]*o+t[8]*a}}function Rl(t){for(var e=0,i=t.length;e<i;e+=3){var r=t[e],n=t[e+1],o=t[e+2],a=1/Math.sqrt(r*r+n*n+o*o);t[e]=r*a,t[e+1]=n*a,t[e+2]=o*a}}function Ll(t){return new Float32Array(t||3)}function Ol(t,e,i){var r=e[0],n=e[1],o=e[2],a=i[0],s=i[1],c=i[2];t[0]=n*c-o*s,t[1]=o*a-r*c,t[2]=r*s-n*a}function Nl(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2]}function Dl(t,e,i){t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2]}function kl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function Fl(t,e,i){Bl(t,e,1/i)}function Bl(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}function zl(t,e){Bl(t,e,1/kl(e))}function Ul(t,e,i){t[0]=e[0]-i,t[1]=e[1]-i,t[2]=e[2]-i}function jl(t,e,i){t[0]=e[0]+i,t[1]=e[1]+i,t[2]=e[2]+i}function Gl(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function Vl(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function $l(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}Ml.position.get=function(){return this.component.position},Ml.rotation.get=function(){return this.component.quaternion},Al.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},Al.prototype.spin=function(t,e){_l.getInverse(this.viewer.rotationGroup.matrix),wl.copy(Ha(t)).applyMatrix4(_l),_l.extractRotation(this.component.transform),_l.premultiply(this.viewer.rotationGroup.matrix),_l.getInverse(_l),wl.copy(Ha(t)),wl.applyMatrix4(_l),_l.makeRotationAxis(wl,e),Sl.setFromRotationMatrix(_l),this.component.quaternion.premultiply(Sl),this.changed()},Object.defineProperties(Al.prototype,Ml),Fl.__deps=[Bl],zl.__deps=[Bl,kl];var Hl=function(t){this.array=t};Hl.prototype.getIndex=function(t){return this.array?this.array[t]:t},Hl.prototype.getObject=function(){return{}},Hl.prototype._applyTransformations=function(t,e,i){return e&&t.applyMatrix4(e.matrix),i&&t.applyMatrix4(i.matrix),t},Hl.prototype._getPosition=function(){return new Me},Hl.prototype.getPosition=function(t,e,i){return this._applyTransformations(this._getPosition(t),e,i)};var Wl=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 i={data:{}};return i.data.get=function(){return this.shape},Object.defineProperties(e.prototype,i),e}(Hl),Xl=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"cylinder"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,color:(new mi).fromArray(e.cylinderColor,3*t),radius:e.cylinderRadius[t],position1:(new Me).fromArray(e.cylinderPosition1,3*t),position2:(new Me).fromArray(e.cylinderPosition2,3*t),name:e.cylinderName[t]}},e.prototype._getPosition=function(t){var e=this.shape,i=(new Me).fromArray(e.cylinderPosition1,3*t),r=(new Me).fromArray(e.cylinderPosition2,3*t);return i.add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Wl),ql=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"arrow"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),position1:(new Me).fromArray(e.arrowPosition1,3*t),position2:(new Me).fromArray(e.arrowPosition2,3*t),color:(new mi).fromArray(e.arrowColor,3*t),radius:e.arrowRadius[t],name:e.arrowName[t]}},e.prototype._getPosition=function(t){var e=this.shape,i=(new Me).fromArray(e.arrowPosition1,3*t),r=(new Me).fromArray(e.arrowPosition2,3*t);return i.add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Wl),Yl=function(t){function e(e,i){t.call(this,e),this.structure=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"atom"},i.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 Me).copy(this.getObject(t))},Object.defineProperties(e.prototype,i),e}(Hl),Zl=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 i={type:{},data:{}};return i.type.get=function(){return"axes"},i.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,i),e}(Hl),Kl=function(t){function e(e,i,r){t.call(this,e),this.structure=i,this.bondStore=r||i.bondStore}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"bond"},i.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 Me).copy(e.atom1).add(e.atom2).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Hl),Ql=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"contact"},Object.defineProperties(e.prototype,i),e}(Kl),Jl=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"cone"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),position1:(new Me).fromArray(e.conePosition1,3*t),position2:(new Me).fromArray(e.conePosition2,3*t),color:(new mi).fromArray(e.coneColor,3*t),radius:e.coneRadius[t],name:e.coneName[t]}},e.prototype._getPosition=function(t){var e=this.shape,i=(new Me).fromArray(e.conePosition1,3*t),r=(new Me).fromArray(e.conePosition2,3*t);return i.add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Wl),tp=function(t){function e(e,i,r){t.call(this,e),this.validation=i,this.structure=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"clash"},i.data.get=function(){return this.validation},e.prototype.getObject=function(t){var e=this.validation,i=this.getIndex(t);return{validation:e,index:i,clash:e.clashArray[i]}},e.prototype._getAtomProxyFromSele=function(t){var e=new cu(t),i=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(i)},e.prototype._getPosition=function(t){var e=this.getObject(t).clash,i=this._getAtomProxyFromSele(e.sele1),r=this._getAtomProxyFromSele(e.sele2);return(new Me).copy(i).add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Hl),ep=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"distance"},Object.defineProperties(e.prototype,i),e}(Kl),ip=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"ellipsoid"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),color:(new mi).fromArray(e.ellipsoidColor,3*t),radius:e.ellipsoidRadius[t],majorAxis:(new Me).fromArray(e.ellipsoidMajorAxis,3*t),minorAxis:(new Me).fromArray(e.ellipsoidMinorAxis,3*t),name:e.ellipsoidName[t]}},e.prototype._getPosition=function(t){return(new Me).fromArray(this.shape.ellipsoidPosition,3*t)},Object.defineProperties(e.prototype,i),e}(Wl),rp=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"ignore"},Object.defineProperties(e.prototype,i),e}(Hl),np=function(t){function e(e,i){t.call(this,e),this.mesh=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.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=Pl(this.mesh.position)),this.__position},Object.defineProperties(e.prototype,i),e}(Wl),op=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"sphere"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),color:(new mi).fromArray(e.sphereColor,3*t),radius:e.sphereRadius[t],name:e.sphereName[t]}},e.prototype._getPosition=function(t){return(new Me).fromArray(this.shape.spherePosition,3*t)},Object.defineProperties(e.prototype,i),e}(Wl),ap=function(t){function e(e,i){t.call(this,e),this.surface=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"surface"},i.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,i),e}(Hl),sp=function(t){function e(e,i){t.call(this),this.unitcell=e,this.structure=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"unitcell"},i.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,i),e}(Hl),cp=(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};i.type.get=function(){return"unknown"},Object.defineProperties(e.prototype,i)}(Hl),function(t){function e(e,i){t.call(this,e),this.volume=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"volume"},i.data.get=function(){return this.volume},e.prototype.getObject=function(t){var e=this.volume,i=this.getIndex(t);return{volume:e,index:i,value:e.data[i]}},e.prototype._getPosition=function(t){var e=this.volume.position,i=this.getIndex(t);return new Me(e[3*i],e[3*i+1],e[3*i+2])},Object.defineProperties(e.prototype,i),e}(Hl)),up=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"slice"},Object.defineProperties(e.prototype,i),e}(cp);function hp(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}var lp=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};lp.prototype.get=function(t){return 0!==(this._words[t>>>5]&1<<t)},lp.prototype.set=function(t){this._words[t>>>5]|=1<<t},lp.prototype.clear=function(t){this._words[t>>>5]&=~(1<<t)},lp.prototype.flip=function(t){this._words[t>>>5]^=1<<t},lp.prototype._assignRange=function(t,e,i){for(var r=this._words,n=!0===i?4294967295:0,o=t>>>5,a=e>>>5,s=o;s<a;++s)r[s]=n;var c=o<<5,u=a<<5;if(!0===i)if(e-t<32)for(var h=t,l=e+1;h<l;++h)r[h>>>5]|=1<<h;else{for(var p=t,d=c;p<d;++p)r[p>>>5]|=1<<p;for(var f=u,m=e+1;f<m;++f)r[f>>>5]|=1<<f}else if(e-t<32)for(var g=t,v=e+1;g<v;++g)r[g>>>5]&=~(1<<g);else{for(var y=t,b=c;y<b;++y)r[y>>>5]&=~(1<<y);for(var x=u,_=e+1;x<_;++x)r[x>>>5]&=~(1<<x)}return this},lp.prototype.setRange=function(t,e){return this._assignRange(t,e,!0)},lp.prototype.clearRange=function(t,e){return this._assignRange(t,e,!1)},lp.prototype.setBits=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];e[n>>>5]|=1<<n}return this},lp.prototype.clearBits=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];e[n>>>5]&=~(1<<n)}return this},lp.prototype.setAll=function(){return this._assignRange(0,this.length-1,!0)},lp.prototype.clearAll=function(){return this._assignRange(0,this.length-1,!1)},lp.prototype.flipAll=function(){for(var t=this._words.length,e=this._words,i=32-this.length%32,r=0;r<t-1;++r)e[r]=~e[r];return e[t-1]=~(e[t-1]<<i)>>>i,this},lp.prototype._isRangeValue=function(t,e,i){for(var r=this._words,n=!0===i?4294967295:0,o=t>>>5,a=e>>>5,s=o;s<a;++s)if(r[s]!==n)return!1;if(e-t<32){for(var c=t,u=e+1;c<u;++c)if(!!(r[c>>>5]&1<<c)!==i)return!1}else{for(var h=a<<5,l=t,p=o<<5<<5;l<p;++l)if(!!(r[l>>>5]&1<<l)!==i)return!1;for(var d=h,f=e+1;d<f;++d)if(!!(r[d>>>5]&1<<d)!==i)return!1}return!0},lp.prototype.isRangeSet=function(t,e){return this._isRangeValue(t,e,!0)},lp.prototype.isRangeClear=function(t,e){return this._isRangeValue(t,e,!1)},lp.prototype.isAllSet=function(){return this._isRangeValue(0,this.length-1,!0)},lp.prototype.isAllClear=function(){return this._isRangeValue(0,this.length-1,!1)},lp.prototype.isSet=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];if(0===(e[n>>>5]&1<<n))return!1}return!0},lp.prototype.isClear=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];if(0!==(e[n>>>5]&1<<n))return!1}return!0},lp.prototype.isEqualTo=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)if(e[n]!==i[n])return!1;return!0},lp.prototype.getSize=function(){for(var t=this._words.length,e=this._words,i=0,r=0;r<t;++r)i+=hp(e[r]);return i},lp.prototype.difference=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]=e[n]&~i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},lp.prototype.union=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]|=i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},lp.prototype.intersection=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]&=i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},lp.prototype.intersects=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)if(0!==(e[n]&i[n]))return!0;return!1},lp.prototype.getIntersectionSize=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0,o=0;o<r;++o)n+=hp(e[o]&i[o]);return n},lp.prototype.makeIntersection=function(t){var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=new Uint32Array(r),o=Object.create(lp.prototype);o._words=n,o.length=Math.min(this.length,t.length);for(var a=0;a<r;++a)n[a]=e[a]&i[a];return o},lp.prototype.forEach=function(t){for(var e=this._words.length,i=this._words,r=0,n=0;n<e;++n)for(var o=i[n];0!==o;){var a=o&-o;t((n<<5)+hp(a-1),r),o^=a,++r}},lp.prototype.toArray=function(){for(var t=this._words,e=new Array(this.getSize()),i=this._words.length,r=0,n=0;n<i;++n)for(var o=t[n];0!==o;){var a=o&-o;e[r++]=(n<<5)+hp(a-1),o^=a}return e},lp.prototype.toString=function(){return"{"+this.toArray().join(",")+"}"},lp.prototype.toSeleString=function(){var t=this.toArray().join(",");return t?"@"+t:"NONE"},lp.prototype.clone=function(){var t=Object.create(lp.prototype);return t.length=this.length,t._words=new Uint32Array(this._words),t};var pp=0,dp=1,fp=2,mp=3,gp=4,vp=0,yp=["D-BETA-PEPTIDE, C-GAMMA LINKING","D-GAMMA-PEPTIDE, C-DELTA LINKING","D-PEPTIDE COOH CARBOXY TERMINUS","D-PEPTIDE NH3 AMINO TERMINUS","D-PEPTIDE LINKING","L-BETA-PEPTIDE, C-GAMMA LINKING","L-GAMMA-PEPTIDE, C-DELTA LINKING","L-PEPTIDE COOH CARBOXY TERMINUS","L-PEPTIDE NH3 AMINO TERMINUS","L-PEPTIDE LINKING","PEPTIDE LINKING","PEPTIDE-LIKE"],bp=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],xp=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],_p=["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","SACCHARIDE"],wp=["NON-POLYMER"].concat(["OTHER"],_p),Sp=["h","g","i"],Ap=["e","b"],Mp=["s","t","l",""],Pp={H:1.1,HE:1.4,LI:1.81,BE:1.53,B:1.92,C:1.7,N:1.55,O:1.52,F:1.47,NE:1.54,NA:2.27,MG:1.73,AL:1.84,SI:2.1,P:1.8,S:1.8,CL:1.75,AR:1.88,K:2.75,CA:2.31,SC:2.3,TI:2.15,V:2.05,CR:2.05,MN:2.05,FE:2.05,CO:2,NI:2,CU:2,ZN:2.1,GA:1.87,GE:2.11,AS:1.85,SE:1.9,BR:1.83,KR:2.02,RB:3.03,SR:2.49,Y:2.4,ZR:2.3,NB:2.15,MO:2.1,TC:2.05,RU:2.05,RH:2,PD:2.05,AG:2.1,CD:2.2,IN:2.2,SN:1.93,SB:2.17,TE:2.06,I:1.98,XE:2.16,CS:3.43,BA:2.68,LA:2.5,CE:2.48,PR:2.47,ND:2.45,PM:2.43,SM:2.42,EU:2.4,GD:2.38,TB:2.37,DY:2.35,HO:2.33,ER:2.32,TM:2.3,YB:2.28,LU:2.27,HF:2.25,TA:2.2,W:2.1,RE:2.05,OS:2,IR:2,PT:2.05,AU:2.1,HG:2.05,TL:1.96,PB:2.02,BI:2.07,PO:1.97,AT:2.02,RN:2.2,FR:3.48,RA:2.83,AC:2,TH:2.4,PA:2,U:2.3,NP:2,PU:2,AM:2,CM:2,BK:2,CF:2,ES:2,FM:2,MD:2,NO:2,LR:2,RF:2,DB:2,SG:2,BH:2,HS:2,MT:2,DS:2,RG:2,CN:2,UUT:2,FL:2,UUP:2,LV:2,UUH:2},Tp={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69,BK:1.6,CF:1.6,ES:1.6,FM:1.6,MD:1.6,NO:1.6,LR:1.6,RF:1.6,DB:1.6,SG:1.6,BH:1.6,HS:1.6,MT:1.6,DS:1.6,RG:1.6,CN:1.6,UUT:1.6,FL:1.6,UUP:1.6,LV:1.6,UUH:1.6},Ep={ALA:[.17,.5,.33],ARG:[.81,1.81,1],ASN:[.42,.85,.43],ASP:[1.23,3.64,2.41],ASH:[-.07,.43,.5],CYS:[-.24,-.02,.22],GLN:[.58,.77,.19],GLU:[2.02,3.63,1.61],GLH:[-.01,.11,.12],GLY:[.01,1.15,1.14],HIS:[.17,.11,-.06],ILE:[-.31,-1.12,-.81],LEU:[-.56,-1.25,-.69],LYS:[.99,2.8,1.81],MET:[-.23,-.67,-.44],PHE:[-1.13,-1.71,-.58],PRO:[.45,.14,-.31],SER:[.13,.46,.33],THR:[.14,.25,.11],TRP:[-1.85,-2.09,-.24],TYR:[-.94,-.71,.23],VAL:[.07,-.46,-.53]},Cp=[0,0,0],Ip={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",ASH:"D",GLH:"E",UNK:""},Rp=Object.keys(Ip),Lp=["A","C","T","G","U"],Op=["DA","DC","DT","DG","DU","TCY","MCY","5CM"],Np=["A","G","DA","DG"],Dp=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4"],kp=["118","119","1AL","1CU","2FK","2HP","2OF","3CO","3MT","3NI","3OF","3P8","4MO","4PU","543","6MO","ACT","AG","AL","ALF","AM","ATH","AU","AU3","AUC","AZI","BA","BCT","BEF","BF4","BO4","BR","BS3","BSY","CA","CAC","CD","CD1","CD3","CD5","CE","CHT","CL","CO","CO3","CO5","CON","CR","CS","CSB","CU","CU1","CU3","CUA","CUZ","CYN","DME","DMI","DSC","DTI","DY","E4N","EDR","EMC","ER3","EU","EU3","F","FE","FE2","FPO","GA","GD3","GEP","HAI","HG","HGC","IN","IOD","IR","IR3","IRI","IUM","K","KO4","LA","LCO","LCP","LI","LU","MAC","MG","MH2","MH3","MLI","MLT","MMC","MN","MN3","MN5","MN6","MO1","MO2","MO3","MO4","MO5","MO6","MOO","MOS","MOW","MW1","MW2","MW3","NA","NA2","NA5","NA6","NAO","NAW","NCO","NET","NH4","NI","NI1","NI2","NI3","NO2","NO3","NRU","O4M","OAA","OC1","OC2","OC3","OC4","OC5","OC6","OC7","OC8","OCL","OCM","OCN","OCO","OF1","OF2","OF3","OH","OS","OS4","OXL","PB","PBM","PD","PDV","PER","PI","PO3","PO4","PR","PT","PT4","PTN","RB","RH3","RHD","RU","SB","SCN","SE4","SEK","SM","SMO","SO3","SO4","SR","T1A","TB","TBA","TCN","TEA","TH","THE","TL","TMA","TRA","UNX","V","VN3","VO4","W","WO5","Y1","YB","YB2","YH","YT3","ZCM","ZN","ZN2","ZN3","ZNO","ZO3","OHX"],Fp=["045","0AT","0BD","0MK","0NZ","0TS","0V4","0XY","0YT","10M","147","149","14T","15L","16G","18T","18Y","1AR","1BW","1GL","1GN","1JB","1LL","1NA","1S3","26M","26Q","26R","26V","26W","26Y","27C","289","291","293","2DG","2F8","2FG","2FL","2FP","2GL","2M4","2M5","32O","34V","3CM","3DO","3DY","3FM","3LR","3MF","3MG","3SA","3ZW","46D","46M","46Z","48Z","4CQ","4GC","4NN","50A","5DI","5GF","5MM","5RP","5SA","5SP","64K","6PG","6SA","7JZ","7SA","A1Q","A2G","AAB","AAL","AAO","ABC","ABD","ABE","ABF","ABL","ACG","ACI","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AHR","AIG","ALL","ALX","AMU","AOG","AOS","ARA","ARB","ARE","ARI","ASG","ASO","AXP","AXR","B0D","B16","B2G","B4G","B6D","B8D","B9D","BBK","BCD","BDG","BDP","BDR","BEM","BFP","BGC","BGL","BGP","BGS","BHG","BMA","BMX","BNG","BNX","BOG","BRI","BXF","BXP","BXX","BXY","C3X","C4X","C5X","CAP","CBI","CBK","CBS","CDR","CEG","CGF","CHO","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D6G","DAF","DAG","DDA","DDB","DDL","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGS","DIG","DLF","DLG","DMU","DNO","DOM","DP5","DQQ","DQR","DR2","DR3","DR4","DRI","DSR","DT6","DVC","E4P","E5G","EAG","EBG","EBQ","EGA","EJT","EPG","ERE","ERI","F1P","F1X","F6P","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FIX","FMO","FRU","FSI","FU4","FUB","FUC","FUD","FUL","FXP","G16","G1P","G2F","G3I","G4D","G4S","G6D","G6P","G6S","GAC","GAD","GAL","GC1","GC4","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GCX","GE1","GFG","GFP","GIV","GL0","GL2","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GMH","GN1","GNX","GP1","GP4","GPH","GPM","GQ1","GQ2","GQ4","GS1","GS4","GSA","GSD","GTE","GTH","GTK","GTR","GTZ","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUP","GUZ","GYP","GYV","H2P","HDL","HMS","HS2","HSD","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","IAB","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IMK","IN1","IPT","ISL","KBG","KD2","KDA","KDM","KDO","KFN","KO1","KO2","KTU","L6S","LAG","LAI","LAK","LAO","LAT","LB2","LBT","LCN","LDY","LGC","LGU","LM2","LMT","LMU","LOG","LOX","LPK","LSM","LTM","LVZ","LXB","LXZ","M1F","M3M","M6P","M8C","MA1","MA2","MA3","MAB","MAG","MAL","MAN","MAT","MAV","MAW","MBG","MCU","MDA","MDM","MDP","MFA","MFB","MFU","MG5","MGA","MGL","MLB","MMA","MMN","MN0","MRP","MTT","MUG","MVP","MXY","N1L","N9S","NAA","NAG","NBG","NDG","NED","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGL","NGS","NGY","NHF","NM6","NM9","NTF","NTO","NTP","NXD","NYT","OPG","OPM","ORP","OX2","P3M","P53","P6P","PA5","PNA","PNG","PNW","PRP","PSJ","PSV","PTQ","QDK","QPS","QV4","R1P","R1X","R2B","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RIB","RIP","RNS","RNT","ROB","ROR","RPA","RST","RUB","RUU","RZM","S6P","S7P","SA0","SCR","SDD","SF6","SF9","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHG","SI3","SIO","SOE","SOL","SSG","SUC","SUP","SUS","T6P","T6T","TAG","TCB","TDG","TGK","TGY","TH1","TIA","TM5","TM6","TM9","TMR","TMX","TOA","TOC","TRE","TYV","UCD","UDC","VG1","X0X","X1X","X2F","X4S","X5S","X6X","XBP","XDN","XDP","XIF","XIM","XLF","XLS","XMM","XUL","XXR","XYP","XYS","YO5","Z3Q","Z6J","Z9M","ZDC","ZDM"],Bp=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","H","H1","H2","H3","HA","BB"],zp=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*"],Up={};function jp(t,e){this.type=t,this.scale=e||1,this.max=10}function Gp(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}function Vp(t,e){for(var i=0,r=0,n=e.rows,o=e.cols,a=0,s=0,c=0,u=e.data,h=t.data;i<n;s+=1,a+=o,i++)for(c=s,r=0;r<o;c+=n,r++)h[c]=u[a+r]}function $p(t,e,i){for(var r=0,n=0,o=0,a=0,s=0,c=0,u=0,h=e.cols,l=e.rows,p=i.rows,d=e.data,f=i.data,m=t.data,g=0;r<l;a+=h,r++)for(c=0,n=0;n<p;u++,n++){for(s=a,g=0,o=0;o<h;s++,c++,o++)g+=d[s]*f[c];m[u]=g}}function Hp(t,e,i){var r=t.data,n=e.data,o=i.data,a=n[0],s=n[1],c=n[2],u=n[3],h=n[4],l=n[5],p=n[6],d=n[7],f=n[8],m=o[0],g=o[1],v=o[2],y=o[3],b=o[4],x=o[5],_=o[6],w=o[7],S=o[8];r[0]=a*m+s*y+c*_,r[1]=a*g+s*b+c*w,r[2]=a*v+s*x+c*S,r[3]=u*m+h*y+l*_,r[4]=u*g+h*b+l*w,r[5]=u*v+h*x+l*S,r[6]=p*m+d*y+f*_,r[7]=p*g+d*b+f*w,r[8]=p*v+d*x+f*S}function Wp(t){var e,i,r=0,n=t.rows,o=t.cols,a=t.data,s=new Array(o);for(i=0;i<o;++i)s[i]=0;for(e=0;e<n;++e)for(i=0;i<o;++i,++r)s[i]+=a[r];for(i=0;i<o;++i)s[i]/=n;return s}function Xp(t,e){var i,r,n=0,o=t.rows,a=t.cols,s=t.data;for(i=0;i<o;++i)for(r=0;r<a;++r,++n)s[n]-=e[r]}function qp(t,e,i,r){r=t[e],t[e]=t[i],t[i]=r}function Yp(t,e){return(t=Math.abs(t))>(e=Math.abs(e))?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}Up[1]={trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT"],backboneStart:"N",backboneEnd:"C"},Up[2]={trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},Up[3]={trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},Up[4]={trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},Up[5]={trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},Up[6]={trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]},Up[vp]={},jp.prototype={constructor:jp,atomRadius:function(t){var e,i=this.type,r=this.scale;switch(i){case"vdw":e=Pp[t.element]||2;break;case"covalent":e=Tp[t.element]||1.6;break;case"bfactor":e=t.bfactor||1;break;case"sstruc":var n=t.sstruc;e="h"===n?.25:"g"===n?.25:"i"===n?.25:"e"===n?.25:"b"===n?.25:zp.includes(t.atomname)?.4:.1;break;default:e=i||1}return Math.min(e*r,this.max)}},jp.types={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size"},Gp.prototype={copyTo:function(t){t.data.set(this.data)}};var Zp=1.192092896e-7,Kp=1e-37;function Qp(t,e,i,r){var n=0,o=0,a=t.rows,s=t.cols,c=a,u=s;c<u&&(n=1,o=c,c=u,u=o);var h=new Gp(c,c),l=new Gp(1,u),p=new Gp(u,u);if(0===n)Vp(h,t);else{for(o=0;o<s*a;o++)h.data[o]=t.data[o];for(;o<u*c;o++)h.data[o]=0}if(function(t,e,i,r,n,o,a,s){for(var c=2*Zp,u=Kp,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,P=0,T=0,E=0,C=0,I=0,R=0,L=4660,O=0,N=0,D=0,k=new Float64Array(a<<3);h<a;h++){for(p=0,M=0;p<o;p++)M+=(w=t[h*e+p])*w;if(k[h]=M,r){for(p=0;p<a;p++)r[h*n+p]=0;r[h*n+h]=1}}for(;d<f;d++){for(b=0,h=0;h<a-1;h++)for(l=h+1;l<a;l++){for(m=h*e|0,g=l*e|0,C=k[h],I=0,R=k[l],p=2,I+=t[m]*t[g],I+=t[m+1]*t[g+1];p<o;p++)I+=t[m+p]*t[g+p];if(!(Math.abs(I)<=c*Math.sqrt(C*R))){for(T=Yp(I*=2,P=C-R),P<0?(E=.5*(T-P),x=I/(T*(_=Math.sqrt(E/T))*2)):_=I/(T*(x=Math.sqrt((T+P)/(2*T)))*2),C=0,R=0,p=2,S=x*t[m]+_*t[g],A=-_*t[m]+x*t[g],t[m]=S,t[g]=A,C+=S*S,R+=A*A,S=x*t[m+1]+_*t[g+1],A=-_*t[m+1]+x*t[g+1],t[m+1]=S,t[g+1]=A,C+=S*S,R+=A*A;p<o;p++)S=x*t[m+p]+_*t[g+p],A=-_*t[m+p]+x*t[g+p],t[m+p]=S,t[g+p]=A,C+=S*S,R+=A*A;if(k[h]=C,k[l]=R,b=1,r)for(y=l*n|0,p=2,S=x*r[v=h*n|0]+_*r[y],A=-_*r[v]+x*r[y],r[v]=S,r[y]=A,S=x*r[v+1]+_*r[y+1],A=-_*r[v+1]+x*r[y+1],r[v+1]=S,r[y+1]=A;p<a;p++)S=x*r[v+p]+_*r[y+p],A=-_*r[v+p]+x*r[y+p],r[v+p]=S,r[y+p]=A}}if(0===b)break}for(h=0;h<a;h++){for(p=0,M=0;p<o;p++)M+=(w=t[h*e+p])*w;k[h]=Math.sqrt(M)}for(h=0;h<a-1;h++){for(l=h,p=h+1;p<a;p++)k[l]<k[p]&&(l=p);if(h!==l&&(qp(k,h,l,M),r)){for(p=0;p<o;p++)qp(t,h*e+p,l*e+p,w);for(p=0;p<a;p++)qp(r,h*n+p,l*n+p,w)}}for(h=0;h<a;h++)i[h]=k[h];if(r)for(h=0;h<s;h++){for(M=h<a?k[h]:0;M<=u;){for(N=1/o,p=0;p<o;p++)O=0!==(256&(L=214013*L+2531011)>>16)?N:-N,t[h*e+p]=O;for(d=0;d<2;d++)for(l=0;l<h;l++){for(M=0,p=0;p<o;p++)M+=t[h*e+p]*t[l*e+p];for(D=0,p=0;p<o;p++)w=t[h*e+p]-M*t[l*e+p],t[h*e+p]=w,D+=Math.abs(w);for(D=D?1/D:0,p=0;p<o;p++)t[h*e+p]*=D}for(M=0,p=0;p<o;p++)M+=(w=t[h*e+p])*w;M=Math.sqrt(M)}for(_=1/M,p=0;p<o;p++)t[h*e+p]*=_}}(h.data,c,l.data,p.data,u,c,u,c),e){for(o=0;o<u;o++)e.data[o]=l.data[o];for(;o<s;o++)e.data[o]=0}0===n?(i&&Vp(i,h),r&&Vp(r,p)):(i&&Vp(i,p),r&&Vp(r,h))}function Jp(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function td(t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g){t[0]=e,t[4]=i,t[8]=r,t[12]=n,t[1]=o,t[5]=a,t[9]=s,t[13]=c,t[2]=u,t[6]=h,t[10]=l,t[14]=p,t[3]=d,t[7]=f,t[11]=m,t[15]=g}function ed(t,e,i){var r=e[0],n=e[4],o=e[8],a=e[12],s=e[1],c=e[5],u=e[9],h=e[13],l=e[2],p=e[6],d=e[10],f=e[14],m=e[3],g=e[7],v=e[11],y=e[15],b=i[0],x=i[4],_=i[8],w=i[12],S=i[1],A=i[5],M=i[9],P=i[13],T=i[2],E=i[6],C=i[10],I=i[14],R=i[3],L=i[7],O=i[11],N=i[15];t[0]=r*b+n*S+o*T+a*R,t[4]=r*x+n*A+o*E+a*L,t[8]=r*_+n*M+o*C+a*O,t[12]=r*w+n*P+o*I+a*N,t[1]=s*b+c*S+u*T+h*R,t[5]=s*x+c*A+u*E+h*L,t[9]=s*_+c*M+u*C+h*O,t[13]=s*w+c*P+u*I+h*N,t[2]=l*b+p*S+d*T+f*R,t[6]=l*x+p*A+d*E+f*L,t[10]=l*_+p*M+d*C+f*O,t[14]=l*w+p*P+d*I+f*N,t[3]=m*b+g*S+v*T+y*R,t[7]=m*x+g*A+v*E+y*L,t[11]=m*_+g*M+v*C+y*O,t[15]=m*w+g*P+v*I+y*N}function id(t,e,i,r){td(t,e,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1)}function rd(t,e,i,r){td(t,1,0,0,e,0,1,0,i,0,0,1,r,0,0,0,1)}function nd(t,e){var i=Math.cos(e),r=Math.sin(e);td(t,i,0,r,0,0,1,0,0,-r,0,i,0,0,0,0,1)}function od(){return new Float32Array([1,0,0,0,1,0,0,0,1])}function ad(t,e){var i=Ll([e[0],e[1],e[2]]),r=Ll([e[4],e[5],e[6]]),n=Ll([e[8],e[9],e[10]]),o=Ll();Ol(o,r,n),t[0]=o[0],t[1]=o[1],t[2]=o[2],Ol(o,n,i),t[3]=o[0],t[4]=o[1],t[5]=o[2],Ol(o,i,r),t[6]=o[0],t[7]=o[1],t[8]=o[2]}id.__deps=[td],rd.__deps=[td],nd.__deps=[td],ad.__deps=[Ll,Ol];var sd=new Me(-1,-1,-1),cd=new Pe,ud=function(t){var e=t.rows,i=e/3,r=new Gp(e,3),n=new Gp(3,3),o=new Gp(1,3),a=new Gp(3,3),s=new Gp(3,3),c=Wp(t);Xp(t,c),Vp(r,t),$p(n,r,r),Qp(n,o,a,s);var u=new Me(c[0],c[1],c[2]),h=new Me(a.data[0],a.data[3],a.data[6]),l=new Me(a.data[1],a.data[4],a.data[7]),p=new Me(a.data[2],a.data[5],a.data[8]),d=h.clone().multiplyScalar(Math.sqrt(o.data[0]/i)),f=l.clone().multiplyScalar(Math.sqrt(o.data[1]/i)),m=p.clone().multiplyScalar(Math.sqrt(o.data[2]/i));this.begA=u.clone().sub(d),this.endA=u.clone().add(d),this.begB=u.clone().sub(f),this.endB=u.clone().add(f),this.begC=u.clone().sub(m),this.endC=u.clone().add(m),this.center=u,this.vecA=d,this.vecB=f,this.vecC=m,this.normVecA=h,this.normVecB=l,this.normVecC=p};function hd(t,e){var i,r,n=3,o=e,a=o.min.x,s=o.min.y,c=o.min.z,u=1+(o.max.x-a>>n),h=1+(o.max.y-s>>n),l=1+(o.max.z-c>>n),p=u*h*l,d=t.count,f=t.x,m=t.y,g=t.z,v=0,y=new Uint32Array(p),b=new Int32Array(d);for(i=0;i<d;++i){var x=f[i]-a>>n,_=m[i]-s>>n,w=g[i]-c>>n,S=(x*h+_)*l+w;1===(y[S]+=1)&&(v+=1),b[i]=S}var A=new Uint16Array(v);for(i=0,r=0;i<p;++i){var M=y[i];M>0&&(y[i]=r+1,A[r]=M,r+=1)}var P=new Uint32Array(v);for(i=1;i<v;++i)P[i]+=P[i-1]+A[i-1];var T=new Uint16Array(v),E=new Int32Array(d);for(i=0;i<d;++i){var C=y[b[i]];if(C>0){var I=C-1;E[P[I]+T[I]]=i,T[I]+=1}}this.within=function(t,e,i,r){for(var o=r*r,p=Math.max(0,t-r-a>>n),d=Math.max(0,e-r-s>>n),v=Math.max(0,i-r-c>>n),b=Math.min(u,t+r-a>>n),x=Math.min(h,e+r-s>>n),_=Math.min(l,i+r-c>>n),w=[],S=p;S<=b;++S)for(var M=d;M<=x;++M)for(var T=v;T<=_;++T){var C=y[(S*h+M)*l+T];if(C>0)for(var I=C-1,R=P[I],L=R+A[I],O=R;O<L;++O){var N=E[O],D=f[N]-t,k=m[N]-e,F=g[N]-i;D*D+k*k+F*F<=o&&w.push(N)}}return w}}function ld(t){var e=0,i=0,r={},n={},o=window.URL.createObjectURL(wu.get(t)),a=new window.Worker(o);wu.activeWorkerCount+=1,a.onmessage=function(i){e-=1;var o=i.data.__postId;xu&&bu.timeEnd("Worker.postMessage "+t+" #"+o),r[o]&&r[o].call(a,i),delete r[o],delete n[o]},a.onerror=function(i){if(e-=1,i.data){var o=i.data.__postId;n[o]?n[o].call(a,i):bu.error("Worker.onerror",o,t,i),delete r[o],delete n[o]}else bu.error("Worker.onerror",t,i)},this.name=t,this.post=function(o,s,c,u){r[i]=c,n[i]=u,(o=o||{}).__name=t,o.__postId=i,o.__debug=xu,xu&&bu.time("Worker.postMessage "+t+" #"+i);try{a.postMessage(o,s)}catch(h){bu.error("worker.post:",h),a.postMessage(o)}return e+=1,i+=1,this},this.terminate=function(){a?(a.terminate(),window.URL.revokeObjectURL(o),wu.activeWorkerCount-=1):bu.log("no worker to terminate")},Object.defineProperties(this,{postCount:{get:function(){return i}},pending:{get:function(){return e}}})}function pd(t,e){e=Math.min(8,e||2);var i=[],r=0;this.name=t,this.maxCount=e,this.post=function(t,e,i,r){return this.getNextWorker().post(t,e,i,r),this},this.terminate=function(){i.forEach(function(t){t.terminate()})},this.getNextWorker=function(){for(var n,o=1/0,a=0;a<e;++a){if(a>=r){n=new ld(t),i.push(n),r+=1;break}var s=i[a];if(0===s.pending){n=s;break}s.pending<o&&(o=s.pending,n=s)}return n},Object.defineProperties(this,{count:{get:function(){return r}}})}function dd(){return new Uint32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0])}function fd(){return new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])}function md(){return[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]]}function gd(t,e,i,r,n){var o,a,s,c,u,h,l,p=0,d=!1,f=!1,m=!1,g=e*i*r,v=e,y=e*i,b=new Int32Array(12),x=[],_=[],w=[],S=[],A=dd(),M=fd(),P=[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]];function T(t,e,i){return t+(e-t)*i}function E(t,n,o){return y*(o=(o+l)%r)+v*(n=(n+h)%i)+(t=(t+u)%e)}function C(t,e,i,r,c,u,h){var l=f?3*t:t;if(a[l]<0){var m=(p-u)/(h-u),g=o,v=3*s;if(x[v+0]=i+m,x[v+1]=r,x[v+2]=c,!d){var y=3*t;_[v]=-T(g[y],g[y+3],m),_[v+1]=-T(g[y+1],g[y+4],m),_[v+2]=-T(g[y+2],g[y+5],m)}n&&(S[s]=n[t+Math.round(m)]),a[l]=s,b[e]=s,s+=1}else b[e]=a[l]}function I(t,e,i,r,c,u,h){var l=f?3*t+1:t;if(a[l]<0){var m=(p-u)/(h-u),g=o,y=3*s;if(x[y]=i,x[y+1]=r+m,x[y+2]=c,!d){var w=3*t,A=w+3*v;_[y]=-T(g[w],g[A],m),_[y+1]=-T(g[w+1],g[A+1],m),_[y+2]=-T(g[w+2],g[A+2],m)}n&&(S[s]=n[t+Math.round(m)*v]),a[l]=s,b[e]=s,s+=1}else b[e]=a[l]}function R(t,e,i,r,c,u,h){var l=f?3*t+2:t;if(a[l]<0){var m=(p-u)/(h-u),g=o,v=3*s;if(x[v]=i,x[v+1]=r,x[v+2]=c+m,!d){var w=3*t,A=w+3*y;_[v]=-T(g[w],g[A],m),_[v+1]=-T(g[w+1],g[A+1],m),_[v+2]=-T(g[w+2],g[A+2],m)}n&&(S[s]=n[t+Math.round(m)*y]),a[l]=s,b[e]=s,s+=1}else b[e]=a[l]}function L(e){var i=3*e;0===o[i]&&(o[i]=t[(e-1+g)%g]-t[(e+1)%g],o[i+1]=t[(e-v+g)%g]-t[(e+v)%g],o[i+2]=t[(e-y+g)%g]-t[(e+y)%g])}function O(e,i,r,n,o){var a,s,u,h,l,g,x;m?(n=E(e,i,r),a=E(e+1,i,r),s=E(e,i+1,r),u=E(e,i,r+1),h=E(e+1,i+1,r),l=E(e+1,i,r+1),g=E(e,i+1,r+1),x=E(e+1,i+1,r+1)):(a=n+1,h=(s=n+v)+1,l=(u=n+y)+1,x=(g=s+y)+1);var _=0,S=t[n],T=t[a],O=t[s],N=t[h],D=t[u],k=t[l],F=t[g],B=t[x];S<p&&(_|=1),T<p&&(_|=2),O<p&&(_|=8),N<p&&(_|=4),D<p&&(_|=16),k<p&&(_|=32),F<p&&(_|=128),B<p&&(_|=64);var z=A[_];if(0===z)return 0;var U=e+1,j=i+1,G=r+1;1&z&&(d||(L(n),L(a)),C(n,0,e,i,r,S,T)),2&z&&(d||(L(a),L(h)),I(a,1,U,i,r,T,N)),4&z&&(d||(L(s),L(h)),C(s,2,e,j,r,O,N)),8&z&&(d||(L(n),L(s)),I(n,3,e,i,r,S,O)),16&z&&(d||(L(u),L(l)),C(u,4,e,i,G,D,k)),32&z&&(d||(L(l),L(x)),I(l,5,U,i,G,k,B)),64&z&&(d||(L(g),L(x)),C(g,6,e,j,G,F,B)),128&z&&(d||(L(u),L(g)),I(u,7,e,i,G,D,F)),256&z&&(d||(L(n),L(u)),R(n,8,e,i,r,S,D)),512&z&&(d||(L(a),L(l)),R(a,9,U,i,r,T,k)),1024&z&&(d||(L(h),L(x)),R(h,10,U,j,r,N,B)),2048&z&&(d||(L(s),L(g)),R(s,11,e,j,r,O,F));for(var V,$,H,W=_<<4,X=0;-1!==M[W+X];)V=M[W+X],$=M[W+X+1],H=M[W+X+2],f?(P[V][$]&o&&(w[c++]=b[V],w[c++]=b[$]),P[$][H]&o&&(w[c++]=b[$],w[c++]=b[H]),P[V][H]&o&&(w[c++]=b[V],w[c++]=b[H])):(w[c++]=b[$],w[c++]=b[V],w[c++]=b[H]),X+=3}function N(n,o,s,c,u,h){var l,g,b,x,_,w,S,A,M,P,T,C,I;if(n=void 0!==n?n:0,o=void 0!==o?o:0,s=void 0!==s?s:0,c=void 0!==c?c:e-1,u=void 0!==u?u:i-1,h=void 0!==h?h:r-1,m||(d?(n=Math.max(0,n),o=Math.max(0,o),s=Math.max(0,s),c=Math.min(e-1,c),u=Math.min(i-1,u),h=Math.min(r-1,h)):(n=Math.max(1,n),o=Math.max(1,o),s=Math.max(1,s),c=Math.min(e-2,c),u=Math.min(i-2,u),h=Math.min(r-2,h))),m)for(A=n-2,M=o-2,T=c+2,C=u+2,I=h+2,_=P=s-2;_<I;++_)for(x=M;x<C;++x)for(b=A;b<T;++b)f?(g=3*E(b,x,_),a[g]=-1,a[g+1]=-1,a[g+2]=-1):(l=E(b,x,_),a[l]=-1);else for(A=Math.max(0,n-2),M=Math.max(0,o-2),P=Math.max(0,s-2),T=Math.min(e,c+2),C=Math.min(i,u+2),I=Math.min(r,h+2),_=P;_<I;++_)for(S=y*_,x=M;x<C;++x)for(w=S+v*x,b=A;b<T;++b)f?(a[l=3*(w+b)]=-1,a[l+1]=-1,a[l+2]=-1):a[l=w+b]=-1;if(!m){var R,L=n,N=o,D=s,k=c,F=u,B=h;for(R=!1,_=s;_<h;++_){for(x=o;x<u;++x){for(b=n;b<c;++b)if(t[l=e*i*_+e*x+b]>=p){D=_,R=!0;break}if(R)break}if(R)break}for(R=!1,x=o;x<u;++x){for(_=D;_<h;++_){for(b=n;b<c;++b)if(t[l=e*i*_+e*x+b]>=p){N=x,R=!0;break}if(R)break}if(R)break}for(R=!1,b=n;b<c;++b){for(x=N;x<u;++x){for(_=D;_<h;++_)if(t[l=e*i*_+e*x+b]>=p){L=b,R=!0;break}if(R)break}if(R)break}for(R=!1,_=h;_>=s;--_){for(x=u;x>=o;--x){for(b=c;b>=n;--b)if(t[l=e*i*_+e*x+b]>=p){B=_,R=!0;break}if(R)break}if(R)break}for(R=!1,x=u;x>=o;--x){for(_=B;_>=s;--_){for(b=c;b>=n;--b)if(t[l=e*i*_+e*x+b]>=p){F=x,R=!0;break}if(R)break}if(R)break}for(R=!1,b=c;b>=n;--b){for(x=F;x>=o;--x){for(_=B;_>=s;--_)if(t[l=e*i*_+e*x+b]>=p){k=b,R=!0;break}if(R)break}if(R)break}d?(n=Math.max(0,L-1),o=Math.max(0,N-1),s=Math.max(0,D-1),c=Math.min(e-1,k+1),u=Math.min(i-1,F+1),h=Math.min(r-1,B+1)):(n=Math.max(1,L-1),o=Math.max(1,N-1),s=Math.max(1,D-1),c=Math.min(e-2,k+1),u=Math.min(i-2,F+1),h=Math.min(r-2,B+1))}var z=15;for(_=s;_<h;++_,z&=-5)for(S=y*_,z|=2,x=o;x<u;++x,z&=-3)for(w=S+v*x,z|=1,b=n;b<c;++b,z&=-2)O(b,x,_,l=w+b,z)}this.triangulate=function(t,v,y,b,A){p=t,f=b,m=A,(d=v||f)||o||(o=new Float32Array(3*g));var M=f?3*g:g;if(a&&a.length===M||(a=new Int32Array(M)),s=0,c=0,void 0!==y){var P=y[0].map(Math.round),T=y[1].map(Math.round);u=e*Math.ceil(Math.abs(P[0])/e),h=i*Math.ceil(Math.abs(P[1])/i),l=r*Math.ceil(Math.abs(P[2])/r),N(P[0],P[1],P[2],T[0],T[1],T[2])}else u=h=l=0,N();return x.length=3*s,d||(_.length=3*s),w.length=c,n&&(S.length=s),{position:new Float32Array(x),normal:d?void 0:new Float32Array(_),index:Va(w,x.length/3),atomindex:n?new Int32Array(S):void 0,contour:f}}}function vd(t,e,i,r){i=i||1,r=r||!0;var n,o=t.length/3,a=e.length/3;r&&(n=new Float32Array(3*o));var s,c,u,h,l=new Float32Array(3*o),p=new Array(20);for(s=0;s<20;++s)p[s]=new Uint32Array(o);for(s=0;s<o;++s)p[0][s]=0;for(s=0;s<a;++s){var d=3*s,f=3*s+1,m=3*s+2;for(h=!0,c=0,u=p[0][e[d]];c<u;++c)if(e[f]===p[c+1][e[d]]){h=!1;break}for(h&&(p[0][e[d]]++,p[p[0][e[d]]][e[d]]=e[f]),h=!0,c=0,u=p[0][e[d]];c<u;++c)if(e[m]===p[c+1][e[d]]){h=!1;break}for(h&&(p[0][e[d]]++,p[p[0][e[d]]][e[d]]=e[m]),h=!0,c=0,u=p[0][e[f]];c<u;++c)if(e[d]===p[c+1][e[f]]){h=!1;break}for(h&&(p[0][e[f]]++,p[p[0][e[f]]][e[f]]=e[d]),h=!0,c=0,u=p[0][e[f]];c<u;++c)if(e[m]===p[c+1][e[f]]){h=!1;break}for(h&&(p[0][e[f]]++,p[p[0][e[f]]][e[f]]=e[m]),h=!0,c=0;c<p[0][e[m]];++c)if(e[d]===p[c+1][e[m]]){h=!1;break}for(h&&(p[0][e[m]]++,p[p[0][e[m]]][e[m]]=e[d]),h=!0,c=0,u=p[0][e[m]];c<u;++c)if(e[f]===p[c+1][e[m]]){h=!1;break}h&&(p[0][e[m]]++,p[p[0][e[m]]][e[m]]=e[f])}for(var g,v,y,b,x,_=0;_<i;++_){for(s=0;s<o;++s)if(g=3*s,(y=p[0][s])<3)l[g]=t[g],l[g+1]=t[g+1],l[g+2]=t[g+2];else if(3===y||4===y){for(l[g]=0,l[g+1]=0,l[g+2]=0,c=0;c<y;++c)v=3*p[c+1][s],l[g]+=t[v],l[g+1]+=t[v+1],l[g+2]+=t[v+2];l[g]+=.5*t[g],l[g+1]+=.5*t[g+1],l[g+2]+=.5*t[g+2],x=.5+y,l[g]/=x,l[g+1]/=x,l[g+2]/=x}else{for(l[g]=0,l[g+1]=0,l[g+2]=0,c=0;c<y;++c)v=3*p[c+1][s],l[g]+=t[v],l[g+1]+=t[v+1],l[g+2]+=t[v+2];l[g]+=1*t[g],l[g+1]+=1*t[g+1],l[g+2]+=1*t[g+2],b=1+y,l[g]/=b,l[g+1]/=b,l[g+2]/=b}if(t.set(l),r){yd(t,e,n);var w=3*o;for(g=0;g<w;g+=3)t[g]+=.75/4.5*-1*n[g],t[g+1]+=.75/4.5*-1*n[g+1],t[g+2]+=.75/4.5*-1*n[g+2]}}}function yd(t,e,i){var r,n;if(void 0===i)i=new Float32Array(t.length);else for(r=0,n=i.length;r<n;r++)i[r]=0;var o=new Float32Array(3),a=new Float32Array(3),s=new Float32Array(3),c=new Float32Array(3),u=new Float32Array(3);if(e)for(r=0,n=e.length;r<n;r+=3){var h=3*e[r],l=3*e[r+1],p=3*e[r+2];Dl(o,t,h),Dl(a,t,l),Dl(s,t,p),Nl(c,s,a),Nl(u,o,a),Ol(c,c,u),i[h]+=c[0],i[h+1]+=c[1],i[h+2]+=c[2],i[l]+=c[0],i[l+1]+=c[1],i[l+2]+=c[2],i[p]+=c[0],i[p+1]+=c[1],i[p+2]+=c[2]}else for(r=0,n=t.length;r<n;r+=9)Dl(o,t,r),Dl(a,t,r+3),Dl(s,t,r+6),Nl(c,s,a),Nl(u,o,a),Ol(c,c,u),i[r]=c[0],i[r+1]=c[1],i[r+2]=c[2],i[r+3]=c[0],i[r+4]=c[1],i[r+5]=c[2],i[r+6]=c[0],i[r+7]=c[1],i[r+8]=c[2];return Rl(i),i}function bd(t){for(var e={},i=0,r=t.length;i<r;++i)e[t[i]]=!0;return e}function xd(t,e,i,r,n){var o=1/r*3;Ul(t,t,n+(o+=i)),jl(e,e,n+o),Bl(t,t,r),Gl(t,t),Fl(t,t,r),Bl(e,e,r),Vl(e,e),Fl(e,e,r);var a=new Float32Array(3);Nl(a,e,t),Bl(a,a,r),Vl(a,a),jl(a,a,1);var s=256*Math.pow(10,6),c=a[0]*a[1]*a[2]*3;s<=c&&(Bl(t,t,r*=Math.pow(s/c,1/3)),Gl(t,t),Fl(t,t,r),Bl(e,e,r),Vl(e,e),Fl(e,e,r),Nl(a,e,t),Bl(a,a,r),Vl(a,a),jl(a,a,1));var u=new Float32Array(t);$l(u,u);var h=Jp(),l=Jp();nd(l,is(90)),ed(h,h,l);var p=Jp();id(p,-1/r,1/r,1/r),ed(h,h,p);var d=Jp();return rd(d,-r*u[2],-r*u[1],-r*u[0]),ed(h,h,d),{dim:a,tran:u,matrix:h,scaleFactor:r}}ud.prototype.getBasisMatrix=function(t){var e=t||new Pe;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(sd),e},ud.prototype.getRotationQuaternion=function(t){var e=t||new Ae;return e.setFromRotationMatrix(this.getBasisMatrix(cd)),e.inverse()},ud.prototype.getProjectedScaleForAtoms=function(t){var e=-1/0,i=-1/0,r=-1/0,n=-1/0,o=-1/0,a=-1/0,s=new Me,c=new Me,u=this.center,h=this.normVecA,l=this.normVecB,p=this.normVecC;return t.eachAtom(function(t){Tl(s.copy(t),h,u);var d=c.subVectors(s,u).normalize().dot(h),f=s.distanceTo(u);d>0?f>e&&(e=f):f>i&&(i=f),Tl(s.copy(t),l,u);var m=c.subVectors(s,u).normalize().dot(l),g=s.distanceTo(u);m>0?g>r&&(r=g):g>n&&(n=g),Tl(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:r,d3a:o,d1b:-i,d2b:-n,d3b:-a}},ld.prototype.constructor=ld,pd.prototype.constructor=pd,gd.__deps=[dd,fd,md,Va],vd.__deps=[yd],yd.__deps=[Nl,Ol,Dl,Rl],xd.__deps=[is,Ul,jl,Fl,Bl,Gl,Vl,Nl,$l,Jp,ed,rd,id,nd];var _d=function(t,e,i){this.name=t||"",this.path=e||"",this.info={},this.center=new Me,this.boundingBox=new Ti,i instanceof $i||i instanceof Ki||i instanceof tn?this.fromGeometry(i):i&&(this.set(i.position,i.index,i.normal,i.color,i.atomindex,i.contour),this.boundingBox.setFromArray(i.position),this.boundingBox.getCenter(this.center))},wd={type:{}};function Sd(t,e,i,r,n){var o=new gd(t,e,i,r,n);this.getSurface=function(t,e,i,r,n,a){var s=o.triangulate(t,e,i,n,a);if(e&&!n&&(vd(s.position,s.index,e,!0),s.normal=yd(s.position,s.index)),r&&(Cl(r,s.position),s.normal)){var c=od();ad(c,r),Il(c,s.normal)}return s}}wd.type.get=function(){return"Surface"},_d.prototype.set=function(t,e,i,r,n,o){this.position=t,this.index=e,this.normal=i,this.color=r,this.atomindex=n,this.size=t.length/3,this.contour=o},_d.prototype.fromGeometry=function(t){var e,i,r,n;if(xu&&bu.time("GeometrySurface.fromGeometry"),t instanceof $i?(t.computeVertexNormals(!0),e=(new Ki).fromGeometry(t)):e=t instanceof Ki?t:t[0],e.boundingBox||e.computeBoundingBox(),this.boundingBox.copy(e.boundingBox),this.boundingBox.getCenter(this.center),e instanceof Ki){var o=e.attributes,a=!!o.normal&&o.normal.array;(!a||0===a[0]&&0===a[1]&&0===a[2])&&e.computeVertexNormals(),i=o.position.array,r=o.index?o.index.array:null,n=o.normal.array}this.set(i,r,n,void 0,void 0),xu&&bu.timeEnd("GeometrySurface.setGeometry")},_d.prototype.getPosition=function(){return this.position},_d.prototype.getColor=function(t){var e=t||{};e.surface=this;var i=this.size,r=new Float32Array(3*i),n=Su.getScheme(e);if(n.volumeColor||"random"===e.scheme)for(var o=0;o<i;++o)n.volumeColorToArray(o,r,3*o);else if(n.positionColor)for(var a=new Me,s=this.position,c=0;c<i;++c){var u=3*c;a.set(s[u],s[u+1],s[u+2]),n.positionColorToArray(a,r,u)}else if(n.atomColor&&this.atomindex)for(var h=e.structure.getAtomProxy(),l=this.atomindex,p=0;p<i;++p)h.index=l[p],n.atomColorToArray(h,r,3*p);else{var d=new mi(e.value);lh(i,d.r,d.g,d.b,r)}return r},_d.prototype.getPicking=function(t){return this.atomindex&&t?new Yl(this.atomindex,t):new ap(ph(this.size),this)},_d.prototype.getNormal=function(){return this.normal},_d.prototype.getSize=function(t,e){return hh(this.size,t*e)},_d.prototype.getIndex=function(){return this.index},_d.prototype.getFilteredIndex=function(t,e){if(t&&this.atomindex){for(var i=new cu(t),r=e.getAtomSet(i),n=[],o=this.atomindex,a=this.index,s=a.length,c=this.contour?2:3,u=0,h=0;h<s;h+=c){for(var l=!0,p=0;p<c;p++){var d=o[a[h+p]];if(!r.get(d)){l=!1;break}}if(l)for(var f=0;f<c;f++,u++)n[u]=a[h+f]}return Va(n,this.position.length/3)}return this.index},_d.prototype.getAtomindex=function(){return this.atomindex},_d.prototype.dispose=function(){},Object.defineProperties(_d.prototype,wd),Sd.__deps=[vd,yd,gd,Cl,Il,od,ad],wu.add("surf",function(t,e){var i=t.data.args,r=t.data.params;if(i&&(self.volsurf=new Sd(i[0],i[1],i[2],i[3],i[4])),r){var n=self.volsurf.getSurface(r.isolevel,r.smooth,r.box,r.matrix,r.contour,r.wrap),o=[n.position.buffer,n.index.buffer];n.normal&&o.push(n.normal.buffer),n.atomindex&&o.push(n.atomindex.buffer),e({sd:n,p:r},o)}},[Sd]);var Ad=function(t,e,i,r,n,o,a){this.name=t,this.path=e,this.matrix=new Pe,this.normalMatrix=new Ci,this.inverseMatrix=new Pe,this.center=new Me,this.boundingBox=new Ti,this.setData(i,r,n,o,a)},Md={type:{},position:{},min:{},max:{},sum:{},mean:{},rms:{}};Md.type.get=function(){return"Volume"},Ad.prototype.setData=function(t,e,i,r,n){this.nx=e||1,this.ny=i||1,this.nz=r||1,this.data=t||new Float32Array(1),this.setAtomindex(n),delete this._position,delete this._min,delete this._max,delete this._mean,delete this._rms,this.worker&&this.worker.terminate()},Ad.prototype.setMatrix=function(t){this.matrix.copy(t);var e=this.boundingBox,i=this.center,r=this.nx-1,n=this.ny-1,o=this.nz-1;e.makeEmpty(),e.expandByPoint(i.set(r,n,o)),e.expandByPoint(i.set(r,n,0)),e.expandByPoint(i.set(r,0,o)),e.expandByPoint(i.set(r,0,0)),e.expandByPoint(i.set(0,n,o)),e.expandByPoint(i.set(0,0,o)),e.expandByPoint(i.set(0,n,0)),e.expandByPoint(i.set(0,0,0)),e.applyMatrix4(this.matrix),e.getCenter(this.center);var a=this.matrix.elements,s=new Me(a[0],a[1],a[2]),c=new Me(a[4],a[5],a[6]),u=new Me(a[8],a[9],a[10]),h=new Me,l=this.normalMatrix.elements;h.crossVectors(c,u),l[0]=h.x,l[1]=h.y,l[2]=h.z,h.crossVectors(u,s),l[3]=h.x,l[4]=h.y,l[5]=h.z,h.crossVectors(s,c),l[6]=h.x,l[7]=h.y,l[8]=h.z,this.inverseMatrix.getInverse(this.matrix)},Ad.prototype.setAtomindex=function(t){this.atomindex=t},Ad.prototype.getBox=function(t,e,i){return i||(i=new Ti),i.set(t,t),i.expandByScalar(e),i.applyMatrix4(this.inverseMatrix),i.min.round(),i.max.round(),i},Ad.prototype._getBox=function(t,e){if(t&&e){this.__box||(this.__box=new Ti);var i=this.getBox(t,e,this.__box);return[i.min.toArray(),i.max.toArray()]}},Ad.prototype._makeSurface=function(t,e,i){var r=this.name+"@"+e.toPrecision(2),n=new _d(r,"",t);return n.info.isolevel=e,n.info.smooth=i,n.info.volume=this,n},Ad.prototype.getSurface=function(t,e,i,r,n,o){t=isNaN(t)?this.getValueForSigma(2):t,e=Oa(e,0),void 0===this.volsurf&&(this.volsurf=new Sd(this.data,this.nx,this.ny,this.nz,this.atomindex));var a=this._getBox(i,r),s=this.volsurf.getSurface(t,e,a,this.matrix.elements,n,o);return this._makeSurface(s,t,e)},Ad.prototype.getSurfaceWorker=function(t,e,i,r,n,o,a){var s=this;if(t=isNaN(t)?this.getValueForSigma(2):t,e=e||0,window.Worker){void 0===this.workerPool&&(this.workerPool=new pd("surf",2));var c={},u=this.workerPool.getNextWorker();0===u.postCount&&(c.args=[this.data,this.nx,this.ny,this.nz,this.atomindex]),c.params={isolevel:t,smooth:e,box:this._getBox(i,r),matrix:this.matrix.elements,contour:n,wrap:o},u.post(c,void 0,function(t){var e=t.data.sd,i=t.data.p;a(s._makeSurface(e,i.isolevel,i.smooth))},function(c){console.warn("Volume.getSurfaceWorker error - trying without worker",c);var u=s.getSurface(t,e,i,r,n,o);a(u)})}else{var h=this.getSurface(t,e,i,r,n,o);a(h)}},Ad.prototype.getValueForSigma=function(t){return this.mean+Oa(t,2)*this.rms},Ad.prototype.getSigmaForValue=function(t){return(Oa(t,0)-this.mean)/this.rms},Md.position.get=function(){if(!this._position){for(var t=this.nz,e=this.ny,i=this.nx,r=new Float32Array(i*e*t*3),n=0,o=0;o<t;++o)for(var a=0;a<e;++a)for(var s=0;s<i;++s)r[n+0]=s,r[n+1]=a,r[n+2]=o,n+=3;Cl(this.matrix.elements,r),this._position=r}return this._position},Ad.prototype.getDataAtomindex=function(){return this.atomindex},Ad.prototype.getDataPosition=function(){return this.position},Ad.prototype.getDataColor=function(t){var e=t||{};e.volume=this,e.scale=e.scale||"Spectral",e.domain=e.domain||[this.min,this.max];for(var i=Su.getScheme(e),r=this.position.length/3,n=new Float32Array(3*r),o=0;o<r;++o)i.volumeColorToArray(o,n,3*o);return n},Ad.prototype.getDataPicking=function(){var t=ph(this.position.length/3);return new cp(t,this)},Ad.prototype.getDataSize=function(t,e){var i,r=this.data,n=this.position.length/3;switch(t){case"value":i=new Float32Array(r);break;case"abs-value":i=new Float32Array(r);for(var o=0;o<n;++o)i[o]=Math.abs(i[o]);break;case"value-min":i=new Float32Array(r);for(var a=this.min,s=0;s<n;++s)i[s]-=a;break;case"deviation":i=new Float32Array(r);break;default:i=hh(n,t)}if(1!==e)for(var c=0;c<n;++c)i[c]*=e;return i},Md.min.get=function(){return void 0===this._min&&(this._min=function(t){for(var e=1/0,i=0,r=t.length;i<r;++i)t[i]<e&&(e=t[i]);return e}(this.data)),this._min},Md.max.get=function(){return void 0===this._max&&(this._max=function(t){for(var e=-1/0,i=0,r=t.length;i<r;++i)t[i]>e&&(e=t[i]);return e}(this.data)),this._max},Md.sum.get=function(){return void 0===this._sum&&(this._sum=gh(this.data)),this._sum},Md.mean.get=function(){var t;return void 0===this._mean&&(this._mean=gh(t=this.data)/t.length),this._mean},Md.rms.get=function(){return void 0===this._rms&&(this._rms=function(t){for(var e=t.length,i=0,r=0;r<e;++r){var n=t[r];i+=n*n}return Math.sqrt(i/e)}(this.data)),this._rms},Ad.prototype.clone=function(){var t=new Ad(this.name,this.path,this.data,this.nx,this.ny,this.nz,this.atomindex);return t.matrix.copy(this.matrix),t.header=Object.assign({},this.header),t},Ad.prototype.dispose=function(){this.workerPool&&this.workerPool.terminate()},Object.defineProperties(Ad.prototype,Md);var Pd=function(t,e,i,r){this.volume=t,this.setFilter(e,i,r)},Td={header:{},matrix:{},normalMatrix:{},inverseMatrix:{},center:{},boundingBox:{},min:{},max:{},mean:{},rms:{}};Td.header.get=function(){return this.volume.header},Td.matrix.get=function(){return this.volume.matrix},Td.normalMatrix.get=function(){return this.volume.normalMatrix},Td.inverseMatrix.get=function(){return this.volume.inverseMatrix},Td.center.get=function(){return this.volume.center},Td.boundingBox.get=function(){return this.volume.boundingBox},Td.min.get=function(){return this.volume.min},Td.max.get=function(){return this.volume.max},Td.mean.get=function(){return this.volume.mean},Td.rms.get=function(){return this.volume.rms},Pd.prototype._getFilterHash=function(t,e,i){return JSON.stringify([t,e,i])},Pd.prototype.setFilter=function(t,e,i){isNaN(t)&&this.header&&(t=this.header.DMEAN+2*this.header.ARMS),t=void 0===t||isNaN(t)?-1/0:t,e=Oa(e,1/0),i=Oa(i,!1);var r=this.volume.data,n=this.volume.position,o=this.volume.atomindex,a=this._getFilterHash(t,e,i);if(a!==this._filterHash){if(t===-1/0&&e===1/0)this.data=r,this.position=n,this.atomindex=o;else{var s=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*s),this._positionBuffer=new ArrayBuffer(3*s*4),o&&(this._atomindexBuffer=new ArrayBuffer(4*s)));var c,u=new Float32Array(this._dataBuffer),h=new Float32Array(this._positionBuffer);o&&(c=new Uint32Array(this._atomindexBuffer));for(var l=0,p=0;p<s;++p){var d=3*p,f=r[p];if(!i&&f>=t&&f<=e||i&&(f<t||f>e)){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(Pd.prototype,Td),Pd.prototype.getValueForSigma=Ad.prototype.getValueForSigma,Pd.prototype.getSigmaForValue=Ad.prototype.getSigmaForValue,Pd.prototype.getDataAtomindex=Ad.prototype.getDataAtomindex,Pd.prototype.getDataPosition=Ad.prototype.getDataPosition,Pd.prototype.getDataColor=Ad.prototype.getDataColor,Pd.prototype.getDataPicking=Ad.prototype.getDataPicking,Pd.prototype.getDataSize=Ad.prototype.getDataSize;var Ed=function(t,e){xu&&bu.time("BondHash init");for(var i=t.count,r=t.atomIndex1,n=t.atomIndex2,o=new Uint8Array(e),a=new Int32Array(e),s=0;s<i;++s)o[r[s]]+=1,o[n[s]]+=1;for(var c=1;c<e;++c)a[c]+=a[c-1]+o[c-1];for(var u=2*i,h=new Int32Array(u),l=0;l<u;++l)h[l]=-1;for(var p=0;p<i;++p){for(var d=r[p],f=n[p],m=a[d];-1!==h[m];)m+=1;h[m]=p;for(var g=a[f];-1!==h[g];)g+=1;h[g]=p}xu&&bu.timeEnd("BondHash init"),this.countArray=o,this.offsetArray=a,this.indexArray=h},Cd=function(t){Number.isInteger(t)?this._init(t):this._init(0)};Cd.prototype._init=function(t){this.length=t,this.count=0;for(var e=0,i=this.__fields.length;e<i;++e){var r=this.__fields[e][0],n=this.__fields[e][1],o=this.__fields[e][2],a=this.length*n;this[r]=Ga(o,a)}},Cd.prototype.resize=function(t){this.length=Math.round(t||0),this.count=Math.min(this.count,this.length);for(var e=0,i=this.__fields.length;e<i;++e){var r=this.__fields[e][0],n=this.__fields[e][1],o=this.length*n,a=new this[r].constructor(o);this[r].length>o?a.set(this[r].subarray(0,o)):a.set(this[r]),this[r]=a}},Cd.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},Cd.prototype.copyFrom=function(t,e,i,r){for(var n=0,o=this.__fields.length;n<o;++n)for(var a=this.__fields[n][0],s=this.__fields[n][1],c=this[a],u=t[a],h=0;h<r;++h)for(var l=s*(e+h),p=s*(i+h),d=0;d<s;++d)c[l+d]=u[p+d]},Cd.prototype.copyWithin=function(t,e,i){for(var r=0,n=this.__fields.length;r<n;++r)for(var o=this.__fields[r][0],a=this.__fields[r][1],s=this[o],c=0;c<i;++c)for(var u=a*(t+c),h=a*(e+c),l=0;l<a;++l)s[u+l]=s[h+l]},Cd.prototype.sort=function(t){bu.time("Store.sort");var e=this,i=new this.constructor(1);!function r(n,o){if(n<o){var a=Math.floor((n+o)/2),s=n,c=o;do{for(;t(s,a)<0;)s+=1;for(;t(c,a)>0;)c-=1;s<=c&&(s===a?a=c:c===a&&(a=s),(u=s)!==(h=c)&&(i.copyFrom(e,0,u,1),e.copyWithin(u,h,1),e.copyFrom(i,h,0,1)),s+=1,c-=1)}while(s<=c);r(n,c),r(s,o)}var u,h}(0,this.count-1),bu.timeEnd("Store.sort")},Cd.prototype.clear=function(){this.count=0},Cd.prototype.dispose=function(){delete this.length,delete this.count;for(var t=0,e=this.__fields.length;t<e;++t){delete this[this.__fields[t][0]]}};var Id=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]},e.prototype.addBond=function(t,e,i){this.growIfFull();var r=this.count,n=t.index,o=e.index;n<o?(this.atomIndex1[r]=n,this.atomIndex2[r]=o):(this.atomIndex2[r]=n,this.atomIndex1[r]=o),i&&(this.bondOrder[r]=i),this.count+=1},e.prototype.addBondIfConnected=function(t,e,i){return!!t.connectedTo(e)&&(this.addBond(t,e,i),!0)},Object.defineProperties(e.prototype,i),e}(Cd),Rd=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["residueIndex",1,"uint32"],["atomTypeId",1,"uint16"],["x",1,"float32"],["y",1,"float32"],["z",1,"float32"],["serial",1,"int32"],["bfactor",1,"float32"],["altloc",1,"uint8"],["occupancy",1,"float32"]]},e.prototype.setAltloc=function(t,e){this.altloc[t]=e.charCodeAt(0)},e.prototype.getAltloc=function(t){var e=this.altloc[t];return e?String.fromCharCode(e):""},Object.defineProperties(e.prototype,i),e}(Cd),Ld=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["chainIndex",1,"uint32"],["atomOffset",1,"uint32"],["atomCount",1,"uint16"],["residueTypeId",1,"uint16"],["resno",1,"int32"],["sstruc",1,"uint8"],["inscode",1,"uint8"]]},e.prototype.setSstruc=function(t,e){this.sstruc[t]=e.charCodeAt(0)},e.prototype.getSstruc=function(t){var e=this.sstruc[t];return e?String.fromCharCode(e):""},e.prototype.setInscode=function(t,e){this.inscode[t]=e.charCodeAt(0)},e.prototype.getInscode=function(t){var e=this.inscode[t];return e?String.fromCharCode(e):""},Object.defineProperties(e.prototype,i),e}(Cd),Od=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["entityIndex",1,"uint16"],["modelIndex",1,"uint16"],["residueOffset",1,"uint32"],["residueCount",1,"uint32"],["chainname",4,"uint8"],["chainid",4,"uint8"]]},e.prototype.setChainname=function(t,e){var i=4*t;this.chainname[i]=e.charCodeAt(0),this.chainname[i+1]=e.charCodeAt(1),this.chainname[i+2]=e.charCodeAt(2),this.chainname[i+3]=e.charCodeAt(3)},e.prototype.getChainname=function(t){for(var e="",i=0;i<4;++i){var r=this.chainname[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e},e.prototype.setChainid=function(t,e){var i=4*t;this.chainid[i]=e.charCodeAt(0),this.chainid[i+1]=e.charCodeAt(1),this.chainid[i+2]=e.charCodeAt(2),this.chainid[i+3]=e.charCodeAt(3)},e.prototype.getChainid=function(t){for(var e="",i=0;i<4;++i){var r=this.chainid[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e},Object.defineProperties(e.prototype,i),e}(Cd),Nd=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["chainOffset",1,"uint32"],["chainCount",1,"uint32"]]},Object.defineProperties(e.prototype,i),e}(Cd);function Dd(t){this.polymer=t,this.size=t.residueCount}function kd(t){this.polymer=t,this.helixorient=new Dd(t),this.position=this.helixorient.getPosition()}function Fd(t){this.content=[],this.scoreFunction=t}function Bd(t,e){for(var i=t.length/3,r=0,n=new Uint32Array(i),o=0;o<i;++o)n[o]=o;var a=new Int32Array(4*i),s=0,c=0;var u=function e(i,o,u,h){i>r&&(r=i);var l=h-u;if(0===l)return-1;var p=4*s;if(s+=1,1===l)return a[p]=u,a[p+1]=-1,a[p+2]=-1,a[p+3]=o,p;var d,f,m,g,v,y=u+Math.floor(l/2);c=i%3;for(var b=u,x=h-1;x>b;){for(g=t[3*n[m=b+x>>1]+c],f=n[m],n[m]=n[x],n[x]=f,v=b,d=b;d<x;++d)t[3*n[d]+c]<g&&(f=n[v],n[v]=n[d],n[d]=f,++v);if(f=n[x],n[x]=n[v],n[v]=f,y===(m=v))break;y<m?x=m-1:b=m+1}return a[p]=y,a[p+1]=e(i+1,p,u,y),a[p+2]=e(i+1,p,y+1,h),a[p+3]=o,p}(0,-1,0,i);this.rootIndex=u,this.maxDepth=r,this.nearest=function(i,r,o){var s=new Fd(function(t){return-t[1]});!function c(u){var h,l,p=function t(e){var i=a[e+3];return-1===i?0:t(i)+1}(u)%3,d=3*n[a[u]],f=[t[d+0],t[d+1],t[d+2]],m=e(i,f);function g(t,e){s.push([t,e]),s.size()>r&&s.pop()}var v=a[u+1],y=a[u+2];if(-1!==y||-1!==v){c(h=-1===y?v:-1===v?y:i[p]<=t[d+p]?v:y),(s.size()<r||m<s.peek()[1])&&m<=o&&g(u,m);for(var b=[],x=0;x<3;x+=1)b[x]=x===p?i[x]:t[d+x];var _=e(b,f);(s.size()<r||Math.abs(_)<s.peek()[1])&&Math.abs(_)<=o&&-1!==(l=h===v?y:v)&&c(l)}else(s.size()<r||m<s.peek()[1])&&m<=o&&g(u,m)}(u);for(var c=[],h=0,l=Math.min(s.size(),r);h<l;h+=1)c.push(s.content[h]);return c},this.indices=n,this.nodes=a,this.verify=function e(i,r){var o=1;if(void 0===i&&(i=u,r=0),-1===i)throw new Error("node is null");var s=r%3,c=a[i+1],h=a[i+2];if(-1!==c){if(t[3*n[a[c]]+s]>t[3*n[a[i]]+s])throw new Error("left child is > parent!");o+=e(c,r+1)}if(-1!==h){if(t[3*n[a[h]]+s]<t[3*n[a[i]]+s])throw new Error("right child is < parent!");o+=e(h,r+1)}return o}}function zd(t,e){var i;xu&&bu.time("Kdtree build"),i=e?function(t,e){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}:function(t,e){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(i*i+r*r+n*n)};var r=new Float32Array(3*t.atomCount),n=new Uint32Array(t.atomCount),o=0;t.eachAtom(function(t){r[o+0]=t.x,r[o+1]=t.y,r[o+2]=t.z,n[o/3]=t.index,o+=3}),this.atomIndices=n,this.points=r,this.kdtree=new Bd(r,i),xu&&bu.timeEnd("Kdtree build")}Dd.prototype={constructor:Dd,getCenterIterator:function(t){var e=this.getPosition().center,i=e.length/3,r=0,n=-1,o=[new Me,new Me,new Me,new Me];return{size:i,next:function(){var t=this.get(n);return n+=1,t},get:function(n){n=Math.min(i-1,Math.max(0,n));var a=o[r%4],s=3*n;if(a.fromArray(e,s),t){var c,u,h,l=Math.min(t,n,i-n-1);for(u=1;u<=l;++u)c=3*u,h=(l+1-u)/(l+1),a.x+=h*e[s-c+0]+h*e[s+c+0],a.y+=h*e[s-c+1]+h*e[s+c+1],a.z+=h*e[s-c+2]+h*e[s+c+2];a.x/=l+1,a.y/=l+1,a.z/=l+1}return r+=1,a},reset:function(){r=0,n=-1}}},getColor:function(t){var e=this.polymer,i=e.structure,r=e.residueCount,n=e.residueIndexStart,o=new Float32Array(3*r),a=t||{};a.structure=i;for(var s=Su.getScheme(a),c=i.getResidueProxy(),u=i.getAtomProxy(),h=0;h<r;++h)c.index=n+h,u.index=c.traceAtomIndex,s.atomColorToArray(u,o,3*h);return{color:o}},getPicking:function(){for(var t=this.polymer,e=t.structure,i=t.residueCount,r=t.residueIndexStart,n=new Float32Array(i),o=e.getResidueProxy(),a=0;a<i;++a)o.index=r+a,n[a]=o.traceAtomIndex;return{picking:new Yl(n,e)}},getSize:function(t,e){for(var i=this.polymer,r=i.structure,n=i.residueCount,o=i.residueIndexStart,a=new Float32Array(n),s=new jp(t,e),c=r.getResidueProxy(),u=r.getAtomProxy(),h=0;h<n;++h)c.index=o+h,u.index=c.traceAtomIndex,a[h]=s.atomRadius(u);return{size:a}},getPosition:function(){var t,e,i,r,n,o=this.polymer,a=o.structure,s=o.residueCount,c=s-3,u=new Float32Array(3*s),h=new Float32Array(3*s),l=new Float32Array(s),p=new Float32Array(s),d=new Float32Array(s),f=new Float32Array(s),m=new Float32Array(3*s),g=new Me,v=new Me,y=new Me,b=new Me,x=new Me,_=new Me,w=new Me,S=new Me,A=new Me,M=new Me,P=new Me,T=new Me(0,0,0),E="trace",C=a.getAtomProxy(),I=a.getAtomProxy(o.getAtomIndexByType(0,E)),R=a.getAtomProxy(o.getAtomIndexByType(1,E)),L=a.getAtomProxy(o.getAtomIndexByType(2,E));for(i=0;i<c;++i)C.index=I.index,I.index=R.index,R.index=L.index,L.index=o.getAtomIndexByType(i+3,E),e=3*i,g.subVectors(I,C),v.subVectors(R,I),y.subVectors(L,R),b.subVectors(g,v),x.subVectors(v,y),A.crossVectors(b,x).normalize(),A.toArray(h,e),i>0&&(l[i]=A.angleTo(M)),t=Math.cos(b.angleTo(x)),f[i]=180/Math.PI*Math.acos(t),r=b.length(),n=x.length(),p[i]=Math.sqrt(n*r)/Math.max(2,2*(1-t)),d[i]=Math.abs(v.dot(A)),_.copy(b).multiplyScalar(p[i]/r),w.copy(x).multiplyScalar(p[i]/n),_.subVectors(I,_),w.subVectors(R,w),_.toArray(u,e+3),w.toArray(u,e+6),P.subVectors(C,T),P.toArray(m,e),M.copy(A),T.copy(_);for(_.fromArray(u,3),w.fromArray(u,6),A.subVectors(_,w).normalize(),C.index=o.getAtomIndexByType(0,E),T.copy(C),S.copy(C),Tl(S,A,_),S.toArray(u,0),P.subVectors(T,_),P.toArray(m,0),_.fromArray(u,3*s-6),w.fromArray(u,3*s-9),A.subVectors(_,w).normalize(),C.index=o.getAtomIndexByType(s-1,E),T.copy(C),S.copy(C),Tl(S,A,_),S.toArray(u,3*s-3),i=s-3;i<s;++i)_.fromArray(u,3*i),C.index=o.getAtomIndexByType(i,E),T.copy(C),P.subVectors(T,_),P.toArray(m,3*i);var O=new Float32Array(s),N=new Float32Array(s),D=new Float32Array(s),k=new Float32Array(s);for(O[1]=p[0],N[1]=f[0],D[1]=p[0],i=2;i<s-2;++i)O[i]=.5*(p[i-2]+p[i-1]),N[i]=.5*(f[i-2]+f[i-1]),D[i]=.5*(d[i-2]+d[i-1]),_.fromArray(h,3*(i-2)),w.fromArray(h,3*(i-1)),k[i]=180/Math.PI*Math.acos(Math.cos(_.angleTo(w)));O[s-2]=p[s-4],N[s-2]=f[s-4],D[s-2]=d[s-4];var F=new Float32Array(3*s);for(fh(h,F,0,0,3),fh(h,F,0,3,3),i=2;i<s-2;++i)_.fromArray(h,3*(i-2)),w.fromArray(h,3*(i-1)),A.addVectors(w,_).multiplyScalar(.5).normalize(),A.toArray(F,3*i);return fh(h,F,3*s-12,3*s-6,3),fh(h,F,3*s-12,3*s-3,3),{center:u,axis:F,bending:k,radius:O,rise:D,twist:N,resdir:m}}},kd.prototype={constructor:kd,getAxis:function(t,e,i,r,n,o){t=t||30,e=e||2.5,i=void 0!==i&&i;var a=this.polymer,s=a.structure,c=a.residueCount,u=a.residueIndexStart,h=this.position,l=r||{};l.structure=s;for(var p,d,f=Su.getScheme(l),m=new jp(n,o),g=0,v=0,y=[],b=[],x=[],_=[],w=[],S=[],A=[],M=[],P=[],T=[],E=[],C=new Me,I=new Me,R=s.getResidueProxy(),L=s.getResidueProxy(),O=s.getAtomProxy(),N=new Me,D=new Me,k=!1,F=0;F<c;++F)if(R.index=u+F,N.fromArray(h.center,3*F),F===c-1?k=!0:(L.index=u+F+1,D.fromArray(h.center,3*F+3),i&&R.sstruc!==L.sstruc?k=!0:N.distanceTo(D)>e?k=!0:h.bending[F]>t&&(k=!0)),k){if(F-g<4){g=F,k=!1;continue}O.index=R.traceAtomIndex,T=h.axis.subarray(3*g+3,3*F),E=h.center.subarray(3*g,3*F+3),p=Pl(T).normalize(),d=Pl(E),C.fromArray(E),Tl(C,p,d),I.fromArray(E,E.length-3),Tl(I,p,d),p.subVectors(I,C),p.toArray(y,v),d.toArray(b,v),C.toArray(x,v),I.toArray(_,v),f.atomColorToArray(O,w,v),S.push(O.index),A.push(m.atomRadius(O)),M.push(u+g),P.push(u+F+1-g),v+=3,g=F,k=!1}var B=new Float32Array(S);return{axis:new Float32Array(y),center:new Float32Array(b),begin:new Float32Array(x),end:new Float32Array(_),color:new Float32Array(w),picking:new Yl(B,s),size:new Float32Array(A),residueOffset:M,residueCount:P}}},Fd.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.content.length,i=0;i<e;i++)if(this.content[i]===t){var r=this.content.pop();return void(i!==e-1&&(this.content[i]=r,this.scoreFunction(r)<this.scoreFunction(t)?this.bubbleUp(i):this.sinkDown(i)))}throw new Error("Node not found.")},size:function(){return this.content.length},bubbleUp:function(t){for(var e=this.content[t];t>0;){var i=Math.floor((t+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(e)<this.scoreFunction(r)))break;this.content[i]=e,this.content[t]=r,t=i}},sinkDown:function(t){for(var e,i=this.content.length,r=this.content[t],n=this.scoreFunction(r);;){var o=2*(t+1),a=o-1,s=null;if(a<i){var c=this.content[a];(e=this.scoreFunction(c))<n&&(s=a)}if(o<i){var u=this.content[o];this.scoreFunction(u)<(null===s?n:e)&&(s=o)}if(null===s)break;this.content[t]=this.content[s],this.content[s]=r,t=s}}},zd.prototype={nearest:function(){var t=new Float32Array(3);return function(e,i,r){e.toArray?e.toArray(t):e.positionToArray&&e.positionToArray(t);for(var n=this.kdtree.nearest(t,i,r),o=this.kdtree.indices,a=this.kdtree.nodes,s=this.atomIndices,c=[],u=0,h=n.length;u<h;++u){var l=n[u],p=l[0],d=l[1];c.push({index:s[o[a[p]]],distance:d})}return c}}()};var Ud={" ":"X","!":"Y","#":"Z",$:"-X","%":"-Y","&":"-Z","'":"Y+1/2","(":"1/2+X",")":"1/2+Y","*":"1/2-X","+":"1/2+Z",",":"1/2-Y","-":"1/2-Z",".":"X+1/2","/":"Z+1/2",0:"-X+1/2",1:"-Y+1/2",2:"-Z+1/2",3:"1/4+X",4:"1/4-Y",5:"1/4+Z",6:"1/4-X",7:"1/4+Y",8:"3/4-Y",9:"3/4+Z",":":"3/4+Y",";":"3/4+X","<":"3/4-X","=":"1/4-Z",">":"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"},jd={"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":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"};function Gd(t){var e="";return t.length>0&&(e=":"+Ua(t).join(" OR :")),new cu(e)}var Vd=function(t){this.name=t||"",this.partList=[]},$d={type:{}};$d.type.get=function(){return"Assembly"},Vd.prototype.addPart=function(t,e){var i=new Hd(t,e);return this.partList.push(i),i},Vd.prototype._getCount=function(t,e){var i=0;return this.partList.forEach(function(r){i+=r[e](t)}),i},Vd.prototype.getAtomCount=function(t){return this._getCount(t,"getAtomCount")},Vd.prototype.getResidueCount=function(t){return this._getCount(t,"getResidueCount")},Vd.prototype.getInstanceCount=function(){var t=0;return this.partList.forEach(function(e){t+=e.matrixList.length}),t},Vd.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 Pe).equals(e.matrixList[0]))return!1;var i=[];return t.eachChain(function(t){i.push(t.chainname)}),i=Ua(i),e.chainList.length===i.length},Vd.prototype.getBoundingBox=function(t){var e=new Ti;return this.partList.forEach(function(i){var r=i.getBoundingBox(t);e.expandByPoint(r.min),e.expandByPoint(r.max)}),e},Vd.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter()},Vd.prototype.getSelection=function(){var t=[];return this.partList.forEach(function(e){t=t.concat(e.chainList)}),Gd(t)},Object.defineProperties(Vd.prototype,$d);var Hd=function(t,e){this.matrixList=t||[],this.chainList=e||[]},Wd={type:{}};function Xd(t,e){if(e){xu&&bu.time("assignSecondaryStructure");var i=[];t.eachModel(function(t){t.eachChain(function(t){i.push(t.chainname)})});var r=i.slice().sort(),n=[];r.forEach(function(t){n.push(i.indexOf(t))});var o=e.helices;(o=o.filter(function(t){return Ba(r,t[0])>=0})).sort(function(t,e){var i=t[0],o=e[0],a=t[1],s=e[1];if(i===o)return a===s?0:a<s?-1:1;var c=Ba(r,i),u=Ba(r,o);return n[c]<n[u]?-1:1});var a=t.residueStore;t.eachModel(function(t){var e=0,i=o.length;if(0!==i){var r=o[e],n=!1,s=!1;t.eachChain(function(t){var c=!1;if(t.chainname===r[0])for(var u=t.residueCount,h=t.residueOffset,l=h+u,p=h;p<l;++p)if(a.resno[p]===r[1]&&a.getInscode(p)===r[2]&&(n=!0),n&&(a.sstruc[p]=r[6],a.resno[p]===r[4]&&a.getInscode(p)===r[5]&&(n=!1,(e+=1)<i?(p=h-1,r=o[e],c=t.chainname!==r[0]):s=!0)),c||s)return})}});var s=e.sheets;(s=s.filter(function(t){return Ba(r,t[0])>=0})).sort(function(t,e){var i=t[0],o=e[0];if(i===o)return 0;var a=Ba(r,i),s=Ba(r,o);return n[a]<n[s]?-1:1});var c="e".charCodeAt(0);t.eachModel(function(t){var e=0,i=s.length;if(0!==i){var r=s[e],n=!1,o=!1;t.eachChain(function(t){var u=!1;if(t.chainname===r[0])for(var h=t.residueCount,l=t.residueOffset,p=l+h,d=l;d<p;++d)if(a.resno[d]===r[1]&&a.getInscode(d)===r[2]&&(n=!0),n&&(a.sstruc[d]=c,a.resno[d]===r[4]&&a.getInscode(d)===r[5]&&(n=!1,(e+=1)<i?(d=l-1,r=s[e],u=t.chainname!==r[0]):o=!0)),u||o)return})}}),xu&&bu.timeEnd("assignSecondaryStructure")}}Wd.type.get=function(){return"AssemblyPart"},Hd.prototype._getCount=function(t,e){var i=0,r=this.chainList;return t.eachChain(function(t){(0===r.length||r.includes(t.chainname))&&(i+=t[e])}),this.matrixList.length*i},Hd.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},Hd.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},Hd.prototype.getBoundingBox=function(t){var e=new Ti,i=new Ti,r=this.getSelection(),n=t.getBoundingBox(r);return this.matrixList.forEach(function(t){i.copy(n).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)}),e},Hd.prototype.getSelection=function(){return Gd(this.chainList)},Hd.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},Hd.prototype.getInstanceList=function(){for(var t=[],e=0,i=this.matrixList.length;e<i;++e)t.push({id:e+1,name:e,matrix:this.matrixList[e]});return t},Object.defineProperties(Hd.prototype,Wd);var qd=function(){var t=function(t,e,i,r){for(var n=t.structure,o=t.residueIndexStart,a=n.getResidueProxy(),s=n.getResidueProxy(),c=n.getAtomProxy(),u=n.getAtomProxy(),h=Math.max(0,e-2);h<=e;++h)for(var l=2;l<5;++l)if(!(h+l>=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-i[l-2])>r)return!1}return!0},e=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},i=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){xu&&bu.time("calculateSecondaryStructure"),t.eachPolymer(function(t){if(!(t.residueCount<4)){if(t.isCg())!function(t){for(var e=t.residueStore,i=t.residueIndexStart,r=new kd(t).position,n=new Me,o=new Me,a=0,s=t.residueCount;a<s;++a){n.fromArray(r.center,3*a),o.fromArray(r.center,3*a+3);var c=n.distanceTo(o);c<2&&c>1&&r.bending[a]<20&&(e.sstruc[i+a]="h".charCodeAt(0),e.sstruc[i+a+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){for(var r=t.residueStore,n=t.residueIndexStart,o=0,a=t.residueCount;o<a;++o){var s="c";e(t,o)?s="h":i(t,o)&&(s="s"),r.sstruc[n+o]=s.charCodeAt(0)}}(t)}var r,n=0;t.eachResidue(function(t){t.sstruc===r?n+=1:(1===n&&(t.index-=1,t.sstruc="c"),n=1,r=t.sstruc)})}}),xu&&bu.timeEnd("calculateSecondaryStructure")}}();function Yd(t){xu&&bu.time("calculateChainnames");var e=!0;if(t.eachChain(function(t){t.chainname&&(e=!1)}),e){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=i.length,n=t.modelStore,o=t.chainStore,a=t.residueStore,s=function(t){for(var e=t,n=0,o=i[e%r];e>=r;)e=Math.floor(e/r),o+=i[e%r],n+=1;return n>=5&&bu.warn("chainname overflow"),o},c=t.getAtomProxy(),u=t.getAtomProxy(),h=0,l=0,p=0,d=0,f=[];1===a.count?f.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):t.eachResidueN(2,function(t,e){var i=!1,r=t.backboneType,n=e.backboneType,o=vp;d=t.index,t.modelIndex!==e.modelIndex?i=!0:t.moleculeType!==e.moleculeType?i=!0:r!==o&&r===n&&(c.index=t.backboneEndAtomIndex,u.index=e.backboneStartAtomIndex,c.connectedTo(u)||(i=!0)),i||e.index!==a.count-1||(i=!0,d=e.index),i&&(f.push({mIndex:l,chainname:s(h),rStart:p,rCount:d-p+1}),h+=1,t.modelIndex!==e.modelIndex&&(h=0,l+=1),e.index===a.count-1&&d!==e.index&&f.push({mIndex:l,chainname:s(h),rStart:a.count-1,rCount:1}),p=e.index,d=e.index)}),o.count=0,f.forEach(function(t){!function(t,e,i,r){for(var s=o.count,c=0;c<r;++c)a.chainIndex[i+c]=s;o.growIfFull(),o.modelIndex[s]=t,o.setChainname(s,e),o.setChainid(s,e),o.residueOffset[s]=i,o.residueCount[s]=r,o.count+=1,n.chainCount[t]+=1}(t.mIndex,t.chainname,t.rStart,t.rCount)});var m=0;t.eachModel(function(t){n.chainOffset[t.index]=m,n.chainCount[t.index]-=1,m+=n.chainCount[t.index]})}xu&&bu.timeEnd("calculateChainnames")}function Zd(t){xu&&bu.time("calculateBonds"),Kd(t),Qd(t),xu&&bu.timeEnd("calculateBonds")}function Kd(t,e){xu&&bu.time("calculateBondsWithin");var i=t.bondStore,r=t.rungBondStore,n=t.getAtomSet(!1),o=t.getAtomProxy(),a=t.getAtomProxy(),s=t.getBondProxy(),c=e?null:function(t){xu&&bu.time("calculateAtomBondMap");var e=[];return t.eachBond(function(t){var i=t.atomIndex1,r=t.atomIndex2;void 0===e[i]&&(e[i]=[]),e[i][r]=t.index}),xu&&bu.timeEnd("calculateAtomBondMap"),e}(t);t.eachResidue(function(t){if(!e){var u=t.atomCount,h=t.atomOffset;if(u>500)return void bu.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;g<m;++g){var v=p[g]+h,y=d[g]+h,b=c[v];if(void 0!==b&&void 0!==(b=b[y]))s.index=b,f[t.residueType.getBondIndex(v,y)]=s.bondOrder;else o.index=v,a.index=y,i.addBond(o,a,f[g])}}var x=t.residueType.traceAtomIndex,_=t.residueType.rungEndAtomIndex;-1!==x&&-1!==_&&(o.index=t.traceAtomIndex,a.index=t.rungEndAtomIndex,r.addBond(o,a),n.set(o.index),n.set(a.index))}),t.atomSetDict.rung=n,xu&&bu.timeEnd("calculateBondsWithin")}function Qd(t,e){xu&&bu.time("calculateBondsBetween");var i=t.bondStore,r=t.backboneBondStore,n=t.getAtomSet(!1),o=t.getAtomProxy(),a=t.getAtomProxy();function s(t,s){var c=t.backboneType,u=s.backboneType;c!==vp&&c===u&&(o.index=t.backboneEndAtomIndex,a.index=s.backboneStartAtomIndex,o.connectedTo(a)&&(e||i.addBond(o,a,1),o.index=t.traceAtomIndex,a.index=s.traceAtomIndex,r.addBond(o,a),n.set(o.index),n.set(a.index)))}0===r.count&&r.resize(t.residueStore.count),t.eachResidueN(2,s);var c=t.getResidueProxy(),u=t.getResidueProxy();t.eachChain(function(t){0!==t.residueCount&&(c.index=t.residueOffset,u.index=t.residueOffset+t.residueCount-1,s(u,c))}),t.atomSetDict.backbone=n,xu&&bu.timeEnd("calculateBondsBetween")}function Jd(t){if(t.unitcell){xu&&bu.time("buildUnitcellAssembly");var e=t.unitcell,i=t.center.clone().applyMatrix4(e.cartToFrac),r=function(t){var e=jd[t],i={};if(void 0===e)return console.warn("getSymmetryOperations: spacegroup '"+t+"' not found in symop library"),i;for(var r=[],n=0,o=e.length;n<o;n+=3){for(var a=[],s=0;s<3;++s)a.push(Ud[e[n+s]]);r.push(a)}var c=/^[1-9]$/;return r.forEach(function(t){var e=0,r=(new Pe).set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1),n=r.elements;i[t]=r,t.forEach(function(t){for(var i=!1,r=!1,o=0,a=t.length;o<a;++o){var s=t[o];if("-"===s)i=!0;else if("+"===s)i=!1;else if("/"===s)r=!0;else if("X"===s)n[0+e]=i?-1:1;else if("Y"===s)n[4+e]=i?-1:1;else if("Z"===s)n[8+e]=i?-1:1;else if(c.test(s)){var u=parseInt(s);r?n[12+e]/=u:n[12+e]=u}else bu.warn('getSymmetryOperations: unknown token "'+s+'"')}e+=1})}),i}(e.spacegroup),n=new Me,o=new Me,a=new Me;i.x>1&&(n.x-=1),i.x<0&&(n.x+=1),i.y>1&&(n.y-=1),i.y<0&&(n.y+=1),i.z>1&&(n.z-=1),i.z<0&&(n.z+=1);var s,c=new Vd("UNITCELL"),u=m();if(t.biomolDict.NCS){s=[new Pe].concat(t.biomolDict.NCS.partList[0].matrixList);var h=[];u.forEach(function(t){s.forEach(function(e){h.push(t.clone().multiply(e))})}),c.addPart(h)}else c.addPart(u);var l=new Me,p=new Vd("SUPERCELL"),d=Array.prototype.concat.call(m(l.set(1,0,0)),m(l.set(0,1,0)),m(l.set(0,0,1)),m(l.set(-1,0,0)),m(l.set(0,-1,0)),m(l.set(0,0,-1)),m(l.set(1,1,0)),m(l.set(1,0,1)),m(l.set(0,1,1)),m(l.set(-1,-1,0)),m(l.set(-1,0,-1)),m(l.set(0,-1,-1)),m(l.set(1,-1,-1)),m(l.set(1,1,-1)),m(l.set(1,-1,1)),m(l.set(-1,1,1)),m(l.set(-1,-1,1)),m(l.set(-1,1,-1)),m(l.set(0,1,-1)),m(l.set(0,-1,1)),m(l.set(1,0,-1)),m(l.set(-1,0,1)),m(l.set(1,-1,0)),m(l.set(-1,1,0)),m(),m(l.set(1,1,1)),m(l.set(-1,-1,-1)));if(t.biomolDict.NCS){var f=[];d.forEach(function(t){s.forEach(function(e){f.push(t.clone().multiply(e))})}),p.addPart(f)}else p.addPart(d);t.biomolDict.UNITCELL=c,t.biomolDict.SUPERCELL=p,xu&&bu.timeEnd("buildUnitcellAssembly")}function m(t){var s=[];return Object.keys(r).forEach(function(c){var u=r[c].clone();o.copy(i).applyMatrix4(u),a.setFromMatrixPosition(u),a.sub(n),o.x>1&&(a.x-=1),o.x<0&&(a.x+=1),o.y>1&&(a.y-=1),o.y<0&&(a.y+=1),o.z>1&&(a.z-=1),o.z<0&&(a.z+=1),t&&a.add(t),u.setPosition(a),u.multiplyMatrices(e.fracToCart,u),u.multiply(e.cartToFrac),s.push(u)}),s}}var tf=["H","C","O","N","S","P"],ef=["NA","CL","FE"];function rf(t){var e=t.trim().toUpperCase();parseInt(e.charAt(0))&&(e=e.substr(1)),parseInt(e.charAt(0))&&(e=e.substr(1));var i=e.length;if(0===i)return"";if(1===i)return e;if(2===i){if(-1!==ef.indexOf(e))return e;if(-1!==tf.indexOf(e[0]))return e[0]}return i>=3&&-1!==tf.indexOf(e[0])?e[0]:""}function nf(t){var e=t.bondHash,i=e.countArray,r=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=r[e],p=0,d=i[e];p<d;++p){o.index=n[l+p];var f=o.atomIndex1,m=o.atomIndex2;if(f>m){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}}})}var of=function(t,e,i){this.structure=t,i=i||rf(e),this.atomname=e,this.element=i,this.vdw=Pp[i],this.covalent=Tp[i]};var af=function(t){this.structure=t,this.dict={},this.list=[]};af.prototype.add=function(t,e){var i=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():rf(t)),r=this.dict[i];if(void 0===r){var n=new of(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(n)}return r},af.prototype.get=function(t){return this.list[t]};var sf=function(t,e,i,r,n,o){this.structure=t,this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=n,this.bonds=o,this.rings=void 0,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();var a=Up[this.backboneType],s=Up[this.backboneStartType],c=Up[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,f=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=void 0!==f?f:-1,d=Np.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=void 0!==d?d:-1,this.bondReferenceAtomIndices=[]};sf.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=Bp;break;case 4:case 5:t=zp;break;default:return e}for(var i=this.structure.atomMap,r=this.atomTypeIdList,n=0,o=this.atomCount;n<o;++n){var a=i.get(r[n]);t.includes(a.atomname)&&e.push(n)}return e},sf.prototype.getMoleculeType=function(){return this.isProtein()?3:this.isRna()?4:this.isDna()?5:this.isWater()?1:this.isIon()?2:this.isSaccharide()?6:0},sf.prototype.getBackboneType=function(t){return this.hasProteinBackbone(t)?1:this.hasRnaBackbone(t)?2:this.hasDnaBackbone(t)?3:this.hasCgProteinBackbone(t)?4:this.hasCgRnaBackbone(t)?5:this.hasCgDnaBackbone(t)?6:vp},sf.prototype.isProtein=function(){return this.chemCompType?yp.includes(this.chemCompType):this.hasAtomWithName("CA","C","N")||Rp.includes(this.resname)},sf.prototype.isCg=function(){var t=this.backboneType;return 4===t||5===t||6===t},sf.prototype.isNucleic=function(){return this.isRna()||this.isDna()},sf.prototype.isRna=function(){return this.chemCompType?bp.includes(this.chemCompType):this.hasAtomWithName(["P","O3'","O3*"],["C4'","C4*"],["O2'","O2*","F2'","F2*"])||Lp.includes(this.resname)&&this.hasAtomWithName(["O2'","O2*","F2'","F2*"])},sf.prototype.isDna=function(){return this.chemCompType?xp.includes(this.chemCompType):this.hasAtomWithName(["P","O3'","O3*"],["C3'","C3*"])&&!this.hasAtomWithName(["O2'","O2*","F2'","F2*"])||Op.includes(this.resname)},sf.prototype.isHetero=function(){return 1===this.hetero},sf.prototype.isIon=function(){return kp.includes(this.resname)},sf.prototype.isWater=function(){return Dp.includes(this.resname)},sf.prototype.isSaccharide=function(){return this.chemCompType?_p.includes(this.chemCompType):Fp.includes(this.resname)},sf.prototype.hasBackboneAtoms=function(t,e){var i=Up[e];return-1===t?this.hasAtomWithName(i.trace,i.backboneEnd,i.direction1,i.direction2):0===t?this.hasAtomWithName(i.trace,i.direction1,i.direction2):1===t?this.hasAtomWithName(i.trace,i.backboneStart,i.direction1,i.direction2):this.hasAtomWithName(i.trace,i.backboneStart,i.backboneEnd,i.direction1,i.direction2)},sf.prototype.hasProteinBackbone=function(t){return this.isProtein()&&this.hasBackboneAtoms(t,1)},sf.prototype.hasRnaBackbone=function(t){return this.isRna()&&this.hasBackboneAtoms(t,2)},sf.prototype.hasDnaBackbone=function(t){return this.isDna()&&this.hasBackboneAtoms(t,3)},sf.prototype.hasCgProteinBackbone=function(t){return this.isProtein()&&this.hasBackboneAtoms(t,4)},sf.prototype.hasCgRnaBackbone=function(t){return this.isRna()&&this.hasBackboneAtoms(t,5)},sf.prototype.hasCgDnaBackbone=function(t){return this.isDna()&&this.hasBackboneAtoms(t,6)},sf.prototype.hasBackbone=function(t){return this.hasProteinBackbone(t)||this.hasRnaBackbone(t)||this.hasDnaBackbone(t)||this.hasCgProteinBackbone(t)||this.hasCgRnaBackbone(t)||this.hasCgDnaBackbone(t)},sf.prototype.getAtomIndexByName=function(t){var e=this.atomCount,i=this.structure.atomMap,r=this.atomTypeIdList;if(Array.isArray(t))for(var n=0;n<e;++n){var o=r[n];if(t.includes(i.get(o).atomname))return n}else for(var a=0;a<e;++a){var s=r[a];if(t===i.get(s).atomname)return a}},sf.prototype.hasAtomWithName=function(){for(var t=arguments,e=this,i=arguments.length,r=0;r<i;++r)if(void 0!==t[r]&&void 0===e.getAtomIndexByName(t[r]))return!1;return!0},sf.prototype.getBonds=function(t){return void 0===this.bonds&&(this.bonds=function(t){var e=t.structure,i=e.getAtomProxy(),r=e.getAtomProxy(),n=t.atomCount,o=t.atomOffset,a=o+n-1;if(!(n>500)){var s,c,u=[],h=[],l=[];if(n>50){var p=new zd(t,!0),d=t.isCg()?1.2:2.3;for(s=o;s<a;++s){i.index=s;var f=i.covalent+d+.3,m=p.nearest(i,1/0,f*f),g=m.length;for(c=0;c<g;++c)r.index=m[c].index,i.index<r.index&&i.connectedTo(r)&&(u.push(i.index-o),h.push(r.index-o),l.push(1))}}else for(s=o;s<a;++s)for(i.index=s,c=s+1;c<=a;++c)r.index=c,i.connectedTo(r)&&(u.push(s-o),h.push(c-o),l.push(1));return{atomIndices1:u,atomIndices2:h,bondOrders:l}}xu&&bu.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName())}(t)),this.bonds},sf.prototype.getRings=function(){return void 0===this.rings&&this.calculateRings(),this.rings},sf.prototype.getBondGraph=function(){return void 0===this.bondGraph&&this.calculateBondGraph(),this.bondGraph},sf.prototype.calculateBondGraph=function(){for(var t=this.bondGraph={},e=this.getBonds(),i=e.atomIndices1.length,r=e.atomIndices1,n=e.atomIndices2,o=0;o<i;++o){var a=r[o],s=n[o];(t[a]=t[a]||[]).push(s),(t[s]=t[s]||[]).push(a)}},sf.prototype.calculateRings=function(){var t=this.getBondGraph(),e=new Int8Array(this.atomCount),i=new Int8Array(this.atomCount),r=[],n=[];function o(a,s,c){if(e[a])throw new Error("DFS revisited atom");e[a]=1,n.push(a);for(var u=s.length,h=0;h<u;++h){var l=s[h];if(0===e[l])t[l]&&t[l].length>=2?o(l,t[l],a):e[l]=2;else if(1===e[l]&&c&&c!==l){var p=[l];i[l]=1,r.push(p);for(var d=n.length-1;d>=0;--d){var f=n[d];if(f===l)break;p.push(f),i[f]=1}}}e[a]=2,n.pop()}for(var a=0;a<this.atomCount;++a)if(!e[a]){var s=t[a];!s||s.length<2?e[a]=2:(n.length=0,o(a,s))}this.rings={flags:i,rings:r}},sf.prototype.assignBondReferenceAtomIndices=function(){var t=this.getBondGraph(),e=this.getRings(),i=e.flags,r=e.rings,n=this.bonds.atomIndices1,o=this.bonds.atomIndices2,a=this.bonds.bondOrders,s=this.bondReferenceAtomIndices,c=this.bonds.atomIndices1.length;s.length=0;for(var u=0;u<c;++u)if(!(a[u]<=1)){var h=n[u],l=o[u];if(i[h]&&i[l]){for(var p=0;p<r.length&&void 0===s[u];++p)for(var d=r[p],f=null,m=!1,g=0;g<d.length;++g){var v=d[g];if(v===h||v===l?m=!0:f=v,m&&null!==f){s[u]=f;break}}if(void 0!==s[u])continue}if(t[h].length>1)for(var y=0;y<t[h].length;++y){var b=t[h][y];if(b!==l){s[u]=b;break}}else if(t[l].length>1)for(var x=0;x<t[l].length;++x){var _=t[l][x];if(_!==h){s[u]=_;break}}else;}},sf.prototype.getBondIndex=function(t,e){for(var i=this.bonds,r=i.atomIndices1,n=i.atomIndices2,o=r.indexOf(t),a=n.indexOf(e),s=a;-1!==o;){for(;-1!==a;){if(o===a)return o;a=n.indexOf(e,a+1)}o=r.indexOf(t,o+1),a=s}},sf.prototype.getBondReferenceAtomIndex=function(t,e){var i=this.getBondIndex(t,e);if(void 0!==i)return 0===this.bondReferenceAtomIndices.length&&this.assignBondReferenceAtomIndices(),this.bondReferenceAtomIndices[i]};var cf=function(t){this.structure=t,this.dict={},this.list=[]};cf.prototype.add=function(t,e,i,r,n){var o=function(t,e,i,r){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+(r||"")}(t=t.toUpperCase(),e,i,r),a=this.dict[o];if(void 0===a){var s=new sf(this.structure,t,e,i,r,n);a=this.list.length,this.dict[o]=a,this.list.push(s)}return a},cf.prototype.get=function(t){return this.list[t]};var uf=function(t,e){this.structure=t,this.bondStore=t.bondStore,this.index=e,this._v12=new Me,this._v13=new Me,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()},hf={atom1:{},atom2:{},atomIndex1:{},atomIndex2:{},bondOrder:{}};hf.atom1.get=function(){return this.structure.getAtomProxy(this.atomIndex1)},hf.atom2.get=function(){return this.structure.getAtomProxy(this.atomIndex2)},hf.atomIndex1.get=function(){return this.bondStore.atomIndex1[this.index]},hf.atomIndex1.set=function(t){this.bondStore.atomIndex1[this.index]=t},hf.atomIndex2.get=function(){return this.bondStore.atomIndex2[this.index]},hf.atomIndex2.set=function(t){this.bondStore.atomIndex2[this.index]=t},hf.bondOrder.get=function(){return this.bondStore.bondOrder[this.index]},hf.bondOrder.set=function(t){this.bondStore.bondOrder[this.index]=t},uf.prototype.getReferenceAtomIndex=function(){var t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex===e.residueIndex){var i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,n=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==n)return n+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}},uf.prototype.calculateShiftDir=function(t){t||(t=new Me);var e=this._ap1,i=this._ap2,r=this._ap3,n=this._v12,o=this._v13;e.index=this.atomIndex1,i.index=this.atomIndex2;var a=this.getReferenceAtomIndex();n.subVectors(e,i).normalize(),void 0!==a?(r.index=a,o.subVectors(e,r)):o.copy(e),o.normalize();var s=n.dot(o);return 1-Math.abs(s)<1e-5&&(o.set(1,0,0),s=n.dot(o),1-Math.abs(s)<1e-5&&(o.set(0,1,0),s=n.dot(o))),t.copy(o.sub(n.multiplyScalar(s))).normalize()},uf.prototype.qualifiedName=function(){return this.atomIndex1+"="+this.atomIndex2},uf.prototype.clone=function(){return new this.constructor(this.structure,this.index)},uf.prototype.toObject=function(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}},Object.defineProperties(uf.prototype,hf);var lf=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},pf={bondHash:{},entity:{},entityIndex:{},modelIndex:{},chainIndex:{},residue:{},residueIndex:{},sstruc:{},inscode:{},resno:{},chainname:{},chainid:{},residueType:{},atomType:{},residueAtomOffset:{},resname:{},hetero:{},atomname:{},element:{},vdw:{},covalent:{},x:{},y:{},z:{},serial:{},bfactor:{},occupancy:{},altloc:{}};pf.bondHash.get=function(){return this.structure.bondHash},pf.entity.get=function(){return this.structure.entityList[this.entityIndex]},pf.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},pf.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},pf.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndex]},pf.residue.get=function(){return console.warn("residue - might be expensive"),this.structure.getResidueProxy(this.residueIndex)},pf.residueIndex.get=function(){return this.atomStore.residueIndex[this.index]},pf.residueIndex.set=function(t){this.atomStore.residueIndex[this.index]=t},pf.sstruc.get=function(){return this.residueStore.getSstruc(this.residueIndex)},pf.inscode.get=function(){return this.residueStore.getInscode(this.residueIndex)},pf.resno.get=function(){return this.residueStore.resno[this.residueIndex]},pf.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},pf.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},pf.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.residueIndex])},pf.atomType.get=function(){return this.atomMap.get(this.atomStore.atomTypeId[this.index])},pf.residueAtomOffset.get=function(){return this.residueStore.atomOffset[this.residueIndex]},pf.resname.get=function(){return this.residueType.resname},pf.hetero.get=function(){return this.residueType.hetero},pf.atomname.get=function(){return this.atomType.atomname},pf.element.get=function(){return this.atomType.element},pf.vdw.get=function(){return this.atomType.vdw},pf.covalent.get=function(){return this.atomType.covalent},pf.x.get=function(){return this.atomStore.x[this.index]},pf.x.set=function(t){this.atomStore.x[this.index]=t},pf.y.get=function(){return this.atomStore.y[this.index]},pf.y.set=function(t){this.atomStore.y[this.index]=t},pf.z.get=function(){return this.atomStore.z[this.index]},pf.z.set=function(t){this.atomStore.z[this.index]=t},pf.serial.get=function(){return this.atomStore.serial[this.index]},pf.serial.set=function(t){this.atomStore.serial[this.index]=t},pf.bfactor.get=function(){return this.atomStore.bfactor[this.index]},pf.bfactor.set=function(t){this.atomStore.bfactor[this.index]=t},pf.occupancy.get=function(){return this.atomStore.occupancy[this.index]},pf.occupancy.set=function(t){this.atomStore.occupancy[this.index]=t},pf.altloc.get=function(){return this.atomStore.getAltloc(this.index)},pf.altloc.set=function(t){this.atomStore.setAltloc(this.index,t)},lf.prototype.eachBond=function(t,e){e=e||this.structure._bp;for(var i=this.index,r=this.bondHash,n=r.indexArray,o=r.countArray[i],a=r.offsetArray[i],s=0;s<o;++s)e.index=n[a+s],t(e)},lf.prototype.eachBondedAtom=function(t,e){e=e||this.structure._ap;var i=this.index;this.eachBond(function(r){i!==r.atomIndex1?e.index=r.atomIndex1:e.index=r.atomIndex2,t(e)})},lf.prototype.isBackbone=function(){var t=this.residueType.backboneIndexList;if(t.length>0){var e=this.residueStore.atomOffset[this.residueIndex];return t.includes(this.index-e)}return!1},lf.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},lf.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},lf.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},lf.prototype.isHetero=function(){return 1===this.residueType.hetero},lf.prototype.isProtein=function(){return 3===this.residueType.moleculeType},lf.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},lf.prototype.isRna=function(){return 4===this.residueType.moleculeType},lf.prototype.isDna=function(){return 5===this.residueType.moleculeType},lf.prototype.isWater=function(){return 1===this.residueType.moleculeType},lf.prototype.isIon=function(){return 2===this.residueType.moleculeType},lf.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},lf.prototype.isHelix=function(){return Sp.includes(this.sstruc)},lf.prototype.isSheet=function(){return Ap.includes(this.sstruc)},lf.prototype.isTurn=function(){return Mp.includes(this.sstruc)&&this.isProtein()},lf.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},lf.prototype.isRing=function(){return 1===this.residueType.getRings().flags[this.index-this.residueAtomOffset]},lf.prototype.distanceTo=function(t){var e=this.atomStore,i=t.atomStore,r=this.index,n=t.index,o=e.x[r]-i.x[n],a=e.y[r]-i.y[n],s=e.z[r]-i.z[n],c=o*o+a*a+s*s;return Math.sqrt(c)},lf.prototype.connectedTo=function(t){var e=this.atomStore,i=t.atomStore,r=this.index,n=t.index;if(e.altloc&&i.altloc){var o=e.altloc[r],a=i.altloc[n];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=e.x[r]-i.x[n],c=e.y[r]-i.y[n],u=e.z[r]-i.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 h<p*p&&h>d*d},lf.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},lf.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.index,r=this.atomStore;return t[e+0]=r.x[i],t[e+1]=r.y[i],t[e+2]=r.z[i],t},lf.prototype.positionToVector3=function(t){return void 0===t&&(t=new Me),t.x=this.x,t.y=this.y,t.z=this.z,t},lf.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},lf.prototype.getResidueBonds=function(t){var e,i,r,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(r=u[e]+o,t)return r;n.push(r),e=c.indexOf(a,e+1)}for(i=u.indexOf(a);-1!==i;){if(r=c[i]+o,t)return r;n.push(r),i=u.indexOf(a,i+1)}return n},lf.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},lf.prototype.clone=function(){return new this.constructor(this.structure,this.index)},lf.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(lf.prototype,pf);var df=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},ff={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:{}};ff.entity.get=function(){return this.structure.entityList[this.entityIndex]},ff.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},ff.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},ff.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},ff.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},ff.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},ff.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},ff.atomCount.get=function(){return this.residueStore.atomCount[this.index]},ff.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},ff.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},ff.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},ff.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},ff.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},ff.resno.get=function(){return this.residueStore.resno[this.index]},ff.resno.set=function(t){this.residueStore.resno[this.index]=t},ff.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},ff.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},ff.inscode.get=function(){return this.residueStore.getInscode(this.index)},ff.inscode.set=function(t){this.residueStore.getInscode(this.index,t)},ff.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},ff.resname.get=function(){return this.residueType.resname},ff.hetero.get=function(){return this.residueType.hetero},ff.moleculeType.get=function(){return this.residueType.moleculeType},ff.backboneType.get=function(){return this.residueType.backboneType},ff.backboneStartType.get=function(){return this.residueType.backboneStartType},ff.backboneEndType.get=function(){return this.residueType.backboneEndType},ff.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},ff.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},ff.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},ff.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},ff.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},ff.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},df.prototype.eachAtom=function(t,e){var i,r=this.atomCount,n=this.atomOffset,o=this.structure._ap,a=n+r;if(e&&e.atomOnlyTest){var s=e.atomOnlyTest;for(i=n;i<a;++i)o.index=i,s(o)&&t(o)}else for(i=n;i<a;++i)o.index=i,t(o)},df.prototype.isProtein=function(){return 3===this.residueType.moleculeType},df.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},df.prototype.isRna=function(){return 4===this.residueType.moleculeType},df.prototype.isDna=function(){return 5===this.residueType.moleculeType},df.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},df.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},df.prototype.isHetero=function(){return 1===this.residueType.hetero},df.prototype.isWater=function(){return 1===this.residueType.moleculeType},df.prototype.isIon=function(){return 2===this.residueType.moleculeType},df.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},df.prototype.isHelix=function(){return Sp.includes(this.sstruc)},df.prototype.isSheet=function(){return Ap.includes(this.sstruc)},df.prototype.isTurn=function(){return Mp.includes(this.sstruc)&&this.isProtein()},df.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},df.prototype.getResname1=function(){return Ip[this.resname.toUpperCase()]||"X"},df.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},df.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},df.prototype.getAtomByName=function(t){return this.residueType.getAtomByName(t)},df.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},df.prototype.getAtomnameList=function(){console.warn("getAtomnameList - might be expensive");for(var t=this.atomCount,e=this.atomOffset,i=new Array(t),r=0;r<t;++r)i[r]=this.getAtomType(e+r).atomname;return i},df.prototype.connectedTo=function(t){var e=this.structure.getAtomProxy(this.backboneEndAtomIndex),i=this.structure.getAtomProxy(t.backboneStartAtomIndex);return!(!e||!i)&&e.connectedTo(i)},df.prototype.getNextConnectedResidue=function(){var t=this.chainStore.residueOffset[this.chainIndex],e=this.chainStore.residueCount[this.chainIndex],i=this.index+1;if(i<t+e){var r=this.structure.getResidueProxy(i);if(this.connectedTo(r))return r}else if(i===t+e){var n=this.structure.getResidueProxy(t);if(this.connectedTo(n))return n}},df.prototype.getPreviousConnectedResidue=function(){var t=this.chainStore.residueOffset[this.chainIndex],e=this.index-1;if(e>=t){var i=this.structure.getResidueProxy(e);if(i.connectedTo(this))return i}else if(e===t-1){var r=this.chainStore.residueCount[this.chainIndex],n=this.structure.getResidueProxy(t+r-1);if(n.connectedTo(this))return n}},df.prototype.getBonds=function(){return this.residueType.getBonds(this)},df.prototype.getRings=function(){return this.residueType.getRings()},df.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},df.prototype.clone=function(){return new this.constructor(this.structure,this.index)},df.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(df.prototype,ff);var mf=function(t,e,i){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueIndexStart=e,this.residueIndexEnd=i,this.residueCount=i-e+1;var r=this.structure.getResidueProxy(this.residueIndexStart),n=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();var o=n.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=this.isNextConnected&&void 0!==o.getNextConnectedResidue(),this.isCyclic=n.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()},gf={chainIndex:{},modelIndex:{},chainname:{}};gf.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},gf.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},gf.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},mf.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},mf.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},mf.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},mf.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},mf.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},mf.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 i,r=this.__residueProxy;switch(r.index=this.residueIndexStart+t,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},mf.prototype.eachAtom=function(t,e){this.eachResidue(function(i){i.eachAtom(t,e)},e)},mf.prototype.eachAtomN=function(t,e,i){var r,n=this.residueCount,o=new Array(t);for(r=0;r<t;++r)o[r]=this.structure.getAtomProxy(this.getAtomIndexByType(r,i));e.apply(this,o);for(var a=t;a<n;++a){for(r=1;r<t;++r)o[r-1].index=o[r].index;o[t-1].index=this.getAtomIndexByType(a,i),e.apply(this,o)}},mf.prototype.eachAtomN2=function(t,e,i){var r=this.atomOffset,n=this.atomCount,o=r+n;if(!(n<t)){for(var a=new Array(t),s=0;s<t;++s)a[s]=this.structure.getAtomProxy();var c=this.structure.atomSetCache["__"+i];void 0===c&&(bu.warn("no precomputed atomSet for: "+i),c=this.structure.getAtomSet(!1),this.eachResidue(function(t){var e=t.getAtomByName(i);c.set(e.index)}));var u=0;c.forEach(function(i){if(i>=r&&i<o){for(var n=1;n<t;++n)a[n-1].index=a[n].index;a[t-1].index=i,(u+=1)>=t&&e.apply(this,a)}})}},mf.prototype.eachResidue=function(t){for(var e=this.structure.getResidueProxy(),i=this.residueCount,r=this.residueIndexStart,n=0;n<i;++n)e.index=r+n,t(e)},mf.prototype.qualifiedName=function(){var t=this.structure.getResidueProxy(this.residueIndexStart),e=this.structure.getResidueProxy(this.residueIndexEnd);return t.qualifiedName()+" - "+e.qualifiedName()},Object.defineProperties(mf.prototype,gf);var vf=function(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e},yf={entity:{},model:{},entityIndex:{},modelIndex:{},residueOffset:{},residueCount:{},residueEnd:{},atomOffset:{},atomEnd:{},atomCount:{},chainname:{},chainid:{}};yf.entity.get=function(){return this.structure.entityList[this.entityIndex]},yf.model.get=function(){return this.structure.getModelProxy(this.modelIndex)},yf.entityIndex.get=function(){return this.chainStore.entityIndex[this.index]},yf.entityIndex.set=function(t){this.chainStore.entityIndex[this.index]=t},yf.modelIndex.get=function(){return this.chainStore.modelIndex[this.index]},yf.modelIndex.set=function(t){this.chainStore.modelIndex[this.index]=t},yf.residueOffset.get=function(){return this.chainStore.residueOffset[this.index]},yf.residueOffset.set=function(t){this.chainStore.residueOffset[this.index]=t},yf.residueCount.get=function(){return this.chainStore.residueCount[this.index]},yf.residueCount.set=function(t){this.chainStore.residueCount[this.index]=t},yf.residueEnd.get=function(){return this.residueOffset+this.residueCount-1},yf.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},yf.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},yf.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},yf.chainname.get=function(){return this.chainStore.getChainname(this.index)},yf.chainname.set=function(t){this.chainStore.setChainname(this.index,t)},yf.chainid.get=function(){return this.chainStore.getChainid(this.index)},yf.chainid.set=function(t){this.chainStore.setChainid(this.index,t)},vf.prototype.eachAtom=function(t,e){this.eachResidue(function(i){i.eachAtom(t,e)},e)},vf.prototype.eachResidue=function(t,e){var i,r=this.residueCount,n=this.residueOffset,o=this.structure._rp,a=n+r;if(e&&e.test){var s=e.residueOnlyTest;if(s)for(i=n;i<a;++i)o.index=i,s(o)&&t(o,e);else for(i=n;i<a;++i)o.index=i,t(o,e)}else for(i=n;i<a;++i)o.index=i,t(o)},vf.prototype.eachResidueN=function(t,e){var i,r=this.residueCount,n=this.residueOffset,o=n+r;if(!(r<t)){var a=new Array(t);for(i=0;i<t;++i)a[i]=this.structure.getResidueProxy(n+i);e.apply(this,a);for(var s=n+t;s<o;++s){for(i=0;i<t;++i)a[i].index+=1;e.apply(this,a)}}},vf.prototype.eachPolymer=function(t,e){for(var i,r,n=e?e.residueOnlyTest:void 0,o=this.model.structure,a=this.residueCount,s=this.residueOffset,c=s+a,u=this.structure.getResidueProxy(),h=this.structure.getResidueProxy(s),l=this.structure.getAtomProxy(),p=this.structure.getAtomProxy(),d=!0,f=s+1;f<c;++f){u.index=h.index,h.index=f,d&&(i=u.index,d=!1),r=h.index;var m=d?u.backboneEndType:u.backboneType,g=h.backboneType;m!==vp&&m===g?(l.index=u.backboneEndAtomIndex,p.index=h.backboneStartAtomIndex,l&&p&&l.connectedTo(p)&&(!n||n(u)&&n(h))||(u.index-i>1&&t(new mf(o,i,u.index)),i=r)):(m!==vp&&u.index-i>1&&t(new mf(o,i,u.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneStartType&&t(new mf(o,i,r))},vf.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},vf.prototype.clone=function(){return new this.constructor(this.structure,this.index)},vf.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(vf.prototype,yf);var bf=function(t,e){this.structure=t,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e},xf={chainOffset:{},chainCount:{},residueOffset:{},atomOffset:{},chainEnd:{},residueEnd:{},atomEnd:{},residueCount:{},atomCount:{}};xf.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},xf.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},xf.chainCount.get=function(){return this.modelStore.chainCount[this.index]},xf.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},xf.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},xf.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},xf.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},xf.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},xf.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},xf.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},xf.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},bf.prototype.eachAtom=function(t,e){this.eachChain(function(i){i.eachAtom(t,e)},e)},bf.prototype.eachResidue=function(t,e){this.eachChain(function(i){i.eachResidue(t,e)},e)},bf.prototype.eachPolymer=function(t,e){if(e&&e.chainOnlyTest){var i=e.chainOnlyTest;this.eachChain(function(r){i(r)&&r.eachPolymer(t,e)})}else this.eachChain(function(i){i.eachPolymer(t,e)})},bf.prototype.eachChain=function(t,e){var i,r=this.chainCount,n=this.chainOffset,o=this.structure._cp,a=n+r;if(e&&e.test){var s=e.chainOnlyTest;if(s)for(i=n;i<a;++i)o.index=i,s(o)&&t(o,e);else for(i=n;i<a;++i)o.index=i,t(o,e)}else for(i=n;i<a;++i)o.index=i,t(o)},bf.prototype.qualifiedName=function(){return"/"+this.index},bf.prototype.clone=function(){return new this.constructor(this.structure,this.index)},bf.prototype.toObject=function(){return{index:this.index,chainOffset:this.chainOffset,chainCount:this.chainCount}},Object.defineProperties(bf.prototype,xf);var _f=function(t,e){this.signals={refreshed:new jc},this.init(t,e)},wf={type:{}};function Sf(t,e){var i=[],r=!1;if(e){for(var n=0,o=e.length;n<o;++n)i.push(e[n]);a()}function a(){var e=i.shift();void 0!==e?(r=!0,setTimeout(function(){!function(e){t(e,a)}(e)})):r=!1}this.push=function(t){i.push(t),r||a()},this.kill=function(){i.length=0},this.length=function(){return i.length}}_f.prototype.init=function(t,e){this.name=t,this.path=e,this.title="",this.id="",this.header={},this.extraData={},this.atomSetCache=void 0,this.atomSetDict={},this.biomolDict={},this.entityList=[],this.unitcell=void 0,this.frames=[],this.boxes=[],this.validation=void 0,this.bondStore=new Id(0),this.backboneBondStore=new Id(0),this.rungBondStore=new Id(0),this.atomStore=new Rd(0),this.residueStore=new Ld(0),this.chainStore=new Od(0),this.modelStore=new Nd(0),this.atomMap=new af(this),this.residueMap=new cf(this),this.bondHash=void 0,this.spatialHash=void 0,this.atomSet=void 0,this.bondSet=void 0,this.center=void 0,this.boundingBox=void 0,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy()},wf.type.get=function(){return"Structure"},_f.prototype.finalizeAtoms=function(){this.atomSet=this.getAtomSet(),this.atomCount=this.atomStore.count,this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(),this.spatialHash=new hd(this.atomStore,this.boundingBox)},_f.prototype.finalizeBonds=function(){for(var t in this.bondSet=this.getBondSet(),this.bondCount=this.bondStore.count,this.bondHash=new Ed(this.bondStore,this.atomStore.count),this.atomSetCache={},this.atomSetDict.rung||(this.atomSetDict.rung=this.getAtomSet(!1)),this.atomSetDict)this.atomSetCache["__"+t]=this.atomSetDict[t].clone()},_f.prototype.getBondProxy=function(t){return new uf(this,t)},_f.prototype.getAtomProxy=function(t){return new lf(this,t)},_f.prototype.getResidueProxy=function(t){return new df(this,t)},_f.prototype.getChainProxy=function(t){return new vf(this,t)},_f.prototype.getModelProxy=function(t){return new bf(this,t)},_f.prototype.getBondSet=function(){var t=this.bondStore.count,e=new lp(t),i=this.atomSet;if(i)for(var r=this.getBondProxy(),n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index);else e.setAll();return e},_f.prototype.getBackboneBondSet=function(){var t=this.backboneBondStore.count,e=new lp(t),i=this.atomSetCache.__backbone;if(i){var r=this.getBondProxy();r.bondStore=this.backboneBondStore;for(var n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index)}else e.set_all(!0);return e},_f.prototype.getRungBondSet=function(){var t=this.rungBondStore.count,e=new lp(t),i=this.atomSetCache.__rung;if(i){var r=this.getBondProxy();r.bondStore=this.rungBondStore;for(var n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index)}else e.set_all(!0);return e},_f.prototype.getAtomSet=function(t){var e,i=this.atomStore.count;if(t instanceof lp)e=t;else if(t&&t.test){var r=t.string;r in this.atomSetCache?e=this.atomSetCache[r]:(e=new lp(i),this.eachAtom(function(t){e.set(t.index)},t),this.atomSetCache[r]=e)}else e=!1===t?new lp(i):new lp(i,!0);return e},_f.prototype.getAtomSetWithinSelection=function(t,e){var i=this.spatialHash,r=this.getAtomSet(!1),n=this.getAtomProxy();return this.getAtomSet(t).forEach(function(t){n.index=t,i.within(n.x,n.y,n.z,e).forEach(function(t){r.set(t)})}),r},_f.prototype.getAtomSetWithinPoint=function(t,e){var i=t,r=this.getAtomSet(!1);return this.spatialHash.within(i.x,i.y,i.z,e).forEach(function(t){r.set(t)}),r},_f.prototype.getAtomSetWithinVolume=function(t,e,i,r,n){for(var o=new Pd(t,i,r,n),a=o.getDataPosition(),s=a.length,c=o.matrix.getMaxScaleOnAxis(),u=this.getAtomSet(!1),h=0;h<s;h+=3)this.spatialHash.within(a[h],a[h+1],a[h+2],c).forEach(function(t){u.set(t)});return u},_f.prototype.getAtomSetWithinGroup=function(t){var e=this.atomStore.residueIndex,i=this.getAtomSet(!1),r=this.getResidueProxy();return this.getAtomSet(t).forEach(function(t){r.index=e[t];for(var n=r.atomOffset;n<=r.atomEnd;++n)i.set(n)}),i},_f.prototype.getSelection=function(){return!1},_f.prototype.getStructure=function(){return this},_f.prototype.eachEntity=function(t,e){this.entityList.forEach(function(i){void 0!==e&&i.getEntityType()!==e||t(i)})},_f.prototype.eachBond=function(t,e){var i,r=this.getBondProxy();if(e&&e.test&&(i=this.getBondSet(e),this.bondSet&&i.intersection(this.bondSet)),i)i.forEach(function(e){r.index=e,t(r)});else for(var n=this.bondStore.count,o=0;o<n;++o)r.index=o,t(r)},_f.prototype.eachAtom=function(t,e){if(e&&e.test)this.eachModel(function(i){i.eachAtom(t,e)},e);else for(var i=this.atomStore.count,r=this.getAtomProxy(),n=0;n<i;++n)r.index=n,t(r)},_f.prototype.eachResidue=function(t,e){var i;if(e&&e.test){var r=this.modelStore.count,n=this.getModelProxy(),o=e.modelOnlyTest;if(o)for(i=0;i<r;++i)n.index=i,o(n)&&n.eachResidue(t,e);else for(i=0;i<r;++i)n.index=i,n.eachResidue(t,e)}else{var a=this.residueStore.count,s=this.getResidueProxy();for(i=0;i<a;++i)s.index=i,t(s)}},_f.prototype.eachResidueN=function(t,e){var i,r,n=this.residueStore.count;if(!(n<t)){var o=new Array(t);for(i=0;i<t;++i)o[i]=this.getResidueProxy(i);for(e.apply(this,o),r=t;r<n;++r){for(i=0;i<t;++i)o[i].index+=1;e.apply(this,o)}}},_f.prototype.eachPolymer=function(t,e){if(e&&e.modelOnlyTest){var i=e.modelOnlyTest;this.eachModel(function(r){i(r)&&r.eachPolymer(t,e)})}else this.eachModel(function(i){i.eachPolymer(t,e)})},_f.prototype.eachChain=function(t,e){if(e&&e.test)this.eachModel(function(i){i.eachChain(t,e)});else for(var i=this.chainStore.count,r=this.getChainProxy(),n=0;n<i;++n)r.index=n,t(r)},_f.prototype.eachModel=function(t,e){var i,r=this.modelStore.count,n=this.getModelProxy();if(e&&e.test){var o=e.modelOnlyTest;if(o)for(i=0;i<r;++i)n.index=i,o(n)&&t(n,e);else for(i=0;i<r;++i)n.index=i,t(n,e)}else for(i=0;i<r;++i)n.index=i,t(n)},_f.prototype.getAtomData=function(t){var e=Object.assign({},t);e.colorParams&&(e.colorParams.structure=this.getStructure());var i,r,n,o,a,s,c,u=e.what,h=Oa(e.atomSet,this.atomSet),l={},p=this.getAtomProxy(),d=h.getSize();return u&&!u.position||(n=new Float32Array(3*d),l.position=n),u&&!u.color||(o=new Float32Array(3*d),l.color=o,r=Su.getScheme(e.colorParams)),u&&!u.picking||(a=new Float32Array(d),l.picking=new Yl(a,this.getStructure())),u&&!u.radius||(s=new Float32Array(d),l.radius=s,i=new jp(e.radiusParams.radius,e.radiusParams.scale)),u&&!u.index||(c=new Float32Array(d),l.index=c),h.forEach(function(t,e){var u=3*e;p.index=t,n&&p.positionToArray(n,u),o&&r.atomColorToArray(p,o,u),a&&(a[e]=t),s&&(s[e]=i.atomRadius(p)),c&&(c[e]=t)}),l},_f.prototype.getBondData=function(t){var e=Object.assign({},t);e.colorParams&&(e.colorParams.structure=this.getStructure());var i,r,n,o,a,s,c,u,h,l=e.what,p=Oa(e.bondSet,this.bondSet),d=Oa(e.multipleBond,"off"),f="off"!==d,m="offset"===d,g=Oa(e.bondScale,.4),v=Oa(e.bondSpacing,1),y={},b=this.getBondProxy();e.bondStore&&(b.bondStore=e.bondStore);var x,_=this.getAtomProxy(),w=this.getAtomProxy();if(f){var S=b.bondStore.bondOrder;x=0,p.forEach(function(t){x+=S[t]})}else x=p.getSize();l&&!l.position||(n=new Float32Array(3*x),o=new Float32Array(3*x),y.position1=n,y.position2=o),l&&!l.color||(a=new Float32Array(3*x),s=new Float32Array(3*x),y.color=a,y.color2=s,r=Su.getScheme(e.colorParams)),l&&!l.picking||(c=new Float32Array(x),y.picking=new Kl(c,this.getStructure(),e.bondStore)),(!l||l.radius||f&&l.position)&&(i=new jp(e.radiusParams.radius,e.radiusParams.scale)),l&&!l.radius||(u=new Float32Array(x),y.radius=u,e.radius2&&(h=new Float32Array(x),y.radius2=h));var A,M,P,T,E,C,I,R=0,L=new Me,O=new Me,N=new Me;return p.forEach(function(t){if(M=3*R,b.index=t,_.index=b.atomIndex1,w.index=b.atomIndex2,T=b.bondOrder,n&&(f&&T>1?(E=i.atomRadius(_),C=E*g/(.5*T),b.calculateShiftDir(N),m?(I=2*v*E,N.multiplyScalar(I),N.negate(),O.subVectors(w,_).multiplyScalar(Math.max(.1,I/1.88)),_.positionToArray(n,M),w.positionToArray(o,M),T>=2&&(L.addVectors(_,N).add(O).toArray(n,M+3),L.addVectors(w,N).sub(O).toArray(o,M+3),T>=3&&(L.subVectors(_,N).add(O).toArray(n,M+6),L.subVectors(w,N).sub(O).toArray(o,M+6)))):(I=(v-g)*E,N.multiplyScalar(I),2===T?(L.addVectors(_,N).toArray(n,M),L.subVectors(_,N).toArray(n,M+3),L.addVectors(w,N).toArray(o,M),L.subVectors(w,N).toArray(o,M+3)):3===T?(_.positionToArray(n,M),L.addVectors(_,N).toArray(n,M+3),L.subVectors(_,N).toArray(n,M+6),w.positionToArray(o,M),L.addVectors(w,N).toArray(o,M+3),L.subVectors(w,N).toArray(o,M+6)):(_.positionToArray(n,M),w.positionToArray(o,M)))):(_.positionToArray(n,M),w.positionToArray(o,M))),a&&(r.bondColorToArray(b,1,a,M),r.bondColorToArray(b,0,s,M),f&&T>1))for(A=1;A<T;++A)mh(a,M,P=3*A+M,3),mh(s,M,P,3);if(c&&(c[R]=t,f&&T>1))for(A=1;A<T;++A)c[R+A]=t;if(u&&(u[R]=i.atomRadius(_),f&&T>1))for(C=u[R]*g/(m?1:.5*T),A=m?1:0;A<T;++A)u[R+A]=C;if(h&&(h[R]=i.atomRadius(w),f&&T>1))for(C=h[R]*g/(m?1:.5*T),A=m?1:0;A<T;++A)h[R+A]=C;R+=f?T:1}),y},_f.prototype.getBackboneAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__backbone},t),this.getAtomData(t)},_f.prototype.getBackboneBondData=function(t){return t=Object.assign({bondSet:this.getBackboneBondSet(),bondStore:this.backboneBondStore},t),this.getBondData(t)},_f.prototype.getRungAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__rung},t),this.getAtomData(t)},_f.prototype.getRungBondData=function(t){return t=Object.assign({bondSet:this.getRungBondSet(),bondStore:this.rungBondStore},t),this.getBondData(t)},_f.prototype.getBoundingBox=function(t,e){xu&&bu.time("getBoundingBox"),e=e||new Ti;var i=1/0,r=1/0,n=1/0,o=-1/0,a=-1/0,s=-1/0;return this.eachAtom(function(t){var e=t.x,c=t.y,u=t.z;e<i&&(i=e),c<r&&(r=c),u<n&&(n=u),e>o&&(o=e),c>a&&(a=c),u>s&&(s=u)},t),e.min.set(i,r,n),e.max.set(o,a,s),xu&&bu.timeEnd("getBoundingBox"),e},_f.prototype.getPrincipalAxes=function(t){xu&&bu.time("getPrincipalAxes");var e=0,i=new Gp(3,this.atomCount),r=i.data;return this.eachAtom(function(t){r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3},t),xu&&bu.timeEnd("getPrincipalAxes"),new ud(i)},_f.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter():this.center.clone()},_f.prototype.getSequence=function(t){var e=[],i=this.getResidueProxy();return this.eachAtom(function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())},t),e},_f.prototype.getAtomIndices=function(t){var e;if(t&&t.string)e=[],this.eachAtom(function(t){e.push(t.index)},t);else{e=this.getAtomData({what:{index:!0}}).index}return e},_f.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain(function(t){t.residueCount&&e.add(t.chainname)},t),e.size},_f.prototype.updatePosition=function(t){var e=0;this.eachAtom(function(i){i.positionFromArray(t,e),e+=3})},_f.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new hd(this.atomStore,this.boundingBox)},_f.prototype.dispose=function(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.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(_f.prototype,wf);var Af=function(t,e){var i;"function"===typeof t.eachAtom?i=t.atomCount:t instanceof Float32Array&&(i=t.length/3);var r=new Gp(3,i),n=new Gp(3,i);this.coords1t=new Gp(i,3),this.coords2t=new Gp(i,3),this.A=new Gp(3,3),this.W=new Gp(1,3),this.U=new Gp(3,3),this.V=new Gp(3,3),this.VH=new Gp(3,3),this.R=new Gp(3,3),this.tmp=new Gp(3,3),this.c=new Gp(3,3),this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,r),this.prepCoords(e,n),this._superpose(r,n)};Af.prototype._superpose=function(t,e){this.mean1=Wp(t),this.mean2=Wp(e),Xp(t,this.mean1),Xp(e,this.mean2),Vp(this.coords1t,t),Vp(this.coords2t,e),$p(this.A,this.coords2t,this.coords1t),Qp(this.A,this.W,this.U,this.V),function(t,e){var i=t.data,r=e.data,n=i[4],o=i[8],a=i[5],s=i[7],c=i[0],u=c*n,h=c*a,l=i[3],p=i[1],d=l*p,f=i[2],m=l*f,g=i[6],v=g*p,y=g*f,b=1/(u*o-h*s-d*o+m*s+v*a-y*n);r[0]=(n*o-a*s)*b,r[1]=-(p*o-f*s)*b,r[2]=-(-p*a+f*n)*b,r[3]=-(l*o-a*g)*b,r[4]=(c*o-y)*b,r[5]=-(h-m)*b,r[6]=-(-l*s+n*g)*b,r[7]=-(c*s-v)*b,r[8]=(u-d)*b}(this.V,this.VH),Hp(this.R,this.U,this.VH),function(t){var e=t.data;return e[0]*e[4]*e[8]-e[0]*e[5]*e[7]-e[3]*e[1]*e[8]+e[3]*e[2]*e[7]+e[6]*e[1]*e[5]-e[6]*e[2]*e[4]}(this.R)<0&&(xu&&bu.log("R not a right handed system"),Hp(this.tmp,this.c,this.VH),Hp(this.R,this.U,this.tmp))},Af.prototype.prepCoords=function(t,e){var i=0,r=e.data;"function"===typeof t.eachAtom?t.eachAtom(function(t){r[i+0]=t.x,r[i+1]=t.y,r[i+2]=t.z,i+=3}):t instanceof Float32Array?r.set(t):bu.warn("prepCoords: input type unknown")},Af.prototype.transform=function(t){var e;"function"===typeof t.eachAtom?e=t.atomCount:t instanceof Float32Array&&(e=t.length/3);var i=new Gp(3,e),r=new Gp(e,3);this.prepCoords(t,i),Xp(i,this.mean1),$p(r,this.R,i),Vp(i,r),function(t,e){var i,r,n=0,o=t.rows,a=t.cols,s=t.data;for(i=0;i<o;++i)for(r=0;r<a;++r,++n)s[n]+=e[r]}(i,this.mean2);var n=0,o=i.data;"function"===typeof t.eachAtom?t.eachAtom(function(t){t.x=o[n+0],t.y=o[n+1],t.z=o[n+2],n+=3}):t instanceof Float32Array?t.set(o.subarray(0,3*e)):bu.warn("transform: input type unknown")};var Mf=function(t,e){this.signals={startedRunning:new jc,haltedRunning:new jc};var i=Object.assign({},e);t.signals.playerChanged.add(function(t){t!==this&&this.pause()},this);var r=Oa(t.numframes,1);this.traj=t,this.start=Oa(i.start,0),this.end=Math.min(Oa(i.end,r-1),r-1),this.step=Oa(i.step,Math.ceil((r+1)/100)),this.timeout=Oa(i.timeout,50),this.interpolateType=Oa(i.interpolateType,""),this.interpolateStep=Oa(i.interpolateStep,5),this.mode=Oa(i.mode,"loop"),this.direction=Oa(i.direction,"forward"),this._stopFlag=!1,this._running=!1,t.signals.gotNumframes.add(function(t){this.end=Math.min(Oa(i.end,t-1),t-1)},this)};Mf.prototype._animate=function(){var t,e,i,r;(this._running=!0,this.traj.inProgress||this._stopFlag||(((t="forward"===this.direction?this.traj.currentFrame+this.step:this.traj.currentFrame-this.step)>=this.end||t<this.start)&&("once"===this.mode?(this.pause(),t="forward"===this.direction?this.end:this.start):t="forward"===this.direction?this.start:this.end),this.interpolateType||this.traj.setFrame(t)),this._stopFlag)?this._running=!1:!this.traj.inProgress&&this.interpolateType?("forward"===this.direction?(e=Math.max(this.start,t-this.step),i=Math.max(this.start,t-2*this.step),r=Math.max(this.start,t-3*this.step)):(e=Math.min(this.end,t+this.step),i=Math.min(this.end,t+2*this.step),r=Math.min(this.end,t+3*this.step)),this._interpolate(t,e,i,r,1/this.interpolateStep,0)):setTimeout(this._animate.bind(this),this.timeout)},Mf.prototype._interpolate=function(t,e,i,r,n,o){if((o+=n)<=1){var a=Math.round(this.timeout*n);this.traj.setFrameInterpolated(t,e,i,r,o,this.interpolateType,function(){setTimeout(function(){this._interpolate(t,e,i,r,n,o)}.bind(this),a)}.bind(this))}else setTimeout(this._animate.bind(this),0)},Mf.prototype.toggle=function(){this._running?this.pause():this.play()},Mf.prototype.play=function(){if(!this._running){this.traj.player!==this&&this.traj.setPlayer(this);var t=this.traj.currentFrame,e=Math.ceil(t/this.step)*this.step;"forward"===this.direction&&t>=this.end?e=this.start:"backward"===this.direction&&t<=this.start&&(e=this.end),this.traj.setFrame(e),this._stopFlag=!1,this._animate(),this.signals.startedRunning.dispatch()}},Mf.prototype.pause=function(){this._running&&(this._stopFlag=!0,this.signals.haltedRunning.dispatch())},Mf.prototype.stop=function(){this.traj.setFrame(this.start),this.pause()};var Pf=function(t,e,i){this.signals={gotNumframes:new jc,frameChanged:new jc,selectionChanged:new jc,playerChanged:new jc};var r=i||{};r.centerPbc=Oa(r.centerPbc,!0),r.removePbc=Oa(r.removePbc,!0),r.superpose=Oa(r.superpose,!0),this.setParameters(r),this.name=t.replace(/^.*[\\\/]/,""),this.selection=new cu(Oa(r.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add(function(){this.makeIndices(),this.resetCache()},this),this.setStructure(e),this.setPlayer(new Mf(this)),this.trajPath=t,this.numframes=void 0,this.getNumframes()};function Tf(t){return"front"===t?w:"back"===t?S:A}Pf.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.makeAtomIndices(),this.saveInitialStructure(),this.backboneIndices=this.getIndices(new cu("backbone and not hydrogen")),this.makeIndices(),this.frameCache=[],this.boxCache=[],this.pathCache=[],this.frameCacheSize=0,this.currentFrame=-1},Pf.prototype.saveInitialStructure=function(){var t=0,e=new Float32Array(3*this.atomCount);this.structure.eachAtom(function(i){e[t+0]=i.x,e[t+1]=i.y,e[t+2]=i.z,t+=3}),this.initialStructure=e},Pf.prototype.setSelection=function(t){return this.selection.setString(t),this},Pf.prototype.getIndices=function(t){var e;if(t&&t.test){var i=0,r=t.test;e=[],this.structure.eachAtom(function(t){r(t)&&e.push(i),i+=1})}else e=this.structure.getAtomIndices(this.selection);return e},Pf.prototype.makeIndices=function(){var t,e;this.indices=this.getIndices(this.selection);var i=3*this.indices.length;this.coords1=new Float32Array(i),this.coords2=new Float32Array(i);var r=this.initialStructure,n=this.coords2;for(t=0;t<i;t+=3)e=3*this.indices[t/3],n[t+0]=r[e+0],n[t+1]=r[e+1],n[t+2]=r[e+2]},Pf.prototype.makeAtomIndices=function(){bu.error("Trajectory.makeAtomIndices not implemented")},Pf.prototype.getNumframes=function(){bu.error("Trajectory.loadFrame not implemented")},Pf.prototype.resetCache=function(){return this.frameCache=[],this.boxCache=[],this.pathCache=[],this.frameCacheSize=0,this.setFrame(this.currentFrame),this},Pf.prototype.setParameters=function(t){var e=t,i=!1;void 0!==e.centerPbc&&e.centerPbc!==this.centerPbc&&(this.centerPbc=e.centerPbc,i=!0),void 0!==e.removePbc&&e.removePbc!==this.removePbc&&(this.removePbc=e.removePbc,i=!0),void 0!==e.superpose&&e.superpose!==this.superpose&&(this.superpose=e.superpose,i=!0),i&&this.resetCache()},Pf.prototype.setFrame=function(t,e){return void 0===t?this:(this.inProgress=!0,-1===(t=parseInt(t))||this.frameCache[t]?this.updateStructure(t,e):this.loadFrame(t,function(){this.updateStructure(t,e)}.bind(this)),this)},Pf.prototype.interpolate=function(t,e,i,r,n,o,a){var s,c=this.frameCache,u=c[t],h=c[e],l=c[i],p=c[r],d=u.length,f=new Float32Array(d);if("spline"===o)for(s=0;s<d;s+=3)f[s+0]=Nc(p[s+0],l[s+0],h[s+0],u[s+0],n,1),f[s+1]=Nc(p[s+1],l[s+1],h[s+1],u[s+1],n,1),f[s+2]=Nc(p[s+2],l[s+2],h[s+2],u[s+2],n,1);else for(s=0;s<d;s+=3)f[s+0]=Oc(h[s+0],u[s+0],n),f[s+1]=Oc(h[s+1],u[s+1],n),f[s+2]=Oc(h[s+2],u[s+2],n);this.structure.updatePosition(f),this.currentFrame=t,this.signals.frameChanged.dispatch(t),"function"===typeof a&&a()},Pf.prototype.setFrameInterpolated=function(t,e,i,r,n,o,a){if(void 0===t)return this;var s=this.frameCache,c=[];return s[r]||c.push(r),s[i]||c.push(i),s[e]||c.push(e),s[t]||c.push(t),c.length?this.loadFrame(c,function(){this.interpolate(t,e,i,r,n,o,a)}.bind(this)):this.interpolate(t,e,i,r,n,o,a),this},Pf.prototype.loadFrame=function(t,e){if(Array.isArray(t)){var i,r=function(t,r){this._loadFrame(t,r),0===i.length()&&"function"===typeof e&&e()}.bind(this);i=new Sf(r,t)}else this._loadFrame(t,e)},Pf.prototype._loadFrame=function(t,e){bu.error("Trajectory._loadFrame not implemented",t,e)},Pf.prototype.updateStructure=function(t,e){this._disposed||(-1===t?this.structure.updatePosition(this.initialStructure):this.structure.updatePosition(this.frameCache[t]),this.structure.trajectory={name:this.trajPath,frame:t},"function"===typeof e&&e(),this.currentFrame=t,this.inProgress=!1,this.signals.frameChanged.dispatch(t))},Pf.prototype.getCircularMean=function(t,e,i){return[ch(e,i[0],3,0,t),ch(e,i[1],3,1,t),ch(e,i[2],3,2,t)]},Pf.prototype.doSuperpose=function(t){var e,i,r=3*this.indices.length,n=this.coords1,o=this.coords2;for(e=0;e<r;e+=3)i=3*this.indices[e/3],n[e+0]=t[i+0],n[e+1]=t[i+1],n[e+2]=t[i+2];new Af(n,o).transform(t)},Pf.prototype.process=function(t,e,i,r){if(this.setNumframes(r),e){if(this.backboneIndices.length>0&&this.centerPbc){var n=[e[0],e[4],e[8]];!function(t,e,i){if(0!==i[0]&&0!==i[8]&&0!==i[4]){var r,n=t.length,o=i[0],a=i[1],s=i[2],c=-e[0]+o+o/2,u=-e[1]+a+a/2,h=-e[2]+s+s/2;for(r=0;r<n;r+=3)t[r+0]=(t[r+0]+c)%o,t[r+1]=(t[r+1]+u)%a,t[r+2]=(t[r+2]+h)%s}}(i,this.getCircularMean(this.backboneIndices,i,n),n)}this.removePbc&&function(t,e){if(0!==e[0]&&0!==e[8]&&0!==e[4]){var i,r,n,o,a=t.length;for(i=3;i<a;i+=3)for(r=0;r<3;++r)if(o=t[i+r]-t[i-3+r],Math.abs(o)>.9*e[3*r+r])if(o>0)for(n=0;n<3;++n)t[i+n]-=e[3*r+n];else for(n=0;n<3;++n)t[i+n]+=e[3*r+n]}}(i,e)}this.indices.length>0&&this.superpose&&this.doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1},Pf.prototype.setNumframes=function(t){t!==this.numframes&&(this.numframes=t,this.signals.gotNumframes.dispatch(t))},Pf.prototype.dispose=function(){this.frameCache=[],this._disposed=!0,this.player&&this.player.stop()},Pf.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},Pf.prototype.getPath=function(t,e){bu.error("Trajectory.getPath not implemented",t,e)},Tu.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}"),Tu.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 Ef={f:1,v2:2,v3:3,c:3};function Cf(t,e){t.matrix.copy(e),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixWorldNeedsUpdate=!0}var If=function(t,e){var i=t||{},r=e||{};this.opaqueBack=Oa(r.opaqueBack,!1),this.dullInterior=Oa(r.dullInterior,!1),this.side=Oa(r.side,"double"),this.opacity=Oa(r.opacity,1),this.depthWrite=Oa(r.depthWrite,!0),this.clipNear=Oa(r.clipNear,0),this.clipRadius=Oa(r.clipRadius,0),this.clipCenter=Oa(r.clipCenter,new Me),this.flatShaded=Oa(r.flatShaded,!1),this.background=Oa(r.background,!1),this.linewidth=Oa(r.linewidth,1),this.wireframe=Oa(r.wireframe,!1),this.wireframeLinewidth=Oa(r.wireframeLinewidth,1),this.roughness=Oa(r.roughness,.4),this.metalness=Oa(r.metalness,0),this.diffuse=Oa(r.diffuse,16777215),this.forceTransparent=Oa(r.forceTransparent,!1),this.disablePicking=Oa(r.disablePicking,!1),this.geometry=new Ki,this.indexVersion=0,this.wireframeIndexVersion=-1,this.uniforms=vi.merge([gi.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 mi(0)},roughness:{value:this.roughness},metalness:{value:this.metalness}},gi.ambient,gi.lights]),this.uniforms.diffuse.value.set(this.diffuse),this.pickingUniforms={nearClip:{value:0},objectId:{value:0},opacity:{value:this.opacity}},this.group=new tn,this.wireframeGroup=new tn,this.pickingGroup=new tn,this.matrix=Oa(r.matrix,new Pe);var n=i.position||i.position1;this._positionDataSize=n?n.length/3:0,this.addAttributes({position:{type:"v3",value:i.position},color:{type:"c",value:i.color},primitiveId:{type:"f",value:i.primitiveId}}),i.index&&this.initIndex(i.index),this.picking=i.picking,this.makeWireframeGeometry()},Rf={parameters:{},matrix:{},transparent:{},size:{},attributeSize:{},pickable:{},dynamic:{},vertexShader:{},fragmentShader:{}};Rf.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},linewidth:{property:!0},wireframe:{updateVisibility:!0},roughness:{uniform:!0},metalness:{uniform:!0},diffuse:{uniform:!0},matrix:{}}},Rf.matrix.set=function(t){this.setMatrix(t)},Rf.matrix.get=function(){return this.group.matrix.clone()},Rf.transparent.get=function(){return this.opacity<1||this.forceTransparent},Rf.size.get=function(){return this._positionDataSize},Rf.attributeSize.get=function(){return this.size},Rf.pickable.get=function(){return!!this.picking&&!this.disablePicking},Rf.dynamic.get=function(){return!0},Rf.vertexShader.get=function(){},Rf.fragmentShader.get=function(){},If.prototype.setMatrix=function(t){Cf(this.group,t),Cf(this.wireframeGroup,t),Cf(this.pickingGroup,t)},If.prototype.initIndex=function(t){this.geometry.setIndex(new Hi(t,1)),this.geometry.getIndex().setDynamic(this.dynamic)},If.prototype.makeMaterial=function(){var t=Tf(this.side),e=new Mi({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!0,fog:!0,side:t,linewidth:this.linewidth});e.vertexColors=C,e.extensions.derivatives=this.flatShaded,e.extensions.fragDepth=this.isImpostor,e.clipNear=this.clipNear;var i=new Mi({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!1,fog:!0,side:t,linewidth:this.linewidth});i.vertexColors=C,i.clipNear=this.clipNear;var r=new Mi({uniforms:this.pickingUniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:!1,depthWrite:this.depthWrite,lights:!1,fog:!1,side:t,linewidth:this.linewidth,blending:I});r.vertexColors=C,r.extensions.fragDepth=this.isImpostor,r.clipNear=this.clipNear,this.material=e,this.wireframeMaterial=i,this.pickingMaterial=r,this.updateShader()},If.prototype.makeWireframeGeometry=function(){this.makeWireframeIndex();var t=this.geometry,e=this.wireframeIndex,i=new Ki;i.attributes=t.attributes,e&&(i.setIndex(new Hi(e,1).setDynamic(this.dynamic)),i.setDrawRange(0,this.wireframeIndexCount)),this.wireframeGeometry=i},If.prototype.makeWireframeIndex=function(){var t=[];function e(e,i){if(e>i){var r=e;e=i,i=r}var n=t[e];return void 0===n?(t[e]=[i],!0):!n.includes(i)&&(n.push(i),!0)}var i=this.geometry,r=i.index;if(this.wireframe)if(r){var n,o=r.array,a=o.length;if(i.drawRange.count!==1/0&&(a=i.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*a)n=this.wireframeIndex;else n=Va(2*a,i.attributes.position.count);var s=0;t.length=0;for(var c=0;c<a;c+=3){var u=o[c+0],h=o[c+1],l=o[c+2];e(u,h)&&(n[s+0]=u,n[s+1]=h,s+=2),e(h,l)&&(n[s+0]=h,n[s+1]=l,s+=2),e(l,u)&&(n[s+0]=l,n[s+1]=u,s+=2)}this.wireframeIndex=n,this.wireframeIndexCount=s,this.wireframeIndexVersion=this.indexVersion}else{var p,d=i.attributes.position.count;p=this.wireframeIndex&&this.wireframeIndex.length>2*d?this.wireframeIndex:Va(2*d,d);for(var f=0,m=0;f<d;f+=3)p[m+0]=f,p[m+1]=f+1,p[m+2]=f+1,p[m+3]=f+2,p[m+4]=f+2,p[m+5]=f,m+=6;this.wireframeIndex=p,this.wireframeIndexCount=2*d,this.wireframeIndexVersion=this.indexVersion}else this.wireframeIndex=new Uint16Array(0),this.wireframeIndexCount=0},If.prototype.updateWireframeIndex=function(){if(this.wireframeGeometry.setDrawRange(0,1/0),this.wireframeIndexVersion<this.indexVersion&&this.makeWireframeIndex(),this.wireframeIndex.length>this.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new Hi(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)},If.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},If.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,i=this.geometry,r=this[t];return this.isLine?e=new Zr(i,r):this.isPoint?(e=new Jr(i,r),this.sortParticles&&(e.sortParticles=!0)):e=new ar(i,r),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},If.prototype.getMesh=function(){return this._getMesh("material")},If.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),(t=new Zr(this.wireframeGeometry,this.wireframeMaterial)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},If.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},If.prototype.getShader=function(t,e){return Ju(t,this.getDefines(e))},If.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},If.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},If.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},If.prototype.getParameters=function(){var t={};for(var e in this.parameters)t[e]=this[e];return t},If.prototype.addUniforms=function(t){this.uniforms=vi.merge([this.uniforms,t]),this.pickingUniforms=vi.merge([this.pickingUniforms,t])},If.prototype.addAttributes=function(t){for(var e in t){var i=void 0,r=t[e],n=this.attributeSize*Ef[r.type];r.value?(n!==r.value.length&&bu.error("attribute value has wrong length",e),i=r.value):i=Ga("float32",n),this.geometry.addAttribute(e,new Hi(i,Ef[r.type]).setDynamic(this.dynamic))}},If.prototype.updateRenderOrder=function(){var t=this.getRenderOrder();function e(e){e.renderOrder=t}this.group.children.forEach(e),this.pickingGroup&&this.pickingGroup.children.forEach(e)},If.prototype.updateShader=function(){var t=this.material,e=this.wireframeMaterial,i=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,i.vertexShader=this.getVertexShader("picking"),i.fragmentShader=this.getFragmentShader("picking"),i.needsUpdate=!0},If.prototype.setParameters=function(t){if(t){var e=t,i=this.parameters,r={},n={},o=!1,a=!1;for(var s in e){var c=e[s];void 0!==c&&(void 0!==i[s]&&(this[s]=c,i[s].property&&(!0!==i[s].property?r[i[s].property]=c:r[s]=c),i[s].uniform&&(!0!==i[s].uniform?n[i[s].uniform]=c:n[s]=c),i[s].updateShader&&(o=!0),i[s].updateVisibility&&(a=!0),this.dynamic&&"wireframe"===s&&!0===c&&this.updateWireframeIndex(),"flatShaded"===s&&(this.material.extensions.derivatives=this.flatShaded),"forceTransparent"===s&&(r.transparent=this.transparent)))}this.setProperties(r),this.setUniforms(n),o&&this.updateShader(),a&&this.setVisibility(this.visible)}},If.prototype.setAttributes=function(t){var e=this.geometry,i=e.attributes;for(var r in t)if("picking"!==r){var n=t[r],o=n.length;if("index"===r){var a=e.getIndex();e.setDrawRange(0,1/0),o>a.array.length?e.setIndex(new Hi(n,1).setDynamic(this.dynamic)):(a.set(n),a.needsUpdate=o>0,a.updateRange.count=o,e.setDrawRange(0,o)),this.indexVersion++,this.wireframe&&this.updateWireframeIndex()}else{var s=i[r];o>s.array.length?e.addAttribute(r,new Hi(n,s.itemSize).setDynamic(this.dynamic)):(i[r].set(n),i[r].needsUpdate=o>0,i[r].updateRange.count=o)}}},If.prototype.setUniforms=function(t){if(t){var e=this.material.uniforms,i=this.wireframeMaterial.uniforms,r=this.pickingMaterial.uniforms;for(var n in t)"opacity"===n&&this.setProperties({transparent:this.transparent}),void 0!==e[n]&&(e[n].value.isVector3?e[n].value.copy(t[n]):e[n].value.set?e[n].value.set(t[n]):e[n].value=t[n]),void 0!==i[n]&&(i[n].value.isVector3?i[n].value.copy(t[n]):i[n].value.set?i[n].value.set(t[n]):i[n].value=t[n]),void 0!==r[n]&&(r[n].value.isVector3?r[n].value.copy(t[n]):r[n].value.set?r[n].value.set(t[n]):r[n].value=t[n])}},If.prototype.setProperties=function(t){if(t){var e=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;for(var n in t){var o=t[n];"transparent"===n?this.updateRenderOrder():"side"===n&&(o=Tf(o)),void 0!==e[n]&&(e[n]=o),void 0!==i[n]&&(i[n]=o),void 0!==r[n]&&(r[n]=o)}e.needsUpdate=!0,i.needsUpdate=!0,r.needsUpdate=!0}},If.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))},If.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(If.prototype,Rf);var Lf=function(t){function e(e,i){var r=e||{};!r.primitiveId&&r.position&&(r.primitiveId=ph(r.position.length/3)),t.call(this,r,i),this.addAttributes({normal:{type:"v3",value:r.normal}}),void 0===r.normal&&this.geometry.computeVertexNormals()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={vertexShader:{},fragmentShader:{}};return i.vertexShader.get=function(){return"Mesh.vert"},i.fragmentShader.get=function(){return"Mesh.frag"},Object.defineProperties(e.prototype,i),e}(If),Of=new Pe,Nf=new Ci,Df=function(t){function e(e,i,r){var n,o=e||{},a=i||{},s=r.attributes.position.array,c=r.attributes.normal.array,u=r.index?r.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=Va(h*u.length,p)),t.call(this,{position:d,color:m,index:n,normal:f,primitiveId:o.primitiveId||dh(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),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(){},e.prototype.setAttributes=function(t,e){var i,r,n,o,a,s,c,u,h,l=this.geometry.attributes,p=this.updateNormals;t.position&&(i=t.position,n=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,l.position.needsUpdate=!0,(p||e)&&(o=this.geoNormal,h=this.meshNormal,s=this.transformedGeoNormal,l.normal.needsUpdate=!0)),t.color&&(r=t.color,u=this.meshColor,l.color.needsUpdate=!0);for(var d=this.positionCount,f=this.geoPositionCount,m=0;m<d;++m){var g=void 0,v=void 0,y=m*f*3,b=3*m;if(i&&(a.set(n),Of.makeTranslation(i[b],i[b+1],i[b+2]),this.applyPositionTransform(Of,m,b),Cl(Of.elements,a),c.set(a,y),p?(s.set(o),Nf.getNormalMatrix(Of),Il(Nf.elements,s),h.set(s,y)):e&&h.set(o,y)),r)for(g=0;g<f;++g)u[v=y+3*g]=r[b],u[v+1]=r[b+1],u[v+2]=r[b+2]}},e.prototype.makeIndex=function(){var t=this.geoIndex,e=this.meshIndex;if(t)for(var i=this.positionCount,r=this.geoPositionCount,n=3*(t.length/3),o=0;o<i;++o){var a=o*n,s=a+n;e.set(t,a);for(var c=a;c<s;++c)e[c]+=o*r}},i.updateNormals.get=function(){return!1},Object.defineProperties(e.prototype,i),e}(Lf),kf=new Me,Ff=function(t){function e(e,i){var r=i||{},n=new fn(1,Oa(r.sphereDetail,1));t.call(this,e,r,n),this.setAttributes(e,!0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.applyPositionTransform=function(t,e){var i=this._radius[e];kf.set(i,i,i),t.scale(kf)},e.prototype.setAttributes=function(e,i){e.radius&&(this._radius=e.radius),t.prototype.setAttributes.call(this,e,i)},e}(Df);Tu.add("shader/SphereImpostor.vert","uniform mat4 projectionMatrixInverse;\nuniform float nearClip;\nvarying float vRadius;\nvarying float vRadiusSq;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\nattribute vec2 mapping;\nattribute float radius;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#endif\n#include matrix_scale\nconst mat4 D = mat4(\n1.0, 0.0, 0.0, 0.0,\n0.0, 1.0, 0.0, 0.0,\n0.0, 0.0, 1.0, 0.0,\n0.0, 0.0, 0.0, -1.0\n);\nmat4 transpose( in mat4 inMatrix ) {\nvec4 i0 = inMatrix[0];\nvec4 i1 = inMatrix[1];\nvec4 i2 = inMatrix[2];\nvec4 i3 = inMatrix[3];\nmat4 outMatrix = mat4(\nvec4(i0.x, i1.x, i2.x, i3.x),\nvec4(i0.y, i1.y, i2.y, i3.y),\nvec4(i0.z, i1.z, i2.z, i3.z),\nvec4(i0.w, i1.w, i2.w, i3.w)\n);\nreturn outMatrix;\n}\nvoid ComputePointSizeAndPositionInClipCoordSphere(){\nvec2 xbc;\nvec2 ybc;\nmat4 T = mat4(\nradius, 0.0, 0.0, 0.0,\n0.0, radius, 0.0, 0.0,\n0.0, 0.0, radius, 0.0,\nposition.x, position.y, position.z, 1.0\n);\nmat4 R = transpose( projectionMatrix * modelViewMatrix * T );\nfloat A = dot( R[ 3 ], D * R[ 3 ] );\nfloat B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );\nfloat C = dot( R[ 0 ], D * R[ 0 ] );\nxbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nxbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nfloat sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;\nA = dot( R[ 3 ], D * R[ 3 ] );\nB = -2.0 * dot( R[ 1 ], D * R[ 3 ] );\nC = dot( R[ 1 ], D * R[ 1 ] );\nybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nfloat sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;\ngl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );\ngl_Position.xy -= mapping * vec2( sx, sy );\ngl_Position.xy *= gl_Position.w;\n}\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#endif\nvRadius = radius * matrixScale( modelViewMatrix );\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nmvPosition.z -= vRadius;\ngl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );\nComputePointSizeAndPositionInClipCoordSphere();\nvRadiusSq = vRadius * vRadius;\nvec4 vPoint4 = projectionMatrixInverse * gl_Position;\nvPoint = vPoint4.xyz / vPoint4.w;\nvPointViewPosition = -mvPosition.xyz / mvPosition.w;\n}"),Tu.add("shader/SphereImpostor.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 float vRadius;\nvarying float vRadiusSq;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\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\nbool flag2 = false;\nbool interior = false;\nvec3 cameraPos;\nvec3 cameraNormal;\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}\nbool Impostor( out vec3 cameraPos, out vec3 cameraNormal ){\nvec3 cameraSpherePos = -vPointViewPosition;\ncameraSpherePos.z += vRadius;\nvec3 rayOrigin = mix( vec3( 0.0, 0.0, 0.0 ), vPoint, ortho );\nvec3 rayDirection = mix( normalize( vPoint ), vec3( 0.0, 0.0, 1.0 ), ortho );\nvec3 cameraSphereDir = mix( cameraSpherePos, rayOrigin - cameraSpherePos, ortho );\nfloat B = dot( rayDirection, cameraSphereDir );\nfloat det = B * B + vRadiusSq - dot( cameraSphereDir, cameraSphereDir );\nif( det < 0.0 ){\ndiscard;\nreturn false;\n}else{\nfloat sqrtDet = sqrt( det );\nfloat posT = mix( B + sqrtDet, B + sqrtDet, ortho );\nfloat negT = mix( B - sqrtDet, sqrtDet - B, ortho );\ncameraPos = rayDirection * negT + rayOrigin;\n#ifdef NEAR_CLIP\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nreturn false;\n}else if( calcClip( cameraPos ) > 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 Bf=function(t){function e(e,i){t.call(this,e,i),this.index=Va(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index,1),this.addAttributes({mapping:{type:this.mappingType,value:null}}),this.setAttributes({primitiveId:ph(this.size)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={attributeSize:{},indexSize:{},mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.attributeSize.get=function(){return this.size*this.mappingSize},i.indexSize.get=function(){return this.size*this.mappingIndicesSize},i.mapping.get=function(){},i.mappingIndices.get=function(){},i.mappingIndicesSize.get=function(){},i.mappingType.get=function(){},i.mappingSize.get=function(){},i.mappingItemSize.get=function(){},e.prototype.addAttributes=function(e){var i={};for(var r in e){var n=e[r];i[r]={type:n.type,value:null}}t.prototype.addAttributes.call(this,i)},e.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},e.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=uh(t.position1,t.position2));var e,i,r,n,o,a,s,c=this.size,u=this.mappingSize,h=this.geometry.attributes;for(var l in t)if("index"!==l&&"picking"!==l){i=t[l],r=(e=h[l]).itemSize,n=e.array;for(var p=0;p<c;++p){a=(o=p*r)*u;for(var d=0;d<u;++d){s=a+r*d;for(var f=0;f<r;++f)n[s+f]=i[o+f]}}e.needsUpdate=!0}},e.prototype.makeMapping=function(){for(var t=this.size,e=this.mapping,i=this.mappingSize,r=this.mappingItemSize,n=this.geometry.attributes.mapping.array,o=0;o<t;o++)n.set(e,o*r*i)},e.prototype.makeIndex=function(){for(var t,e,i=this.size,r=this.mappingSize,n=this.mappingIndices,o=this.mappingIndicesSize,a=this.index,s=0;s<i;s++){t=s*o,e=s*r,a.set(n,t);for(var c=0;c<o;++c)a[t+c]+=e}},Object.defineProperties(e.prototype,i),e}(If),zf=new Float32Array([-1,1,-1,-1,1,1,1,-1]),Uf=new Uint16Array([0,1,2,1,3,2]),jf=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.mapping.get=function(){return zf},i.mappingIndices.get=function(){return Uf},i.mappingIndicesSize.get=function(){return 6},i.mappingType.get=function(){return"v2"},i.mappingSize.get=function(){return 4},i.mappingItemSize.get=function(){return 2},Object.defineProperties(e.prototype,i),e}(Bf),Gf=function(t){function e(e,i){t.call(this,e,i),this.addUniforms({projectionMatrixInverse:{value:new Pe},ortho:{value:0}}),this.addAttributes({radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isImpostor:{},vertexShader:{},fragmentShader:{}};return i.isImpostor.get=function(){return!0},i.vertexShader.get=function(){return"SphereImpostor.vert"},i.fragmentShader.get=function(){return"SphereImpostor.frag"},Object.defineProperties(e.prototype,i),e}(jf),Vf=function(t,e){return!vu||e&&e.disableImpostor?new Ff(t,e):new Gf(t,e)},$f=new Me,Hf=new Me,Wf=new Me,Xf=new Me(0,0,0),qf=function(t){function e(e,i){var r=i||{},n=new fn(1,Oa(r.sphereDetail,2));t.call(this,e,r,n),this.setAttributes(e,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,i){Hf.fromArray(this._majorAxis,i),Wf.fromArray(this._minorAxis,i),t.lookAt(Xf,Hf,Wf),$f.set(this._radius[e],Wf.length(),Hf.length()),t.scale($f)},e.prototype.setAttributes=function(e,i){e.radius&&(this._radius=e.radius),e.majorAxis&&(this._majorAxis=e.majorAxis),e.minorAxis&&(this._minorAxis=e.minorAxis),t.prototype.setAttributes.call(this,e,i)},i.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Df),Yf=function(t,e){return new qf(t,e)},Zf=new Me,Kf=new Me,Qf=new Me,Jf=new Me(0,1,0),tm=function(t){function e(e,i){var r=e||{},n=i||{},o=Oa(n.radialSegments,10),a=Oa(n.openEnded,!0),s=(new Pe).makeRotationX(Math.PI/2),c=new Bn(1,1,1,o,1,a);c.applyMatrix(s);var u=r.position1.length,h=r.radius.length,l=c.attributes.position.array.length/3,p=u/3,d=new Float32Array(2*p*l);dh(p,l,0,d),dh(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:r.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(r,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,i){Kf.fromArray(this._from,i),Qf.fromArray(this._to,i),t.lookAt(Kf,Qf,Jf);var r=this._radius[e];Zf.set(r,r,Kf.distanceTo(Qf)),t.scale(Zf)},e.prototype.setAttributes=function(e,i){var r={};e.position1&&e.position2&&(uh(e.position1,e.position2,this.__center),uh(e.position1,this.__center,this._position),uh(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),r.position=this._position),e.color&&e.color2&&(this._color.set(e.color),this._color.set(e.color2,e.color.length),r.color=this._color),e.radius&&(this._radius.set(e.radius),this._radius.set(e.radius,e.radius.length),r.radius=this._radius),t.prototype.setAttributes.call(this,r,i)},i.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Df);Tu.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}"),Tu.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 em=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),im=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),rm=function(t){function e(e,i){t.call(this,e,i);var r=i||{};this.openEnded=Oa(r.openEnded,!1),this.addUniforms({modelViewMatrixInverse:{value:new Pe},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},isImpostor:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{openEnded:{updateShader:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.openEnded||(i.CAP=1),i},i.isImpostor.get=function(){return!0},i.vertexShader.get=function(){return"CylinderImpostor.vert"},i.fragmentShader.get=function(){return"CylinderImpostor.frag"},Object.defineProperties(e.prototype,i),e}(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.mapping.get=function(){return em},i.mappingIndices.get=function(){return im},i.mappingIndicesSize.get=function(){return 12},i.mappingType.get=function(){return"v3"},i.mappingSize.get=function(){return 6},i.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,i),e}(Bf)),nm=function(t,e){return!vu||e&&e.disableImpostor?new tm(t,e):new rm(t,e)},om=new Me,am=new Me,sm=new Me,cm=new Me(0,1,0),um=function(t){function e(e,i){var r=i||{},n=Oa(r.radialSegments,60),o=Oa(r.openEnded,!1),a=(new Pe).makeRotationX(-Math.PI/2),s=new Un(1,1,n,1,o);s.applyMatrix(a);var c=e.position1.length,u=e.radius.length,h=new Float32Array(c);t.call(this,{position:h,color:e.color,picking:e.picking},r,s),this._position=h,this._from=new Float32Array(c),this._to=new Float32Array(c),this._radius=new Float32Array(u),this.setAttributes(e,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,i){am.fromArray(this._from,i),sm.fromArray(this._to,i),t.lookAt(am,sm,cm);var r=this._radius[e];om.set(r,r,am.distanceTo(sm)),t.scale(om)},e.prototype.setAttributes=function(e,i){var r={};e.position1&&e.position2&&(uh(e.position1,e.position2,this._position),this._from.set(e.position1),this._to.set(e.position2),r.position=this._position),e.color&&(r.color=e.color),e.radius&&this._radius.set(e.radius),t.prototype.setAttributes.call(this,r,i)},i.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Df),hm=function(t,e){return new um(t,e)},lm=function(t){this.geometryList=t,this.boundingBox=null};lm.prototype.computeBoundingBox=function(){var t=this;this.boundingBox?this.boundingBox.empty():this.boundingBox=new Ti,this.geometryList.forEach(function(e){e.boundingBox||e.computeBoundingBox(),t.boundingBox.union(e.boundingBox)})};var pm=function(t,e){var i=t||{},r=e||{};this.aspectRatio=Oa(r.aspectRatio,1.5),this.wireframe=Oa(r.wireframe,!1),this.splitPosition=new Float32Array(i.position1.length),this.cylinderRadius=new Float32Array(i.radius.length);var n=this.makeAttributes(i),o={radialSegments:Oa(r.radialSegments,50),openEnded:Oa(r.openEnded,!1),disableImpostor:Oa(r.disableImpostor,!1)};this.cylinderBuffer=new nm(n.cylinder,o),this.coneBuffer=new hm(n.cone,o),this.geometry=new lm([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.group=new tn,this.wireframeGroup=new tn,this.pickingGroup=new tn,this.matrix=Oa(r.matrix,new Pe),this.picking=i.picking},dm={matrix:{},pickable:{}};dm.matrix.set=function(t){If.prototype.setMatrix.call(this,t)},dm.matrix.get=function(){return this.group.matrix.clone()},dm.pickable.get=function(){return!!this.picking},pm.prototype.makeAttributes=function(t){var e,i,r=this.splitPosition,n=this.cylinderRadius,o=this.aspectRatio,a={},s={};if(t.radius){for(e=0,i=n.length;e<i;++e)n[e]=t.radius[e]/o;a.radius=n,s.radius=t.radius}if(t.position1&&t.position2){var c=new Me,u=new Me,h=new Me,l=new Me;for(e=0,i=r.length;e<i;e+=3){c.fromArray(t.position1,e),u.fromArray(t.position2,e),h.subVectors(c,u);var p=h.length(),d=n[e/3]*o*2,f=Math.min(p,d);h.setLength(f),l.copy(u).add(h),l.toArray(r,e)}a.position1=t.position1,a.position2=r,s.position1=r,s.position2=t.position2}return t.color&&(a.color=t.color,a.color2=t.color,s.color=t.color),{cylinder:a,cone:s}},pm.prototype.getMesh=function(t){return(new tn).add(this.cylinderBuffer.getMesh(t),this.coneBuffer.getMesh(t))},pm.prototype.getWireframeMesh=function(){return(new tn).add(this.cylinderBuffer.getWireframeMesh(),this.coneBuffer.getWireframeMesh())},pm.prototype.getPickingMesh=function(){return(new tn).add(this.cylinderBuffer.getPickingMesh(),this.coneBuffer.getPickingMesh())},pm.prototype.setAttributes=function(t){var e=this.makeAttributes(t);this.cylinderBuffer.setAttributes(e.cylinder),this.coneBuffer.setAttributes(e.cone)},pm.prototype.setParameters=function(t){(t=Object.assign({},t))&&void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,t&&void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),this.cylinderBuffer.setParameters(t),this.coneBuffer.setParameters(t)},pm.prototype.setVisibility=function(){If.prototype.setVisibility.apply(this,arguments)},pm.prototype.dispose=function(){this.cylinderBuffer.dispose(),this.coneBuffer.dispose()},Object.defineProperties(pm.prototype,dm),Tu.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}"),Tu.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 fm={};var mm=function(t){var e=Object.assign({},t);if(this.font=Oa(e.font,["sans-serif"]),this.size=Oa(e.size,36),this.style=Oa(e.style,"normal"),this.variant=Oa(e.variant,"normal"),this.weight=Oa(e.weight,"normal"),this.outline=Oa(e.outline,0),this.width=Oa(e.width,2048),this.height=Oa(e.height,2048),this.gamma=1,"undefined"!==typeof navigator){var i=navigator.userAgent;i.match(/Chrome/)&&i.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 rn(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};mm.prototype.build=function(){var t=this.size+2*this.outline+Math.round(this.size/4),e=this.width/4,i=document.createElement("canvas");i.width=e,i.height=t;var r=i.getContext("2d");r.font=this.style+" "+this.variant+" "+this.weight+" "+this.size+"px "+this.font,r.fillStyle="#FF0000",r.textAlign="left",r.textBaseline="bottom",r.lineJoin="round";for(var n=[],o=3*this.outline,a=0;a<o;++a){var s=("00"+Math.max(0,8*-a+128-8*!a).toString(16)).slice(-2);n.push("#"+s+s+s)}var c=new Uint8Array(e*t*2);this.canvas=i,this.context=r,this.lineHeight=t,this.maxWidth=e,this.colors=n,this.scratch=c,this.data=new Uint8Array(this.width*this.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=this.width,this.canvas2.height=this.height,this.context2=this.canvas2.getContext("2d")},mm.prototype.map=function(t){return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>this.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]},mm.prototype.get=function(t){return this.mapped[t]||this.placeholder},mm.prototype.draw=function(t){var e,i,r,n,o,a=this.lineHeight,s=this.outline,c=this.context,u=this.scratch,h=this.maxWidth,l=this.colors,p=s,d=a-this.outline,f=c.measureText(t),m=Math.min(h,Math.ceil(f.width+2*p+1));if(c.clearRect(0,0,m,a),0===this.outline)for(c.fillText(t,p,d),r=3,e=0,i=(o=(n=c.getImageData(0,0,m,a)).data).length/4;e<i;++e)u[e]=o[r],r+=4;else{for(c.globalCompositeOperation="source-over",e=s+1;e>0;--e)r=e>1?2*e-2:e,c.strokeStyle=l[r-1],c.lineWidth=r,c.strokeText(t,p,d);c.globalCompositeOperation="multiply",c.fillStyle="#FF00FF",c.fillText(t,p,d),o=(n=c.getImageData(0,0,m,a)).data,r=0;var g=this.gamma;for(e=0,i=o.length/4;e<i;++e){var v=o[r],y=v?o[r+1]/v:1;.5===g&&(y=Math.sqrt(y));var b=256-v,x=b+(v-b)*(y=Math.min(1,Math.max(0,y)));u[e]=Math.max(0,Math.min(255,x+2)),o[r+3]=u[e],r+=4}}c.putImageData(n,0,0),this.scratchW=m,this.scratchH=a},mm.prototype.populate=function(){this.placeholder=this.map(String.fromCharCode(65533));for(var t=0;t<127;++t)this.map(String.fromCharCode(t));for(var e=128;e<255;++e)this.map(String.fromCharCode(e));for(var i=880;i<1023;++i)this.map(String.fromCharCode(i));for(var r=1024;r<1279;++r)this.map(String.fromCharCode(r));this.map(String.fromCharCode(8491))};var gm=function(t){function e(e,i){var r=e||{},n=i||{};n.forceTransparent=!0;for(var o=r.position.length/3,a=0,s=0;s<o;++s)a+=r.text[s].length;var c=a;n.showBackground&&(c+=o),t.call(this,{position:new Float32Array(3*c),color:new Float32Array(3*c),picking:new rp},n),this.fontFamily=Oa(n.fontFamily,"sans-serif"),this.fontStyle=Oa(n.fontStyle,"normal"),this.fontWeight=Oa(n.fontWeight,"bold"),this.fontSize=Oa(n.fontSize,48),this.sdf=Oa(n.sdf,"Chrome"===fu),this.xOffset=Oa(n.xOffset,0),this.yOffset=Oa(n.yOffset,0),this.zOffset=Oa(n.zOffset,.5),this.attachment=Oa(n.attachment,"bottom-left"),this.showBorder=Oa(n.showBorder,!1),this.borderColor=Oa(n.borderColor,"lightgrey"),this.borderWidth=Oa(n.borderWidth,.15),this.showBackground=Oa(n.showBackground,!1),this.backgroundColor=Oa(n.backgroundColor,"lightgrey"),this.backgroundMargin=Oa(n.backgroundMargin,.5),this.backgroundOpacity=Oa(n.backgroundOpacity,1),this.text=r.text,this.positionCount=o,this.addUniforms({fontTexture:{value:null},xOffset:{value:this.xOffset},yOffset:{value:this.yOffset},zOffset:{value:this.zOffset},ortho:{value:!1},showBorder:{value:this.showBorder},borderColor:{value:new mi(this.borderColor)},borderWidth:{value:this.borderWidth},backgroundColor:{value:new mi(this.backgroundColor)},backgroundOpacity:{value:this.backgroundOpacity}}),this.addAttributes({inputTexCoord:{type:"v2",value:null},inputSize:{type:"f",value:null}}),this.setAttributes(e),this.makeTexture(),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},wireframe:{},isText:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{fontFamily:{uniform:!0},fontStyle:{uniform:!0},fontWeight:{uniform:!0},fontSize:{uniform:!0},sdf:{updateShader:!0,uniform:!0},xOffset:{uniform:!0},yOffset:{uniform:!0},zOffset:{uniform:!0},showBorder:{uniform:!0},borderColor:{uniform:!0},borderWidth:{uniform:!0},backgroundColor:{uniform:!0},backgroundOpacity:{uniform:!0}},t.prototype.parameters,{flatShaded:void 0})},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this);var e=this.texture,i=this.material;i.extensions.derivatives=!0,i.lights=!1,i.uniforms.fontTexture.value=e,i.needsUpdate=!0;var r=this.wireframeMaterial;r.extensions.derivatives=!0,r.lights=!1,r.uniforms.fontTexture.value=e,r.needsUpdate=!0;var n=this.pickingMaterial;n.extensions.derivatives=!0,n.lights=!1,n.uniforms.fontTexture.value=e,n.needsUpdate=!0},e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s=this.text,c=this.geometry.attributes;t.position&&(e=t.position,n=c.position.array,c.position.needsUpdate=!0),t.size&&(i=t.size,o=c.inputSize.array,c.inputSize.needsUpdate=!0),t.color&&(r=t.color,a=c.color.array,c.color.needsUpdate=!0);for(var u,h,l,p,d=this.positionCount,f=0,m=0;m<d;++m)for(h=3*m,p=s[m].length,this.showBackground&&(p+=1),l=0;l<p;++l,++f)for(var g=0;g<4;g++)u=4*f*3+3*g,e&&(n[u]=e[h],n[u+1]=e[h+1],n[u+2]=e[h+2]),i&&(o[4*f+g]=i[m]),r&&(a[u]=r[h],a[u+1]=r[h+1],a[u+2]=r[h+2])},e.prototype.makeTexture=function(){this.textAtlas=function(t){var e=JSON.stringify(t);return void 0===fm[e]&&(fm[e]=new mm(t)),fm[e]}({font:[this.fontFamily],style:this.fontStyle,weight:this.fontWeight,size:this.fontSize,outline:this.sdf?5:0}),this.texture=this.textAtlas.texture},e.prototype.makeMapping=function(){for(var t,e,i,r,n,o,a,s,c=this.textAtlas,u=this.text,h=this.attachment,l=c.lineHeight*this.backgroundMargin*.1-10,p=this.geometry.attributes.inputTexCoord.array,d=this.geometry.attributes.mapping.array,f=this.positionCount,m=0,g=0;g<f;++g){for(r=0,o=(i=u[g]).length,n=0;n<o;++n)r+=(t=c.get(i[n])).w-2*c.outline;for(s=h.startsWith("top")?c.lineHeight/1.25:h.startsWith("middle")?c.lineHeight/2.5:0,a=h.endsWith("right")?r:h.endsWith("center")?r/2:0,a+=c.outline,s+=c.outline,this.showBackground&&(d[(e=2*m*4)+0]=-c.lineHeight/6-a-l,d[e+1]=c.lineHeight-s+l,d[e+2]=-c.lineHeight/6-a-l,d[e+3]=0-s-l,d[e+4]=r+c.lineHeight/6-a+2*c.outline+l,d[e+5]=c.lineHeight-s+l,d[e+6]=r+c.lineHeight/6-a+2*c.outline+l,d[e+7]=0-s-l,p[e+0]=10,p[e+2]=10,p[e+4]=10,p[e+6]=10,m+=1),r=0,n=0;n<o;++n,++m){t=c.get(i[n]),d[(e=2*m*4)+0]=r-a,d[e+1]=t.h-s,d[e+2]=r-a,d[e+3]=0-s,d[e+4]=r+t.w-a,d[e+5]=t.h-s,d[e+6]=r+t.w-a,d[e+7]=0-s;var v=c.width,y=c.height,b=[t.x/v,t.y/y,t.x/v,(t.y+t.h)/y,(t.x+t.w)/v,t.y/y,(t.x+t.w)/v,(t.y+t.h)/y];p.set(b,e),r+=t.w-2*c.outline}}this.geometry.attributes.inputTexCoord.needsUpdate=!0,this.geometry.attributes.mapping.needsUpdate=!0},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.sdf&&(i.SDF=1),i},e.prototype.setUniforms=function(e){!e||void 0===e.fontFamily&&void 0===e.fontStyle&&void 0===e.fontWeight&&void 0===e.fontSize&&void 0===e.sdf||(this.makeTexture(),this.makeMapping(),this.texture.needsUpdate=!0,e.fontTexture=this.texture),t.prototype.setUniforms.call(this,e)},i.wireframe.set=function(t){},i.wireframe.get=function(){return!1},i.isText.get=function(){return!0},i.vertexShader.get=function(){return"SDFFont.vert"},i.fragmentShader.get=function(){return"SDFFont.frag"},Object.defineProperties(e.prototype,i),e}(jf);function vm(t,e){void 0!==t.toArray?t=t.toArray():void 0!==t.x?t=[t.x,t.y,t.z]:void 0!==t.r&&(t=[t.r,t.g,t.b]),e.push.apply(e,t)}var ym=new Me,bm=new Ti,xm=function(t,e){this.name=Oa(t,"shape");var i=e||{};this.aspectRatio=Oa(i.aspectRatio,1.5),this.sphereDetail=Oa(i.sphereDetail,2),this.radialSegments=Oa(i.radialSegments,50),this.disableImpostor=Oa(i.disableImpostor,!1),this.openEnded=Oa(i.openEnded,!1),this.labelParams=Oa(i.labelParams,{}),this.boundingBox=new Ti,this.bufferList=[],this.meshCount=0,this.spherePosition=[],this.sphereColor=[],this.sphereRadius=[],this.sphereName=[],this.ellipsoidPosition=[],this.ellipsoidColor=[],this.ellipsoidRadius=[],this.ellipsoidMajorAxis=[],this.ellipsoidMinorAxis=[],this.ellipsoidName=[],this.cylinderPosition1=[],this.cylinderPosition2=[],this.cylinderColor=[],this.cylinderRadius=[],this.cylinderName=[],this.conePosition1=[],this.conePosition2=[],this.coneColor=[],this.coneRadius=[],this.coneName=[],this.arrowPosition1=[],this.arrowPosition2=[],this.arrowColor=[],this.arrowRadius=[],this.arrowName=[],this.labelPosition=[],this.labelColor=[],this.labelSize=[],this.labelText=[]},_m={center:{},type:{}};xm.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},xm.prototype.addMesh=function(t,e,i,r,n){t=qa(t),e=qa(e),Array.isArray(i)&&(i=Va(i,t.length)),r&&(r=qa(r));var o={position:t,color:e,index:i,normal:r},a=new np(this,Object.assign({serial:this.meshCount,name:n},o)),s=new Lf(Object.assign({picking:a},o));return this.bufferList.push(s),bm.setFromArray(t),this.boundingBox.union(bm),this.meshCount+=1,this},xm.prototype.addSphere=function(t,e,i,r){return vm(t,this.spherePosition),vm(e,this.sphereColor),this.sphereRadius.push(i),this.sphereName.push(r),this.boundingBox.expandByPoint(ym.fromArray(t)),this},xm.prototype.addEllipsoid=function(t,e,i,r,n,o){return vm(t,this.ellipsoidPosition),vm(e,this.ellipsoidColor),this.ellipsoidRadius.push(i),vm(r,this.ellipsoidMajorAxis),vm(n,this.ellipsoidMinorAxis),this.ellipsoidName.push(o),this.boundingBox.expandByPoint(ym.fromArray(t)),this},xm.prototype.addCylinder=function(t,e,i,r,n){return vm(t,this.cylinderPosition1),vm(e,this.cylinderPosition2),vm(i,this.cylinderColor),this.cylinderRadius.push(r),this.cylinderName.push(n),this.boundingBox.expandByPoint(ym.fromArray(t)),this.boundingBox.expandByPoint(ym.fromArray(e)),this},xm.prototype.addCone=function(t,e,i,r,n){return vm(t,this.conePosition1),vm(e,this.conePosition2),vm(i,this.coneColor),this.coneRadius.push(r),this.coneName.push(n),this.boundingBox.expandByPoint(ym.fromArray(t)),this.boundingBox.expandByPoint(ym.fromArray(e)),this},xm.prototype.addArrow=function(t,e,i,r,n){return vm(t,this.arrowPosition1),vm(e,this.arrowPosition2),vm(i,this.arrowColor),this.arrowRadius.push(r),this.arrowName.push(n),this.boundingBox.expandByPoint(ym.fromArray(t)),this.boundingBox.expandByPoint(ym.fromArray(e)),this},xm.prototype.addLabel=function(t,e,i,r){return vm(t,this.labelPosition),vm(e,this.labelColor),this.labelSize.push(i),this.labelText.push(r),this.boundingBox.expandByPoint(ym.fromArray(t)),this},xm.prototype.getBufferList=function(){var t=[];if(this.spherePosition.length){var e=new Vf({position:new Float32Array(this.spherePosition),color:new Float32Array(this.sphereColor),radius:new Float32Array(this.sphereRadius),picking:new op(this)},{sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor});t.push(e)}if(this.ellipsoidPosition.length){var i=new Yf({position:new Float32Array(this.ellipsoidPosition),color:new Float32Array(this.ellipsoidColor),radius:new Float32Array(this.ellipsoidRadius),majorAxis:new Float32Array(this.ellipsoidMajorAxis),minorAxis:new Float32Array(this.ellipsoidMinorAxis),picking:new ip(this)},{sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor});t.push(i)}if(this.cylinderPosition1.length){var r=new nm({position1:new Float32Array(this.cylinderPosition1),position2:new Float32Array(this.cylinderPosition2),color:new Float32Array(this.cylinderColor),color2:new Float32Array(this.cylinderColor),radius:new Float32Array(this.cylinderRadius),picking:new Xl(this)},{radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded});t.push(r)}if(this.conePosition1.length){var n=new hm({position1:new Float32Array(this.conePosition1),position2:new Float32Array(this.conePosition2),color:new Float32Array(this.coneColor),radius:new Float32Array(this.coneRadius),picking:new Jl(this)},{radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded});t.push(n)}if(this.arrowPosition1.length){var o=new pm({position1:new Float32Array(this.arrowPosition1),position2:new Float32Array(this.arrowPosition2),color:new Float32Array(this.arrowColor),radius:new Float32Array(this.arrowRadius),picking:new ql(this)},{aspectRatio:this.aspectRatio,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded});t.push(o)}if(this.labelPosition.length){var a=new gm({position:new Float32Array(this.labelPosition),color:new Float32Array(this.labelColor),size:new Float32Array(this.labelSize),text:this.labelText},this.labelParams);t.push(a)}return this.bufferList.concat(t)},xm.prototype.dispose=function(){this.bufferList.forEach(function(t){t.dispose()}),this.bufferList.length=0,this.spherePosition.length=0,this.sphereColor.length=0,this.sphereRadius.length=0,this.sphereName.length=0,this.ellipsoidPosition.length=0,this.ellipsoidColor.length=0,this.ellipsoidRadius.length=0,this.ellipsoidMajorAxis.length=0,this.ellipsoidMinorAxis.length=0,this.ellipsoidName.length=0,this.cylinderPosition1.length=0,this.cylinderPosition2.length=0,this.cylinderColor.length=0,this.cylinderRadius.length=0,this.cylinderName.length=0,this.conePosition1.length=0,this.conePosition2.length=0,this.coneColor.length=0,this.coneRadius.length=0,this.coneName.length=0,this.arrowPosition1.length=0,this.arrowPosition2.length=0,this.arrowColor.length=0,this.arrowRadius.length=0,this.arrowName.length=0,this.labelPosition.length=0,this.labelColor.length=0,this.labelSize.length=0,this.labelText.length=0},_m.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter()),this._center},_m.type.get=function(){return"Shape"},Object.defineProperties(xm.prototype,_m);var wm=function(t,e,i){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},linewidth:{type:"integer",max:50,min:1,buffer:!0},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:Su.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:Su.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 Yu,this.queue=new Sf(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=Su.getSchemes())};wm.prototype.init=function(t){var e=t||{};this.clipNear=Oa(e.clipNear,0),this.clipRadius=Oa(e.clipRadius,0),this.clipCenter=Oa(e.clipCenter,new Me),this.flatShaded=Oa(e.flatShaded,!1),this.side=Oa(e.side,"double"),this.opacity=Oa(e.opacity,1),this.depthWrite=Oa(e.depthWrite,!0),this.wireframe=Oa(e.wireframe,!1),this.linewidth=Oa(e.linewidth,2),this.setColor(e.color,e),this.colorScheme=Oa(e.colorScheme,"uniform"),this.colorScale=Oa(e.colorScale,""),this.colorReverse=Oa(e.colorReverse,!1),this.colorValue=Oa(e.colorValue,9474192),this.colorDomain=Oa(e.colorDomain,void 0),this.colorMode=Oa(e.colorMode,"hcl"),this.visible=Oa(e.visible,!0),this.quality=Oa(e.quality,void 0),this.roughness=Oa(e.roughness,.4),this.metalness=Oa(e.metalness,0),this.diffuse=Oa(e.diffuse,16777215),this.lazy=Oa(e.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=Oa(e.matrix,new Pe),this.disablePicking=Oa(e.disablePicking,!1);var i=this.parameters;!0===i.sphereDetail&&(i.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===i.radialSegments&&(i.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===i.openEnded&&(i.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===i.disableImpostor&&(i.disableImpostor={type:"boolean",rebuild:!0}),"low"===e.quality?(i.sphereDetail&&(this.sphereDetail=0),i.radialSegments&&(this.radialSegments=5)):"medium"===e.quality?(i.sphereDetail&&(this.sphereDetail=1),i.radialSegments&&(this.radialSegments=10)):"high"===e.quality?(i.sphereDetail&&(this.sphereDetail=2),i.radialSegments&&(this.radialSegments=20)):(i.sphereDetail&&(this.sphereDetail=Oa(e.sphereDetail,1)),i.radialSegments&&(this.radialSegments=Oa(e.radialSegments,10))),i.openEnded&&(this.openEnded=Oa(e.openEnded,!0)),i.disableImpostor&&(this.disableImpostor=Oa(e.disableImpostor,!1))},wm.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)},wm.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,linewidth:this.linewidth,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,matrix:this.matrix,disablePicking:this.disablePicking},t)},wm.prototype.setColor=function(t,e){return Object.keys(Su.getSchemes()).includes(t)?e?e.colorScheme=t:this.setParameters({colorScheme:t}):void 0!==t&&(t=new mi(t).getHex(),e?(e.colorScheme="uniform",e.colorValue=t):this.setParameters({colorScheme:"uniform",colorValue:t})),this},wm.prototype.create=function(){},wm.prototype.update=function(){this.build()},wm.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},wm.prototype.make=function(t,e){xu&&bu.time("Representation.make "+this.type);var i=function(){t?(this.update(t),this.viewer.requestRender(),this.tasks.decrement(),e&&e()):(this.clear(),this.create(),this.manualAttach||this.disposed||(xu&&bu.time("Representation.attach "+this.type),this.attach(function(){xu&&bu.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),e&&e()}.bind(this)))),xu&&bu.timeEnd("Representation.make "+this.type)}.bind(this);this.prepare?this.prepare(i):i()},wm.prototype.attach=function(t){this.setVisibility(this.visible),t()},wm.prototype.setVisibility=function(t,e){if(this.visible=t,this.visible){var i=this.lazyProps,r=i.bufferParams,n=i.what;if(i.build)return i.build=!1,void this.build();(Object.keys(r).length||Object.keys(n).length)&&(i.bufferParams={},i.what={},this.updateParameters(r,n))}return this.bufferList.forEach(function(e){e.setVisibility(t)}),e||this.viewer.requestRender(),this},wm.prototype.setParameters=function(t,e,i){var r=t||{},n=this.parameters;e=e||{},i=i||!1;var o={};for(var a in r)void 0!==r[a]&&void 0!==n[a]&&(n[a].int&&(r[a]=parseInt(r[a])),n[a].float&&(r[a]=parseFloat(r[a])),(r[a]!==this[a]||r[a].equals&&!r[a].equals(this[a]))&&(this[a].set?this[a].set(r[a]):this[a]=r[a],n[a].buffer&&(!0===n[a].buffer?o[a]=r[a]:o[n[a].buffer]=r[a]),n[a].update&&(e[n[a].update]=!0),!n[a].rebuild||"impostor"===n[a].rebuild&&vu&&!this.disableImpostor||(i=!0)));return i?this.build():this.updateParameters(o,e),this},wm.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()},wm.prototype.getParameters=function(){var t=this,e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(function(i){null!==t.parameters[i]&&(e[i]=t[i])}),e},wm.prototype.clear=function(){var t=this;this.bufferList.forEach(function(e){t.viewer.remove(e),e.dispose()}),this.bufferList.length=0,this.viewer.requestRender()},wm.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var Sm=function(t){function e(e,i,r){Array.isArray(e)||(e=[e]),t.call(this,e,i,r),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(r)}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}(wm),Am=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isSurface:{}};return i.isSurface.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Lf);function Mm(t){t.visible=!0}function Pm(t){t.visible=!1}var Tm=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 tn,this.wireframeGroup=new tn,this.pickingGroup=new tn,this.matrix=t.matrix,this.frontMeshes=[],this.backMeshes=[];var e=t,i=new t.constructor;e.makeMaterial(),i.makeMaterial(),i.picking=t.picking,i.geometry=t.geometry,i.wireframeGeometry=t.wireframeGeometry,i.setParameters(t.getParameters()),i.updateShader(),e.setParameters({side:"front"}),i.setParameters({side:"back",opacity:i.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=i},Em={matrix:{},pickable:{}};Em.matrix.set=function(t){If.prototype.setMatrix.call(this,t)},Em.matrix.get=function(){return this.group.matrix.clone()},Em.pickable.get=function(){return!!this.picking&&!this.disablePicking},Tm.prototype.getMesh=function(t){var e,i;return t?(i=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(i=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(i),this.setParameters({side:this.side}),(new tn).add(i,e)},Tm.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},Tm.prototype.getPickingMesh=function(){return this.getMesh(!0)},Tm.prototype.setAttributes=function(t){this.buffer.setAttributes(t)},Tm.prototype.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(Mm),this.backMeshes.forEach(Pm)):"back"===t.side?(this.frontMeshes.forEach(Pm),this.backMeshes.forEach(Mm)):"double"===t.side&&(this.frontMeshes.forEach(Mm),this.backMeshes.forEach(Mm)),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)},Tm.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},Object.defineProperties(Tm.prototype,Em),Tm.prototype.setVisibility=If.prototype.setVisibility,Tu.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}"),Tu.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 Cm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(If),Im=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},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 Ad?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new Me,this.__boxCenter=new Me,this.box=new Ti,this.__box=new Ti,this._position=new Me,this.setBox=function(){this._position.copy(i.translationGroup.position).negate(),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.viewer.signals.ticked.add(this.setBox,this),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"uniform"),i.colorValue=Oa(i.colorValue,14540253),this.isolevelType=Oa(i.isolevelType,"sigma"),this.isolevel=Oa(i.isolevel,2),this.negateIsolevel=Oa(i.negateIsolevel,!1),this.smooth=Oa(i.smooth,0),this.background=Oa(i.background,!1),this.opaqueBack=Oa(i.opaqueBack,!0),this.boxSize=Oa(i.boxSize,0),this.colorVolume=Oa(i.colorVolume,void 0),this.contour=Oa(i.contour,!1),this.useWorker=Oa(i.useWorker,!0),this.wrap=Oa(i.wrap,!1),t.prototype.init.call(this,i),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,i=this;if(this.volume)if(e="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(e*=-1),!this.surface||this.__isolevel!==e||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=e,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var r=function(e){i.surface=e,t()};this.useWorker?this.volume.getSurfaceWorker(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,r):r(this.volume.getSurface(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t();else t()},e.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new Cm(e,this.getBufferParams({wireframe:!1}));else{e.normal=this.surface.getNormal(),e.picking=this.surface.getPicking();var i=new Am(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new Tm(i)}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,i,r){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,i,r),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&(i.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}(wm);function Rm(t,e,i,r){var n=i-t,o=r-e;return Math.sqrt(n*n+o*o)}Tu.add("shader/Point.vert","uniform float nearClip;\nuniform float clipRadius;\nuniform vec3 clipCenter;\nuniform float size;\nuniform float canvasHeight;\nuniform float pixelRatio;\nvarying vec3 vViewPosition;\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\n#include common\nvoid main(){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#endif\n#include begin_vertex\n#include project_vertex\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * pixelRatio * ( ( canvasHeight / 2.0 ) / -mvPosition.z );\n#else\ngl_PointSize = size * pixelRatio;\n#endif\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n#include radiusclip_vertex\n}"),Tu.add("shader/Point.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float nearClip;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\n#ifdef USE_MAP\nif( texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) ).a < 0.5 )\ndiscard;\n#endif\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\n#ifdef USE_MAP\ndiffuseColor *= texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n#endif\n#include color_fragment\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 Lm=function(t){function e(e,i){var r=e||{},n=i||{};r.primitiveId||(r.primitiveId=ph(r.position.length/3)),t.call(this,r,n),this.pointSize=Oa(n.pointSize,1),this.sizeAttenuation=Oa(n.sizeAttenuation,!0),this.sortParticles=Oa(n.sortParticles,!1),this.alphaTest=Oa(n.alphaTest,.5),this.useTexture=Oa(n.useTexture,!1),this.forceTransparent=Oa(n.forceTransparent,!1),this.edgeBleach=Oa(n.edgeBleach,0),this.addUniforms({size:{value:this.pointSize},canvasHeight:{value:1},pixelRatio:{value:1},map:{value:null}})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},isPoint:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{pointSize:{uniform:"size"},sizeAttenuation:{updateShader:!0},sortParticles:{},alphaTest:{updateShader:!0},useTexture:{updateShader:!0},forceTransparent:{},edgeBleach:{uniform:!0}},t.prototype.parameters)},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.makeTexture();var e=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;e.uniforms.map.value=this.tex,e.needsUpdate=!0,i.uniforms.map.value=this.tex,i.needsUpdate=!0,r.uniforms.map.value=this.tex,r.needsUpdate=!0},e.prototype.makeTexture=function(){this.tex&&this.tex.dispose(),this.tex=function(t){for(var e=t||{},i=Oa(e.width,256),r=Oa(e.height,256),n=[i/2,r/2],o=Math.min(i/2,r/2),a=Oa(e.delta,1/(o+1))*o,s=0,c=0,u=new Uint8Array(i*r*4),h=0,l=u.length;h<l;h+=4){var p=1-Dc(o-a,o,Rm(s,c,n[0],n[1]));u[h]=255*p,u[h+1]=255*p,u[h+2]=255*p,u[h+3]=255*p,++s===i&&(s=0,c++)}var d=new Te(u,i,r);return d.needsUpdate=!0,d}({delta:this.edgeBleach})},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.sizeAttenuation&&(i.USE_SIZEATTENUATION=1),this.useTexture&&(i.USE_MAP=1),this.alphaTest>0&&this.alphaTest<=1&&(i.ALPHATEST=this.alphaTest.toPrecision(2)),i},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()},i.isPoint.get=function(){return!0},i.vertexShader.get=function(){return"Point.vert"},i.fragmentShader.get=function(){return"Point.frag"},Object.defineProperties(e.prototype,i),e}(If),Om=function(t){function e(e,i,r){t.call(this,e,i,r),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 Ad?(this.surface=void 0,this.volume=new Pd(e)):(this.surface=e,this.volume=void 0),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"uniform"),i.colorValue=Oa(i.colorValue,14540253),this.thresholdType=Oa(i.thresholdType,"sigma"),this.thresholdMin=Oa(i.thresholdMin,2),this.thresholdMax=Oa(i.thresholdMax,1/0),this.thresholdOut=Oa(i.thresholdOut,!1),this.dotType=Oa(i.dotType,"point"),this.radius=Oa(i.radius,.1),this.scale=Oa(i.scale,1),this.pointSize=Oa(i.pointSize,1),this.sizeAttenuation=Oa(i.sizeAttenuation,!0),this.sortParticles=Oa(i.sortParticles,!1),this.useTexture=Oa(i.useTexture,!1),this.alphaTest=Oa(i.alphaTest,.5),this.forceTransparent=Oa(i.forceTransparent,!1),this.edgeBleach=Oa(i.edgeBleach,0),t.prototype.init.call(this,i),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,i,r=this.volume;"sigma"===this.thresholdType?(e=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,i=this.thresholdMax),r.setFilter(e,i,this.thresholdOut),t.position=r.getDataPosition(),t.color=r.getDataColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=r.getDataSize(this.radius,this.scale),t.picking=r.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 Vf(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Lm(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,i,r){return i=i||{},e&&void 0!==e.thresholdType&&this.volume instanceof Ad&&("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,i.radius=!0,"sphere"!==this.dotType||vu&&!this.disableImpostor||(r=!0)),e&&void 0!==e.radius&&(i.radius=!0,"sphere"!==this.dotType||vu&&!this.disableImpostor||(r=!0)),e&&void 0!==e.scale&&(i.scale=!0,"sphere"!==this.dotType||vu&&!this.disableImpostor||(r=!0)),t.prototype.setParameters.call(this,e,i,r),this},e}(wm);Tu.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}"),Tu.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 Nm=new Uint16Array([0,1,2,1,3,2]),Dm=new Float32Array([0,1,0,0,1,1,1,0]),km=function(t){function e(e,i){var r=e||{},n=i||{};t.call(this,{position:r.position,index:Nm,picking:r.picking},n),this.forceTransparent=!0,this.filter=Oa(n.filter,"nearest");var o=new Te(r.imageData,r.width,r.height);o.flipY=!0,this.tex=o;for(var a=r.imageData.length,s=new Uint8Array(a),c=0;c<a;c+=4){var u=c/4;s[c]=u>>16&255,s[c+1]=u>>8&255,s[c+2]=255&u}var h=new Te(s,r.width,r.height);h.flipY=!0,h.minFilter=At,h.magFilter=At,this.pickingTex=h,this.addUniforms({map:{value:o},pickingMap:{value:h},mapSize:{value:new be(r.width,r.height)}}),this.geometry.addAttribute("uv",new Hi(Dm,2))}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{filter:{updateShader:!0,uniform:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.filter.startsWith("cubic")&&(i.CUBIC_INTERPOLATION=1,this.filter.endsWith("bspline")?i.BSPLINE_FILTER=1:this.filter.endsWith("catmulrom")?i.CATMULROM_FILTER=1:this.filter.endsWith("mitchell")&&(i.MITCHELL_FILTER=1)),i},e.prototype.updateTexture=function(){var t=this.tex;this.filter.startsWith("cubic")?(t.minFilter=At,t.magFilter=At):"linear"===this.filter?(t.minFilter=Tt,t.magFilter=Tt):(t.minFilter=At,t.magFilter=At),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.updateTexture();var e=this.material;e.uniforms.map.value=this.tex,e.blending=R,e.needsUpdate=!0;var i=this.wireframeMaterial;i.uniforms.map.value=this.tex,i.blending=R,i.needsUpdate=!0;var r=this.pickingMaterial;r.uniforms.map.value=this.tex,r.uniforms.pickingMap.value=this.pickingTex,r.blending=R,r.needsUpdate=!0},e.prototype.setUniforms=function(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},i.vertexShader.get=function(){return"Image.vert"},i.fragmentShader.get=function(){return"Image.frag"},Object.defineProperties(e.prototype,i),e}(If),Fm=function(t,e){var i=e||{};this.dimension=Oa(i.dimension,"x"),this.positionType=Oa(i.positionType,"percent"),this.position=Oa(i.position,30),this.thresholdType=Oa(i.thresholdType,"sigma"),this.thresholdMin=Oa(i.thresholdMin,-1/0),this.thresholdMax=Oa(i.thresholdMax,1/0),this.normalize=Oa(i.normalize,!1),this.volume=t};Fm.prototype.getPositionFromCoordinate=function(t){var e,i=this.dimension,r=this.volume,n=r.matrix,o=(new Me).setFromMatrixPosition(n)[i],a=(new Me).setFromMatrixScale(n)[i];return e="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-o)/(e/100)+1)/a)},Fm.prototype.getData=function(t){t=t||{};var e,i=this.volume,r=i.data,n=i.matrix;function o(t){return Math.round(t/100*(e-1))}function a(t,e,r,n){return 3*(r*i.ny*i.nx+e*i.nx+t)+n}e="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var s,c,u,h,l,p=new Float32Array(12),d=new Me,f=0,m=0,g=0,v=i.nx,y=i.ny,b=i.nz;function x(t,e,i,r){d.set(t,e,i).applyMatrix4(n).toArray(p,r)}"x"===this.dimension?(u=o(i.nx),h=i.ny-1,l=i.nz-1,s=i.nz,c=i.ny,v=(f=u)+1,x(u,0,0,0),x(u,h,0,3),x(u,0,l,6),x(u,h,l,9)):"y"===this.dimension?(u=i.nx-1,h=o(i.ny),l=i.nz-1,s=i.nz,c=i.nx,y=(m=h)+1,x(0,h,0,0),x(u,h,0,3),x(0,h,l,6),x(u,h,l,9)):"z"===this.dimension&&(u=i.nx-1,h=i.ny-1,l=o(i.nz),s=i.nx,c=i.ny,b=(g=l)+1,x(0,0,l,0),x(0,h,l,3),x(u,0,l,6),x(u,h,l,9));var _,w,S=0,A=0,M=new Uint8Array(s*c*4),P=new Float32Array(s*c);"sigma"===this.thresholdType?(_=i.getValueForSigma(this.thresholdMin),w=i.getValueForSigma(this.thresholdMax)):(_=this.thresholdMin,w=this.thresholdMax);var T=Object.assign({},t.colorParams,{volume:i});this.normalize&&(T.domain=[0,1]);var E,C,I,R=Su.getScheme(T),L=new Float32Array(3),O=R.getScale();if(this.normalize){E=1/0,C=-1/0;for(var N=m;N<y;++N)for(var D=f;D<v;++D)for(var k=g;k<b;++k){var F=r[a(D,N,k,0)/3];F<E&&(E=F),F>C&&(C=F)}I=C-E}for(var B=m;B<y;++B)for(var z=f;z<v;++z)for(var U=g;U<b;++U){var j=a(z,B,U,0)/3,G=r[j];this.normalize&&(G=(G-E)/I),R.colorToArray(O(G),L),M[S]=Math.round(255*L[0]),M[S+1]=Math.round(255*L[1]),M[S+2]=Math.round(255*L[2]),M[S+3]=G>_&&G<w?255:0,P[A]=j,++A,S+=4}var V=new up(P,i);return{position:p,imageData:M,width:s,height:c,picking:V}};var Bm=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="slice",this.parameters=Object.assign({filter:{type:"select",buffer:!0,options:{nearest:"nearest",linear:"linear","cubic-bspline":"cubic-bspline","cubic-catmulrom":"cubic-catmulrom","cubic-mitchell":"cubic-mitchell"}},positionType:{type:"select",rebuild:!0,options:{percent:"percent",coordinate:"coordinate"}},position:{type:"range",step:.1,max:100,min:1,rebuild:!0},dimension:{type:"select",rebuild:!0,options:{x:"x",y:"y",z:"z"}},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},normalize:{type:"boolean",rebuild:!0}},this.parameters,{flatShaded:null,side:null,wireframe:null,linewidth:null,colorScheme:null,roughness:null,metalness:null,diffuse:null}),this.volume=e,this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=this.volume,r=e||{};r.colorDomain=Oa(r.colorDomain,[i.min,i.max]),r.colorScheme=Oa(r.colorScheme,"value"),r.colorScale=Oa(r.colorScale,"Spectral"),this.colorScheme="value",this.dimension=Oa(r.dimension,"x"),this.filter=Oa(r.filter,"cubic-bspline"),this.positionType=Oa(r.positionType,"percent"),this.position=Oa(r.position,30),this.thresholdType=Oa(r.thresholdType,"sigma"),this.thresholdMin=Oa(r.thresholdMin,-1/0),this.thresholdMax=Oa(r.thresholdMax,1/0),this.normalize=Oa(r.normalize,!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.create=function(){var t=new Fm(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),e=new km(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)},e}(wm),zm=function(t){function e(e,i,r){var n=r||{};if(t.call(this,e,i,n),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:jp.types},radius:{type:"number",precision:3,max:10,min:.001},scale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new cu(n.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){var o={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach(function(t){o[t]=t}),this.parameters.assembly={type:"select",options:o,rebuild:!0}}else this.parameters.assembly=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultScale:{}};return i.defaultScale.get=function(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}},e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"element"),this.radius=Oa(i.radius,"vdw"),this.scale=Oa(i.scale,1),this.assembly=Oa(i.assembly,"default"),this.defaultAssembly=Oa(i.defaultAssembly,""),"auto"===i.quality&&(i.quality=this.getQuality()),t.prototype.init.call(this,i),this.selection.signals.stringChanged.add(function(){this.build()},this),this.build()},e.prototype.getAssembly=function(){var t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]},e.prototype.getQuality=function(){var t,e=this.structureView,i=this.getAssembly();return t=i?i.getAtomCount(e):e.atomCount,mu&&(t*=4),e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=this.getAssembly();if(t)t.partList.forEach(function(t,e){var i=t.getView(this.structureView);if(0!==i.atomCount){var r=this.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),this.dataList.push(r))}},this);else{var e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}},e.prototype.createData=function(){console.error("createData not implemented")},e.prototype.update=function(t){!this.lazy||this.visible?this.dataList.forEach(function(e){e.bufferList.length>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,i,r){return i=i||{},e&&void 0!==e.radiusType&&("size"===e.radiusType?this.radius=1:this.radius=e.radiusType,delete e.radiusType,i.radius=!0,vu&&!this.disableImpostor||(r=!0)),e&&void 0!==e.radius&&(i.radius=!0,vu&&!this.disableImpostor||(r=!0)),e&&void 0!==e.scale&&(i.radius=!0,vu&&!this.disableImpostor||(r=!0)),e&&void 0!==e.defaultAssembly&&(r=!0),t.prototype.setParameters.call(this,e,i,r),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,i=this.bufferList;this.dataList.forEach(function(t){t.bufferList.forEach(function(r){i.push(r),e.add(r,t.instanceList)})}),this.setVisibility(this.visible),t()},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,i),e}(wm),Um=function(t){function e(e,i){var r=4*(e.position1.length/3);t.call(this,{position:new Float32Array(3*r),color:new Float32Array(3*r)},i),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s=this.geometry.attributes;t.position1&&t.position2&&(e=t.position1,i=t.position2,o=s.position.array,s.position.needsUpdate=!0),t.color&&t.color2&&(r=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;x<b;x++)u=3*x,c=4*x*3,e&&i&&(d=e[u],f=e[u+1],m=e[u+2],h=(d+(g=i[u]))/2,l=(f+(v=i[u+1]))/2,p=(m+(y=i[u+2]))/2,o[c]=d,o[c+1]=f,o[c+2]=m,o[c+3]=h,o[c+4]=l,o[c+5]=p,o[c+6]=h,o[c+7]=l,o[c+8]=p,o[c+9]=g,o[c+10]=v,o[c+11]=y),r&&n&&(a[c]=a[c+3]=r[u],a[c+1]=a[c+4]=r[u+1],a[c+2]=a[c+5]=r[u+2],a[c+6]=a[c+9]=n[u],a[c+7]=a[c+10]=n[u+1],a[c+8]=a[c+11]=n[u+2])},i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(If),jm=function(t){function e(e,i,r){t.call(this,e.structure,i,r),this.type="trajectory",this.parameters=Object.assign({drawLine:{type:"boolean",rebuild:!0},drawCylinder:{type:"boolean",rebuild:!0},drawPoint:{type:"boolean",rebuild:!0},drawSphere:{type:"boolean",rebuild:!0},linewidth:{type:"integer",max:20,min:1,rebuild:!0},pointSize:{type:"integer",max:20,min:1,rebuild:!0},sizeAttenuation:{type:"boolean",rebuild:!0},sort:{type:"boolean",rebuild:!0}},this.parameters),this.manualAttach=!0,this.trajectory=e,this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"uniform"),i.colorValue=Oa(i.colorValue,14540253),this.drawLine=Oa(i.drawLine,!0),this.drawCylinder=Oa(i.drawCylinder,!1),this.drawPoint=Oa(i.drawPoint,!1),this.drawSphere=Oa(i.drawSphere,!1),this.pointSize=Oa(i.pointSize,1),this.sizeAttenuation=Oa(i.sizeAttenuation,!1),this.sort=Oa(i.sort,!0),t.prototype.init.call(this,i)},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){t()},e.prototype.create=function(){if(0!==this.atomSet.atomCount){var t=this,e=this.atomSet.atoms[0].index;this.trajectory.getPath(e,function(e){var i=e.length/3,r=new mi(t.colorValue);if(t.drawSphere){var n=new Vf({position:e,color:lh(i,r.r,r.g,r.b),radius:hh(i,.2)},t.getBufferParams({sphereDetail:t.sphereDetail,dullInterior:!0,disableImpostor:t.disableImpostor}));t.bufferList.push(n)}if(t.drawCylinder){var o=new nm({position1:e.subarray(0,-3),position2:e.subarray(3),color:lh(i-1,r.r,r.g,r.b),color2:lh(i-1,r.r,r.g,r.b),radius:hh(i,.05)},t.getBufferParams({openEnded:!1,radialSegments:t.radialSegments,disableImpostor:t.disableImpostor,dullInterior:!0}));t.bufferList.push(o)}if(t.drawPoint){var a=new Lm({position:e,color:lh(i,r.r,r.g,r.b)},t.getBufferParams({pointSize:t.pointSize,sizeAttenuation:t.sizeAttenuation,sort:t.sort}));t.bufferList.push(a)}if(t.drawLine){var s=new Um({position1:e.subarray(0,-3),position2:e.subarray(3),color:lh(i-1,r.r,r.g,r.b),color2:lh(i-1,r.r,r.g,r.b)},t.getBufferParams());t.bufferList.push(s)}t.attach()})}},e}(zm);function Gm(t){bu.error("makeRepresentation: representation type "+t+" unknown")}var Vm=0,$m=new Pe,Hm=new Me,Wm=function(t,e){Object.defineProperty(this,"id",{value:Vm++});var i=e||{};this.name=i.name,this.uuid=Ic(),this.visible=void 0===i.visible||i.visible,this.signals={representationAdded:new jc,representationRemoved:new jc,visibilityChanged:new jc,matrixChanged:new jc,statusChanged:new jc,nameChanged:new jc,disposed:new jc},this.stage=t,this.viewer=t.viewer,this.reprList=[],this.annotationList=[],this.matrix=new Pe,this.position=new Me,this.quaternion=new Ae,this.scale=new Me(1,1,1),this.transform=new Pe,this.controls=new Al(this)},Xm={type:{}};Xm.type.get=function(){return"component"},Wm.prototype.setPosition=function(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this},Wm.prototype.setRotation=function(t){if(Array.isArray(t))if(3===t.length){var e=(new Ni).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof Ni?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this},Wm.prototype.setScale=function(t){return this.scale.set(t,t,t),this.updateMatrix(),this},Wm.prototype.setTransform=function(t){return this.transform.copy(t),this.updateMatrix(),this},Wm.prototype.updateMatrix=function(){var t=this,e=this.getCenterUntransformed(Hm);this.matrix.makeTranslation(-e.x,-e.y,-e.z),$m.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply($m),$m.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply($m);var i=this.position;$m.makeTranslation(i.x+e.x,i.y+e.y,i.z+e.z),this.matrix.premultiply($m),this.matrix.premultiply(this.transform),this.reprList.forEach(function(e){e.setParameters({matrix:t.matrix})}),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)},Wm.prototype.addAnnotation=function(t,e,i){var r=new xl(this,t,e,i);return this.annotationList.push(r),r},Wm.prototype.removeAnnotation=function(t){var e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())},Wm.prototype.removeAllAnnotations=function(){this.annotationList.forEach(function(t){t.dispose()}),this.annotationList.length=0},Wm.prototype.addRepresentation=function(t,e,i){var r=i||{},n=this.stage.getParameters();r.matrix=this.matrix.clone(),r.quality=r.quality||n.quality,r.disableImpostor=Oa(r.disableImpostor,!n.impostor),r.useWorker=Oa(r.useWorker,n.workerDefault),r.visible=Oa(r.visible,!0);var o=Object.assign({},r,{visible:this.visible&&r.visible}),a=function(t,e,i,r){var n;if(xu&&bu.time("makeRepresentation "+t),e instanceof _f){if(!(n=Mu.get(t)))return void Gm(t)}else if(e instanceof _d)if("surface"===t)n=Im;else{if("dot"!==t)return void Gm(t);n=Om}else if(e instanceof Ad)if("surface"===t)n=Im;else if("dot"===t)n=Om;else{if("slice"!==t)return void Gm(t);n=Bm}else if(e instanceof Pf)n=jm;else if(e instanceof xm)n=Sm,e=e.getBufferList();else{if("buffer"!==t)return void bu.error("makeRepresentation: object "+e+" unknown");n=Sm}var o=new n(e,i,r);return xu&&bu.timeEnd("makeRepresentation "+t),o}(t,e,this.viewer,o),s=this.__getRepresentationComponent(a,r);return this.reprList.push(s),this.signals.representationAdded.dispatch(s),s},Wm.prototype.addBufferRepresentation=function(t,e){return Wm.prototype.addRepresentation.call(this,"buffer",t,e)},Wm.prototype.hasRepresentation=function(t){return-1!==this.reprList.indexOf(t)},Wm.prototype.removeRepresentation=function(t){var e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))},Wm.prototype.updateRepresentations=function(t){this.reprList.forEach(function(e){e.update(t)}),this.stage.viewer.requestRender()},Wm.prototype.removeAllRepresentations=function(){this.reprList.slice(0).forEach(function(t){t.dispose()})},Wm.prototype.dispose=function(){this.removeAllAnnotations(),this.removeAllRepresentations(),delete this.annotationList,delete this.reprList,this.signals.disposed.dispatch()},Wm.prototype.setVisibility=function(t){return this.visible=t,this.eachRepresentation(function(t){t.updateVisibility()}),this.annotationList.forEach(function(t){t.updateVisibility()}),this.signals.visibilityChanged.dispatch(t),this},Wm.prototype.setStatus=function(t){return this.status=t,this.signals.statusChanged.dispatch(t),this},Wm.prototype.setName=function(t){return this.name=t,this.signals.nameChanged.dispatch(t),this},Wm.prototype.getBox=function(){return(t=this).getBoxUntransformed.apply(t,arguments).clone().applyMatrix4(this.matrix);var t},Wm.prototype.getCenter=function(){return(t=this).getCenterUntransformed.apply(t,arguments).clone().applyMatrix4(this.matrix);var t},Wm.prototype.getZoom=function(){return this.stage.getZoomForBox((t=this).getBox.apply(t,arguments));var t},Wm.prototype.getBoxUntransformed=function(){},Wm.prototype.getCenterUntransformed=function(){return this.getBoxUntransformed().getCenter()},Wm.prototype.autoView=function(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),Oa(t,0))},Wm.prototype.eachRepresentation=function(t){this.reprList.forEach(t)},Object.defineProperties(Wm.prototype,Xm),Wm.prototype.__getRepresentationComponent=function(t,e){return new qm(this.stage,t,e,this)};var qm=function(t){function e(e,i,r,n){var o=r||{};o.name=Oa(o.name,i.type),t.call(this,e,o),this.signals=Object.assign(this.signals,{parametersChanged:new jc}),this.parent=n,this.setRepresentation(i)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"representation"},e.prototype.getType=function(){return this.repr.type},e.prototype.setRepresentation=function(t){this.disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()},e.prototype.addRepresentation=function(){},e.prototype.removeRepresentation=function(){},e.prototype.hasRepresentation=function(){},e.prototype.disposeRepresentation=function(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())},e.prototype.dispose=function(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this.disposeRepresentation(),this.signals.disposed.dispatch())},e.prototype.setVisibility=function(t){return this.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.visible),this},e.prototype.getVisibility=function(){return this.parent?this.parent.visible&&this.visible:this.visible},e.prototype.toggleVisibility=function(){return this.setVisibility(!this.visible)},e.prototype.updateVisibility=function(){this.repr.setVisibility(this.getVisibility())},e.prototype.update=function(t){return this.repr.update(t),this},e.prototype.build=function(t){return this.repr.build(t),this},e.prototype.setSelection=function(t){return this.repr.setSelection(t),this},e.prototype.setParameters=function(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this},e.prototype.getParameters=function(){return this.repr.getParameters()},e.prototype.setColor=function(t){return this.repr.setColor(t),this},e.prototype.getCenter=function(){},e.prototype.getZoom=function(){},e.prototype.getBox=function(){},Object.defineProperties(e.prototype,i),e}(Wm),Ym=function(t){this.list=t||[];for(var e=this.list.length,i=0;i<e;++i){this.list[i].signals.disposed.add(this._remove,this)}};Ym.prototype._remove=function(t){var e=this.list.indexOf(t);-1!==e&&this.list.splice(e,1)},Ym.prototype._invoke=function(t,e){for(var i=this.list.length,r=0;r<i;++r){var n=this.list[r],o=n[t];"function"===typeof o&&o.apply(n,e)}return this},Ym.prototype.setVisibility=function(t){return this._invoke("setVisibility",[t])},Ym.prototype.setSelection=function(t){return this._invoke("setSelection",[t])},Ym.prototype.dispose=function(){return this._invoke("dispose")};var Zm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.addRepresentation=function(t,e){return this._invoke("addRepresentation",[t,e])},e.prototype.autoView=function(t){return this._invoke("autoView",[t])},e}(Ym),Km=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setParameters=function(t){return this._invoke("setParameters",[t])},e.prototype.setColor=function(t){return this._invoke("setColor",[t])},e}(Ym);function Qm(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}var Jm=new Me,tg=function(t,e){if(this.signals={parametersChanged:new jc,fullscreenChanged:new jc,componentAdded:new jc,componentRemoved:new jc,clicked:new jc,hovered:new jc},this.tasks=new Yu,this.compList=[],this.defaultFileParams={},this.viewer=new Th(t),this.viewer.renderer){this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:2+(parseInt(this.viewer.container.style.zIndex)||0),pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),document.body.appendChild(this.tooltip),this.mouseObserver=new Ch(this.viewer.renderer.domElement),this.viewerControls=new Kh(this),this.trackballControls=new Bh(this),this.pickingControls=new Gh(this),this.animationControls=new hl(this),this.mouseControls=new ml(this),this.pickingBehavior=new gl(this),this.mouseBehavior=new vl(this),this.animationBehavior=new yl(this),this.keyBehavior=new bl(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0);var i=Object.assign({impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,fogNear:50,fogFar:100,cameraFov:40,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"},e);this.parameters={backgroundColor:{type:"color"},quality:{type:"select",options:{auto:"auto",low:"low",medium:"medium",high:"high"}},sampleLevel:{type:"range",step:1,max:5,min:-1},impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:{type:"number",precision:1,max:10,min:0},zoomSpeed:{type:"number",precision:1,max:10,min:0},panSpeed:{type:"number",precision:1,max:10,min:0},clipNear:{type:"range",step:1,max:100,min:0},clipFar:{type:"range",step:1,max:100,min:0},clipDist:{type:"integer",max:200,min:0},fogNear:{type:"range",step:1,max:100,min:0},fogFar:{type:"range",step:1,max:100,min:0},cameraType:{type:"select",options:{perspective:"perspective",orthographic:"orthographic"}},cameraFov:{type:"range",step:1,max:120,min:15},lightColor:{type:"color"},lightIntensity:{type:"number",precision:2,max:10,min:0},ambientColor:{type:"color"},ambientIntensity:{type:"number",precision:2,max:10,min:0},hoverTimeout:{type:"integer",max:1e4,min:-1},tooltip:{type:"boolean"},mousePreset:{type:"select",options:{default:"default",pymol:"pymol",coot:"coot"}}},this.setParameters(i),this.viewer.animate()}};tg.prototype.setParameters=function(t){var e=Object.assign({},t),i=this.parameters,r=this.viewer,n=this.trackballControls;for(var o in e)void 0!==e[o]&&i[o]&&(i[o].int&&(e[o]=parseInt(e[o])),i[o].float&&(e[o]=parseFloat(e[o])),i[o].value=e[o]);return void 0!==e.quality&&this.setQuality(e.quality),void 0!==e.impostor&&this.setImpostor(e.impostor),void 0!==e.rotateSpeed&&(n.rotateSpeed=e.rotateSpeed),void 0!==e.zoomSpeed&&(n.zoomSpeed=e.zoomSpeed),void 0!==e.panSpeed&&(n.panSpeed=e.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(e.mousePreset),this.mouseObserver.setParameters({hoverTimeout:e.hoverTimeout}),r.setClip(e.clipNear,e.clipFar,e.clipDist),r.setFog(void 0,e.fogNear,e.fogFar),r.setCamera(e.cameraType,e.cameraFov),r.setSampling(e.sampleLevel),r.setBackground(e.backgroundColor),r.setLight(e.lightColor,e.lightIntensity,e.ambientColor,e.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this},tg.prototype.getParameters=function(){var t={};for(var e in this.parameters)t[e]=this.parameters[e].value;return t},tg.prototype.defaultFileRepresentation=function(t){if("structure"===t.type){var e,i,r;t.setSelection("/0");var n=t.structure;if(n.biomolDict.BU1){var o=n.biomolDict.BU1;e=o.getAtomCount(n),i=o.getResidueCount(n),r=o.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=n.getModelProxy(0).atomCount,i=n.getModelProxy(0).residueCount,r=1;var a=e;mu&&(a*=4);var s=n.atomStore.count/n.residueStore.count<2;s&&(a*=10);var c="chainname",u="RdYlBu",h=!1;if(1===n.getChainnameCount("polymer and /0")&&(c="residueindex",u="spectral",h=!0),xu&&console.log(a,e,r,s),i/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&a>15e3||a>7e5){var l=Math.min(1.5,Math.max(.1,2e3/(a/r)));s&&(l=Math.min(l,.15)),t.addRepresentation("surface",{sele:"polymer",surfaceType:"sas",probeRadius:1.4,scaleFactor:l,colorScheme:c,colorScale:u,colorReverse:h,useWorker:!1})}else a>25e4?t.addRepresentation("backbone",{lineOnly:!0,colorScheme:c,colorScale:u,colorReverse:h}):a>1e5?t.addRepresentation("backbone",{quality:"low",disableImpostor:!0,colorScheme:c,colorScale:u,colorReverse:h,scale:2}):a>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,scale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:u,colorReverse:h,scale:.7,aspectRatio:5,quality:"auto"}),a<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:u,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else"surface"!==t.type&&"volume"!==t.type||t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},tg.prototype.loadFile=function(t,e){var i=Object.assign({},this.defaultFileParams,e),r=new Wm(this,i);r.name=ka(t).name,this.addComponent(r);var n=this.tasks;n.increment();var o=function(t){return this.removeComponent(r),"script"===(r=this.addComponentFromObject(t,i)).type?r.run():i.defaultRepresentation&&this.defaultFileRepresentation(r),n.decrement(),r}.bind(this);return("dcd"===Oa(i.ext,ka(t).ext)?Promise.reject(new Error("loadFile: ext 'dcd' must be loaded into a structure component")):Vu(t,i)).then(o,function(t){throw r.setStatus(t),n.decrement(),t})},tg.prototype.addComponent=function(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):bu.warn("Stage.addComponent: no component given")},tg.prototype.addComponentFromObject=function(t,e){var i=Cu.get(t.type);if(i){var r=new i(this,t,e);return this.addComponent(r),r}bu.warn("no component for object type",t.type)},tg.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},tg.prototype.removeAllComponents=function(t){this.compList.slice().forEach(function(e){t&&e.type!==t||this.removeComponent(e)},this)},tg.prototype.handleResize=function(){this.viewer.handleResize()},tg.prototype.setSize=function(t,e){var i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())},tg.prototype.toggleFullscreen=function(t){if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var e=this;t=t||this.viewer.container,this.lastFullscreenElement=t,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width,t.dataset.normalHeight=t.style.height,t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout(function(){e.handleResize()},100))}else bu.log("fullscreen mode (currently) not possible");function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&e.lastFullscreenElement){var t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth,t.style.height=t.dataset.normalHeight,document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}},tg.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},tg.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},tg.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},tg.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},tg.prototype.setFocus=function(t){var e=Rc(t/2,0,49.9),i=100-e,r=(i-e)/2;this.setParameters({clipNear:e,clipFar:i,fogNear:Lc(i-r),fogFar:Lc(i+r)})},tg.prototype.getZoomForBox=function(t){var e=t.getSize(Jm),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z),n=i+Math.sqrt(r),o=is(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=s<a?1:a/s;return n=Math.abs(.5*n/c/Math.sin(o/2)),-(n+=this.parameters.clipDist.value)},tg.prototype.getBox=function(){return this.viewer.boundingBox},tg.prototype.getZoom=function(){return this.getZoomForBox(this.getBox())},tg.prototype.getCenter=function(t){return this.getBox().getCenter(t)},tg.prototype.autoView=function(t){this.animationControls.zoomMove(this.getCenter(),this.getZoom(),Oa(t,0))},tg.prototype.makeImage=function(t){var e=this.viewer,i=this.tasks;return new Promise(function(r,n){i.onZeroOnce(function(){i.increment(),e.makeImage(t).then(function(t){i.decrement(),r(t)}).catch(function(t){i.decrement(),n(t)})})})},tg.prototype.setImpostor=function(t){this.parameters.impostor.value=t;var e=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(i){if("script"!==i.type&&e.includes(i.getType())){var r=i.getParameters();r.disableImpostor=!t,i.build(r)}})},tg.prototype.setQuality=function(t){this.parameters.quality.value=t;var e=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(r){if("script"!==r.type){var n=r.getParameters();if(!e.includes(r.getType())){if(!i.includes(r.getType()))return;if(!n.disableImpostor)return void(r.repr.quality=t)}n.quality=t,r.build(n)}})},tg.prototype.eachComponent=function(t,e){this.compList.slice().forEach(function(i,r){e&&i.type!==e||t(i,r)})},tg.prototype.eachRepresentation=function(t,e){this.eachComponent(function(e){e.reprList.slice().forEach(function(i){t(i,e)})},e)},tg.prototype.getComponentsByName=function(t,e){var i=[];return this.eachComponent(function(e){(void 0===t||Qm(t,e))&&i.push(e)},e),new Zm(i)},tg.prototype.getComponentsByObject=function(t){var e=[];return this.eachComponent(function(i){i[i.type]===t&&e.push(i)}),new Zm(e)},tg.prototype.getRepresentationsByName=function(t,e){var i,r;"object"!==typeof t||t instanceof RegExp?(i=void 0,r=t):(i=t.comp,r=t.repr);var n=[];return this.eachRepresentation(function(t,e){(void 0===i||Qm(i,e))&&(void 0===r||Qm(r,t))&&n.push(t)},e),new Km(n)},tg.prototype.getAnythingByName=function(t){var e=this.getComponentsByName(t).list,i=this.getRepresentationsByName(t).list;return new Ym(e.concat(i))},tg.prototype.dispose=function(){this.tasks.dispose()};var eg=[[4,0,-2,-1,-2,0,-2,-1,-1,-1,-1,-2,-1,-1,-1,1,0,0,-3,-2],[0,9,-3,-4,-2,-3,-3,-1,-3,-1,-1,-3,-3,-3,-3,-1,-1,-1,-2,-2],[-2,-3,6,2,-3,-1,-1,-3,-1,-4,-3,1,-1,0,-2,0,-1,-3,-4,-3],[-1,-4,2,5,-3,-2,0,-3,1,-3,-2,0,-1,2,0,0,-1,-2,-3,-2],[-2,-2,-3,-3,6,-3,-1,0,-3,0,0,-3,-4,-3,-3,-2,-2,-1,1,3],[0,-3,-1,-2,-3,6,-2,-4,-2,-4,-3,0,-2,-2,-2,0,-2,-3,-2,-3],[-2,-3,-1,0,-1,-2,8,-3,-1,-3,-2,1,-2,0,0,-1,-2,-3,-2,2],[-1,-1,-3,-3,0,-4,-3,4,-3,2,1,-3,-3,-3,-3,-2,-1,3,-3,-1],[-1,-3,-1,1,-3,-2,-1,-3,5,-2,-1,0,-1,1,2,0,-1,-2,-3,-2],[-1,-1,-4,-3,0,-4,-3,2,-2,4,2,-3,-3,-2,-2,-2,-1,1,-2,-1],[-1,-1,-3,-2,0,-3,-2,1,-1,2,5,-2,-2,0,-1,-1,-1,1,-1,-1],[-2,-3,1,0,-3,0,1,-3,0,-3,-2,6,-2,0,0,1,0,-3,-4,-2],[-1,-3,-1,-1,-4,-2,-2,-3,-1,-3,-2,-2,7,-1,-2,-1,-1,-2,-4,-3],[-1,-3,0,2,-3,-2,0,-3,1,-2,0,0,-1,5,1,0,-1,-2,-2,-1],[-1,-3,-2,0,-3,-2,0,-3,2,-2,-1,0,-2,1,5,-1,-1,-3,-3,-2],[1,-1,0,0,-2,0,-1,-2,0,-2,-1,1,-1,0,-1,4,1,-2,-3,-2],[0,-1,-1,-1,-2,-2,-2,-1,-1,-1,-1,0,-1,-1,-1,1,5,0,-2,-2],[0,-1,-3,-2,-1,-3,-3,3,-2,1,1,-3,-2,-2,-3,-2,0,4,-3,-1],[-3,-2,-4,-3,1,-2,-2,-3,-3,-2,-1,-4,-4,-2,-3,-3,-2,-3,11,2],[-2,-2,-3,-2,3,-3,2,-1,-2,-1,-1,-2,-3,-1,-2,-2,-2,-1,2,7]];function ig(t,e){var i,r=0,n={};return e.forEach(function(e){i=0;var o={};e.forEach(function(e){o[t[i++]]=e}),n[t[r++]]=o}),n}var rg={blosum62:ig("ARNDCQEGHILKMFPSTWYVBZ?",[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1]]),blosum62x:ig("ACDEFGHIKLMNPQRSTVWY",eg)},ng=function(t,e,i,r,n){this.seq1=t,this.seq2=e,this.gapPenalty=i||-10,this.gapExtensionPenalty=r||-1,this.substMatrix=n||"blosum62",this.substMatrix&&(this.substMatrix=rg[this.substMatrix])};ng.prototype.initMatrices=function(){var t,e;for(this.n=this.seq1.length,this.m=this.seq2.length,this.score=void 0,this.ali="",this.S=[],this.V=[],this.H=[],t=0;t<=this.n;++t)for(this.S[t]=[],this.V[t]=[],this.H[t]=[],e=0;e<=this.m;++e)this.S[t][e]=0,this.V[t][e]=0,this.H[t][e]=0;for(t=0;t<=this.n;++t)this.S[t][0]=this.gap(0),this.H[t][0]=-1/0;for(e=0;e<=this.m;++e)this.S[0][e]=this.gap(0),this.V[0][e]=-1/0;this.S[0][0]=0},ng.prototype.gap=function(t){return this.gapPenalty+t*this.gapExtensionPenalty},ng.prototype.makeScoreFn=function(){var t,e,i=this.seq1,r=this.seq2,n=this.substMatrix;return n?function(o,a){t=i[o],e=r[a];try{return n[t][e]}catch(s){return-4}}:(bu.warn("Alignment: no subst matrix"),function(n,o){return t=i[n],e=r[o],t===e?5:-3})},ng.prototype.calc=function(){xu&&bu.time("Alignment.calc"),this.initMatrices();var t,e,i,r,n,o,a,s=this.gap(0),c=this.makeScoreFn(),u=this.gapExtensionPenalty,h=this.V,l=this.H,p=this.S,d=this.n,f=this.m;for(o=1;o<=d;++o)for(e=p[o-1],t=h[o-1],i=h[o],r=l[o],n=p[o],a=1;a<=f;++a)i[a]=Math.max(e[a]+s,t[a]+u),r[a]=Math.max(n[a-1]+s,r[a-1]+u),n[a]=Math.max(e[a-1]+c(o-1,a-1),i[a],r[a]);xu&&bu.timeEnd("Alignment.calc"),xu&&bu.log(this.S,this.V,this.H)},ng.prototype.trace=function(){xu&&bu.time("Alignment.trace"),this.ali1="",this.ali2="";var t,e=this.makeScoreFn(),i=this.n,r=this.m;for(this.S[i][r]>=this.V[i][r]?(t="S",this.score=this.S[i][r]):this.V[i][r]>=this.H[i][r]?(t="V",this.score=this.V[i][r]):(t="H",this.score=this.H[i][r]),xu&&bu.log("Alignment: SCORE",this.score),xu&&bu.log("Alignment: S, V, H",this.S[i][r],this.V[i][r],this.H[i][r]);i>0&&r>0;)"S"===t?this.S[i][r]===this.S[i-1][r-1]+e(i-1,r-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--i,--r,t="S"):this.S[i][r]===this.V[i][r]?t="V":this.S[i][r]===this.H[i][r]?t="H":(--i,--r):"V"===t?this.V[i][r]===this.V[i-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,t="V"):this.V[i][r]===this.S[i-1][r]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,t="S"):--i:"H"===t?this.H[i][r]===this.H[i][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,t="H"):this.H[i][r]===this.S[i][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,t="S"):--r:bu.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;xu&&bu.timeEnd("Alignment.trace"),xu&&bu.log([this.ali1,this.ali2])};var og=function(t){function e(e){var i=this;t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=Oa(e.reverse,!0)),this.scalePerModel={},this.structure.eachModel(function(t){i.domain=[t.atomOffset,t.atomEnd],i.scalePerModel[t.index]=i.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}(Bc);Su.add("atomindex",og);var ag=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="OrRd"),!e.domain){var i,r=1/0,n=-1/0;e.sele&&(i=new cu(e.sele)),this.structure.eachAtom(function(t){var e=t.bfactor;r=Math.min(r,e),n=Math.max(n,e)},i),this.domain=[r,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}(Bc);Su.add("bfactor",ag);var sg=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var i={},r={};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],i[t.index]=n,r[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=i[t.modelIndex];return r[t.modelIndex](e[t.chainid])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("chainid",sg);var cg=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="Spectral"),e.domain){var i=this.getScale();this.atomColor=function(t){return i(t.chainIndex)}}else{var r={};this.structure.eachModel(function(t){this.domain=[t.chainOffset,t.chainEnd],r[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){return r[t.modelIndex](t.chainIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("chainindex",cg);var ug=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var i={},r={};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],i[t.index]=n,r[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=i[t.modelIndex];return r[t.modelIndex](e[t.chainname])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("chainname",ug);var hg=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 i=e.structure.validation||{};this.rsrzDict=i.rsrzDict||{},this.rsccDict=i.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 i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);var r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192},e}(Bc);Su.add("densityfit",hg);var lg={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}},pg=12,dg=1.04,fg=.25;var mg=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rwb"),e.domain||(this.domain=[-.5,0,.5]);var i=this.getScale();var r=this.structure,n=new Float32Array(r.atomCount),o=[],a=[];r.eachAtom(function(t){var e;if(n[t.index]=((e=t).isProtein()&&(lg[e.resname]&&lg[e.resname][e.atomname]||lg.backbone[e.atomname])||0)*t.occupancy,"N"===t.atomname){var i=function(t,e){e=e||new Me;var i=!1,r=!1,n=!1;return e.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom(function(t){if(!i)return"H"===t.atomname?(e.set(t),void(i=!0)):void(r||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,e.sub(t)):(e.sub(t),r=!0))}),i?e:r&&n?(e.normalize(),e.multiplyScalar(dg),e.add(t),e):void 0}(t);void 0!==i&&(o.push(i),a.push(fg*t.occupancy))}});var s=this.structure.getBoundingBox();s.expandByScalar(dg);var c=function(t){for(var e=t.length,i=new Float32Array(e),r=new Float32Array(e),n=new Float32Array(e),o=0;o<t.length;o++){var a=t[o];i[o]=a.x,r[o]=a.y,n[o]=a.z}return{x:i,y:r,z:n,count:e}}(o),u=new hd(c,s),h=new hd(this.structure.atomStore,s),l=this.atomProxy,p=new Me,d=pg*pg;this.positionColor=function(t){for(var e=0,r=h.within(t.x,t.y,t.z,pg),o=0;o<r.length;o++){var s=r[o],f=n[s];if(0!==f){l.index=s,p.x=t.x-l.x,p.y=t.y-l.y,p.z=t.z-l.z;var m=p.lengthSq();m<d&&(e+=f/m)}}for(var g=u.within(t.x,t.y,t.z,pg),v=0;v<g.length;v++){var y=g[v];p.x=t.x-c.x[y],p.y=t.y-c.y[y],p.z=t.z-c.z[y];var b=p.lengthSq();b<d&&(e+=a[y]/b)}return i(e)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("electrostatic",mg);var gg={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120},vg=function(t){function e(e){var i=e||{};i.value=Oa(i.value,gg.C),t.call(this,i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.element;return"C"===e?this.value:gg[e]||16777215},e}(Bc);Su.add("element",vg);var yg=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral"),e.domain||(this.domain=[0,this.structure.entityList.length-1]);var i=this.getScale();this.atomColor=function(t){return i(t.entityIndex)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("entityindex",yg);var 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.atomColor=function(t){var e=t.entity;switch(e?e.entityType:void 0){case dp:return 8374655;case fp:return 16629894;case mp:return 12496596;case gp:return 3697840;default:return 16777113}},e}(Bc);Su.add("entitytype",bg);var xg=function(t){function e(e){t.call(this,e);var i=e.structure.validation||{};this.geoAtomDict=i.geoAtomDict||{},this.geoDict=i.geoDict||{}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e,i=t.resno;t.inscode&&(i+="^"+t.inscode),t.chainname&&(i+=":"+t.chainname),i+="/"+t.modelIndex;var r,n=this.geoAtomDict[i];if(void 0!==n){var o=n[t.atomname]||0;r=o,e=16843009*((r=(858993459&(r-=r>>1&1431655765))+(r>>2&858993459))+(r>>4)&252645135)>>24}else e=this.geoDict[i]||0;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192},e}(Bc);Su.add("geoquality",xg);var _g=function(t){function e(e){var i;t.call(this,e),e.scale||(this.scale="RdYlGn");var r={};for(i in Ep)r[i]=Ep[i][0];if(!e.domain){var n,o=1/0,a=-1/0;for(i in r)n=r[i],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(r[t.resname]||Cp)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("hydrophobicity",_g);var wg=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rainbow"),e.domain||(this.domain=[0,this.structure.modelStore.count]);var i=this.getScale();this.atomColor=function(t){return i(t.modelIndex)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);Su.add("modelindex",wg);var Sg=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}(Bc);Su.add("moleculetype",Sg);var Ag=function(t){function e(e){t.call(this,e),e.scale||(this.scale="PuBu"),e.domain||(this.domain=[0,1]);var i=this.getScale();this.atomColor=function(t){return i(t.occupancy)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Bc);function Mg(){return 16777215*Math.random()}Su.add("occupancy",Ag);var Pg=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 Mg()},e.prototype.volumeColor=function(){return Mg()},e.prototype.positionColor=function(){return Mg()},e}(Bc);Su.add("random",Pg);var Tg=function(t){function e(e){var i=this;if(t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=Oa(e.reverse,!0)),e.domain){var r=this.getScale();this.atomColor=function(t){return r(t.residueIndex)}}else{var n={};this.structure.eachChain(function(t){i.domain=[t.residueOffset,t.residueEnd],n[t.index]=i.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}(Bc);Su.add("residueindex",Tg);var Eg={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},Cg=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 Eg[t.resname]||16711935},e}(Bc);Su.add("resname",Cg);var Ig=16711808,Rg=10485888,Lg=6291584,Og=16762880,Ng=6324479,Dg=16777215,kg=11403518,Fg=16580962,Bg=10921722,zg=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,i=this.rp;return"h"===e?Ig:"g"===e?Rg:"i"===e?Lg:"e"===e||"b"===e?Og:"t"===e?Ng:(i.index=t.residueIndex,i.isDna()?kg:i.isRna()?Fg:i.isSaccharide()?Bg:i.isProtein()||"s"===e||"l"===e?Dg:8421504)},e}(Bc);Su.add("sstruc",zg);var Ug=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}(Bc);Su.add("uniform",Ug);var jg=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}(Bc);Su.add("value",jg);var Gg=function(t){function e(e){t.call(this,e);var i=this.volume;if(i&&i.inverseMatrix){var r=this.getScale(),n=i.inverseMatrix,o=i.data,a=i.nx,s=i.ny,c=a*s,u=new Me;this.positionColor=function(t){u.copy(t),u.applyMatrix4(n);var e=Math.floor(u.x),i=Math.floor(u.y),h=Math.floor(u.z),l=(h*s+i)*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],P=o[y],T=u.x-e,E=u.y-i,C=u.z-h,I=Oc(b,x,T),R=Oc(w,A,T),L=Oc(_,S,T),O=Oc(M,P,T),N=Oc(I,L,E),D=Oc(R,O,E),k=Oc(N,D,C);return r(k)}}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}(Bc);Su.add("volume",Gg);var Vg=function(t){function e(e,i,r){var n=this,o=r||{};o.name=Oa(o.name,i.name),t.call(this,e,o),this.script=i,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 i={type:{}};return i.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,i),e}(Wm);Cu.add("script",Vg);var $g=function(t){function e(e,i,r){var n=r||{};n.name=Oa(n.name,i.name),t.call(this,e,n),this.shape=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"shape"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.shape,i)},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,i),e}(Wm);Cu.add("shape",$g);var Hg=function(t){function e(e,i,r,n){var o=this,a=r||{};a.name=Oa(a.name,i.name),t.call(this,e,a),this.signals=Object.assign(this.signals,{frameChanged:new jc,playerChanged:new jc,gotNumframes:new jc,parametersChanged:new jc}),this.trajectory=i,this.parent=n,this.status="loaded",this.defaultStep=Oa(a.defaultStep,void 0),this.defaultTimeout=Oa(a.defaultTimeout,50),this.defaultInterpolateType=Oa(a.defaultInterpolateType,""),this.defaultInterpolateStep=Oa(a.defaultInterpolateStep,5),this.defaultMode=Oa(a.defaultMode,"loop"),this.defaultDirection=Oa(a.defaultDirection,"forward"),i.signals.frameChanged.add(function(t){o.signals.frameChanged.dispatch(t)}),i.signals.playerChanged.add(function(t){o.signals.playerChanged.dispatch(t)}),i.signals.gotNumframes.add(function(t){o.signals.gotNumframes.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 i={type:{}};return i.type.get=function(){return"trajectory"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.trajectory,i)},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,i),e}(Wm),Wg=function(t){function e(e,i,r){t.call(this,"",i,r),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this.getNumframes()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.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 i,r=this.frames[t];if(this.atomIndices){var n=this.atomIndices,o=n.length;i=new Float32Array(3*o);for(var a=0;a<o;++a){var s=3*a,c=3*n[a];i[s+0]=r[c+0],i[s+1]=r[c+1],i[s+2]=r[c+2]}}else i=new Float32Array(r);var u=this.boxes[t],h=this.frames.length;this.process(t,u,i,h),"function"===typeof e&&e()},e.prototype.getNumframes=function(){this.frames&&this.setNumframes(this.frames.length)},e.prototype.getPath=function(t,e){var i,r,n,o=this.numframes,a=3*t,s=new Float32Array(3*o);for(i=0;i<o;++i)r=3*i,n=this.frames[i],s[r+0]=n[a+0],s[r+1]=n[a+1],s[r+2]=n[a+2];e(s)},Object.defineProperties(e.prototype,i),e}(Pf),Xg=function(t){function e(e,i,r){t.call(this,"",i,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"structure"},e.prototype.makeAtomIndices=function(){this.structure.atomSet.getSize()<this.structure.atomStore.count?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=null},e.prototype._loadFrame=function(t,e){var i,r=this.structure,n=r.frames[t];if(this.atomIndices){var o=this.atomIndices,a=o.length;i=new Float32Array(3*a);for(var s=0;s<a;++s){var c=3*s,u=3*o[s];i[c+0]=n[u+0],i[c+1]=n[u+1],i[c+2]=n[u+2]}}else i=new Float32Array(n);var h=r.boxes[t],l=r.frames.length;this.process(t,h,i,l),"function"===typeof e&&e()},e.prototype.getNumframes=function(){this.setNumframes(this.structure.frames.length)},e.prototype.getPath=function(t,e){var i,r,n,o=this.numframes,a=3*t,s=new Float32Array(3*o);for(i=0;i<o;++i)r=3*i,n=this.structure.frames[i],s[r+0]=n[a+0],s[r+1]=n[a+1],s[r+2]=n[a+2];e(s)},Object.defineProperties(e.prototype,i),e}(Pf),qg=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"remote"},e.prototype.makeAtomIndices=function(){var t=[];if("StructureView"===this.structure.type){var e,i,r=this.structure.getAtomIndices(),n=r[0],o=r[0],a=r.length;for(e=1;e<a;++e)o+1<(i=r[e])&&(t.push([n,o+1]),n=i),o=i;t.push([n,o+1])}else t.push([0,this.atomCount]);this.atomIndices=t},e.prototype._loadFrame=function(t,e){var i=new window.XMLHttpRequest,r=Au.trajectory,n=r.getFrameUrl(this.trajPath,t),o=r.getFrameParams(this.trajPath,this.atomIndices);i.open("POST",n,!0),i.responseType="arraybuffer",i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.addEventListener("load",function(){var r=i.response;if(r){var o=new Int32Array(r,0,1)[0],a=new Float32Array(r,8,9),s=new Float32Array(r,44);this.process(t,a,s,o),"function"===typeof e&&e()}else bu.error("empty arrayBuffer for '"+n+"'")}.bind(this),!1),i.send(o)},e.prototype.getNumframes=function(){var t=new window.XMLHttpRequest,e=Au.trajectory.getNumframesUrl(this.trajPath);t.open("GET",e,!0),t.addEventListener("load",function(){this.setNumframes(parseInt(t.response))}.bind(this),!1),t.send(null)},e.prototype.getPath=function(t,e){if(this.pathCache[t])e(this.pathCache[t]);else{bu.time("loadPath");var i=new window.XMLHttpRequest,r=Au.trajectory.getPathUrl(this.trajPath,t);i.open("POST",r,!0),i.responseType="arraybuffer",i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.addEventListener("load",function(){bu.timeEnd("loadPath");var n=i.response;if(n){var o=new Float32Array(n);this.pathCache[t]=o,e(o)}else bu.error("empty arrayBuffer for '"+r+"'")}.bind(this),!1),i.send("")}},Object.defineProperties(e.prototype,i),e}(Pf);_f.prototype.getView=function(t){return new Yg(this,t)};var Yg=function(t){function e(e,i){t.call(this),this.structure=e,this.selection=i,this.center=new Me,this.boundingBox=new Ti,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},name:{},path:{},title:{},id:{},atomSetDict:{},biomolDict:{},entityList:{},unitcell:{},frames:{},boxes:{},validation:{},bondStore:{},backboneBondStore:{},rungBondStore:{},atomStore:{},residueStore:{},chainStore:{},modelStore:{},atomMap:{},residueMap:{},bondHash:{},spatialHash:{}};return e.prototype.init=function(){},i.type.get=function(){return"StructureView"},i.name.get=function(){return this.structure.name},i.path.get=function(){return this.structure.path},i.title.get=function(){return this.structure.title},i.id.get=function(){return this.structure.id},i.atomSetDict.get=function(){return this.structure.atomSetDict},i.biomolDict.get=function(){return this.structure.biomolDict},i.entityList.get=function(){return this.structure.entityList},i.unitcell.get=function(){return this.structure.unitcell},i.frames.get=function(){return this.structure.frames},i.boxes.get=function(){return this.structure.boxes},i.validation.get=function(){return this.structure.validation},i.bondStore.get=function(){return this.structure.bondStore},i.backboneBondStore.get=function(){return this.structure.backboneBondStore},i.rungBondStore.get=function(){return this.structure.rungBondStore},i.atomStore.get=function(){return this.structure.atomStore},i.residueStore.get=function(){return this.structure.residueStore},i.chainStore.get=function(){return this.structure.chainStore},i.modelStore.get=function(){return this.structure.modelStore},i.atomMap.get=function(){return this.structure.atomMap},i.residueMap.get=function(){return this.structure.residueMap},i.bondHash.get=function(){return this.structure.bondHash},i.spatialHash.get=function(){return this.structure.spatialHash},e.prototype.refresh=function(){for(var t in xu&&bu.time("StructureView.refresh"),this.atomSetCache={},this.atomSet=this.getAtomSet(this.selection,!0),this.structure.atomSet&&(this.atomSet=this.atomSet.intersection(this.structure.atomSet)),this.bondSet=this.getBondSet(),this.atomSetDict){var e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(),xu&&bu.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()},e.prototype.setSelection=function(t){this.selection=t,this.refresh()},e.prototype.getSelection=function(t){var e=[];t&&t.string&&e.push(t.string);var i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);var r="";return e.length>0&&(r="( "+e.join(" ) AND ( ")+" )"),new cu(r)},e.prototype.getStructure=function(){return this.structure.getStructure()},e.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},e.prototype.eachAtom=function(t,e){var i=this.getAtomProxy(),r=this.getAtomSet(e),n=this.atomStore.count;if(r.getSize()<n)r.forEach(function(e){i.index=e,t(i)});else for(var o=0;o<n;++o)i.index=o,t(i)},e.prototype.eachResidue=function(t,e){this.structure.eachResidue(t,this.getSelection(e))},e.prototype.eachResidueN=function(){console.error("StructureView.eachResidueN() not implemented")},e.prototype.eachChain=function(t,e){this.structure.eachChain(t,this.getSelection(e))},e.prototype.eachModel=function(t,e){this.structure.eachModel(t,this.getSelection(e))},e.prototype.getAtomSet=function(t,e){var i=this.structure.getAtomSet(t);return!e&&this.atomSet&&(i=i.makeIntersection(this.atomSet)),i},e.prototype.getAtomIndices=function(t){return this.structure.getAtomIndices(this.getSelection(t))},e.prototype.refreshPosition=function(){return this.structure.refreshPosition()},e.prototype.dispose=function(){this.selection&&this.selection.signals.stringChanged.remove(this.refresh,this),this.structure.signals.refreshed.remove(this.refresh,this),delete this.structure,delete this.atomSet,delete this.bondSet,delete this.atomCount,delete this.bondCount},Object.defineProperties(e.prototype,i),e}(_f),Zg=function(t){function e(e,i,r){var n=r||{};n.name=Oa(n.name,i.name),t.call(this,e,n),this.signals=Object.assign(this.signals,{trajectoryAdded:new jc,trajectoryRemoved:new jc,defaultAssemblyChanged:new jc}),this.structure=i,this.trajList=[],this.initSelection(n.sele),this.setDefaultAssembly(n.assembly||"")}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"structure"},e.prototype.initSelection=function(t){var e=this;this.selection=new cu(t),this.structureView=new Yg(this.structure,this.selection),this.selection.signals.stringChanged.add(function(){e.structureView.setSelection(e.selection),e.rebuildRepresentations(),e.rebuildTrajectories()})},e.prototype.setSelection=function(t){return this.selection.setString(t),this},e.prototype.setDefaultAssembly=function(t){var e=this;this.defaultAssembly=t,this.reprList.forEach(function(t){t.setParameters({defaultAssembly:e.defaultAssembly})}),this.signals.defaultAssemblyChanged.dispatch(t)},e.prototype.rebuildRepresentations=function(){this.reprList.forEach(function(t){t.build()})},e.prototype.rebuildTrajectories=function(){var t=this;this.trajList.slice().forEach(function(e){e.trajectory.setStructure(t.structureView)})},e.prototype.addRepresentation=function(e,i){var r=i||{};return r.defaultAssembly=this.defaultAssembly,t.prototype.addRepresentation.call(this,e,this.structureView,r)},e.prototype.addTrajectory=function(t,e){var i=this,r=function(t,e,i){return t&&"Frames"===t.type?new Wg(t,e,i):!t&&e.frames?new Xg(t,e,i):new qg(t,e,i)}(t,this.structureView,e);r.signals.frameChanged.add(function(){i.updateRepresentations({position:!0})});var n=new Hg(this.stage,r,e,this);return this.trajList.push(n),this.signals.trajectoryAdded.dispatch(n),n},e.prototype.removeTrajectory=function(t){var e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)},e.prototype.dispose=function(){this.trajList.slice().forEach(function(t){t.dispose()}),this.trajList.length=0,this.structure.dispose(),t.prototype.dispose.call(this)},e.prototype.autoView=function(t,e){Number.isInteger(t)&&(e=t,t=void 0),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),Oa(e,0))},e.prototype.getBoxUntransformed=function(t){return t?this.structureView.getBoundingBox(new cu(t)):this.structureView.boundingBox},e.prototype.getCenterUntransformed=function(t){return t&&"string"===typeof t?this.structure.atomCenter(new cu(t)):this.structure.center},e.prototype.superpose=function(t,e,i,r){return function(t,e,i,r,n){var o,a,s,c,u;if(i=Oa(i,!1),r=Oa(r,""),n=Oa(n,""),i){var h=t,l=e;r&&n&&(h=t.getView(new cu(r)),l=e.getView(new cu(n)));var p,d,f,m,g,v=h.getSequence(),y=l.getSequence(),b=new ng(v.join(""),y.join(""));b.calc(),b.trace(),o=0,a=0,s=b.ali1.length;var x=[],_=[];for(p=0;p<s;++p)m=b.ali1[p],g=b.ali2[p],d=0,f=0,"-"===m?_[a]=!1:(_[a]=!0,d=1),"-"===g?x[o]=!1:(x[o]=!0,f=1),o+=d,a+=f;var w=[],S=[],A=h.getAtomProxy(),M=l.getAtomProxy();o=0,h.eachResidue(function(t){void 0!==t.traceAtomIndex&&t.traceAtomIndex===t.getAtomIndexByName("CA")&&(x[o]&&(A.index=t.getAtomIndexByName("CA"),w.push(A.x,A.y,A.z)),o+=1)}),o=0,l.eachResidue(function(t){void 0!==t.traceAtomIndex&&t.traceAtomIndex===t.getAtomIndexByName("CA")&&(_[o]&&(M.index=t.getAtomIndexByName("CA"),S.push(M.x,M.y,M.z)),o+=1)}),c=new Float32Array(w),u=new Float32Array(S)}else{c=t.getView(new cu(r+" and .CA")),u=e.getView(new cu(n+" and .CA"))}new Af(c,u).transform(t),t.refreshPosition()}(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this},e.prototype.setVisibility=function(e){return t.prototype.setVisibility.call(this,e),this.trajList.forEach(function(t){t.setVisibility(e)}),this},Object.defineProperties(e.prototype,i),e}(Wm);Cu.add("structure",Zg),Cu.add("structureview",Zg);var Kg=function(t){function e(e,i,r){var n=r||{};n.name=Oa(n.name,i.name),t.call(this,e,n),this.surface=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"surface"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.surface,i)},e.prototype.getBoxUntransformed=function(){return this.surface.boundingBox},e.prototype.getCenterUntransformed=function(){return this.surface.center},e.prototype.dispose=function(){this.surface.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,i),e}(Wm);Cu.add("surface",Kg);var Qg=function(t){function e(e,i,r){var n=r||{};n.name=Oa(n.name,i.name),t.call(this,e,n),this.volume=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"volume"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.volume,i)},e.prototype.getBoxUntransformed=function(){return this.volume.boundingBox},e.prototype.getCenterUntransformed=function(){return this.volume.center},e.prototype.dispose=function(){this.volume.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,i),e}(Wm);Cu.add("volume",Qg);var Jg=function(t){function e(e,i,r){t.call(this,e,i,r),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(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=Oa(i.radius,.5),i.colorValue=Oa(i.colorValue,"lightgreen"),this.showAxes=Oa(i.showAxes,!0),this.showBox=Oa(i.showBox,!1),t.prototype.init.call(this,i)},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),i=new mi(this.colorValue),r=0,n=0;this.showAxes&&(r+=6,n+=3),this.showBox&&(r+=8,n+=12);var o=new Float32Array(3*r),a=lh(r,i.r,i.g,i.b),s=hh(r,this.radius),c=new Float32Array(3*n),u=new Float32Array(3*n),h=lh(n,i.r,i.g,i.b),l=hh(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 Me,m=e.getProjectedScaleForAtoms(t),g=m.d1a,v=m.d2a,y=m.d3a,b=m.d1b,x=m.d2b,_=m.d3b;console.log(g,v,y,b,x,_);var w=2*p,S=function(t,i,r){f.copy(e.center).addScaledVector(e.normVecA,t).addScaledVector(e.normVecB,i).addScaledVector(e.normVecC,r),f.toArray(o,w),w+=3};S(g,v,y),S(g,v,_),S(g,x,_),S(g,x,y),S(b,x,_),S(b,x,y),S(b,v,y),S(b,v,_);var A=p,M=function(t,e){f.fromArray(o,2*p+3*t).toArray(c,A),f.fromArray(o,2*p+3*e).toArray(u,A),A+=3};M(0,1),M(0,3),M(0,6),M(1,2),M(1,7),M(2,3),M(2,4),M(3,5),M(4,5),M(4,7),M(5,6),M(6,7)}var P=new Zl(e);return{vertex:{position:o,color:a,radius:s,picking:P},edge:{position1:c,position2:u,color:h,color2:h,radius:l,picking:P}}},e.prototype.create=function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new Vf(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new nm(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 i=this.getAxesData(e.sview),r={},n={};t&&!t.position||(r.position=i.vertex.position,n.position1=i.edge.position1,n.position2=i.edge.position2),t&&!t.color||(r.color=i.vertex.color,n.color=i.edge.color,n.color2=i.edge.color),t&&!t.radius||(r.radius=i.vertex.radius,n.radius=i.edge.radius),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(n)},e}(zm);Mu.add("axes",Jg);var tv=function(t){function e(e,i,r){t.call(this,e,i,r),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}},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=Oa(i.radius,.15),this.aspectRatio=Oa(i.aspectRatio,2),this.lineOnly=Oa(i.lineOnly,!1),this.cylinderOnly=Oa(i.cylinderOnly,!1),this.multipleBond=Oa(i.multipleBond,"off"),this.bondSpacing=Oa(i.bondSpacing,1),this.bondScale=Oa(i.bondScale,.4),t.prototype.init.call(this,i)},e.prototype.getAtomParams=function(e,i){return i=Object.assign({radiusParams:{radius:this.radius,scale:this.scale*this.aspectRatio}},i),t.prototype.getAtomParams.call(this,e,i)},e.prototype.getAtomData=function(t,e,i){return t.getAtomData(this.getAtomParams(e,i))},e.prototype.getBondParams=function(e,i){return i=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},i),t.prototype.getBondParams.call(this,e,i)},e.prototype.getBondData=function(t,e,i){return t.getBondData(this.getBondParams(e,i))},e.prototype.createData=function(t){var e=this.getBondData(t),i=[];if(this.lineOnly)this.lineBuffer=new Um(e,this.getBufferParams()),i.push(this.lineBuffer);else{var r=new nm(e,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(i.push(r),!this.cylinderOnly){var n=new Vf(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));i.push(n)}}return{bufferList:i}},e.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var i=this.getBondData(e.sview,t);if(this.lineOnly){var r={};t&&!t.position||(r.position1=i.position1,r.position2=i.position2),t&&!t.color||(r.color=i.color,r.color2=i.color2),e.bufferList[0].setAttributes(r)}else{var n={};if(t&&!t.position||(n.position1=i.position1,n.position2=i.position2),t&&!t.color||(n.color=i.color,n.color2=i.color2),t&&!t.radius||(n.radius=i.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 i=!1,r={};return e&&(e.aspectRatio||e.bondSpacing||e.bondScale)&&(r.radius=!0,vu&&!this.disableImpostor||(i=!0)),t.prototype.setParameters.call(this,e,r,i),this},e}(zm);Mu.add("ball+stick",tv);var ev=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=Oa(i.aspectRatio,1),i.radius=Oa(i.radius,.25),t.prototype.init.call(this,i)},e.prototype.getAtomData=function(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))},e.prototype.getBondData=function(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))},e}(tv);Mu.add("backbone",ev);var iv=function(t){function e(e,i,r){t.call(this,e,i,r),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 i=e||{};i.aspectRatio=Oa(i.aspectRatio,1),i.radius=Oa(i.radius,.3),t.prototype.init.call(this,i)},e.prototype.getAtomData=function(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))},e.prototype.getBondData=function(t,e,i){var r=this.getBondParams(e,i);return r.colorParams.rung=!0,t.getRungBondData(r)},e}(tv);function rv(t,e){var i=1/t,r=1e-4,n=new Me,o=new Me;function a(t,i,r,n,o,a,s){a[s+0]=Nc(t.x,i.x,r.x,n.x,o,e),a[s+1]=Nc(t.y,i.y,r.y,n.y,o,e),a[s+2]=Nc(t.z,i.z,r.z,n.z,o,e)}function s(t,i,r,n,o,a){a.x=Nc(t.x,i.x,r.x,n.x,o,e),a.y=Nc(t.y,i.y,r.y,n.y,o,e),a.z=Nc(t.z,i.z,r.z,n.z,o,e)}function c(e,r,n,o,s,c){for(var u=0;u<t;++u){a(e,r,n,o,i*u,s,c+3*u)}}function u(e,a,c,u,h,l){for(var p=0;p<t;++p){var d=i*p,f=d-r,m=d+r,g=l+3*p;f<0&&(f=0),m>1&&(m=1),s(e,a,c,u,f,n),s(e,a,c,u,m,o),o.sub(n).normalize(),o.toArray(h,g)}}function h(e,i,r,n,o){for(var a=i.next(),s=i.next(),c=i.next(),u=i.size,h=u-1,l=n||0,p=0;p<h;++p)e(a,a=s,s=c,c=i.next(),r,l),l+=3*t;o&&(e(i.get(u-2),a=i.get(u-1),s=i.get(0),c=i.get(1),r,l),l+=3*t)}this.getPosition=function(e,i,r,n){e.reset(),h(c,e,i,r,n);var o=e.size-1,a=o*t*3;n&&(a+=3*t);var s=e.get(n?0:o);i[a]=s.x,i[a+1]=s.y,i[a+2]=s.z},this.getTangent=function(e,i,r,n){e.reset(),h(u,e,i,r,n);var o=(e.size-1)*t*3;n&&(o+=3*t),fh(i,i,o-3,o,3)};var l=new Me,p=new Me,d=new Me,f=new Me,m=Math.ceil(t/2);function g(e,r,a,c,u,h,g,v,y,b,x,_,w){for(var S=0;S<t;++S){var A=_+3*S;w&&(A+=3*m);var M=i*S;s(e,r,a,c,M,n),s(u,h,g,v,M,o),l.subVectors(o,n).normalize(),p.fromArray(y,A),f.crossVectors(l,p).normalize(),f.toArray(x,A),d.crossVectors(p,f).normalize(),d.toArray(b,A)}}function v(e,i,r,n,o){for(var a=0;a<t;++a){var s=o+3*a;e.copy(d),p.fromArray(i,s),f.crossVectors(e,p).normalize(),f.toArray(n,s),d.crossVectors(p,f).normalize(),d.toArray(r,s)}}function y(e,i,r,n,o){var a;for(a=0;a<m;++a)r(e,n,o+3*a);for(a=m;a<t;++a)r(i,n,o+3*a)}function b(e,i,r,n,o){var a;for(a=0;a<m;++a)n[o+a]=r(e);for(a=m;a<t;++a)n[o+a]=r(i)}function x(e,i,r,n,o){for(var a=r(e),s=r(i),c=0;c<t;++c){var u=c/t;n[o+c]=(1-u)*a+u*s}}this.getNormal=function(e,i,r,n,o,a){d.set(0,0,1);for(var s=e-1,c=o||0,u=0;u<s;++u)v(l,i,r,n,c),c+=3*t;a&&(v(l,i,r,n,c),c+=3*t),f.toArray(n,c),d.toArray(r,c)},this.getNormalDir=function(e,i,r,n,o,a,s,c){e.reset(),i.reset();var u=new Me,h=new Me,l=new Me,p=new Me,v=new Me,y=(new Me).copy(e.next()),b=(new Me).copy(e.next()),x=(new Me).copy(e.next()),_=new Me,w=(new Me).copy(i.next()),S=(new Me).copy(i.next()),A=(new Me).copy(i.next());d.set(0,0,1);for(var M=e.size,P=M-1,T=a||0,E=0;E<P;++E)v.copy(y),y.copy(b),b.copy(x),x.copy(e.next()),_.copy(w),w.copy(S),S.copy(A),A.copy(i.next()),0===E?(u.subVectors(_,v),h.subVectors(w,y),u.dot(h)<0&&(h.multiplyScalar(-1),w.addVectors(y,h)),l.subVectors(S,b),h.dot(l)<0&&(l.multiplyScalar(-1),S.addVectors(b,l))):l.copy(p),p.subVectors(A,x),l.dot(p)<0&&(p.multiplyScalar(-1),A.addVectors(x,p)),g(v,y,b,x,_,w,S,A,r,n,o,T,c),T+=3*t;if(s&&(v.copy(e.get(M-2)),y.copy(e.get(M-1)),b.copy(e.get(0)),x.copy(e.get(1)),_.copy(i.get(M-2)),w.copy(i.get(M-1)),S.copy(i.get(0)),A.copy(i.get(1)),l.copy(p),p.subVectors(A,x),l.dot(p)<0&&(p.multiplyScalar(-1),A.addVectors(x,p)),g(v,y,b,x,_,w,S,A,r,n,o,T,c),T+=3*t),c){f.fromArray(o,3*m),d.fromArray(n,3*m);for(var C=0;C<m;++C)f.toArray(o,3*C),d.toArray(n,3*C)}else f.toArray(o,T),d.toArray(n,T)},this.getColor=function(e,i,r,n,o){e.reset(),e.next();for(var a=e.next(),s=e.size,c=s-1,u=n||0,h=0;h<c;++h)y(a,a=e.next(),i,r,u),u+=3*t;o&&(y(e.get(s-1),a=e.get(0),i,r,u),u+=3*t),r[u]=r[u-3],r[u+1]=r[u-2],r[u+2]=r[u-1]},this.getPicking=function(e,i,r,n,o){e.reset(),e.next();for(var a=e.next(),s=e.size,c=s-1,u=n||0,h=0;h<c;++h)b(a,a=e.next(),i,r,u),u+=t;o&&(b(e.get(s-1),a=e.get(0),i,r,u),u+=t),r[u]=r[u-1]},this.getSize=function(e,i,r,n,o){e.reset(),e.next();for(var a=e.next(),s=e.size,c=s-1,u=n||0,h=0;h<c;++h)x(a,a=e.next(),i,r,u),u+=t;o&&(x(e.get(s-1),a=e.get(0),i,r,u),u+=t),r[u]=r[u-1]}}function nv(t,e){this.polymer=t,this.size=t.residueCount;var i=e||{};this.directional=i.directional||!1,this.positionIterator=i.positionIterator||!1,this.subdiv=i.subdiv||1,this.smoothSheet=i.smoothSheet||!1,isNaN(i.tension)?this.tension=this.polymer.isNucleic()?.5:.9:this.tension=i.tension||.5,this.interpolator=new rv(this.subdiv,this.tension)}Mu.add("base",iv),nv.prototype={constructor:nv,getAtomIterator:function(t,e){var i=this.polymer,r=i.structure,n=i.residueCount,o=0,a=-1,s=[r.getAtomProxy(),r.getAtomProxy(),r.getAtomProxy(),r.getAtomProxy()],c=[new Me,new Me,new Me,new Me];var u=r.getAtomProxy(),h=r.getAtomProxy();return{size:n,next:function(){var t=this.get(a);return a+=1,t},get:function(r){var a=s[o%4];if(a.index=i.getAtomIndexByType(r,t),e&&r>0&&r<n&&"e"===a.sstruc){var l=c[o%4];return u.index=i.getAtomIndexByType(r+1,t),h.index=i.getAtomIndexByType(r-1,t),l.addVectors(u,h).add(a).add(a).multiplyScalar(.25),o+=1,l}return o+=1,a},reset:function(){o=0,a=-1}}},getSubdividedColor:function(t){var e=this.subdiv,i=this.polymer,r=(i.residueCount-1)*e*3+3;i.isCyclic&&(r+=3*e);var n=new Float32Array(r),o=this.getAtomIterator("trace"),a=t||{};a.structure=i.structure;var s=Su.getScheme(a);return this.interpolator.getColor(o,function(t,e,i){s.atomColorToArray(t,e,i)},n,0,i.isCyclic),{color:n}},getSubdividedPicking:function(){var t=this.subdiv,e=this.polymer,i=(e.residueCount-1)*t+1;e.isCyclic&&(i+=t);var r=e.structure,n=this.getAtomIterator("trace"),o=new Float32Array(i);return this.interpolator.getPicking(n,function(t){return t.index},o,0,e.isCyclic),{picking:new Yl(o,r)}},getSubdividedPosition:function(){return{position:this.getPosition()}},getSubdividedOrientation:function(){var t=this.getTangent(),e=this.getNormals(t);return{tangent:t,normal:e.normal,binormal:e.binormal}},getSubdividedSize:function(t,e){var i=this.subdiv,r=this.polymer,n=(r.residueCount-1)*i+1;r.isCyclic&&(n+=i);var o=new Float32Array(n),a=this.getAtomIterator("trace"),s=new jp(t,e);return this.interpolator.getSize(a,function(t){return s.atomRadius(t)},o,0,r.isCyclic),{size:o}},getPosition:function(){var t=this.subdiv,e=this.polymer,i=(e.residueCount-1)*t*3+3;e.isCyclic&&(i+=3*t);var r=new Float32Array(i),n=this.positionIterator||this.getAtomIterator("trace",this.smoothSheet);return this.interpolator.getPosition(n,r,0,e.isCyclic),r},getTangent:function(){var t=this.subdiv,e=this.polymer,i=(this.size-1)*t*3+3;e.isCyclic&&(i+=3*t);var r=new Float32Array(i),n=this.positionIterator||this.getAtomIterator("trace",this.smoothSheet);return this.interpolator.getTangent(n,r,0,e.isCyclic),r},getNormals:function(t){var e=this.subdiv,i=this.polymer,r=i.isProtein(),n=this.size,o=(n-1)*e*3+3;i.isCyclic&&(o+=3*e);var a=new Float32Array(o),s=new Float32Array(o);if(this.directional&&!this.polymer.isCg()){var c=this.getAtomIterator("direction1"),u=this.getAtomIterator("direction2");this.interpolator.getNormalDir(c,u,t,a,s,0,i.isCyclic,r)}else this.interpolator.getNormal(n,t,a,s,0,i.isCyclic,r);return{normal:a,binormal:s}}};var ov=new Me,av=new Me,sv=function(t){function e(e,i){var r=e||{},n=i||{},o=Oa(n.radialSegments,4),a=Oa(n.capped,!1),s=a?o:0,c=a?o-2:0,u=r.position.length/3,h=u*o*3+2*s*3,l=2*(u-1)*o*3+2*c*3,p=new Float32Array(h),d=new Float32Array(h),f=new Float32Array(h),m=Va(l,h/3);t.call(this,{position:p,color:d,index:m,normal:f,picking:r.picking},n),this.aspectRatio=Oa(n.aspectRatio,1),this.radialSegments=o,this.capped=a,this.capVertices=s,this.capTriangles=c,this.size2=u,r.primitiveId=ph(u),this.setAttributes(r),this.meshIndex=m,this.makeIndex()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I,R,L,O,N,D=this.aspectRatio,k=this.size2,F=k-1,B=this.radialSegments,z=this.geometry.attributes;t.position&&(e=t.position,i=t.normal,r=t.binormal,n=t.tangent,a=t.size,c=z.position.array,h=z.normal.array,z.position.needsUpdate=!0,z.normal.needsUpdate=!0),t.color&&(o=t.color,u=z.color.array,z.color.needsUpdate=!0),t.primitiveId&&(s=t.primitiveId,l=z.primitiveId.array,z.primitiveId.needsUpdate=!0);var U=[],j=[],G=[],V=[],$=[],H=[];if(e)for(d=0;d<B;++d)y=d/B*2*Math.PI,U[d]=D*Math.cos(y),j[d]=Math.sin(y),G[d]=D*Math.cos(y-.01),V[d]=Math.sin(y-.01),$[d]=D*Math.cos(y+.01),H[d]=Math.sin(y+.01);for(p=0;p<k;++p)for(m=(f=3*p)*B,e&&(ov.set(n[f],n[f+1],n[f+2]),P=i[f],T=i[f+1],E=i[f+2],C=r[f],I=r[f+1],R=r[f+2],L=e[f],O=e[f+1],N=e[f+2],M=a[p]),d=0;d<B;++d)g=m+3*d,e&&(b=-M*U[d],x=M*j[d],_=-M*G[d],w=M*V[d],S=-M*$[d],A=M*H[d],c[g]=L+b*P+x*C,c[g+1]=O+b*T+x*I,c[g+2]=N+b*E+x*R,av.set(S*P+A*C-(_*P+w*C),S*T+A*I-(_*T+w*I),S*E+A*R-(_*E+w*R)).cross(ov),h[g]=av.x,h[g+1]=av.y,h[g+2]=av.z),o&&(u[g]=o[f],u[g+1]=o[f+1],u[g+2]=o[f+2]),s&&(l[p*B+d]=s[p]);for(f=0,m=3*k*B,d=0;d<B;++d)g=f+3*d,v=m+3*d,e&&(c[v]=c[g],c[v+1]=c[g+1],c[v+2]=c[g+2],h[v]=n[f],h[v+1]=n[f+1],h[v+2]=n[f+2]),o&&(u[v]=u[g],u[v+1]=u[g+1],u[v+2]=u[g+2]),s&&(l[k*B+d]=l[0+d]);for(f=3*(k-1)*B,m=3*(k+1)*B,d=0;d<B;++d)g=f+3*d,v=m+3*d,e&&(c[v]=c[g],c[v+1]=c[g+1],c[v+2]=c[g+2],h[v]=n[3*F],h[v+1]=n[3*F+1],h[v+2]=n[3*F+2]),o&&(u[v]=u[g],u[v+1]=u[g+1],u[v+2]=u[g+2]),s&&(l[(k+1)*B+d]=l[(k-1)*B+d])},e.prototype.makeIndex=function(){var t,e,i,r,n,o,a=this.meshIndex,s=this.size2,c=s-1,u=this.capTriangles,h=this.radialSegments,l=this.radialSegments+1;for(t=0;t<c;++t)for(e=t*h*3*2,i=t*h,r=(t+1)*h,o=0;o<h;++o)a[n=e+3*o*2]=i+o,a[n+1]=i+(o+1)%h,a[n+2]=r+o,a[n+3]=r+o,a[n+4]=i+(o+1)%h,a[n+5]=r+(o+1)%h;var p=[0];for(o=1;o<l/2;++o)p.push(o),h-o!==o&&p.push(h-o);for(n=c*h*3*2,e=s*h,o=0;o<p.length-2;++o)o%2===0?(a[n+3*o+0]=e+p[o+0],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+2]):(a[n+3*o+0]=e+p[o+2],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+0]);for(n=c*h*3*2+3*u,e=s*h+h,o=0;o<p.length-2;++o)o%2===0?(a[n+3*o+0]=e+p[o+0],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+2]):(a[n+3*o+0]=e+p[o+2],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+0])},e}(Lf),cv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="cartoon",this.parameters=Object.assign({aspectRatio:{type:"number",precision:1,max:10,min:1},subdiv:{type:"integer",max:50,min:1,rebuild:!0},radialSegments:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},capped:{type:"boolean",rebuild:!0},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"chainname"),i.colorScale=Oa(i.colorScale,"RdYlBu"),i.radius=Oa(i.radius,"sstruc"),i.scale=Oa(i.scale,.7),this.aspectRatio=Oa(i.aspectRatio,5),this.tension=Oa(i.tension,NaN),this.capped=Oa(i.capped,!0),this.smoothSheet=Oa(i.smoothSheet,!1),"low"===i.quality?(this.subdiv=3,this.radialSegments=6):"medium"===i.quality?this.subdiv=6:"high"===i.quality?this.subdiv=12:this.subdiv=Oa(i.subdiv,6),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:1!==this.aspectRatio,smoothSheet:this.smoothSheet},t)},e.prototype.getSpline=function(t){return new nv(t,this.getSplineParams())},e.prototype.getScale=function(t){return t.isCg()?this.scale*this.aspectRatio:this.scale},e.prototype.getAspectRatio=function(t){return t.isCg()?1:this.aspectRatio},e.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=e.getSpline(t),o=n.getSubdividedPosition(),a=n.getSubdividedOrientation(),s=n.getSubdividedColor(e.getColorParams()),c=n.getSubdividedPicking(),u=n.getSubdividedSize(e.radius,e.getScale(t));i.push(new sv(Object.assign({},o,a,s,c,u),e.getBufferParams({radialSegments:e.radialSegments,aspectRatio:e.getAspectRatio(t),capped:e.capped,dullInterior:!0})))}},t.getSelection()),{bufferList:i,polymerList:r}},e.prototype.updateData=function(t,e){xu&&bu.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i<r;++i){var n={},o=e.polymerList[i],a=this.getSpline(o);if(e.bufferList[i].aspectRatio=this.getAspectRatio(o),t.position||t.radius){var s=a.getSubdividedPosition(),c=a.getSubdividedOrientation(),u=a.getSubdividedSize(this.radius,this.getScale(o));n.position=s.position,n.normal=c.normal,n.binormal=c.binormal,n.tangent=c.tangent,n.size=u.size}if(t.color){var h=a.getSubdividedColor(this.getColorParams());n.color=h.color}if(t.picking){var l=a.getSubdividedPicking();n.picking=l.picking}e.bufferList[i].setAttributes(n)}xu&&bu.timeEnd(this.type+" repr update")},e.prototype.setParameters=function(e){var i={};return e&&e.aspectRatio&&(i.radius=!0),e&&e.tension&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(zm);Mu.add("cartoon",cv);var uv=function(t,e){this.sview1=t,this.sview2=e,this.kdtree2=new zd(e)};function hv(t,e,i){e=e||3.5,i=i||40;for(var r=new cu("( ARG and ( .NE or .NH1 or .NH2 ) ) or ( ASP and .ND2 ) or ( GLN and .NE2 ) or ( HIS and ( .ND1 or .NE2 ) ) or ( LYS and .NZ ) or ( SER and .OG ) or ( THR and .OG1 ) or ( TRP and .NE1 ) or ( TYR and .OH ) or ( PROTEIN and .N )"),n=new cu("( ASN and .OD1 ) or ( ASP and ( OD1 or .OD2 ) ) or ( GLN and .OE1 ) or ( GLU and ( .OE1 or .OE2 ) ) or ( HIS and ( .ND1 or .NE2 ) ) or ( SER and .OG ) or ( THR and .OG1 ) or ( TYR and .OH ) or ( PROTEIN and .O )"),o=t.getView(r),a=t.getView(n),s=new uv(o,a).within(e),c=s.bondStore,u=t.getAtomProxy(),h=t.getAtomProxy(),l=t.getAtomProxy(),p=t.getAtomProxy(),d=t.getResidueProxy(),f=t.getResidueProxy(),m=new Me,g=new Me,v=function(t,e,r,n){var o,a;t.atomname===r?(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),rs(m.angleTo(g))<i},y=0,b=c.count;y<b;++y)if(u.index=c.atomIndex1[y],h.index=c.atomIndex2[y],"O"===u.atomname&&"N"===h.atomname||"N"===u.atomname&&"O"===h.atomname)s.bondSet.clear(y);else if("N"===u.atomname||"N"===h.atomname){var x,_;if("N"===u.atomname?(x=u,_=h):(x=h,_=u),d.index=x.residueIndex,l.index=d.getAtomIndexByName("CA"),void 0===l.index)continue;var w=d.getPreviousConnectedResidue(f);if(void 0===w)continue;if(p.index=w.getAtomIndexByName("C"),void 0===p.index)continue;m.subVectors(x,p),g.subVectors(x,l),m.add(g).multiplyScalar(.5),g.subVectors(_,x),rs(m.angleTo(g))>i&&s.bondSet.clear(y)}else("OH"===u.atomname&&"TYR"===u.resname||"OH"===h.atomname&&"TYR"===h.resname)&&(v(u,h,"OH","CZ")||s.bondSet.clear(y));return{atomSet:s.atomSet,bondSet:s.bondSet,bondStore:s.bondStore}}function lv(t,e,i){e=e||3.5,i=i||40;for(var r=new cu("( PROTEIN and .N )"),n=new cu("( PROTEIN and .O )"),o=t.getView(r),a=t.getView(n),s=new uv(o,a).within(e),c=s.bondStore,u=t.getAtomProxy(),h=t.getAtomProxy(),l=t.getAtomProxy(),p=t.getAtomProxy(),d=t.getResidueProxy(),f=t.getResidueProxy(),m=new Me,g=new Me,v=0,y=c.count;v<y;++v){var b,x;if(u.index=c.atomIndex1[v],h.index=c.atomIndex2[v],"N"===u.atomname?(b=u,x=h):(b=h,x=u),d.index=b.residueIndex,l.index=d.getAtomIndexByName("CA"),void 0!==l.index){var _=d.getPreviousConnectedResidue(f);void 0!==_&&(p.index=_.getAtomIndexByName("C"),void 0!==p.index&&(m.subVectors(b,p),g.subVectors(b,l),m.add(g).multiplyScalar(.5),g.subVectors(x,b),rs(m.angleTo(g))>i&&s.bondSet.clear(v)))}}return{atomSet:s.atomSet,bondSet:s.bondSet,bondStore:s.bondStore}}uv.prototype.within=function(t,e){bu.time("Contact within");var i=this.kdtree2,r=this.sview1.getAtomProxy(),n=this.sview1.getAtomSet(!1),o=new Id;this.sview1.eachAtom(function(a){for(var s=!1,c=i.nearest(a,1/0,t),u=0,h=c.length;u<h;++u){var l=c[u];r.index=l.index,a.residueIndex!==r.residueIndex&&(!e||l.distance>e)&&(s=!0,n.set(r.index),o.addBond(a,r,1))}s&&n.set(a.index)});var a=new lp(o.count,!0);return bu.timeEnd("Contact within"),{atomSet:n,bondSet:a,bondStore:o}};var pv=function(t){function e(e,i,r){t.call(this,e,i,r),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(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=Oa(i.radius,.25),this.contactType=Oa(i.contactType,"polarBackbone"),this.maxDistance=Oa(i.maxDistance,3.5),this.maxAngle=Oa(i.maxAngle,40),t.prototype.init.call(this,i)},e.prototype.getContactData=function(t){return{polar:hv,polarBackbone:lv}[this.contactType](t,this.maxDistance,this.maxAngle)},e.prototype.getBondData=function(t,e,i){var r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new Ql(r.picking.array,r.picking.structure,i.bondStore)),r},e.prototype.createData=function(t){var e=this.getContactData(t);return{bufferList:[new nm(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 i=this.getContactData(e.sview);e.bondSet=i.bondSet,e.bondStore=i.bondStore}var r={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(e.sview,t,r),o={};t&&!t.position||(o.position=uh(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}(zm);Mu.add("contact",pv);var dv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="distance",this.parameters=Object.assign({labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelVisible:{type:"boolean"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelUnit:{type:"select",rebuild:!0,options:{"":"",angstrom:"angstrom",nm:"nm"}},atomPair:{type:"hidden",rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters,{flatShaded:null,assembly:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=Oa(i.radius,.15),this.fontFamily=Oa(i.fontFamily,"sans-serif"),this.fontStyle=Oa(i.fontStyle,"normal"),this.fontWeight=Oa(i.fontWeight,"bold"),this.sdf=Oa(i.sdf,"Firefox"!==fu),this.labelSize=Oa(i.labelSize,2),this.labelColor=Oa(i.labelColor,16777215),this.labelVisible=Oa(i.labelVisible,!0),this.labelZOffset=Oa(i.labelZOffset,.5),this.labelUnit=Oa(i.labelUnit,""),this.atomPair=Oa(i.atomPair,[]),t.prototype.init.call(this,i)},e.prototype.getDistanceData=function(t,e){var i=e.length,r=new Array(i),n=new Float32Array(3*i),o=new cu,a=new cu,s=new Id,c=t.getAtomProxy(),u=t.getAtomProxy(),h=0;e.forEach(function(e,i){var l=e[0],p=e[1];if(Number.isInteger(l)&&Number.isInteger(p))c.index=l,u.index=p;else{o.setString(l),a.setString(p);var d=t.getAtomIndices(o),f=t.getAtomIndices(a);if(!d.length||!f.length)return void(h+=1);c.index=d[0],u.index=f[0]}s.addBond(c,u,1),i-=h;var m=c.distanceTo(u);switch(this.labelUnit){case"angstrom":r[i]=m.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(m/10).toFixed(2)+" nm";break;default:r[i]=m.toFixed(2)}var g=3*i;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),h>0&&(i-=h,n=n.subarray(0,3*i));var l=new lp(s.count,!0);return{text:r,position:n,bondSet:l,bondStore:s}},e.prototype.getBondData=function(t,e,i){var r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new ep(r.picking.array,r.picking.structure,i.bondStore)),r},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),i=new mi(this.labelColor);this.textBuffer=new gm({position:e.position,size:hh(t,this.labelSize),color:lh(t,i.r,i.g,i.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 r={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(this.structureView,void 0,r);this.cylinderBuffer=new nm(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 i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),n={},o={},a=this.atomPair.length;if(t.labelSize&&(o.size=hh(a,this.labelSize)),t.labelColor){var s=new mi(this.labelColor);o.color=lh(a,s.r,s.g,s.b)}t.color&&(n.color=r.color,n.color2=r.color2),(t.radius||t.scale)&&(n.radius=r.radius),this.textBuffer.setAttributes(o),this.cylinderBuffer.setAttributes(n)},e.prototype.setVisibility=function(e,i){return t.prototype.setVisibility.call(this,e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),i||this.viewer.requestRender(),this},e.prototype.setParameters=function(e){var i={};return e&&e.labelSize&&(i.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(i.labelColor=!0),t.prototype.setParameters.call(this,e,i,!1),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this},e}(zm);Mu.add("distance",dv);var fv=function(t){function e(e,i){var r=i||{},n=2*(e.position.length/3),o=new mi(Oa(r.color,"grey")),a=new Float32Array(3*n),s=lh(n,o.r,o.g,o.b);t.call(this,{position:a,color:s},r),this.scale=Oa(r.scale,1),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n=this.geometry.attributes;t.position&&t.vector&&(e=t.position,i=t.vector,r=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<s;u++)a=3*u,r[(o=2*u*3)+0]=e[a+0],r[o+1]=e[a+1],r[o+2]=e[a+2],r[o+3]=e[a+0]+i[a+0]*c,r[o+4]=e[a+1]+i[a+1]*c,r[o+5]=e[a+2]+i[a+2]*c},i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(If),mv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="helixorient",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"sstruc"),i.radius=Oa(i.radius,.15),i.scale=Oa(i.scale,1),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=new Dd(t),o=n.getPosition(),a=n.getColor(e.getColorParams()),s=n.getSize(e.radius,e.scale),c=n.getPicking();i.push(new Vf({position:o.center,color:a.color,radius:s.size,picking:c.picking},e.getBufferParams({sphereDetail:e.sphereDetail,disableImpostor:e.disableImpostor,dullInterior:!0})),new fv({position:o.center,vector:o.axis},e.getBufferParams({color:"skyblue",scale:1})),new fv({position:o.center,vector:o.resdir},e.getBufferParams({color:"lightgreen",scale:1})))}},t.getSelection()),{bufferList:i,polymerList:r}},e.prototype.updateData=function(t,e){xu&&bu.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i<r;++i){var n=3*i,o={},a=new Dd(e.polymerList[i]);if(t.position){var s=a.getPosition();o.position=s.center,e.bufferList[n+1].setAttributes({position:s.center,vector:s.axis}),e.bufferList[n+2].setAttributes({position:s.center,vector:s.resdir})}e.bufferList[n].setAttributes(o)}xu&&bu.timeEnd(this.type+" repr update")},e}(zm);Mu.add("helixorient",mv);var gv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="licorice",this.parameters=Object.assign({},this.parameters,{aspectRatio:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=1,t.prototype.init.call(this,i)},e}(tv);Mu.add("licorice",gv),Tu.add("shader/HyperballStickImpostor.vert","\nattribute vec3 mapping;\nattribute float radius;\nattribute float radius2;\nattribute vec3 position1;\nattribute vec3 position2;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\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 float shrink;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewProjectionMatrixInverse;\nvoid main(){\nvRadius = radius;\nvRadius2 = radius2;\nvec4 spaceposition;\nvec3 position_atom1;\nvec3 position_atom2;\nvec4 vertex_position;\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\nvColor1 = color;\nvColor2 = color2;\n#endif\nfloat radius1 = radius;\nposition_atom1 = position1;\nposition_atom2 = position2;\nfloat distance = distance( position_atom1, position_atom2 );\nspaceposition.z = mapping.z * distance;\nif (radius1 > 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}"),Tu.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 vv=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]),yv=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]),bv=function(t){function e(e,i){t.call(this,e,i);var r=e||{},n=Oa((i||{}).shrink,.14);this.addUniforms({modelViewProjectionMatrix:{value:new Pe},modelViewProjectionMatrixInverse:{value:new Pe},modelViewMatrixInverseTranspose:{value:new Pe},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(r),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},isImpostor:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{shrink:{uniform:!0}},t.prototype.parameters)},i.isImpostor.get=function(){return!0},i.vertexShader.get=function(){return"HyperballStickImpostor.vert"},i.fragmentShader.get=function(){return"HyperballStickImpostor.frag"},Object.defineProperties(e.prototype,i),e}(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.mapping.get=function(){return vv},i.mappingIndices.get=function(){return yv},i.mappingIndicesSize.get=function(){return 36},i.mappingType.get=function(){return"v3"},i.mappingSize.get=function(){return 8},i.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,i),e}(Bf)),xv=function(t,e){return!vu||e&&e.disableImpostor?(t.radius=function(t,e){for(var i=t.length,r=new Float32Array(i),n=0;n<i;n++)r[n]=Math.min(t[n],e[n]);return r}(t.radius1,t.radius2),new tm(t,e)):new bv(t,e)},_v=function(t){function e(e,i,r){t.call(this,e,i,r),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 i=e||{};i.scale=Oa(i.scale,.2),i.radius=Oa(i.radius,"vdw"),this.shrink=Oa(i.shrink,.12),t.prototype.init.call(this,i)},e.prototype.getBondParams=function(e,i){return e&&!e.radius||(i=Object.assign({radius2:!0},i)),t.prototype.getBondParams.call(this,e,i)},e.prototype.createData=function(t){var e=new Vf(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 xv(t.getBondData(this.getBondParams()),this.getBufferParams({shrink:this.shrink,radialSegments:this.radialSegments,dullInterior:!0}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams()),r=e.sview.getBondData(this.getBondParams()),n={},o={};if(!t||t.position){n.position=i.position;var a=r.position1,s=r.position2;o.position=uh(a,s,this.__center),o.position1=a,o.position2=s}t&&!t.color||(n.color=i.color,o.color=r.color,o.color2=r.color2),t&&!t.radius||(n.radius=i.radius,o.radius=r.radius,o.radius2=r.radius2),e.bufferList[0].setAttributes(n),e.bufferList[1].setAttributes(o)},e}(gv);function wv(t,e){this.type=t,this.text=e||{}}Mu.add("hyperball",_v),wv.prototype={constructor:wv,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 i=t.resname.toUpperCase();e=(Ip[i]||i)+t.resno;break;case"text":e=this.text[t.index];break;default:e=t.qualifiedName()}return void 0===e?"":e}},wv.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 Sv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="label",this.parameters=Object.assign({labelType:{type:"select",options:wv.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(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};this.labelType=Oa(i.labelType,"res"),this.labelText=Oa(i.labelText,{}),this.fontFamily=Oa(i.fontFamily,"sans-serif"),this.fontStyle=Oa(i.fontStyle,"normal"),this.fontWeight=Oa(i.fontWeight,"bold"),this.sdf=Oa(i.sdf,"Chrome"===fu),this.xOffset=Oa(i.xOffset,0),this.yOffset=Oa(i.yOffset,0),this.zOffset=Oa(i.zOffset,.5),this.attachment=Oa(i.attachment,"bottom-left"),this.showBorder=Oa(i.showBorder,!1),this.borderColor=Oa(i.borderColor,"lightgrey"),this.borderWidth=Oa(i.borderWidth,.15),this.showBackground=Oa(i.showBackground,!1),this.backgroundColor=Oa(i.backgroundColor,"lightgrey"),this.backgroundMargin=Oa(i.backgroundMargin,.5),this.backgroundOpacity=Oa(i.backgroundOpacity,1),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,radius:!0})),i=[],r=new wv(this.labelType,this.labelText);return t.eachAtom(function(t){i.push(r.atomLabel(t))}),{bufferList:[new gm({position:e.position,size:e.radius,color:e.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 i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||(r.position=i.position),t&&!t.radius||(r.size=i.radius),t&&!t.color||(r.color=i.color),e.bufferList[0].setAttributes(r)},e}(zm);Mu.add("label",Sv);var Av=function(t){function e(e,i,r){t.call(this,e,i,r),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}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null,diffuse:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};this.multipleBond=Oa(i.multipleBond,"off"),this.bondSpacing=Oa(i.bondSpacing,1),t.prototype.init.call(this,i)},e.prototype.getBondParams=function(e,i){return i=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{radius:.1,scale:1}},i),t.prototype.getBondParams.call(this,e,i)},e.prototype.createData=function(t){var e=t.getBondData(this.getBondParams({position:!0,color:!0}));return{bufferList:[new Um(e,this.getBufferParams())]}},e.prototype.updateData=function(t,e){var i=e.sview.getBondData(this.getBondParams(t)),r={};t&&!t.position||(r.position1=i.position1,r.position2=i.position2),t&&!t.color||(r.color=i.color,r.color2=i.color2),e.bufferList[0].setAttributes(r)},e.prototype.setParameters=function(e){var i={};return e&&e.bondSpacing&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(zm);function Mv(t,e,i,r,n){var o,a=new(r=r||Int32Array)(t*e*i*(n=n||1));function s(t,r,o){return((t*e+r)*i+o)*n}this.data=a,this.index=s,this.set=function(t,e,i){var r=arguments,c=s(t,e,i);for(o=0;o<n;++o)a[c+o]=r[3+o]},this.toArray=function(t,e,i,r,c){var u=s(t,e,i);for(void 0===r&&(r=[]),void 0===c&&(c=0),o=0;o<n;++o)r[c+o]=a[u+o]},this.fromArray=function(t,e,i,r,c){var u=s(t,e,i);for(void 0===c&&(c=0),o=0;o<n;++o)a[u+o]=r[c+o]},this.copy=function(t){this.data.set(t.data)},this.clone=function(){return new Mv(t,e,i,r,n).copy(this)}}function Pv(t,e,i){var r=bd(e),n=El(t);0===t.length&&(n[0].set([0,0,0]),n[1].set([0,0,0]));var o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x=n[0],_=n[1];function w(t,e,i,n,w){o=e||1.4,a=i||2,g=w||!0;var S=0;for(var A in r)S=Math.max(S,A);var M=xd(x,_,S,a,t?o:0);c=M.dim[0],u=M.dim[1],h=M.dim[2],l=M.matrix,p=M.tran,a=M.scaleFactor,d={},f={},T(t),m=o*a,s=n||o/a,v=new Uint8Array(c*u*h),t&&(y=new Float64Array(c*u*h)),g&&(b=new Int32Array(c*u*h))}var S=1,A=2,M=4,P=[new Int32Array([1,0,0]),new Int32Array([-1,0,0]),new Int32Array([0,1,0]),new Int32Array([0,-1,0]),new Int32Array([0,0,1]),new Int32Array([0,0,-1]),new Int32Array([1,1,0]),new Int32Array([1,-1,0]),new Int32Array([-1,1,0]),new Int32Array([-1,-1,0]),new Int32Array([1,0,1]),new Int32Array([1,0,-1]),new Int32Array([-1,0,1]),new Int32Array([-1,0,-1]),new Int32Array([0,1,1]),new Int32Array([0,1,-1]),new Int32Array([0,-1,1]),new Int32Array([0,-1,-1]),new Int32Array([1,1,1]),new Int32Array([1,1,-1]),new Int32Array([1,-1,1]),new Int32Array([-1,1,1]),new Int32Array([1,-1,-1]),new Int32Array([-1,-1,1]),new Int32Array([-1,1,-1]),new Int32Array([-1,-1,-1])];function T(t){var e,i,n,s,c,u,h,l,p,m;for(var g in r)if(e=r[g],!d[g]){for(u=(h=t?(e+o)*a+.5:e*a+.5)*h,l=Math.floor(h)+1,p=new Int32Array(l*l),m=0,i=0;i<l;++i)for(n=0;n<l;++n)(s=i*i+n*n)>u?p[m]=-1:(c=Math.sqrt(u-s),p[m]=Math.floor(c)),++m;f[g]=l,d[g]=p}}function E(i){var r,n,o,s,l,m,y,x,_,w,A,M,P,T,E,C,I,R,L=3*i,O=i;r=Math.floor(.5+a*(t[L]+p[0])),n=Math.floor(.5+a*(t[L+1]+p[1])),o=Math.floor(.5+a*(t[L+2]+p[2]));var N,D=e[O],k=d[D],F=0,B=u*h,z=f[D];for(w=0;w<z;++w)for(A=0;A<z;++A){if(-1!==(N=k[F]))for(C=-1;C<2;++C)for(I=-1;I<2;++I)for(R=-1;R<2;++R)if(0!==C&&0!==I&&0!==R)for(y=C*w,_=R*A,M=0;M<=N;++M)if(T=n+(x=M*I),E=o+_,!((P=r+y)<0||T<0||E<0||P>=c||T>=u||E>=h)){var U=P*B+T*h+E;if(g)if(v[U]&S){if(v[U]&S){var j=b[U];j!==L&&y*y+x*x+_*_<(s=r+y-Math.floor(.5+a*(t[j]+p[0])))*s+(l=n+x-Math.floor(.5+a*(t[j+1]+p[1])))*l+(m=o+_-Math.floor(.5+a*(t[j+2]+p[2])))*m&&(b[U]=i)}}else v[U]|=S,b[U]=i;else v[U]|=S}F++}}function C(e){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=v.length;i<r;++i)v[i]=0,e&&(y[i]=-1),g&&(b[i]=-1);for(i=0,r=t.length/3;i<r;++i)E(i);for(i=0,r=v.length;i<r;++i)v[i]&S&&(v[i]|=A);console.timeEnd("EDTSurface fillvoxels")}function I(i){var r,n,o,s,l,m,y,x,_,w,S,M,P,T,E,C,I,R,L,O=3*i,N=i,D=0;r=Math.floor(.5+a*(t[O]+p[0])),n=Math.floor(.5+a*(t[O+1]+p[1])),o=Math.floor(.5+a*(t[O+2]+p[2]));var k=e[N],F=u*h;for(P=0,L=f[k];P<L;++P)for(T=0;T<L;++T){if(-1!==d[k][D])for(C=-1;C<2;++C)for(I=-1;I<2;++I)for(R=-1;R<2;++R)if(0!==C&&0!==I&&0!==R)for(y=C*P,_=R*T,E=0;E<=d[k][D];++E)if(S=n+(x=E*I),M=o+_,!((w=r+y)<0||S<0||M<0||w>=c||S>=u||M>=h)){var B=w*F+S*h+M;if(v[B]&A){if(g){var z=b[B];y*y+x*x+_*_<(s=Math.floor(.5+a*(t[z]+p[0])))*s+(l=Math.floor(.5+a*(t[z+1]+p[1])))*l+(m=Math.floor(.5+a*(t[z+2]+p[2])))*m&&(b[B]=i)}}else v[B]|=A,g&&(b[B]=i)}D++}}function R(){var t,e,i,r;console.time("EDTSurface fastdistancemap");var n,o=new Mv(c,u,h,Uint16Array,3),a=u*h,l=m*m,p=0;for(t=0;t<c;++t)for(e=0;e<u;++e)for(i=0;i<h;++i)v[n=t*a+e*h+i]&=~A,v[n]&S&&v[n]&M&&(o.set(t,e,i,t,e,i),y[n]=0,v[n]|=A,p+=1);var d=new Int32Array(3*p),f=0,x=new Int32Array(3*p),_=0;for(t=0;t<c;++t)for(e=0;e<u;++e)for(i=0;i<h;++i)v[n=t*a+e*h+i]&M&&(d[f]=t,d[f+1]=e,d[f+2]=i,f+=3,v[n]&=~M);do{for(_=L(d,o,f,x),f=0,t=0,r=_;t<r;t+=3)n=a*x[t]+h*x[t+1]+x[t+2],v[n]&=~M,y[n]<=1.0404*l&&(d[f]=x[t],d[f+1]=x[t+1],d[f+2]=x[t+2],f+=3)}while(f>0);var w,P=s*s,T=new Uint16Array(3);for(t=0;t<c;++t)for(e=0;e<u;++e)for(i=0;i<h;++i)v[n=t*a+e*h+i]&=~M,v[n]&S&&(v[n]&A&&!(v[n]&A&&y[n]>=P)||(v[n]|=M,g&&v[n]&A&&(o.toArray(t,e,i,T),w=T[0]*a+T[1]*h+T[2],b[n]=b[w])));console.timeEnd("EDTSurface fastdistancemap")}function L(t,e,i,r){var n,o,a,s,l,p,d,f,m,g,b,x,_=new Uint16Array(3),w=0;if(0===i)return w;var T=-1,E=-1,C=-1,I=u*h;for(d=0,m=i;d<m;d+=3)for(n=t[d],o=t[d+1],a=t[d+2],e.toArray(n,o,a,_),f=0;f<6;++f)T=n+(x=P[f])[0],E=o+x[1],C=a+x[2],T<c&&T>-1&&E<u&&E>-1&&C<h&&C>-1&&(v[b=T*I+h*E+C]&S&&!(v[b]&A)?(e.fromArray(T,E,C,_),g=(s=T-_[0])*s+(l=E-_[1])*l+(p=C-_[2])*p,y[b]=g,v[b]|=A,v[b]|=M,r[w]=T,r[w+1]=E,r[w+2]=C,w+=3):v[b]&S&&v[b]&A&&(g=(s=T-_[0])*s+(l=E-_[1])*l+(p=C-_[2])*p)<y[b]&&(e.fromArray(T,E,C,_),y[b]=g,v[b]&M||(v[b]|=M,r[w]=T,r[w+1]=E,r[w+2]=C,w+=3)));for(d=0,m=i;d<m;d+=3)for(n=t[d],o=t[d+1],a=t[d+2],e.toArray(n,o,a,_),f=6;f<18;f++)T=n+(x=P[f])[0],E=o+x[1],C=a+x[2],T<c&&T>-1&&E<u&&E>-1&&C<h&&C>-1&&(v[b=T*I+h*E+C]&S&&!(v[b]&A)?(e.fromArray(T,E,C,_),g=(s=T-_[0])*s+(l=E-_[1])*l+(p=C-_[2])*p,y[b]=g,v[b]|=A,v[b]|=M,r[w]=T,r[w+1]=E,r[w+2]=C,w+=3):v[b]&S&&v[b]&A&&(g=(s=T-_[0])*s+(l=E-_[1])*l+(p=C-_[2])*p)<y[b]&&(e.fromArray(T,E,C,_),y[b]=g,v[b]&M||(v[b]|=M,r[w]=T,r[w+1]=E,r[w+2]=C,w+=3)));for(d=0,m=i;d<m;d+=3)for(n=t[d],o=t[d+1],a=t[d+2],e.toArray(n,o,a,_),f=18;f<26;f++)T=n+(x=P[f])[0],E=o+x[1],C=a+x[2],T<c&&T>-1&&E<u&&E>-1&&C<h&&C>-1&&(v[b=T*I+h*E+C]&S&&!(v[b]&A)?(e.fromArray(T,E,C,_),g=(s=T-_[0])*s+(l=E-_[1])*l+(p=C-_[2])*p,y[b]=g,v[b]|=A,v[b]|=M,r[w]=T,r[w+1]=E,r[w+2]=C,w+=3):v[b]&S&&v[b]&A&&(g=(s=T-_[0])*s+(l=E-_[1])*l+(p=C-_[2])*p)<y[b]&&(e.fromArray(T,E,C,_),y[b]=g,v[b]&M||(v[b]|=M,r[w]=T,r[w+1]=E,r[w+2]=C,w+=3)));return w}this.getVolume=function(e,r,n,o,a){console.time("EDTSurface.getVolume");var s="vws"!==e;w(s,r,n,o,a),C(s),function(){var t,e,i,r=u*h;for(t=0;t<c;++t)for(e=0;e<h;++e)for(i=0;i<u;++i){var n=t*r+i*h+e;if(v[n]&S)for(var o=0;o<26;){var a=t+P[o][0],s=e+P[o][2],l=i+P[o][1];if(a>-1&&a<c&&l>-1&&l<u&&s>-1&&s<h&&!(v[a*r+l*h+s]&S)){v[n]|=M;break}o++}}}(),"ms"!==e&&"ses"!==e||R(),"ses"===e&&(T(!1),function(){var e,i;for(e=0,i=v.length;e<i;++e)v[e]&=~A;for(e=0,i=t.length/3;e<i;++e)I(e)}()),function(t){var e,i=v.length;if("vws"===t)for(e=0;e<i;++e)v[e]&=~M,v[e]=v[e]&A?1:0;else if("ms"===t)for(e=0;e<i;++e)v[e]&=~A,v[e]&M&&(v[e]|=A),v[e]&=~M,v[e]=v[e]&A?1:0;else if("ses"===t)for(e=0;e<i;++e)v[e]&M&&v[e]&A?v[e]&=~M:v[e]&M&&!(v[e]&A)&&(v[e]|=A),v[e]=v[e]&A?1:0;else if("sas"===t)for(e=0;e<i;++e)v[e]&=~M,v[e]=v[e]&A?1:0}(e);for(var l=0,p=b.length;l<p;++l)b[l]=i[b[l]];return console.timeEnd("EDTSurface.getVolume"),{data:v,nx:h,ny:u,nz:c,atomindex:b}},this.getSurface=function(t,e,i,r,n,o,a){var s=this.getVolume(t,e,i,r,n);return new Sd(s.data,s.nx,s.ny,s.nz,s.atomindex).getSurface(1,o,void 0,l,a)}}function Tv(t,e,i,r,n,o,a){var s=t.length,c=n[0],u=n[1],h=n[2],l=o[0],p=o[1],d=o[2];function f(t,e){return Math.floor((t-e)/a)}for(var m,g,v,y=f(l,c)+1,b=f(p,u)+1,x=f(d,h)+1,_=y*b*x,w=b*x,S=[],A=0;A<s;A++){var M=(m=t[A],g=e[A],v=i[A],(f(m,c)*b+f(g,u))*x+f(v,h));void 0===S[M]?S[M]=[A]:S[M].push(A)}var P=new Uint32Array(_),T=new Uint16Array(_),E=new Uint32Array(s),C=0,I=0;for(A=0;A<_;A++){var R=P[A]=C,L=S[A];if(void 0!==L)for(var O=0;O<L.length;O++)E[C]=L[O],C++;var N=C-R;T[A]=N,N>I&&(I=N)}this.neighbourListLength=27*I+1,this.withinRadii=function(n,o,a,s,l){for(var p=0,d=f(n,c),m=f(o,u),g=f(a,h),v=Math.max(0,d-1),_=Math.max(0,m-1),S=Math.max(0,g-1),A=Math.min(y,d+1),M=Math.min(b,m+1),C=Math.min(x,g+1),I=v;I<=A;++I)for(var R=I*w,L=_;L<=M;++L)for(var O=L*x,N=S;N<=C;++N)for(var D=R+O+N,k=P[D],F=k+T[D],B=k;B<F;B++){var z=E[B],U=t[z]-n,j=e[z]-o,G=i[z]-a,V=r[z]+s;U*U+j*j+G*G<=V*V&&(l[p++]=E[B])}l[p]=-1}}function Ev(t,e,i){for(var r=e.length,n=new Float32Array(r),o=new Float32Array(r),a=new Float32Array(r),s=0;s<r;s++){var c=3*s;n[s]=t[c],o[s]=t[c+1],a[s]=t[c+2]}var u=El(t);0===t.length&&(u[0].set([0,0,0]),u[1].set([0,0,0]));var h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C=u[0],I=u[1],R=-1,L=new Float32Array([0,0,0]),O=new Float32Array([0,0,0]),N=new Float32Array([0,0,0]);function D(t,i,s,c){d=Oa(t,1.4),f=Oa(i,2),m=Oa(s,!0),g=Oa(c,30),h=new Float32Array(r),l=new Float32Array(r);for(var u=0;u<h.length;++u){var L=e[u]+d;h[u]=L,l[u]=L*L}p=0;for(var O=0;O<h.length;++O)h[O]>p&&(p=h[O]);!function(){var t=xd(C,I,p,f,0);f=t.scaleFactor,v=t.dim,y=t.matrix,E=Math.min(5,2+Math.floor(d*f)),b=hh(v[0]*v[1]*v[2],-1001),x=new Int32Array(b.length),_=new Float32Array(v[0]),w=new Float32Array(v[1]),S=new Float32Array(v[2]),k(_,C[0],1/f),k(w,C[1],1/f),k(S,C[2],1/f)}(),function(){var t=0,e=2*Math.PI/g;M=new Float32Array(g),A=new Float32Array(g);for(var i=0;i<g;i++)M[i]=Math.cos(t),A[i]=Math.sin(t),t+=e}(),P=new Tv(n,o,a,h,C,I,2.01*p),T=new Int32Array(P.neighbourListLength),R=-1}function k(t,e,i){for(var r=0;r<t.length;r++)t[r]=e+i*r}function F(t,e,i,r,n){var o;if(-1!==R){if((o=R)!==r&&o!==n&&B(o,t,e,i))return o;R=-1}var a=0;for(o=T[a];o>=0;){if(o!==r&&o!==n&&B(o,t,e,i))return R=o,o;o=T[++a]}return R=-1,-1}function B(e,i,r,n){var o=3*e,a=l[e],s=t[o]-i,c=t[o+1]-r,u=t[o+2]-n;return s*s+c*c+u*u<a}function z(){for(var t=0;t<r;t++){var e=n[t],i=o[t],s=a[t],c=h[t],u=l[t];P.withinRadii(e,i,s,c,T);for(var p=Math.ceil(c*f),d=Math.floor(f*(e-C[0])),g=Math.floor(f*(i-C[1])),y=Math.floor(f*(s-C[2])),A=Math.max(0,d-p),M=Math.max(0,g-p),E=Math.max(0,y-p),I=Math.min(v[0],d+p+2),R=Math.min(v[1],g+p+2),L=Math.min(v[2],y+p+2),O=A;O<I;O++)for(var N=_[O]-e,D=v[1]*v[2]*O,k=M;k<R;k++)for(var B=w[k]-i,z=N*N+B*B,U=D+v[2]*k,j=E;j<L;j++){var G=S[j]-s,V=z+G*G;if(V<u){var $=j+U;b[$]<0&&(b[$]=-b[$]);var H=Math.sqrt(V),W=c/H,X=N*W,q=B*W,Y=G*W;if(-1===F(X+=e,q+=i,Y+=s,t,-1)){var Z=c-H;Z<b[$]&&(b[$]=Z,m&&(x[$]=t))}}}}}function U(t,e){var i=h[t],r=h[e],s=L[0]=n[e]-n[t],c=L[1]=o[e]-o[t],u=L[2]=a[e]-a[t],l=s*s+c*c+u*u,p=Math.sqrt(l),d=i*((i*i+p*p-r*r)/(2*i*p));zl(L,L),function(t,e){t[0]=t[1]=t[2]=1,0!==e[0]?t[0]=(e[1]+e[2])/-e[0]:0!==e[1]?t[1]=(e[0]+e[2])/-e[1]:0!==e[2]&&(t[2]=(e[0]+e[1])/-e[2])}(O,L),zl(O,O),Ol(N,L,O),zl(N,N);var y=Math.sqrt(i*i-d*d);Bl(O,O,y),Bl(N,N,y),Bl(L,L,d),L[0]+=n[t],L[1]+=o[t],L[2]+=a[t],R=-1;for(var P=E,T=0;T<g;T++){var I=M[T],D=A[T],k=L[0]+I*O[0]+D*N[0],B=L[1]+I*O[1]+D*N[1],z=L[2]+I*O[2]+D*N[2];if(-1===F(k,B,z,t,e))for(var U=Math.floor(f*(k-C[0])),j=Math.floor(f*(B-C[1])),G=Math.floor(f*(z-C[2])),V=Math.max(0,U-P),$=Math.max(0,j-P),H=Math.max(0,G-P),W=Math.min(v[0],U+P+2),X=Math.min(v[1],j+P+2),q=Math.min(v[2],G+P+2),Y=V;Y<W;Y++){s=k-_[Y];for(var Z=v[1]*v[2]*Y,K=$;K<X;K++)for(var Q=s*s+(c=B-w[K])*c,J=Z+v[2]*K,tt=H;tt<q;tt++){l=Q+(u=z-S[tt])*u;var et=tt+J,it=b[et];it>0&&l<it*it&&(b[et]=Math.sqrt(l),m&&(x[et]=t))}}}}function j(t,e,s){console.time("AVSurface.getVolume"),console.time("AVSurface.init"),D(t,e,s),console.timeEnd("AVSurface.init"),console.time("AVSurface.projectPoints"),z(),console.timeEnd("AVSurface.projectPoints"),console.time("AVSurface.projectTorii"),function(){for(var t=0;t<r;t++){P.withinRadii(n[t],o[t],a[t],h[t],T);for(var e=0,i=T[e];i>=0;)t<i&&U(t,i),i=T[++e]}}(),console.timeEnd("AVSurface.projectTorii"),function(){for(var t=0;t<b.length;t++)b[t]<0&&(b[t]=0)}(),function(){for(var t=0;t<x.length;t++)x[t]=i[x[t]]}(),console.timeEnd("AVSurface.getVolume")}this.getSurface=function(t,e,i,r,n,o,a){return j(e,i,n),new Sd(b,v[2],v[1],v[0],x).getSurface(e,!1,void 0,y,a)}}Mu.add("line",Av),Pv.__deps=[xd,bd,Sd,El,Mv],Ev.__deps=[xd,Sd,hh,El,Bl,Ol,zl,Tv,Oa],wu.add("molsurf",function(t,e){var i=t.data.args,r=t.data.params;if(i&&r){var n=new("av"===r.type?Ev:Pv)(i.coordList,i.radiusList,i.indexList).getSurface(r.type,r.probeRadius,r.scaleFactor,r.cutoff,!0,r.smooth,r.contour),o=[n.position.buffer,n.index.buffer];n.normal&&o.push(n.normal.buffer),n.atomindex&&o.push(n.atomindex.buffer),e({sd:n,p:r},o)}},[Pv,Ev]);var Cv=function(t){this.structure=t};Cv.prototype._getAtomData=function(){return this.structure.getAtomData({what:{position:!0,radius:!0,index:!0},radiusParams:{radius:"vdw",scale:1}})},Cv.prototype._makeSurface=function(t,e){var i=new _d(e.name,"",t);return i.info.type=e.type,i.info.probeRadius=e.probeRadius,i.info.scaleFactor=e.scaleFactor,i.info.smooth=e.smooth,i.info.cutoff=e.cutoff,i},Cv.prototype.getSurface=function(t){var e=t||{},i=this._getAtomData(),r=i.position,n=i.radius,o=i.index,a=new("av"===e.type?Ev:Pv)(r,n,o).getSurface(e.type,e.probeRadius,e.scaleFactor,e.cutoff,!0,e.smooth,e.contour);return this._makeSurface(a,e)},Cv.prototype.getSurfaceWorker=function(t,e){var i=this,r=Object.assign({},t);if(window.Worker){void 0===this.worker&&(this.worker=new ld("molsurf"));var n=this._getAtomData(),o=n.position,a=n.radius,s=n.index,c={args:{coordList:o,radiusList:a,indexList:s},params:r},u=[o.buffer,a.buffer,s.buffer];this.worker.post(c,u,function(t){e(i._makeSurface(t.data.sd,r))},function(t){console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),i.worker.terminate(),i.worker=void 0;var n=i.getSurface(r);e(n)})}else{var h=this.getSurface(r);e(h)}},Cv.prototype.dispose=function(){this.worker&&this.worker.terminate()};var Iv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radiusType:null,radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add(function(){this.__forceNewMolsurf=!0},this),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"uniform"),i.colorValue=Oa(i.colorValue,14540253),i.disablePicking=Oa(i.disablePicking,!0),this.surfaceType=Oa(i.surfaceType,"ms"),this.probeRadius=Oa(i.probeRadius,1.4),this.smooth=Oa(i.smooth,2),this.scaleFactor=Oa(i.scaleFactor,2),this.cutoff=Oa(i.cutoff,0),this.contour=Oa(i.contour,!1),this.background=Oa(i.background,!1),this.opaqueBack=Oa(i.opaqueBack,!0),this.filterSele=Oa(i.filterSele,""),this.colorVolume=Oa(i.colorVolume,void 0),this.useWorker=Oa(i.useWorker,!0),t.prototype.init.call(this,e)},e.prototype.prepareData=function(t,e,i){var r=this.__infoList[e];if(r||(r={},this.__infoList[e]=r),r.molsurf&&r.sele===t.selection.string)i(e);else{if(this.filterSele){var n=t.structure.getView(new cu(this.filterSele)),o=n.boundingBox.getSize(),a=Math.max(o.x,o.y,o.z),s=t.getAtomSetWithinPoint(n.center,a/2+6);t=t.getView(new cu(t.getAtomSetWithinSelection(s,3).toSeleString()))}r.sele=t.selection.string,r.molsurf=new Cv(t);var c=this.getSurfaceParams(),u=function(t){r.surface=t,i(e)};this.useWorker?r.molsurf.getSurfaceWorker(c,u):u(r.molsurf.getSurface(c))}},e.prototype.prepare=function(t){var e=this;if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach(function(t){t.molsurf.dispose()}),this.__infoList.length=0),0!==this.structureView.atomCount){var i=function(){this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()}.bind(this),r="default"===this.assembly?this.defaultAssembly:this.assembly,n=this.structure.biomolDict[r];n?n.partList.forEach(function(t,r){var o=t.getView(e.structureView);e.prepareData(o,r,function(t){t===n.partList.length-1&&i()})}):this.prepareData(this.structureView,0,i)}else t()},e.prototype.createData=function(t,e){var i=this.__infoList[e],r=i.surface,n={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},o=[];if(r.contour){var a=new Cm(n,this.getBufferParams({wireframe:!1}));o.push(a)}else{n.normal=r.getNormal(),n.picking=r.getPicking(t.getStructure());var s=new Am(n,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1})),c=new Tm(s);o.push(c)}return{bufferList:o,info:i}},e.prototype.updateData=function(t,e){var i={};if(t.position)return this.__forceNewMolsurf=!0,void this.build();t.color&&(i.color=e.info.surface.getColor(this.getColorParams())),t.index&&(i.index=e.info.surface.getFilteredIndex(this.filterSele,e.sview)),e.bufferList[0].setAttributes(i)},e.prototype.setParameters=function(e,i,r){return i=i||{},e&&e.filterSele&&(i.index=!0),e&&void 0!==e.colorVolume&&(i.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,i,r),this},e.prototype.getSurfaceParams=function(t){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker},t)},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.clear=function(){t.prototype.clear.call(this)},e.prototype.dispose=function(){this.__infoList.forEach(function(t){t.molsurf.dispose()}),this.__infoList.length=0,t.prototype.dispose.call(this)},e}(zm);Mu.add("surface",Iv);var Rv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};this.pointSize=Oa(i.pointSize,1),this.sizeAttenuation=Oa(i.sizeAttenuation,!0),this.sortParticles=Oa(i.sortParticles,!1),this.useTexture=Oa(i.useTexture,!1),this.alphaTest=Oa(i.alphaTest,.5),this.forceTransparent=Oa(i.forceTransparent,!1),this.edgeBleach=Oa(i.edgeBleach,0),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Lm(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||(r.position=i.position),t&&!t.color||(r.color=i.color),e.bufferList[0].setAttributes(r)},e}(zm);Mu.add("point",Rv),Tu.add("shader/Ribbon.vert","#define STANDARD\nuniform float nearClip;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");var Lv=new Uint16Array([0,1,2,1,3,2]),Ov=function(t){function e(e,i){var r=e||{},n=r.position.length/3-1,o=4*n,a=3*o,s=new Float32Array(a),c=new Float32Array(a),u=new Float32Array(a),h=Va(a,a/3);t.call(this,{position:s,color:c,index:h,normal:u,picking:r.picking},i),this.addAttributes({dir:{type:"v3",value:new Float32Array(a)}}),this.addAttributes({size:{type:"f",value:new Float32Array(o)}}),r.primitiveId=ph(n),this.setAttributes(r),this.meshIndex=h,this.makeIndex()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={vertexShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x=this.size/4,_=this.geometry.attributes;t.position&&(e=t.position,s=_.position.array,_.position.needsUpdate=!0),t.normal&&(i=t.normal,c=_.normal.array,_.normal.needsUpdate=!0),t.size&&(r=t.size,u=_.size.array,_.size.needsUpdate=!0),t.dir&&(n=t.dir,h=_.dir.array,_.dir.needsUpdate=!0),t.color&&(o=t.color,l=_.color.array,_.color.needsUpdate=!0),t.primitiveId&&(a=t.primitiveId,p=_.primitiveId.array,_.primitiveId.needsUpdate=!0);var w=r?r[0]:null;for(d=0;d<x;++d){for(y=3*d,m=3*d*4,v=4*d,e&&(s[m]=s[m+3]=e[y],s[m+1]=s[m+4]=e[y+1],s[m+2]=s[m+5]=e[y+2],s[m+6]=s[m+9]=e[y+3],s[m+7]=s[m+10]=e[y+4],s[m+8]=s[m+11]=e[y+5]),i&&(c[m]=c[m+3]=-i[y],c[m+1]=c[m+4]=-i[y+1],c[m+2]=c[m+5]=-i[y+2],c[m+6]=c[m+9]=-i[y+3],c[m+7]=c[m+10]=-i[y+4],c[m+8]=c[m+11]=-i[y+5]),f=0;f<4;++f)g=m+3*f,o&&(l[g]=o[y],l[g+1]=o[y+1],l[g+2]=o[y+2]),a&&(p[v+f]=a[d]);r&&(b=r[d],w!==r[d]?(u[v]=w,u[v+1]=w,u[v+2]=b,u[v+3]=b):(u[v]=b,u[v+1]=b,u[v+2]=b,u[v+3]=b),w=b),n&&(h[m]=n[y],h[m+1]=n[y+1],h[m+2]=n[y+2],h[m+3]=-n[y],h[m+4]=-n[y+1],h[m+5]=-n[y+2],h[m+6]=n[y+3],h[m+7]=n[y+4],h[m+8]=n[y+5],h[m+9]=-n[y+3],h[m+10]=-n[y+4],h[m+11]=-n[y+5])}},e.prototype.makeIndex=function(){var t,e,i,r,n=this.meshIndex,o=n.length/4/3;for(e=0;e<o;++e)for(i=6*e,r=4*e,n.set(Lv,i),t=0;t<6;++t)n[i+t]+=r},i.vertexShader.get=function(){return"Ribbon.vert"},Object.defineProperties(e.prototype,i),e}(Lf),Nv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="ribbon",this.parameters=Object.assign({subdiv:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters,{side:null,wireframe:null,linewidth:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"chainname"),i.colorScale=Oa(i.colorScale,"RdYlBu"),i.radius=Oa(i.radius,"sstruc"),i.scale=Oa(i.scale,4),"low"===i.quality?this.subdiv=3:"medium"===i.quality?this.subdiv=6:"high"===i.quality?this.subdiv=12:this.subdiv=Oa(i.subdiv,6),this.tension=Oa(i.tension,NaN),this.smoothSheet=Oa(i.smoothSheet,!1),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:!0,smoothSheet:this.smoothSheet},t)},e.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=new nv(t,e.getSplineParams()),o=n.getSubdividedPosition(),a=n.getSubdividedOrientation(),s=n.getSubdividedColor(e.getColorParams()),c=n.getSubdividedPicking(),u=n.getSubdividedSize(e.radius,e.scale);i.push(new Ov({position:o.position,normal:a.binormal,dir:a.normal,color:s.color,size:u.size,picking:c.picking},e.getBufferParams()))}},t.getSelection()),{bufferList:i,polymerList:r}},e.prototype.updateData=function(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i<r;++i){var n={},o=new nv(e.polymerList[i],this.getSplineParams());if(t.position){var a=o.getSubdividedPosition(),s=o.getSubdividedOrientation();n.position=a.position,n.normal=s.binormal,n.dir=s.normal}if(t.radius||t.scale){var c=o.getSubdividedSize(this.radius,this.scale);n.size=c.size}if(t.color){var u=o.getSubdividedColor(this.getColorParams());n.color=u.color}e.bufferList[i].setAttributes(n)}},e.prototype.setParameters=function(e){var i={};return e&&e.tension&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(zm);Mu.add("ribbon",Nv);var Dv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="rocket",this.parameters=Object.assign({localAngle:{type:"integer",max:180,min:0,rebuild:!0},centerDist:{type:"number",precision:1,max:10,min:0,rebuild:!0},ssBorder:{type:"boolean",rebuild:!0},radialSegments:!0,openEnded:!0,disableImpostor:!0},this.parameters),this.helixbundleList=[],this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"sstruc"),i.radius=Oa(i.radius,1.5),i.scale=Oa(i.scale,1),i.openEnded=Oa(i.openEnded,!1),this.localAngle=Oa(i.localAngle,30),this.centerDist=Oa(i.centerDist,2.5),this.ssBorder=Oa(i.ssBorder,!1),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e=this,i=0,r=[],n=[];this.structure.eachPolymer(function(t){if(!(t.residueCount<4||t.isNucleic())){var o=new kd(t),a=o.getAxis(e.localAngle,e.centerDist,e.ssBorder,e.getColorParams(),e.radius,e.scale);i+=a.size.length,r.push(a),n.push(o)}},t.getSelection());var o={begin:new Float32Array(3*i),end:new Float32Array(3*i),size:new Float32Array(i),color:new Float32Array(3*i),picking:new Float32Array(i)},a=0;return r.forEach(function(t){o.begin.set(t.begin,3*a),o.end.set(t.end,3*a),o.size.set(t.size,a),o.color.set(t.color,3*a),o.picking.set(t.picking.array,a),a+=t.size.length}),i&&(o.picking=new Yl(o.picking,t.getStructure())),{bufferList:[new nm({position1:o.begin,position2:o.end,color:o.color,color2:o.color,radius:o.size,picking:o.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:r,helixbundleList:n,axisData:o}},e.prototype.updateData=function(t,e){var i=this;if((t=t||{}).position)this.build();else{var r={};if(t.color||t.radius){var n=0;e.helixbundleList.forEach(function(r){var o=r.getAxis(i.localAngle,i.centerDist,i.ssBorder,i.getColorParams(),i.radius,i.scale);t.color&&e.axisData.color.set(o.color,3*n),(t.radius||t.scale)&&e.axisData.size.set(o.size,n),n+=o.size.length}),t.color&&(r.color=e.axisData.color,r.color2=e.axisData.color),(t.radius||t.scale)&&(r.radius=e.axisData.size)}e.bufferList[0].setAttributes(r)}},e}(zm);Mu.add("rocket",Dv);var kv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=1,i.tension=Oa(i.tension,.5),i.scale=Oa(i.scale,5),i.smoothSheet=!1,this.smooth=Oa(i.smooth,2),t.prototype.init.call(this,i)},e.prototype.getSpline=function(t){var e=new Dd(t);return new nv(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))},e}(cv);Mu.add("rope",kv);var Fv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};t.prototype.init.call(this,i)},e.prototype.createData=function(t){return{bufferList:[new Vf(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||(r.position=i.position),t&&!t.color||(r.color=i.color),t&&!t.radius||(r.radius=i.radius),e.bufferList[0].setAttributes(r)},e}(zm);Mu.add("spacefill",Fv);var Bv=function(t){function e(e,i){var r=i||{},n=(e||{}).position.length/3-1,o=new Float32Array(3*n*2),a=new Float32Array(3*n*2);t.call(this,{position:o,color:a},r),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n,o=this.geometry.attributes;if(t.position&&(e=t.position,r=o.position.array,o.position.needsUpdate=!0),t.color&&(i=t.color,n=o.color.array,o.color.needsUpdate=!0),e||i)for(var a,s,c=this.size-1,u=0;u<c;++u)a=3*u,s=3*u*2,e&&(r[s]=e[a],r[s+1]=e[a+1],r[s+2]=e[a+2],r[s+3]=e[a+3],r[s+4]=e[a+4],r[s+5]=e[a+5]),i&&(n[s]=i[a],n[s+1]=i[a+1],n[s+2]=i[a+2],n[s+3]=i[a+3],n[s+4]=i[a+4],n[s+5]=i[a+5]);else bu.warn("TraceBuffer.prototype.setAttributes no data")},i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(If),zv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="trace",this.parameters=Object.assign({subdiv:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters,{flatShaded:null,side:null,wireframe:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=Oa(i.colorScheme,"chainname"),i.colorScale=Oa(i.colorScale,"RdYlBu"),"low"===i.quality?this.subdiv=3:"medium"===i.quality?this.subdiv=6:"high"===i.quality?this.subdiv=12:this.subdiv=Oa(i.subdiv,6),this.tension=Oa(i.tension,NaN),this.smoothSheet=Oa(i.smoothSheet,!1),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:!1,smoothSheet:this.smoothSheet},t)},e.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=new nv(t,e.getSplineParams()),o=n.getSubdividedPosition(),a=n.getSubdividedColor(e.getColorParams());i.push(new Bv(Object.assign({},o,a),e.getBufferParams()))}},t.getSelection()),{bufferList:i,polymerList:r}},e.prototype.updateData=function(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i<r;++i){var n={},o=new nv(e.polymerList[i],this.getSplineParams());if(t.position){var a=o.getSubdividedPosition();n.position=a.position}if(t.color){var s=o.getSubdividedColor(this.getColorParams());n.color=s.color}e.bufferList[i].setAttributes(n)}},e.prototype.setParameters=function(e){var i={};return e&&e.tension&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(zm);Mu.add("trace",zv);var Uv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="tube",this.parameters=Object.assign({},this.parameters,{aspectRatio:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=1,i.scale=Oa(i.scale,2),"low"===i.quality&&(this.radialSegments=5),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(){return t.prototype.getSplineParams.call(this,{directional:!1})},e}(cv);Mu.add("tube",Uv);var jv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="unitcell",this.parameters=Object.assign({radius:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0},this.parameters,{assembly:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{},r=.5;this.structure.unitcell&&(r=Math.cbrt(this.structure.unitcell.volume)/200),i.radius=Oa(i.radius,r),i.colorValue=Oa(i.colorValue,"orange"),t.prototype.init.call(this,i)},e.prototype.getUnitcellData=function(t){return t.unitcell.getData(t)},e.prototype.create=function(){var t=this.structureView.getStructure();if(t.unitcell){var e=this.getUnitcellData(t);this.sphereBuffer=new Vf(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new nm(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}},e.prototype.updateData=function(t,e){var i=e.sview.getStructure(),r=this.getUnitcellData(i),n={},o={};t&&!t.position||(n.position=r.vertexPosition,o.position1=r.edgePosition1,o.position2=r.edgePosition2),t&&!t.color||(n.color=r.vertexColor,o.color=r.edgeColor,o.color2=r.edgeColor),t&&!t.radius||(n.radius=r.vertexRadius,o.radius=r.edgeRadius),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(o)},e}(zm);Mu.add("unitcell",jv);var Gv=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="validation",this.parameters=Object.assign({},this.parameters,{radiusType:null,radius:null,scale:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorValue=Oa(i.colorValue,"#f0027f"),t.prototype.init.call(this,i)},e.prototype.createData=function(t){if(t.validation){var e=t.validation.getClashData({structure:t,color:this.colorValue});return{bufferList:[new nm(e,this.getBufferParams({openEnded:!1}))]}}},e}(zm);Mu.add("validation",Gv);var Vv=function(t,e){var i=e||{};this.streamer=t,this.name=Oa(i.name,""),this.path=Oa(i.path,"")},$v={type:{},__objName:{}};function Hv(t){var e,i,r=null,n=null,o=null,a=null,s=null,c=null,u=t.atomStore,h=t.residueStore,l=t.chainStore,p=t.modelStore,d=t.residueMap,f=-1,m=-1,g=-1,v=-1;function y(t){for(var r=h.atomCount[t],n=h.atomOffset[t],o=new Array(r),a=0;a<r;++a)o[a]=u.atomTypeId[n+a];h.residueTypeId[t]=d.add(e,o,i)}this.addAtom=function(t,d,b,x,_,w,S,A){var M=!1,P=!1,T=!1;r!==t?(M=!0,P=!0,T=!0,v+=1,g+=1,m+=1):n!==b?(P=!0,T=!0,g+=1,m+=1):a===_&&o===x&&s===A||(T=!0,m+=1),f+=1,M&&(p.growIfFull(),p.chainOffset[v]=g,p.chainCount[v]=0,p.count+=1,l.modelIndex[g]=v),P&&(l.growIfFull(),l.setChainname(g,d),l.setChainid(g,b),l.residueOffset[g]=m,l.residueCount[g]=0,l.count+=1,l.modelIndex[g]=v,p.chainCount[v]+=1,h.chainIndex[m]=g),T&&(e=o,i=c,m>0&&y(m-1),h.growIfFull(),h.resno[m]=_,void 0!==S&&(h.sstruc[m]=S.charCodeAt(0)),void 0!==A&&(h.inscode[m]=A.charCodeAt(0)),h.atomOffset[m]=f,h.atomCount[m]=0,h.count+=1,h.chainIndex[m]=g,l.residueCount[g]+=1),u.count+=1,u.residueIndex[f]=m,h.atomCount[m]+=1,r=t,n=b,o=x,a=_,s=A,c=w},this.finalize=function(){e=o,i=c,m>-1&&y(m)}}$v.type.get=function(){return""},$v.__objName.get=function(){return""},Vv.prototype.parse=function(){var t=this;return this.streamer.read().then(function(){return t._beforeParse(),t._parse(),t._afterParse(),t[t.__objName]})},Vv.prototype._parse=function(){},Vv.prototype._beforeParse=function(){},Vv.prototype._afterParse=function(){xu&&bu.log(this[this.__objName])},Object.defineProperties(Vv.prototype,$v);var Wv=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.firstModelOnly=Oa(r.firstModelOnly,!1),this.asTrajectory=Oa(r.asTrajectory,!1),this.cAlphaOnly=Oa(r.cAlphaOnly,!1),this.structure=new _f(this.name,this.path),this.structureBuilder=new Hv(this.structure)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"structure"},i.__objName.get=function(){return"structure"},Object.defineProperties(e.prototype,i),e}(Vv);var Xv=function(t,e,i,r,n){this.structure=t,this.index=e,this.description=i||"",this.entityType=function(t){switch(t=t.toLowerCase()){case"polymer":return dp;case"non-polymer":return fp;case"macrolide":return mp;case"water":return gp;default:return pp}}(r||""),this.chainIndexList=n||[],n.forEach(function(i){t.chainStore.entityIndex[i]=e})},qv={type:{}};qv.type.get=function(){return"Entity"},Xv.prototype.getEntityType=function(){return this.entityType},Xv.prototype.isPolymer=function(){return this.entityType===dp},Xv.prototype.isNonPolymer=function(){return this.entityType===fp},Xv.prototype.isMacrolide=function(){return this.entityType===mp},Xv.prototype.isWater=function(){return this.entityType===gp},Xv.prototype.eachChain=function(t){var e=this.structure.getChainProxy();this.chainIndexList.forEach(function(i){e.index=i,t(e)})},Object.defineProperties(Xv.prototype,qv);var Yv=function(t){var e=t||{};this.a=e.a||1,this.b=e.b||1,this.c=e.c||1,this.alpha=e.alpha||90,this.beta=e.beta||90,this.gamma=e.gamma||90,this.spacegroup=e.spacegroup||"P 1",this.cartToFrac=e.cartToFrac||e.scale,this.fracToCart=new Pe;var i=is(this.alpha),r=is(this.beta),n=is(this.gamma),o=Math.cos(i),a=Math.cos(r),s=Math.cos(n),c=Math.sin(r),u=Math.sin(n);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-o*o-a*a-s*s+2*o*a*s),void 0===this.cartToFrac){var h=this.a*this.b*u/this.volume,l=(a*s-o)/(c*u);this.fracToCart.set(this.a,0,0,0,this.b*s,this.b*u,0,0,this.c*a,-this.c*c*l,1/h,0,0,0,0,1).transpose(),this.cartToFrac=(new Pe).getInverse(this.fracToCart)}else this.fracToCart.getInverse(this.cartToFrac)};Yv.prototype.getPosition=function(t){var e=new Float32Array(24),i=t.unitcell,r=t.center.clone().applyMatrix4(i.cartToFrac).floor().multiplyScalar(2).addScalar(1),n=new Me,o=0;function a(t,a,s){n.set(t,a,s).multiply(r).applyMatrix4(i.fracToCart).toArray(e,o),o+=3}return a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1),e},Yv.prototype.getCenter=function(t){return function(t,e){var i=t.length;e=e||new Me;for(var r=0;r<i;r+=3)e.x+=t[r],e.y+=t[r+1],e.z+=t[r+2];return e.divideScalar(i/3),e}(this.getPosition(t))},Yv.prototype.getData=function(t,e){var i=e||{},r=Oa(i.colorValue,"orange"),n=Oa(i.radius,Math.cbrt(this.volume)/200),o=new mi(r),a=new Me,s=this.getPosition(t),c=lh(8,o.r,o.g,o.b),u=hh(8,n),h=new Float32Array(36),l=new Float32Array(36),p=lh(12,o.r,o.g,o.b),d=hh(12,n),f=0;function m(t,e){a.fromArray(s,3*t).toArray(h,f),a.fromArray(s,3*e).toArray(l,f),f+=3}m(0,1),m(0,2),m(0,3),m(1,4),m(1,5),m(2,6),m(3,5),m(4,7),m(5,7),m(2,4),m(7,6),m(3,6);var g=new sp(this,t);return{vertex:{position:s,color:c,radius:u,picking:g},edge:{position1:h,position2:l,color:p,color2:p,radius:d,picking:g}}};var Zv={1:"h",2:"h",3:"i",4:"h",5:"g",6:"h",7:"h",8:"h",9:"h",10:"h","":"h"},Kv=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.hex=Oa(r.hex,!1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"pdb"},e.prototype._parse=function(){xu&&bu.time("PdbParser._parse "+this.name);var t=!1,e=this.streamer.peekLines(1)[0],i=e.substr(62,4),r=e.substr(72,4);i===r&&r.trim()&&(t=!0);var n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I,R,L,O,N,D,k="pqr"===this.type,F=/\s+/,B=this.structure,z=this.structureBuilder,U=this.hex,j=10,G=10,V=this.firstModelOnly,$=this.asTrajectory,H=this.cAlphaOnly,W=B.frames,X=B.boxes,q=!1,Y=B.biomolDict,Z={},K={},Q={},J=[],tt=["MOL_ID","MOLECULE","CHAIN","FRAGMENT","SYNONYM","EC","ENGINEERED","MUTATION","OTHER_DETAILS"],et={},it={},rt={helices:[],sheets:[]},nt=rt.helices,ot=rt.sheets,at=B.atomMap,st=B.atomStore;st.resize(Math.round(this.streamer.data.length/80));var ct=B.getAtomProxy(),ut=B.getAtomProxy(),ht=0,lt=0,pt=!0;this.streamer.eachChunkOfLines(function(e){!function(e,i,r){for(var rt=e;rt<i;++rt)if(u=r[rt],"ATOM "===(h=u.substr(0,6))||"HETATM"===h){if(pt&&($?(q?(n=new Float32Array(3*st.count),W.push(n)):n=[],o=0):V||(Z={}),I=(C=1).toString(),R=!0,pt=!1),V&&lt>0)continue;var dt=void 0,ft=void 0,mt=void 0,gt=void 0,vt=void 0;if(k){if(vt=10===(gt=u.split(F)).length?1:0,v=gt[2],H&&"CA"!==v)continue;dt=parseFloat(gt[6-vt]),ft=parseFloat(gt[7-vt]),mt=parseFloat(gt[8-vt])}else{if(v=u.substr(12,4).trim(),H&&"CA"!==v)continue;dt=parseFloat(u.substr(30,8)),ft=parseFloat(u.substr(38,8)),mt=parseFloat(u.substr(46,8))}if($){var yt=3*o;if(n[yt+0]=dt,n[yt+1]=ft,n[yt+2]=mt,o+=1,q)continue}var bt=void 0;k?(l=parseInt(gt[1]),bt="",y="H"===u[0]?1:0,p=vt?"":gt[4],d=parseInt(gt[5-vt]),g="",f=gt[3],b=parseFloat(gt[9-vt]),x="",m=0):(l=parseInt(u.substr(6,5),j),U&&99999===l&&(j=16),y="H"===u[0]?1:0,p=u[21].trim(),d=parseInt(u.substr(22,4),G)||1,U&&9999===d&&(G=16),g=u[26].trim(),f=u.substr(17,4).trim()||"MOL",b=parseFloat(u.substr(60,6)),x=u[16].trim(),m=parseFloat(u.substr(54,6)),t||(bt=u.substr(76,2).trim(),p||(p=u.substr(72,4).trim()))),st.growIfFull(),st.atomTypeId[ht]=at.add(v,bt),st.x[ht]=dt,st.y[ht]=ft,st.z[ht]=mt,st.serial[ht]=l,st.bfactor[ht]=isNaN(b)?0:b,st.altloc[ht]=x.charCodeAt(0),st.occupancy[ht]=isNaN(m)?0:m,y?L===p&&N===f&&(Dp.includes(f)||O===d&&D===g)||(I=(C+=1).toString(),O=d,N=f,D=g):R||L===p||(I=(C+=1).toString()),z.addAtom(lt,p,I,f,d,y,void 0,g),Z[l]=ht,ht+=1,R=!1,L=p}else if("CONECT"===h){var xt=Z[parseInt(u.substr(6,5))],_t=[11,16,21,26],wt={};if(void 0===xt)continue;for(var St=0;St<4;++St){var At=parseInt(u.substr(_t[St],5));if(!Number.isNaN(At)&&void 0!==(At=Z[At]))if(xt<At?(ct.index=xt,ut.index=At):(ct.index=At,ut.index=xt),void 0!==wt[At])B.bondStore.bondOrder[wt[At]]+=1;else{var Mt=ct.index+"|"+ut.index;void 0===Q[Mt]&&(Q[Mt]=!0,wt[At]=B.bondStore.count,B.bondStore.addBond(ct,ut,1))}}}else if("HELIX "===h){_=u[19].trim(),w=parseInt(u.substr(21,4)),S=u[25].trim(),A=u[31].trim(),M=parseInt(u.substr(33,4)),P=u[37].trim();var Pt=parseInt(u.substr(39,1));Pt=(Zv[Pt]||Zv[""]).charCodeAt(0),nt.push([_,w,S,A,M,P,Pt])}else if("SHEET "===h)_=u[21].trim(),w=parseInt(u.substr(22,4)),S=u[26].trim(),A=u[32].trim(),M=parseInt(u.substr(33,4)),P=u[37].trim(),ot.push([_,w,S,A,M,P]);else if("HETNAM"===h)it[u.substr(11,3)]=u.substr(15).trim();else if("COMPND"===h){var Tt=u.substr(10,70).trim(),Et=Tt.indexOf(":"),Ct=Tt.substring(0,Et),It=void 0;tt.includes(Ct)?(E=Ct,It=Tt.substring(Et+2)):It=Tt,It=It.replace(/;$/,""),"MOL_ID"===E?(T={chainList:[],name:""},J.push(T)):"MOLECULE"===E?(T.name&&(T.name+=" "),T.name+=It):"CHAIN"===E&&Array.prototype.push.apply(T.chainList,It.split(/\s*,\s*/))}else if(u.startsWith("TER")){var Rt=B.getChainProxy(B.chainStore.count-1);et[Rt.chainname]=Rt.index,I=(C+=1).toString(),R=!0}else if("REMARK"===h&&"350"===u.substr(7,3)){if("BIOMOLECULE:"===u.substr(11,12)){var Lt=u.substr(23).trim();/^(0|[1-9][0-9]*)$/.test(Lt)&&(Lt="BU"+Lt),a=new Vd(Lt),Y[Lt]=a}else if("BIOMT"===u.substr(13,5)){var Ot=u.split(/\s+/),Nt=parseInt(u[18])-1;0===Nt&&(c=new Pe,s.matrixList.push(c));var Dt=c.elements;Dt[0+Nt]=parseFloat(Ot[4]),Dt[4+Nt]=parseFloat(Ot[5]),Dt[8+Nt]=parseFloat(Ot[6]),Dt[12+Nt]=parseFloat(Ot[7])}else if("APPLY THE FOLLOWING TO CHAINS:"===u.substr(11,30)||" AND CHAINS:"===u.substr(11,30)){"APPLY"===u.substr(11,5)&&(s=a.addPart());for(var kt=u.substr(41,30).split(","),Ft=0,Bt=kt.length;Ft<Bt;++Ft){var zt=kt[Ft].trim();zt&&s.chainList.push(zt)}}}else if("HEADER"===h)B.id=u.substr(62,4);else if("TITLE "===h)B.title+=(B.title?" ":"")+u.substr(10,70).trim();else if("MODEL "===h)pt=!0;else if("ENDMDL"===h||u.startsWith("END")){if(pt)continue;$&&!q&&(W.push(new Float32Array(n)),q=!0),lt+=1,pt=!0}else if("MTRIX"===u.substr(0,5)){if("1"===u[59])continue;var Ut=u.split(/\s+/),jt=Ut[1].trim();if("1"===u[5]&&"1"===jt){a=new Vd("NCS"),Y.NCS=a,s=a.addPart()}var Gt=parseInt(u[5])-1;0===Gt&&(c=new Pe,s.matrixList.push(c));var Vt=c.elements;Vt[0+Gt]=parseFloat(Ut[2]),Vt[4+Gt]=parseFloat(Ut[3]),Vt[8+Gt]=parseFloat(Ut[4]),Vt[12+Gt]=parseFloat(Ut[5])}else if("ORIGX"===u.substr(0,5)){K.origx||(K.origx=new Pe);var $t=u.split(/\s+/),Ht=parseInt(u[5])-1,Wt=K.origx.elements;Wt[0+Ht]=parseFloat($t[1]),Wt[4+Ht]=parseFloat($t[2]),Wt[8+Ht]=parseFloat($t[3]),Wt[12+Ht]=parseFloat($t[4])}else if("SCALE"===u.substr(0,5)){K.scale||(K.scale=new Pe);var Xt=u.split(/\s+/),qt=parseInt(u[5])-1,Yt=K.scale.elements;Yt[0+qt]=parseFloat(Xt[1]),Yt[4+qt]=parseFloat(Xt[2]),Yt[8+qt]=parseFloat(Xt[3]),Yt[12+qt]=parseFloat(Xt[4])}else if("CRYST1"===h){var Zt=parseFloat(u.substr(6,9)),Kt=parseFloat(u.substr(15,9)),Qt=parseFloat(u.substr(24,9)),Jt=parseFloat(u.substr(33,7)),te=parseFloat(u.substr(40,7)),ee=parseFloat(u.substr(47,7)),ie=u.substr(55,11).trim(),re=new Float32Array(9);re[0]=Zt,re[4]=Kt,re[8]=Qt,X.push(re),0===lt&&(K.a=Zt,K.b=Kt,K.c=Qt,K.alpha=Jt,K.beta=te,K.gamma=ee,K.spacegroup=ie)}}(0,e.length,e)});var dt=J.length;if(J.length){B.eachChain(function(t){t.entityIndex=dt}),J.forEach(function(t,e){var i=t.chainList.map(function(t){return et[t]});B.entityList.push(new Xv(B,e,t.name,"polymer",i))});var ft=J.length,mt=B.getResidueProxy(),gt={};B.eachChain(function(t){t.entityIndex===dt&&(mt.index=t.residueOffset,gt[mt.resname]||(gt[mt.resname]=[]),gt[mt.resname].push(t.index))}),Object.keys(gt).forEach(function(t){var e=gt[t],i="non-polymer",r=it[t]||t;Dp.includes(t)&&(r="water",i="water"),B.entityList.push(new Xv(B,ft,r,i,e)),ft+=1})}void 0!==K.a?B.unitcell=new Yv(K):B.unitcell=void 0,(nt.length||ot.length)&&Xd(B,rt),z.finalize(),B.finalizeAtoms(),t||Yd(B),Zd(B),B.finalizeBonds(),nt.length||ot.length||qd(B),Jd(B),xu&&bu.timeEnd("PdbParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("pdb",Kv),Pu.add("pdb1",Kv),Pu.add("ent",Kv);var Qv=/\s+/,Jv=/'((?:(?!'\s).)*)'|"((?:(?!"\s).)*)"|(\S+)/g,ty=/"/g,ey=/^['"]+|['"]+$/g;function iy(t){return!t||t[0]!==t[t.length-1]||"'"!==t[0]&&'"'!==t[0]?t:t.substring(1,t.length-1)}function ry(t,e){Array.isArray(t[e])||Object.keys(t).forEach(function(e){t[e]=[t[e]]})}function ny(t){return"?"!==t}function oy(t,e){return ny(t)?t:e}function ay(t){switch(t.toLowerCase()){case"?":case"sing":return 1;case"doub":return 2;case"trip":return 3;case"quad":return 4}return 0}var sy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"cif"},e.prototype._parse=function(){bu.time("CifParser._parse "+this.name);var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_=this.structure,w=this.structureBuilder,S=this.firstModelOnly,A=this.asTrajectory,M=this.cAlphaOnly,P=_.frames,T={},E={},C={},I=!1,R=null,L=!1,O=!1,N=!1,D=[],k=null,F=null,B=null,z=null,U=[],j=_.atomMap,G=_.atomStore;G.resize(this.streamer.data.length/100);var V,$=0,H=0;if(this.streamer.eachChunkOfLines(function(W){!function(W,X,q){for(var Y=W;Y<X;++Y)if(i=q[Y],((r=i.trim())||I||O)&&"#"!==r[0])if("data_"===r.substring(0,5))T.data=r.substring(5).trim();else if(";"===r[0])I?(O?(k===D.length&&(k=0),D[k].push(R),k+=1):!1===B?T[F]=R:T[F][B]=R,I=!1,R=null):(I=!0,R=r.substring(1));else if("loop_"===r)O=!0,N=!0,D.length=0,U.length=0,k=0;else if("_"===r[0]){var Z,K,Q;if(O&&!N&&(O=!1),O)K=(Z=r.split("."))[0].substring(1),Q=Z[1],1===Z.length?(Q=!1,T[K]||(T[K]=[]),D.push(T[K])):(T[K]||(T[K]={}),T[K][Q]?xu&&bu.warn(K,Q,"already exists"):(T[K][Q]=[],D.push(T[K][Q]),U.push(Q))),F=K,B=Q,z=!0;else{var J=r.match(Jv),tt=J[0],et=J[1];K=(Z=tt.split("."))[0].substring(1),Q=Z[1],1===Z.length?(Q=!1,T[K]=et):(T[K]||(T[K]={}),T[K][Q]?xu&&bu.warn(K,Q,"already exists"):T[K][Q]=et),et||(L=!0),F=K,B=Q}}else if(I)R+=i;else if(O){if(!r)continue;if("atom_site"===F){var it=r.split(Qv);z&&(n=U.indexOf("auth_asym_id"),o=U.indexOf("auth_seq_id"),a=U.indexOf("label_atom_id"),s=U.indexOf("label_comp_id"),c=U.indexOf("label_asym_id"),u=U.indexOf("label_entity_id"),h=U.indexOf("label_alt_id"),g=U.indexOf("Cartn_x"),v=U.indexOf("Cartn_y"),y=U.indexOf("Cartn_z"),p=U.indexOf("id"),d=U.indexOf("type_symbol"),l=U.indexOf("group_PDB"),b=U.indexOf("B_iso_or_equiv"),f=U.indexOf("pdbx_PDB_model_num"),m=U.indexOf("pdbx_PDB_ins_code"),x=U.indexOf("occupancy"),z=!1,V=parseInt(it[f]),A&&(t=[],e=0));var rt=parseInt(it[f]);if(V!==rt&&(A&&(0===H&&P.push(new Float32Array(t)),t=new Float32Array(3*G.count),P.push(t),e=0),H+=1),V=rt,S&&H>0)continue;var nt=it[a].replace(ty,"");if(M&&"CA"!==nt)continue;var ot=parseFloat(it[g]),at=parseFloat(it[v]),st=parseFloat(it[y]);if(A){var ct=3*e;if(t[ct+0]=ot,t[ct+1]=at,t[ct+2]=st,e+=1,H>0)continue}var ut=it[s],ht=parseInt(it[o]),lt=it[m];lt="?"===lt?"":lt;var pt=it[n],dt=it[c],ft="H"===it[l][0]?1:0,mt=it[d],gt=parseFloat(it[b]),vt=parseFloat(it[x]),yt=it[h];if(yt="."===yt?"":yt,G.growIfFull(),G.atomTypeId[$]=j.add(nt,mt),G.x[$]=ot,G.y[$]=at,G.z[$]=st,G.serial[$]=parseInt(it[p]),G.bfactor[$]=isNaN(gt)?0:gt,G.occupancy[$]=isNaN(vt)?0:vt,G.altloc[$]=yt.charCodeAt(0),w.addAtom(H,pt,dt,ut,ht,ft,void 0,lt),xu){var bt=E[dt];void 0!==bt&&bt!==pt&&xu&&bu.warn(bt,pt)}E[dt]=pt;var xt=it[u];C[xt]||(C[xt]=new Set),C[xt].add(_.chainStore.count-1),$+=1}else{var _t=r.match(Jv),wt=_t.length;k===D.length&&(k=0);for(var St=0;St<wt;++St)D[k+St].push(_t[St]);k+=wt}N=!1}else if("'"===r[0]&&"'"===r[r.length-1]){var At=r.substring(1,r.length-1);!1===B?T[F]=At:T[F][B]=At}else L?!1===B?T[F]=r:T[F][B]=r:xu&&bu.log("CifParser._parse: unknown state",r);else I=!1,O=!1,L=!1,D.length=0,k=null,F=null,B=null,z=null,U.length=0}(0,W.length,W)}),T.chem_comp&&T.chem_comp_atom)!function(t,e,i){var r,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(ey,"")),s.id&&(e.id=s.id.trim().replace(ey,"")));var h={};if(c){var l,p,d,f;for(n=c.comp_id.length,r=0;r<n;++r)o.growIfFull(),l=c.atom_id[r].replace(ty,""),p=c.type_symbol[r],h[l]=r,o.atomTypeId[r]=a.add(l,p),o.x[r]=c.model_Cartn_x[r],o.y[r]=c.model_Cartn_y[r],o.z[r]=c.model_Cartn_z[r],o.serial[r]=r,d=c.pdbx_component_comp_id[r],f=c.pdbx_residue_numbering?c.pdbx_residue_numbering[r]:1,i.addAtom(0,"","",d,f,1);for(r=0;r<n;++r){var m=r+n;o.growIfFull(),l=c.atom_id[r].replace(ty,""),p=c.type_symbol[r],o.atomTypeId[m]=a.add(l,p),o.x[m]=c.pdbx_model_Cartn_x_ideal[r],o.y[m]=c.pdbx_model_Cartn_y_ideal[r],o.z[m]=c.pdbx_model_Cartn_z_ideal[r],o.serial[m]=m,d=c.pdbx_component_comp_id[r],f=c.pdbx_residue_numbering?c.pdbx_residue_numbering[r]:1,i.addAtom(1,"","",d,f,1)}}if(c&&u){var g,v,y;n=u.comp_id.length;var b=c.comp_id.length,x=e.getAtomProxy(),_=e.getAtomProxy();for(r=0;r<n;++r)g=u.atom_id_1[r].replace(ty,""),v=u.atom_id_2[r].replace(ty,""),y=ay(u.value_order[r]),x.index=h[g],_.index=h[v],e.bondStore.growIfFull(),e.bondStore.addBond(x,_,y),x.index+=b,_.index+=b,e.bondStore.growIfFull(),e.bondStore.addBond(x,_,y)}}(T,_,w),w.finalize(),_.finalizeAtoms(),_.finalizeBonds(),nf(_);else if(T.atom_site_type_symbol&&T.atom_site_label&&T.atom_site_fract_x)!function(t,e,i){var r=e.atomStore,n=e.atomMap;t.data&&(e.id=t.data,e.name=t.data),e.unitcell=new Yv({a:parseFloat(t.cell_length_a),b:parseFloat(t.cell_length_b),c:parseFloat(t.cell_length_c),alpha:parseFloat(t.cell_angle_alpha),beta:parseFloat(t.cell_angle_beta),gamma:parseFloat(t.cell_angle_gamma),spacegroup:iy(t.symmetry_space_group_name_H)});for(var o=new Me,a=new Me,s=t.atom_site_type_symbol.length,c=0;c<s;++c){r.growIfFull();var u=t.atom_site_label[c],h=t.atom_site_type_symbol[c];r.atomTypeId[c]=n.add(u,h),o.set(t.atom_site_fract_x[c],t.atom_site_fract_y[c],t.atom_site_fract_z[c]),o.applyMatrix4(e.unitcell.fracToCart),a.add(o),r.x[c]=o.x,r.y[c]=o.y,r.z[c]=o.z,t.atom_site_occupancy&&(r.occupancy[c]=parseFloat(t.atom_site_occupancy[c])),r.serial[c]=c,i.addAtom(0,"","","HET",1,1)}a.divideScalar(s),e.center=a,Jd(e);var l=new Me,p=new Me,d=e.biomolDict.SUPERCELL.partList[0].matrixList,f=s;function m(t){return n.get(r.atomTypeId[t]).covalent}for(var g=new Pe,v=function(t){var e=m(t);o.set(r.x[t],r.y[t],r.z[t]),d.forEach(function(n){if(!g.equals(n)){l.copy(o),l.applyMatrix4(n);for(var a=0;a<s;++a){p.set(r.x[a],r.y[a],r.z[a]);var c=l.distanceToSquared(p),u=m(a)+e,h=u+.3,d=u-.5;if(c<h*h&&c>d*d)return r.growIfFull(),r.atomTypeId[f]=r.atomTypeId[t],r.x[f]=l.x,r.y[f]=l.y,r.z[f]=l.z,r.occupancy[f]=r.occupancy[t],r.serial[f]=f,r.altloc[f]="A".charCodeAt(0),i.addAtom(0,"","","HET",1,1),void(f+=1)}}})},y=0;y<s;++y)v(y)}(T,_,w),w.finalize(),_.finalizeAtoms(),Zd(_),_.finalizeBonds();else{var W=function(t,e,i){var r,n,o,a,s=[],c=[],u=t.struct_conf;if(u)for(ry(u,"id"),r=0,n=u.beg_auth_seq_id.length;r<n;++r){var h=parseInt(u.pdbx_PDB_helix_class[r]);Number.isNaN(h)||(o=u.pdbx_beg_PDB_ins_code[r],a=u.pdbx_end_PDB_ins_code[r],s.push([i[u.beg_label_asym_id[r]],parseInt(u.beg_auth_seq_id[r]),oy(o,""),i[u.end_label_asym_id[r]],parseInt(u.end_auth_seq_id[r]),oy(a,""),(Zv[h]||Zv[""]).charCodeAt(0)]))}var l=t.struct_sheet_range;if(l)for(ry(l,"id"),r=0,n=l.beg_auth_seq_id.length;r<n;++r)o=l.pdbx_beg_PDB_ins_code[r],a=l.pdbx_end_PDB_ins_code[r],c.push([i[l.beg_label_asym_id[r]],parseInt(l.beg_auth_seq_id[r]),oy(o,""),i[l.end_label_asym_id[r]],parseInt(l.end_auth_seq_id[r]),oy(a,"")]);return!(!u&&!l)&&{helices:s,sheets:c}}(T,0,E);if(function(t,e,i){var r={},n=e.biomolDict;if(t.pdbx_struct_oper_list){var o=t.pdbx_struct_oper_list;ry(o,"id"),o.id.forEach(function(t,e){var i=new Pe,n=i.elements;n[0]=parseFloat(o["matrix[1][1]"][e]),n[1]=parseFloat(o["matrix[1][2]"][e]),n[2]=parseFloat(o["matrix[1][3]"][e]),n[4]=parseFloat(o["matrix[2][1]"][e]),n[5]=parseFloat(o["matrix[2][2]"][e]),n[6]=parseFloat(o["matrix[2][3]"][e]),n[8]=parseFloat(o["matrix[3][1]"][e]),n[9]=parseFloat(o["matrix[3][2]"][e]),n[10]=parseFloat(o["matrix[3][3]"][e]),n[3]=parseFloat(o["vector[1]"][e]),n[7]=parseFloat(o["vector[2]"][e]),n[11]=parseFloat(o["vector[3]"][e]),i.transpose(),r[t]=i})}if(t.pdbx_struct_assembly_gen){var a=t.pdbx_struct_assembly_gen;ry(a,"assembly_id");var s=function(t){var e={};return t.replace(/[()']/g,"").split(",").forEach(function(t){if(t.includes("-"))for(var i=t.split("-"),n=parseInt(i[0]),o=parseInt(i[1]);n<=o;++n)e[n]=r[n];else e[t]=r[t]}),e};a.assembly_id.forEach(function(t,e){var r={},o=a.oper_expression[e].replace(/['"]\(|['"]/g,"");if(o.includes(")(")||o.indexOf("(")>0){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 i=new Pe;i.multiplyMatrices(c[t],u[e]),r[t+"x"+e]=i})})}else r=s(o);var h=[];for(var l in r)h.push(r[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;f<m;++f)d[f]=i[d[f]];void 0===n[p]&&(n[p]=new Vd(p)),n[p].addPart(h,d)})}if(t.struct_ncs_oper){var c=t.struct_ncs_oper;ry(c,"id");n.NCS=new Vd("NCS");var u=n.NCS.addPart();c.id.forEach(function(t,e){if("given"!==c.code[e]){var i=new Pe,r=i.elements;r[0]=parseFloat(c["matrix[1][1]"][e]),r[1]=parseFloat(c["matrix[1][2]"][e]),r[2]=parseFloat(c["matrix[1][3]"][e]),r[4]=parseFloat(c["matrix[2][1]"][e]),r[5]=parseFloat(c["matrix[2][2]"][e]),r[6]=parseFloat(c["matrix[2][3]"][e]),r[8]=parseFloat(c["matrix[3][1]"][e]),r[9]=parseFloat(c["matrix[3][2]"][e]),r[10]=parseFloat(c["matrix[3][3]"][e]),r[3]=parseFloat(c["vector[1]"][e]),r[7]=parseFloat(c["vector[2]"][e]),r[11]=parseFloat(c["vector[3]"][e]),i.transpose(),u.matrixList.push(i)}}),0===u.matrixList.length&&delete n.NCS}var h={};if(t.cell){var l=t.cell,p=parseFloat(l.length_a),d=parseFloat(l.length_b),f=parseFloat(l.length_c),m=new Float32Array(9);m[0]=p,m[4]=d,m[8]=f,e.boxes.push(m),h.a=p,h.b=d,h.c=f,h.alpha=parseFloat(l.angle_alpha),h.beta=parseFloat(l.angle_beta),h.gamma=parseFloat(l.angle_gamma)}t.symmetry&&(h.spacegroup=iy(t.symmetry["space_group_name_H-M"]));var g=new Pe;if(t.database_PDB_matrix){var v=t.database_PDB_matrix,y=g.elements;y[0]=parseFloat(v["origx[1][1]"]),y[1]=parseFloat(v["origx[1][2]"]),y[2]=parseFloat(v["origx[1][3]"]),y[4]=parseFloat(v["origx[2][1]"]),y[5]=parseFloat(v["origx[2][2]"]),y[6]=parseFloat(v["origx[2][3]"]),y[8]=parseFloat(v["origx[3][1]"]),y[9]=parseFloat(v["origx[3][2]"]),y[10]=parseFloat(v["origx[3][3]"]),y[3]=parseFloat(v["origx_vector[1]"]),y[7]=parseFloat(v["origx_vector[2]"]),y[11]=parseFloat(v["origx_vector[3]"]),g.transpose(),h.origx=g}var b=new Pe;if(t.atom_sites){var x=t.atom_sites,_=b.elements;_[0]=parseFloat(x["fract_transf_matrix[1][1]"]),_[1]=parseFloat(x["fract_transf_matrix[1][2]"]),_[2]=parseFloat(x["fract_transf_matrix[1][3]"]),_[4]=parseFloat(x["fract_transf_matrix[2][1]"]),_[5]=parseFloat(x["fract_transf_matrix[2][2]"]),_[6]=parseFloat(x["fract_transf_matrix[2][3]"]),_[8]=parseFloat(x["fract_transf_matrix[3][1]"]),_[9]=parseFloat(x["fract_transf_matrix[3][2]"]),_[10]=parseFloat(x["fract_transf_matrix[3][3]"]),_[3]=parseFloat(x["fract_transf_vector[1]"]),_[7]=parseFloat(x["fract_transf_vector[2]"]),_[11]=parseFloat(x["fract_transf_vector[3]"]),b.transpose(),h.scale=b}void 0!==h.a?e.unitcell=new Yv(h):e.unitcell=void 0}(T,_,E),function(t,e,i){var r=t.struct_conn;if(r){ry(r,"id");for(var n=/"/g,o=e.getAtomProxy(),a=e.getAtomProxy(),s={},c=0,u=r.id.length;c<u;++c){var h=r.conn_type_id[c];if("hydrog"!==h&&"mismat"!==h&&"saltbr"!==h&&("1_555"===r.ptnr1_symmetry[c]&&"1_555"===r.ptnr2_symmetry[c])){var l=r.pdbx_ptnr1_PDB_ins_code[c],p=r.pdbx_ptnr1_label_alt_id[c],d=r.ptnr1_auth_seq_id[c]+(ny(l)?"^"+l:"")+":"+i[r.ptnr1_label_asym_id[c]]+"."+r.ptnr1_label_atom_id[c].replace(n,"")+(ny(p)?"%"+p:""),f=s[d];if(!f){var m=new cu(d);if(m.selection.error){xu&&bu.warn("invalid selection for connection",d);continue}f=e.getAtomIndices(m),s[d]=f}var g=r.pdbx_ptnr2_PDB_ins_code[c],v=r.pdbx_ptnr2_label_alt_id[c],y=r.ptnr2_auth_seq_id[c]+(ny(g)?"^"+g:"")+":"+i[r.ptnr2_label_asym_id[c]]+"."+r.ptnr2_label_atom_id[c].replace(n,"")+(ny(v)?"%"+v:""),b=s[y];if(!b){var x=new cu(y);if(x.selection.error){xu&&bu.warn("invalid selection for connection",y);continue}b=e.getAtomIndices(x),s[y]=b}var _=f.length,w=b.length;if(_>w){var S=_;_=w,w=S;var A=f;f=b,b=A}if(0!==_&&0!==w)for(var M=0;M<w;++M)o.index=f[M%_],a.index=b[M],o&&a?e.bondStore.addBond(o,a,ay(r.pdbx_value_order[c])):bu.log("atoms for connection not found");else xu&&bu.warn("no atoms found for",d,y)}}}}(T,_,E),function(t,e,i){if(t.entity){ry(t.entity,"id");for(var r=t.entity,n=r.id.length,o=0;o<n;++o){var a=r.pdbx_description[o],s=r.type[o],c=Array.from(i[r.id[o]]);e.entityList[o]=new Xv(e,o,a,s,c)}}}(T,_,C),T.struct&&T.struct.title&&(_.title=T.struct.title.trim().replace(ey,"")),T.entry&&T.entry.id&&(_.id=T.entry.id.trim().replace(ey,"")),T.database_PDB_rev){if(T.database_PDB_rev.date){ry(T.database_PDB_rev,"date");var X=T.database_PDB_rev.date.filter(ny);X.length&&(_.header.releaseDate=X[X.length-1])}if(T.database_PDB_rev.date_original){ry(T.database_PDB_rev,"date_original");var q=T.database_PDB_rev.date_original.filter(ny);q.length&&(_.header.depositionDate=q[q.length-1])}}T.reflns&&T.reflns.d_resolution_high?ny(T.reflns.d_resolution_high)&&(_.header.resolution=parseFloat(T.reflns.d_resolution_high)):T.refine&&T.refine.ls_d_res_high&&ny(T.refine.ls_d_res_high)&&(_.header.resolution=parseFloat(T.refine.ls_d_res_high)),T.refine&&T.refine.ls_R_factor_R_free&&ny(T.refine.ls_R_factor_R_free)&&(_.header.rFree=parseFloat(T.refine.ls_R_factor_R_free)),T.refine&&T.refine.ls_R_factor_R_work&&ny(T.refine.ls_R_factor_R_work)&&(_.header.rWork=parseFloat(T.refine.ls_R_factor_R_work)),T.exptl&&T.exptl.method&&(ry(T.exptl,"method"),_.header.experimentalMethods=T.exptl.method.map(function(t){return t.replace(ey,"")})),w.finalize(),_.finalizeAtoms(),Zd(_),_.finalizeBonds(),W?Xd(_,W):qd(_),Jd(_),_.extraData.cif=T}xu&&bu.timeEnd("CifParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("cif",sy),Pu.add("mcif",sy),Pu.add("mmcif",sy);var 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 i={type:{}};return i.type.get=function(){return"gro"},e.prototype._parse=function(){xu&&bu.time("GroParser._parse "+this.name);var t,e,i=this.structure,r=this.structureBuilder,n=this.firstModelOnly,o=this.asTrajectory,a=this.cAlphaOnly,s=i.frames,c=i.boxes,u=this.streamer.peekLines(3);i.title=u[0].trim();var h,l,p,d,f=5+(u[2].length-u[2].lastIndexOf(".")-1),m=20,g=20+f,v=20+2*f,y=parseInt(u[1]),b=y+3,x=i.atomMap,_=i.atomStore;_.resize(y);var w=0,S=0,A=0;this.streamer.eachChunkOfLines(function(i){!function(i,u,M){for(var P=i;P<u;++P){var T=++A-1,E=M[P];if(E)if(T%b===0)o&&(t=new Float32Array(3*y),s.push(t),e=0);else if(T%b===1);else if(T%b===b-1){var C=E.trim().split(/\s+/),I=new Float32Array(9);if(I[0]=10*parseFloat(C[0]),I[4]=10*parseFloat(C[1]),I[8]=10*parseFloat(C[2]),c.push(I),n)return!0;S+=1}else{if(h=E.substr(10,5).trim(),a&&"CA"!==h)continue;var R=10*parseFloat(E.substr(m,f)),L=10*parseFloat(E.substr(g,f)),O=10*parseFloat(E.substr(v,f));if(o){var N=3*e;if(t[N+0]=R,t[N+1]=L,t[N+2]=O,e+=1,T>b)continue}l=E.substr(5,5).trim(),p=parseInt(E.substr(0,5)),d=parseInt(E.substr(15,5)),_.growIfFull(),_.atomTypeId[w]=x.add(h),_.x[w]=R,_.y[w]=L,_.z[w]=O,_.serial[w]=d,r.addAtom(S,"","",l,p,0,"l"),w+=1}}}(0,i.length,i)}),r.finalize(),i.finalizeAtoms(),Yd(i),Zd(i),i.finalizeBonds(),qd(i),xu&&bu.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("gro",cy);var uy=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function hy(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function ly(t){return hy(DataView,t)}function py(t){return hy(Int8Array,t)}function dy(t){return hy(Int32Array,t,4)}function fy(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,n=0;r<i;++r,n+=2)e[r]=t[n]<<8^t[n+1]<<0;return e}function my(t,e){var i=t.length/4;e||(e=new Int32Array(i));for(var r=0,n=0;r<i;++r,n+=4)e[r]=t[n]<<24^t[n+1]<<16^t[n+2]<<8^t[n+3]<<0;return e}function gy(t,e,i){var r=t.length,n=1/e;i||(i=new Float32Array(r));for(var o=0;o<r;++o)i[o]=t[o]*n;return i}function vy(t,e){var i,r;if(!e){var n=0;for(i=0,r=t.length;i<r;i+=2)n+=t[i+1];e=new t.constructor(n)}var o=0;for(i=0,r=t.length;i<r;i+=2)for(var a=t[i],s=t[i+1],c=0;c<s;++c)e[o]=a,++o;return e}function yy(t,e){var i=t.length;e||(e=new t.constructor(i)),i&&(e[0]=t[0]);for(var r=1;r<i;++r)e[r]=t[r]+e[r-1];return e}function by(t,e){var i,r,n=t instanceof Int8Array?127:32767,o=-n-1,a=t.length;if(!e){var s=0;for(i=0;i<a;++i)t[i]<n&&t[i]>o&&++s;e=new Int32Array(s)}for(i=0,r=0;i<a;){for(var c=0;t[i]===n||t[i]===o;)c+=t[i],++i;c+=t[i],++i,e[r]=c,++r}return e}function xy(t,e,i){return gy(by(t,dy(i)),e,i)}function _y(t,e,i){var r=by(t,dy(i));return function(t,e,i){return gy(yy(t,dy(i)),e,i)}(r,e,hy(Float32Array,r,4))}function wy(t,e,i,r){switch(t){case 1:return function(t,e){var i=t.length;e||(e=new Float32Array(i/4));for(var r=ly(e),n=ly(t),o=0,a=0,s=i/4;o<s;++o,a+=4)r.setFloat32(a,n.getFloat32(a),!0);return e}(e);case 2:return py(e);case 3:return fy(e);case 4:return my(e);case 5:return hy(Uint8Array,e);case 6:return vy(my(e),new Uint8Array(i));case 7:return vy(my(e));case 8:return yy(vy(my(e)),n);case 9:return function(t,e,i){return gy(vy(t,dy(i)),e,i)}(my(e),my(r)[0]);case 10:return _y(fy(e),my(r)[0]);case 11:return gy(fy(e),my(r)[0]);case 12:return xy(fy(e),my(r)[0]);case 13:return xy(py(e),my(r)[0]);case 14:return by(fy(e));case 15:return by(py(e))}var n}function Sy(t,e){var i=(e=e||{}).ignoreFields,r={};return uy.forEach(function(e){var n=!!i&&-1!==i.indexOf(e),o=t[e];n||void 0===o||(o instanceof Uint8Array?r[e]=wy.apply(null,function(t){var e=ly(t),i=e.getInt32(0),r=e.getInt32(4),n=t.subarray(8,12);return[i,t=t.subarray(12),r,n]}(o)):r[e]=o)}),r}var Ay={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)},My=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"mmtf"},e.prototype._parse=function(){var t,e,i,r,n;xu&&bu.time("MmtfParser._parse "+this.name);var o,a,s,c,u,h,l=this.structure,p=Sy(function(t){var e=0,i=new DataView(t.buffer);function r(t){for(var e={},i=0;i<t;i++){e[s()]=s()}return e}function n(i){var r=t.subarray(e,e+i);return e+=i,r}function o(i){var r=t.subarray(e,e+i);e+=i;if(i>65535){for(var n=[],o=0;o<r.length;o+=65535)n.push(String.fromCharCode.apply(null,r.subarray(o,o+65535)));return n.join("")}return String.fromCharCode.apply(null,r)}function a(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=s();return e}function s(){var s,c,u=t[e];if(0===(128&u))return e++,u;if(128===(240&u))return e++,r(c=15&u);if(144===(240&u))return e++,a(c=15&u);if(160===(224&u))return e++,o(c=31&u);if(224===(224&u))return s=i.getInt8(e),e++,s;switch(u){case 192:return e++,null;case 194:return e++,!1;case 195:return e++,!0;case 196:return c=i.getUint8(e+1),e+=2,n(c);case 197:return c=i.getUint16(e+1),e+=3,n(c);case 198:return c=i.getUint32(e+1),e+=5,n(c);case 202:return s=i.getFloat32(e+1),e+=5,s;case 203:return s=i.getFloat64(e+1),e+=9,s;case 204:return s=t[e+1],e+=2,s;case 205:return s=i.getUint16(e+1),e+=3,s;case 206:return s=i.getUint32(e+1),e+=5,s;case 208:return s=i.getInt8(e+1),e+=2,s;case 209:return s=i.getInt16(e+1),e+=3,s;case 210:return s=i.getInt32(e+1),e+=5,s;case 217:return c=i.getUint8(e+1),e+=2,o(c);case 218:return c=i.getUint16(e+1),e+=3,o(c);case 219:return c=i.getUint32(e+1),e+=5,o(c);case 220:return c=i.getUint16(e+1),e+=3,a(c);case 221:return c=i.getUint32(e+1),e+=5,a(c);case 222:return c=i.getUint16(e+1),e+=3,r(c);case 223:return c=i.getUint32(e+1),e+=5,r(c)}throw new Error("Unknown type 0x"+u.toString(16))}return s()}(this.streamer.data));if(["depositionDate","releaseDate","resolution","rFree","rWork","experimentalMethods"].forEach(function(t){void 0!==p[t]&&(l.header[t]=p[t])}),l.id=p.structureId,l.title=p.title,this.firstModelOnly||this.asTrajectory){for(u=1,s=0,t=0,e=c=p.chainsPerModel[0];t<e;++t)s+=p.groupsPerChain[t];for(a=0,t=0,e=s;t<e;++t)a+=(n=p.groupList[p.groupTypeList[t]]).atomNameList.length;o=p.numBonds,h=[c]}else o=p.numBonds,a=p.numAtoms,s=p.numGroups,c=p.numChains,u=p.numModels,h=p.chainsPerModel;if(o+=s,this.asTrajectory)for(t=0,e=p.numModels;t<e;++t){var d=new Float32Array(3*a),f=a*t;for(i=0;i<a;++i){var m=3*i,g=i+f;d[m]=p.xCoordList[g],d[m+1]=p.yCoordList[g],d[m+2]=p.zCoordList[g]}l.frames.push(d)}var v=new Uint32Array(o),y=new Uint32Array(o),b=new Uint8Array(o),x=new Uint32Array(a),_=new Uint32Array(s),w=new Uint32Array(s),S=new Uint16Array(s),A=new Uint16Array(c),M=new Uint32Array(c),P=new Uint32Array(c),T=new Uint32Array(u),E=new Uint32Array(u),C=0;for(t=0,e=u;t<e;++t){var I=h[t];for(T[t]=C,E[t]=I,i=0;i<I;++i)A[i+C]=t;C+=I}var R=p.groupsPerChain,L=0;for(t=0,e=c;t<e;++t){var O=R[t];for(M[t]=L,P[t]=O,i=0;i<O;++i)_[i+L]=t;L+=O}var N=0,D=0;for(t=0,e=s;t<e;++t){var k=(n=p.groupList[p.groupTypeList[t]]).atomNameList.length,F=n.bondAtomList,B=n.bondOrderList;for(i=0,r=B.length;i<r;++i)v[D]=N+F[2*i],y[D]=N+F[2*i+1],b[D]=B[i],D+=1;for(w[t]=N,S[t]=k,i=0;i<k;++i)x[N]=t,N+=1}var z=p.bondAtomList;if(z)for(p.bondOrderList&&b.set(p.bondOrderList,D),t=0,e=z.length;t<e;t+=2){var U=z[t],j=z[t+1];U<a&&j<a&&(v[D]=U,y[D]=j,D+=1)}l.bondStore.length=b.length,l.bondStore.count=D,l.bondStore.atomIndex1=v,l.bondStore.atomIndex2=y,l.bondStore.bondOrder=b,l.atomStore.length=a,l.atomStore.count=a,l.atomStore.residueIndex=x,l.atomStore.atomTypeId=new Uint16Array(a),l.atomStore.x=p.xCoordList.subarray(0,a),l.atomStore.y=p.yCoordList.subarray(0,a),l.atomStore.z=p.zCoordList.subarray(0,a),l.atomStore.serial=p.atomIdList.subarray(0,a),l.atomStore.bfactor=p.bFactorList.subarray(0,a),l.atomStore.altloc=p.altLocList.subarray(0,a),l.atomStore.occupancy=p.occupancyList.subarray(0,a),l.residueStore.length=s,l.residueStore.count=s,l.residueStore.chainIndex=_,l.residueStore.residueTypeId=p.groupTypeList,l.residueStore.atomOffset=w,l.residueStore.atomCount=S,l.residueStore.resno=p.groupIdList.subarray(0,s),l.residueStore.sstruc=p.secStructList.subarray(0,s),l.residueStore.inscode=p.insCodeList.subarray(0,s),l.chainStore.length=c,l.chainStore.count=c,l.chainStore.entityIndex=new Uint16Array(c),l.chainStore.modelIndex=A,l.chainStore.residueOffset=M,l.chainStore.residueCount=P,l.chainStore.chainname=p.chainNameList.subarray(0,4*c),l.chainStore.chainid=p.chainIdList.subarray(0,4*c),l.modelStore.length=u,l.modelStore.count=u,l.modelStore.chainOffset=T,l.modelStore.chainCount=E;var G={};for(t=0,e=p.groupList.length;t<e;++t){var V=p.groupList[t],$=[];for(i=0,r=V.atomNameList.length;i<r;++i){var H=V.elementList[i].toUpperCase(),W=V.atomNameList[i];$.push(l.atomMap.add(W,H))}var X=V.chemCompType.toUpperCase(),q=wp.includes(X),Y=V.bondOrderList.length,Z=new Array(Y),K=new Array(Y);for(i=0;i<Y;++i)Z[i]=V.bondAtomList[2*i],K[i]=V.bondAtomList[2*i+1];var Q={atomIndices1:Z,atomIndices2:K,bondOrders:V.bondOrderList};G[t]=l.residueMap.add(V.groupName,$,q,X,Q)}for(t=0,e=s;t<e;++t)l.residueStore.residueTypeId[t]=G[l.residueStore.residueTypeId[t]];for(t=0,e=l.atomStore.count;t<e;++t){var J=l.atomStore.residueIndex[t],tt=l.residueMap.list[l.residueStore.residueTypeId[J]],et=l.residueStore.atomOffset[J];l.atomStore.atomTypeId[t]=tt.atomTypeIdList[t-et]}if(p.secStructList){var it=p.secStructList.length;for(t=0,e=l.residueStore.count;t<e;++t){var rt=Ay[l.residueStore.sstruc[t%it]];void 0!==rt&&(l.residueStore.sstruc[t]=rt)}}if(p.entityList&&p.entityList.forEach(function(t,e){l.entityList[e]=new Xv(l,e,t.description,t.type,t.chainIndexList)}),p.bioAssemblyList&&p.bioAssemblyList.forEach(function(t,e){var i=e+1,r=new Vd(i);l.biomolDict["BU"+i]=r;var n={};t.transformList.forEach(function(t){var e=(new Pe).fromArray(t.matrix).transpose(),i=t.chainIndexList.map(function(t){for(var e="",i=0;i<4;++i){var r=p.chainNameList[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e}),o=n[i];o?o.matrixList.push(e):n[i]=r.addPart([e],i)})}),p.ncsOperatorList){var nt=new Vd("NCS"),ot=nt.addPart();p.ncsOperatorList.forEach(function(t){var e=(new Pe).fromArray(t).transpose();ot.matrixList.push(e)}),ot.matrixList.length>0&&(l.biomolDict.NCS=nt)}var at=p.unitCell;at&&Array.isArray(at)&&at[0]?l.unitcell=new Yv({a:at[0],b:at[1],c:at[2],alpha:at[3],beta:at[4],gamma:at[5],spacegroup:p.spaceGroup}):l.unitcell=void 0,Qd(l,!0),Kd(l,!0),l.finalizeAtoms(),l.finalizeBonds(),Jd(l),xu&&bu.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("mmtf",My);var Py=/\s+/,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 i={type:{}};return i.type.get=function(){return"mol2"},e.prototype._parse=function(){xu&&bu.time("Mol2Parser._parse "+this.name);var t,e,i=this.structure,r=this.structureBuilder,n=this.firstModelOnly,o=this.asTrajectory,a=i.frames,s=!1,c=i.atomMap,u=i.atomStore;u.resize(Math.round(this.streamer.data.length/60));var h=0,l=0,p=0,d=-1,f=0,m=0,g=1,v=2,y=3,b=i.getAtomProxy(),x=i.getAtomProxy(),_={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};this.streamer.eachChunkOfLines(function(w){!function(w,S,A){for(var M,P=w;P<S;++P){var T=A[P].trim();if(""!==T&&"#"!==T[0])if("@"===T[0])"@<TRIPOS>MOLECULE"===T?(m=g,l=0,++d):"@<TRIPOS>ATOM"===T?(m=v,p=u.count,o&&(e=0,t=new Float32Array(3*f),a.push(t),d>0&&(s=!0))):m="@<TRIPOS>BOND"===T?y:0;else if(m===g)0===l?(i.title=T,i.id=T):1===l&&(M=T.split(Py),f=parseInt(M[0])),++l;else if(m===v){if(M=T.split(Py),n&&d>0)continue;var E=parseFloat(M[2]),C=parseFloat(M[3]),I=parseFloat(M[4]);if(o){var R=3*e;if(t[R+0]=E,t[R+1]=C,t[R+2]=I,e+=1,s)continue}var L=M[0],O=M[1],N=M[5].split(".")[0],D=M[6]?parseInt(M[6]):1,k=M[7]?M[7]:"",F=M[8]?parseFloat(M[8]):0;u.growIfFull(),u.atomTypeId[h]=c.add(O,N),u.x[h]=E,u.y[h]=C,u.z[h]=I,u.serial[h]=L,u.bfactor[h]=F,r.addAtom(d,"","",k,D,1),h+=1}else if(m===y){if(n&&d>0)continue;if(o&&d>0)continue;M=T.split(Py),b.index=parseInt(M[1])-1+p,x.index=parseInt(M[2])-1+p;var B=_[M[3]];i.bondStore.addBond(b,x,B)}}}(0,w.length,w)}),r.finalize(),i.finalizeAtoms(),Yd(i),Kd(i,!0),Qd(i,!0),i.finalizeBonds(),nf(i),qd(i),xu&&bu.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("mol2",Ty);var 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 i={type:{}};return i.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,i),e}(Kv);Pu.add("pqr",Ey);var Cy=1,Iy=2,Ry=3,Ly=4,Oy=5,Ny=6,Dy=/\s+/,ky=/(^\*|REMARK)*/,Fy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"psf"},e.prototype._parse=function(){xu&&bu.time("PsfParser._parse "+this.name);var t,e,i,r,n=this.structure,o=this.structureBuilder,a=n.atomMap,s=n.atomStore,c=[],u=0,h=0;this.streamer.eachChunkOfLines(function(n){!function(n,l,p){for(var d=n;d<l;++d){var f=p[d].trim();if(f)if(t===Iy){var m=f.split(Dy),g=parseInt(m[0]),v=parseInt(m[2]),y=m[3],b=m[4];s.growIfFull(),s.atomTypeId[u]=a.add(b),s.serial[u]=g,o.addAtom(0,"","",y,v,1),u+=1}else if(t===Ry)for(var x=f.split(Dy),_=0,w=x.length;_<w;_+=2)e[h]=parseInt(x[_])-1,i[h]=parseInt(x[_+1])-1,r[h]=1,h+=1;else if(t===Cy)c.push(f.replace(ky,"").trim());else if(t===Ly);else if(t===Oy);else if(t===Ny);else if(f.includes("!NATOM")){t=Iy;var S=parseInt(f.split(Dy)[0]);s.resize(S)}else if(f.includes("!NBOND")){t=Ry;var A=parseInt(f.split(Dy)[0]);e=new Uint32Array(A),i=new Uint32Array(A),r=new Uint8Array(A)}else f.includes("!NTITLE")?t=Cy:f.includes("!NTHETA")?t=Ly:f.includes("!NPHI")?t=Oy:f.includes("!NIMPHI")&&(t=Ny);else t=void 0}}(0,n.length,n)}),n.title=c.join(" "),n.bondStore.length=r.length,n.bondStore.count=h,n.bondStore.atomIndex1=e,n.bondStore.atomIndex2=i,n.bondStore.bondOrder=r,o.finalize(),n.finalizeAtoms(),Yd(n),n.finalizeBonds(),nf(n),xu&&bu.timeEnd("PsfParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("psf",Fy);var By=/> <(.+)>/,zy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"sdf"},e.prototype._parse=function(){xu&&bu.time("SdfParser._parse "+this.name);var t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,n=this.streamer.peekLines(2);t.id=n[0].trim(),t.title=n[1].trim();var o,a,s=t.frames,c=!1,u=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50));var l,p,d,f,m,g,v,y=t.getAtomProxy(),b=t.getAtomProxy(),x=0,_=0,w=0,S=0,A=[],M=!1,P={};t.extraData.sdf=A,this.streamer.eachChunkOfLines(function(n){!function(n,T,E){for(var C=n;C<T;++C){var I=E[C];if("$$$$"===I.substr(0,4))_=-1,++w,S=h.count,A.push(P),P={},M=!1;else if(3===_)p=parseInt(I.substr(0,3)),d=parseInt(I.substr(3,3)),v=(g=m=(f=4)+p)+d,r&&(a=0,o=new Float32Array(3*p),s.push(o),w>0&&(c=!0));else if(_>=f&&_<m){if(i&&w>0)continue;var R=parseFloat(I.substr(0,10)),L=parseFloat(I.substr(10,10)),O=parseFloat(I.substr(20,10));if(r){var N=3*a;if(o[N+0]=R,o[N+1]=L,o[N+2]=O,a+=1,c)continue}var D=I.substr(31,3).trim(),k=D+(x+1);h.growIfFull(),h.atomTypeId[x]=u.add(k,D),h.x[x]=R,h.y[x]=L,h.z[x]=O,h.serial[x]=x,e.addAtom(w,"","","HET",1,1),x+=1}else if(_>=g&&_<v){if(i&&w>0)continue;if(r&&w>0)continue;y.index=parseInt(I.substr(0,3))-1+S,b.index=parseInt(I.substr(3,3))-1+S;var F=parseInt(I.substr(6,3));t.bondStore.addBond(y,b,F)}else(l=I.match(By))?(M=l[1],P[M]=[]):!1!==M&&I&&P[M].push(I);++_}}(0,n.length,n)}),e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),nf(t),xu&&bu.timeEnd("SdfParser._parse "+this.name)},e.prototype._postProcess=function(){nf(this.structure)},Object.defineProperties(e.prototype,i),e}(Wv);Pu.add("sdf",zy),Pu.add("sd",zy);var Uy=function(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[]},jy={type:{}};jy.type.get=function(){return"Frames"},Object.defineProperties(Uy.prototype,jy);var Gy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"dcd"},e.prototype._parse=function(){xu&&bu.time("DcdParser._parse "+this.name);var t=this.streamer.data;t instanceof Uint8Array&&(t=t.buffer);var e,i,r=new DataView(t),n=this.frames,o=n.coordinates,a=n.boxes,s={},c=0,u=new Int32Array(t,0,23),h=u[0]!==r.getInt32(0);if(84!==u[0])for(i=t.byteLength,e=0;e<i;e+=4)r.setFloat32(e,r.getFloat32(e),!0);84!==u[0]&&bu.error("dcd bad format, header block start"),"CORD"!==String.fromCharCode(r.getUint8(4),r.getUint8(5),r.getUint8(6),r.getUint8(7))&&bu.error("dcd bad format, format string");var l=!1,p=!1,d=!1;0!==u[22]&&(l=!0,0!==u[12]&&(p=!0),1===u[13]&&(d=!0)),s.NSET=u[2],s.ISTART=u[3],s.NSAVC=u[4],s.NAMNF=u[10],s.DELTA=l?r.getFloat32(44,h):r.getFloat64(44,h),84!==u[22]&&bu.error("dcd bad format, header block end"),c=c+84+8;var f=r.getInt32(c,h),m=c+1;if((f-4)%80!==0&&bu.error("dcd bad format, title block start"),s.TITLE=ja(new Uint8Array(t,m,f)),r.getInt32(m+f+4-1,h)!==f&&bu.error("dcd bad format, title block end"),c=c+f+8,4!==r.getInt32(c,h)&&bu.error("dcd bad format, natom block start"),s.NATOM=r.getInt32(c+4,h),4!==r.getInt32(c+8,h)&&bu.error("dcd bad format, natom block end"),c=c+4+8,s.NAMNF>0)bu.error("dcd format with fixed atoms unsupported, aborting");else{var g=s.NATOM,v=4*g;for(e=0,i=s.NSET;e<i;++e){if(p){c+=4;var y=new Float32Array(9);y[0]=r.getFloat64(c,h),y[4]=r.getFloat64(c+16,h),y[8]=r.getFloat64(c+40,h),a.push(y),c+=48,c+=4}for(var b=new Float32Array(3*g),x=0;x<3;++x){r.getInt32(c,h)!==v&&bu.error("dcd bad format, coord block start",e,x),c+=4;for(var _=new Float32Array(t,c,g),w=0;w<g;++w)b[3*w+x]=_[w];c+=v,r.getInt32(c,h)!==v&&bu.error("dcd bad format, coord block end",e,x),c+=4}if(o.push(b),d)c+=4+r.getInt32(c,h)+4}xu&&bu.timeEnd("DcdParser._parse "+this.name)}},Object.defineProperties(e.prototype,i),e}(function(t){function e(e,i){t.call(this,e,i),this.frames=new Uy(this.name,this.path)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"trajectory"},i.__objName.get=function(){return"frames"},Object.defineProperties(e.prototype,i),e}(Vv));Pu.add("dcd",Gy);var Vy=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.volume=new Ad(this.name,this.path),this.voxelSize=Oa(r.voxelSize,1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"volume"},i.__objName.get=function(){return"volume"},e.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix())},e.prototype.getMatrix=function(){return new Pe},Object.defineProperties(e.prototype,i),e}(Vv),$y=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"cube"},e.prototype._parse=function(){xu&&bu.time("CubeParser._parse "+this.name);var t=this.volume,e=this.streamer.peekLines(6),i={},r=/\s+/,n=.529177210859*this.voxelSize;function o(t,i){var n=e[t].trim().split(r)[i];return parseFloat(n)}i.atomCount=Math.abs(o(2,0)),i.originX=.529177210859*o(2,1),i.originY=.529177210859*o(2,2),i.originZ=.529177210859*o(2,3),i.NVX=o(3,0),i.NVY=o(4,0),i.NVZ=o(5,0),i.basisX=new Me(o(3,1),o(3,2),o(3,3)).multiplyScalar(n),i.basisY=new Me(o(4,1),o(4,2),o(4,3)).multiplyScalar(n),i.basisZ=new Me(o(5,1),o(5,2),o(5,3)).multiplyScalar(n);var a=new Float32Array(i.NVX*i.NVY*i.NVZ),s=0,c=0,u=o(2,0)>0?0:1;this.streamer.eachChunkOfLines(function(t){!function(t,e,n){for(var o=t;o<e;++o){var h=n[o].trim();if(""!==h&&c>=i.atomCount+6+u)for(var l=0,p=(h=h.split(r)).length;l<p;++l)1!==h.length&&(a[s]=parseFloat(h[l]),++s);++c}}(0,t.length,t)}),t.header=i,t.setData(a,i.NVZ,i.NVY,i.NVX),xu&&bu.timeEnd("CubeParser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=new Pe;return e.multiply((new Pe).makeTranslation(t.originX,t.originY,t.originZ)),e.multiply((new Pe).makeBasis(t.basisZ,t.basisY,t.basisX)),e},Object.defineProperties(e.prototype,i),e}(Vy);Pu.add("cub",$y),Pu.add("cube",$y);var 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 i={type:{}};return i.type.get=function(){return"dsn6"},e.prototype._parse=function(){xu&&bu.time("Dsn6Parser._parse "+this.name);var t=this.streamer.data;t instanceof Uint8Array&&(t=t.buffer);var e,i,r=this.volume,n={},o=new Int16Array(t),a=new Uint8Array(t),s=String.fromCharCode.apply(null,a.subarray(0,512));if(s.startsWith(":-)"))n.xStart=parseInt(s.substr(10,5)),n.yStart=parseInt(s.substr(15,5)),n.zStart=parseInt(s.substr(20,5)),n.xExtent=parseInt(s.substr(32,5)),n.yExtent=parseInt(s.substr(38,5)),n.zExtent=parseInt(s.substr(42,5)),n.xRate=parseInt(s.substr(52,5)),n.yRate=parseInt(s.substr(58,5)),n.zRate=parseInt(s.substr(62,5)),n.xlen=parseFloat(s.substr(73,10))*this.voxelSize,n.ylen=parseFloat(s.substr(83,10))*this.voxelSize,n.zlen=parseFloat(s.substr(93,10))*this.voxelSize,n.alpha=parseFloat(s.substr(103,10)),n.beta=parseFloat(s.substr(113,10)),n.gamma=parseFloat(s.substr(123,10)),e=parseFloat(s.substr(138,12))/100,i=parseInt(s.substr(155,8));else{if(100!==o[18])for(var c=0,u=o.length;c<u;++c){var h=o[c];o[c]=(255&h)<<8|h>>8&255}n.xStart=o[0],n.yStart=o[1],n.zStart=o[2],n.xExtent=o[3],n.yExtent=o[4],n.zExtent=o[5],n.xRate=o[6],n.yRate=o[7],n.zRate=o[8];var l=1/o[17],p=l*this.voxelSize;n.xlen=o[9]*p,n.ylen=o[10]*p,n.zlen=o[11]*p,n.alpha=o[12]*l,n.beta=o[13]*l,n.gamma=o[14]*l,e=o[15]/100,i=o[16]}r.header=n,bu.log(n,e,i);for(var d=new Float32Array(n.xExtent*n.yExtent*n.zExtent),f=512,m=Math.ceil(n.xExtent/8),g=Math.ceil(n.yExtent/8),v=Math.ceil(n.zExtent/8),y=0;y<v;++y)for(var b=0;b<g;++b)for(var x=0;x<m;++x)for(var _=0;_<8;++_)for(var w=8*y+_,S=0;S<8;++S)for(var A=8*b+S,M=0;M<8;++M){var P=8*x+M;if(!(P<n.xExtent&&A<n.yExtent&&w<n.zExtent)){f+=8-M;break}d[(P*n.yExtent+A)*n.zExtent+w]=(a[f]-i)/e,++f}r.setData(d,n.zExtent,n.yExtent,n.xExtent),xu&&bu.timeEnd("Dsn6Parser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],r=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[0,e,i,r],o=[0,t.xRate,t.yRate,t.zRate],a=[0,1,2,3],s=new Pe;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.multiply((new Pe).makeRotationY(is(90))),s.multiply((new Pe).makeTranslation(-t.zStart,t.yStart,t.xStart)),s.multiply((new Pe).makeScale(-1,1,1)),s},Object.defineProperties(e.prototype,i),e}(Vy);Pu.add("dsn6",Hy),Pu.add("brix",Hy);var Wy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"dx"},e.prototype._parse=function(){xu&&bu.time("DxParser._parse "+this.name);var t=this.volume,e=this.streamer.peekLines(30),i=this.parseHeaderLines(e),r=this.volume.header,n=i.dataLineStart,o=/\s+/,a=r.nx*r.ny*r.nz,s=new Float32Array(a),c=0,u=0;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){if(c<a&&u>n){var h=i[r].trim();if(""!==h)for(var l=h.split(o),p=0,d=l.length;p<d;++p)s[c]=parseFloat(l[p]),++c}++u}}(0,t.length,t)}),t.setData(s,r.nz,r.ny,r.nx),xu&&bu.timeEnd("DxParser._parse "+this.name)},e.prototype.parseHeaderLines=function(t){for(var e={},i=/\s+/,r=t.length,n=0,o=0,a=0,s=0;s<r;++s){var c,u=t[s];if(u.startsWith("object 1"))c=u.split(i),e.nx=parseInt(c[5]),e.ny=parseInt(c[6]),e.nz=parseInt(c[7]);else if(u.startsWith("origin"))c=u.split(i),e.xmin=parseFloat(c[1]),e.ymin=parseFloat(c[2]),e.zmin=parseFloat(c[3]);else if(u.startsWith("delta"))c=u.split(i),0===a?e.hx=parseFloat(c[1])*this.voxelSize:1===a?e.hy=parseFloat(c[2])*this.voxelSize:2===a&&(e.hz=parseFloat(c[3])*this.voxelSize),a+=1;else if(u.startsWith("object 3")){n=s,o+=u.length+1;break}o+=u.length+1}return this.volume.header=e,{dataLineStart:n,headerByteCount:o}},e.prototype.getMatrix=function(){var t=this.volume.header,e=new Pe;return e.multiply((new Pe).makeRotationY(is(90))),e.multiply((new Pe).makeTranslation(-t.zmin,t.ymin,t.xmin)),e.multiply((new Pe).makeScale(-t.hz,t.hy,t.hx)),e},Object.defineProperties(e.prototype,i),e}(Vy);Pu.add("dx",Wy);var Xy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"dxbin"},e.prototype._parse=function(){xu&&bu.time("DxbinParser._parse "+this.name);var t=this.streamer.data;t instanceof Uint8Array&&(t=t.buffer);for(var e=function(t,e,i){e=void 0!==e?e:10485760,i=void 0!==i?i:"\n";for(var r="",n=[],o=0;o<t.length;o+=e){var a=ja(t.subarray(o,o+e)),s=a.lastIndexOf(i);if(-1===s)r+=a;else{var c=r+a.substr(0,s);n=n.concat(c.split(i)),r=s===a.length-i.length?"":a.substr(s+i.length)}}return""!==r&&n.push(r),n}(new Uint8Array(t,0,1e3)),i=this.parseHeaderLines(e),r=this.volume.header,n=i.headerByteCount,o=r.nx*r.ny*r.nz,a=new DataView(t),s=new Float32Array(o),c=0;c<o;++c)s[c]=a.getFloat64(8*c+n,!0);this.volume.setData(s,r.nz,r.ny,r.nx),xu&&bu.timeEnd("DxbinParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Wy);Pu.add("dxbin",Xy);var qy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"mrc"},e.prototype._parse=function(){xu&&bu.time("MrcParser._parse "+this.name);var t=this.streamer.data;t instanceof Uint8Array&&(t=t.buffer);var e,i=this.volume,r={},n=new Int32Array(t,0,56),o=new Float32Array(t,0,56),a=new DataView(t);if(r.MAP=String.fromCharCode(a.getUint8(208),a.getUint8(209),a.getUint8(210),a.getUint8(211)),r.MACHST=[a.getUint8(212),a.getUint8(213)],17===r.MACHST[0]&&17===r.MACHST[1])for(var s=t.byteLength,c=0;c<s;c+=4)a.setFloat32(c,a.getFloat32(c),!0);if(r.NX=n[0],r.NY=n[1],r.NZ=n[2],r.MODE=n[3],r.NXSTART=n[4],r.NYSTART=n[5],r.NZSTART=n[6],r.MX=n[7],r.MY=n[8],r.MZ=n[9],r.xlen=o[10]*this.voxelSize,r.ylen=o[11]*this.voxelSize,r.zlen=o[12]*this.voxelSize,r.alpha=o[13],r.beta=o[14],r.gamma=o[15],r.MAPC=n[16],r.MAPR=n[17],r.MAPS=n[18],r.DMIN=o[19],r.DMAX=o[20],r.DMEAN=o[21],r.ISPG=n[22],r.NSYMBT=n[23],r.LSKFLG=n[24],r.originX=o[49],r.originY=o[50],r.originZ=o[51],r.ARMS=o[54],i.header=r,2===r.MODE)e=new Float32Array(t,1024+r.NSYMBT,r.NX*r.NY*r.NZ);else if(0===r.MODE){if(e=new Float32Array(new Int8Array(t,1024+r.NSYMBT,r.NX*r.NY*r.NZ)),-128===n[39]&&127===n[40])for(var u=(r.DMAX-r.DMIN)/255,h=.5*(r.DMIN+r.DMAX+u),l=0,p=e.length;l<p;++l)e[l]=u*e[l]+h}else bu.error("MrcParser unknown mode",r.MODE);i.setData(e,r.NX,r.NY,r.NZ),xu&&bu.timeEnd("MrcParser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],r=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[0,e,i,r],o=[0,t.MX,t.MY,t.MZ],a=[0,t.MAPC,t.MAPR,t.MAPS],s=new Pe;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.setPosition(new Me(t.originX,t.originY,t.originZ)),s.multiply((new Pe).makeTranslation(t.NXSTART,t.NYSTART,t.NZSTART)),s},Object.defineProperties(e.prototype,i),e}(Vy);Pu.add("mrc",qy),Pu.add("ccp4",qy),Pu.add("map",qy);var Yy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"xplor"},e.prototype._parse=function(){xu&&bu.time("XplorParser._parse "+this.name);var t,e=this.volume,i=this.streamer.peekLines(8),r={},n=/\s+/;function o(t){return t.trim().split(n).map(parseFloat)}var a=(t=i[2].startsWith("REMARKS")?parseInt(i[1].substring(0,8))+2:5)+3,s=o(i[t]);r.NA=s[0],r.AMIN=s[1],r.AMAX=s[2],r.NB=s[3],r.BMIN=s[4],r.BMAX=s[5],r.NC=s[6],r.CMIN=s[7],r.CMAX=s[8];var c=o(i[t+1]);r.a=c[0]*this.voxelSize,r.b=c[1]*this.voxelSize,r.c=c[2]*this.voxelSize,r.alpha=c[3],r.beta=c[4],r.gamma=c[5];var u=r.AMAX-r.AMIN+1,h=r.BMAX-r.BMIN+1,l=r.CMAX-r.CMIN+1,p=u*h*l,d=new Float32Array(p),f=0,m=0,g=1+u*h/6;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r];if(m>=a&&(m-a)%g!==0&&f<p)for(var o=0;o<6;++o)d[f]=parseFloat(n.substr(12*o,12)),++f;++m}}(0,t.length,t)}),e.header=r,e.setData(d,u,h,l),xu&&bu.timeEnd("XplorParser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=[t.a,0,0],i=[t.b*Math.cos(Math.PI/180*t.gamma),t.b*Math.sin(Math.PI/180*t.gamma),0],r=[t.c*Math.cos(Math.PI/180*t.beta),t.c*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.c*t.c*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[0,e,i,r],o=[0,t.NA,t.NB,t.NC],a=[0,1,2,3],s=new Pe;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.multiply((new Pe).makeTranslation(t.AMIN,t.BMIN,t.CMIN)),s},Object.defineProperties(e.prototype,i),e}(Vy);Pu.add("xplor",Yy),Pu.add("cns",Yy);var Zy=function(t){function e(e,i){t.call(this,e,i),this.loader=this.getLoader(),this.surface=new _d(this.name,this.path)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"surface"},i.__objName.get=function(){return"surface"},e.prototype._parse=function(){var t=this.loader.parse(this.streamer.asText());this.surface.fromGeometry(t)},Object.defineProperties(e.prototype,i),e}(Vv);function Ky(){this.regexp={vertex_pattern:/^v\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)/,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 /}}Ky.prototype={constructor:Ky,setPath:function(t){this.path=t},_createParserState:function(){var t={objects:[],object:{},vertices:[],normals:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);this.object={name:t||"",geometry:{vertices:[],normals:[]},fromDeclaration:!1!==e},this.objects.push(this.object)},parseVertexIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseNormalIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},addVertex:function(t,e,i){var r=this.vertices,n=this.object.geometry.vertices;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])},addVertexLine:function(t){var e=this.vertices,i=this.object.geometry.vertices;i.push(e[t+0]),i.push(e[t+1]),i.push(e[t+2])},addNormal:function(t,e,i){var r=this.normals,n=this.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])},addFace:function(t,e,i,r,n,o,a,s){var c,u=this.vertices.length,h=this.parseVertexIndex(t,u),l=this.parseVertexIndex(e,u),p=this.parseVertexIndex(i,u);if(void 0===r?this.addVertex(h,l,p):(c=this.parseVertexIndex(r,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===r?this.addNormal(h,l,p):(c=this.parseNormalIndex(s,d),this.addNormal(h,l,c),this.addNormal(l,p,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,r=t.length;i<r;i++)this.addVertexLine(this.parseVertexIndex(t[i],e))}};return t.startObject("",!1),t},parse:function(t){var e,i,r=this._createParserState();-1!==t.indexOf("\r\n")&&(t=t.replace(/\r\n/g,"\n")),-1!==t.indexOf("\\\n")&&(t=t.replace(/\\\n/g,""));var n=t.split("\n"),o="",a="",s="",c=[],u="function"===typeof"".trimLeft;for(e=0,i=n.length;e<i;e++)if(o=n[e],0!==(o=u?o.trimLeft():o.trim()).length&&"#"!==(a=o.charAt(0)))if("v"===a){if(" "===(s=o.charAt(1))&&null!==(c=this.regexp.vertex_pattern.exec(o)))r.vertices.push(parseFloat(c[1]),parseFloat(c[2]),parseFloat(c[3]));else if("n"===s&&null!==(c=this.regexp.normal_pattern.exec(o)))r.normals.push(parseFloat(c[1]),parseFloat(c[2]),parseFloat(c[3]));else if("t"!==s||null===(c=this.regexp.uv_pattern.exec(o)))throw new Error("Unexpected vertex/normal/uv line: '"+o+"'")}else if("f"===a)if(null!==(c=this.regexp.face_vertex_uv_normal.exec(o)))r.addFace(c[1],c[4],c[7],c[10],c[3],c[6],c[9],c[12]);else if(null!==(c=this.regexp.face_vertex_uv.exec(o)));else if(null!==(c=this.regexp.face_vertex_normal.exec(o)))r.addFace(c[1],c[3],c[5],c[7],c[2],c[4],c[6],c[8]);else{if(null===(c=this.regexp.face_vertex.exec(o)))throw new Error("Unexpected face line: '"+o+"'");r.addFace(c[1],c[2],c[3],c[4])}else if("l"===a){var h=o.substring(1).trim().split(" "),l=[],p=[];if(-1===o.indexOf("/"))l=h;else for(var d=0,f=h.length;d<f;d++){var m=h[d].split("/");""!==m[0]&&l.push(m[0]),""!==m[1]&&p.push(m[1])}r.addLineGeometry(l,p)}else if(null!==(c=this.regexp.object_pattern.exec(o))){var g=c[0].substr(1).trim();r.startObject(g)}else if(this.regexp.material_use_pattern.test(o));else if(this.regexp.material_library_pattern.test(o));else if(null===(c=this.regexp.smoothing_pattern.exec(o))){if("\0"===o)continue;throw new Error("Unexpected line: '"+o+"'")}var v=[];for(e=0,i=r.objects.length;e<i;e++){var y=r.objects[e].geometry;if(0!==y.vertices.length){var b=new Ki;b.addAttribute("position",new Hi(new Float32Array(y.vertices),3)),y.normals.length>0?b.addAttribute("normal",new Hi(new Float32Array(y.normals),3)):b.computeVertexNormals(),v.push(b)}}return v}};var Qy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new Ky},Object.defineProperties(e.prototype,i),e}(Zy);function Jy(){this.propertyNameMapping={}}Pu.add("obj",Qy),Jy.prototype={constructor:Jy,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r<t.byteLength;r++)i+=String.fromCharCode(e[r]);return i},isASCII:function(t){return"ascii"===this.parseHeader(this.bin2str(t)).format},parse:function(t){return t instanceof ArrayBuffer?this.isASCII(t)?this.parseASCII(this.bin2str(t)):this.parseBinary(t):this.parseASCII(t)},parseHeader:function(t){var e="",i=0,r=/ply([\s\S]*)end_header\s/.exec(t);null!==r&&(e=r[1],i=r[0].length);var n,o,a,s={comments:[],elements:[],headerLength:i},c=e.split("\n");function u(t,e){var i={type:t[0]};return"list"===i.type?(i.name=t[3],i.countType=t[1],i.itemType=t[2]):i.name=t[1],i.name in e&&(i.name=e[i.name]),i}for(var h=0;h<c.length;h++){var l=c[h];if(""!==(l=l.trim()))switch(o=(a=l.split(/\s+/)).shift(),l=a.join(" "),o){case"format":s.format=a[0],s.version=a[1];break;case"comment":s.comments.push(l);break;case"element":void 0!==n&&s.elements.push(n),(n={}).name=a[0],n.count=parseInt(a[1]),n.properties=[];break;case"property":n.properties.push(u(a,this.propertyNameMapping));break;default:console.log("unhandled",o,a)}}return void 0!==n&&s.elements.push(n),s},parseASCIINumber:function(t,e){switch(e){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(t);case"float":case"double":case"float32":case"float64":return parseFloat(t)}},parseASCIIElement:function(t,e){for(var i=e.split(/\s+/),r={},n=0;n<t.length;n++)if("list"===t[n].type){for(var o=[],a=this.parseASCIINumber(i.shift(),t[n].countType),s=0;s<a;s++)o.push(this.parseASCIINumber(i.shift(),t[n].itemType));r[t[n].name]=o}else r[t[n].name]=this.parseASCIINumber(i.shift(),t[n].type);return r},parseASCII:function(t){var e,i=new $i,r=this.parseHeader(t),n="";null!==(e=/end_header\s([\s\S]*)$/.exec(t))&&(n=e[1]);var o=n.split("\n"),a=0,s=0;i.useColor=!1;for(var c=0;c<o.length;c++){var u=o[c];if(""!==(u=u.trim())){s>=r.elements[a].count&&(a++,s=0);var h=this.parseASCIIElement(r.elements[a].properties,u);this.handleElement(i,r.elements[a].name,h),s++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e<t.faces.length;e++)t.faces[e].vertexColors=[t.colors[t.faces[e].a],t.colors[t.faces[e].b],t.colors[t.faces[e].c]];t.elementsNeedUpdate=!0}return t.computeBoundingSphere(),t},handleElement:function(t,e,i){if("vertex"===e){if(t.vertices.push(new Me(i.x,i.y,i.z)),"red"in i&&"green"in i&&"blue"in i){t.useColor=!0;var r=new mi;r.setRGB(i.red/255,i.green/255,i.blue/255),t.colors.push(r)}}else if("face"===e){var n=i.vertex_indices;3===n.length?t.faces.push(new ji(n[0],n[1],n[2])):4===n.length&&t.faces.push(new ji(n[0],n[1],n[3]),new ji(n[1],n[2],n[3]))}},binaryRead:function(t,e,i,r){switch(i){case"int8":case"char":return[t.getInt8(e),1];case"uint8":case"uchar":return[t.getUint8(e),1];case"int16":case"short":return[t.getInt16(e,r),2];case"uint16":case"ushort":return[t.getUint16(e,r),2];case"int32":case"int":return[t.getInt32(e,r),4];case"uint32":case"uint":return[t.getUint32(e,r),4];case"float32":case"float":return[t.getFloat32(e,r),4];case"float64":case"double":return[t.getFloat64(e,r),8]}},binaryReadElement:function(t,e,i,r){for(var n,o={},a=0,s=0;s<i.length;s++)if("list"===i[s].type){var c=[],u=(n=this.binaryRead(t,e+a,i[s].countType,r))[0];a+=n[1];for(var h=0;h<u;h++)n=this.binaryRead(t,e+a,i[s].itemType,r),c.push(n[0]),a+=n[1];o[i[s].name]=c}else n=this.binaryRead(t,e+a,i[s].type,r),o[i[s].name]=n[0],a+=n[1];return[o,a]},parseBinary:function(t){for(var e,i=new $i,r=this.parseHeader(this.bin2str(t)),n="binary_little_endian"===r.format,o=new DataView(t,r.headerLength),a=0,s=0;s<r.elements.length;s++)for(var c=0;c<r.elements[s].count;c++){a+=(e=this.binaryReadElement(o,a,r.elements[s].properties,n))[1];var u=e[0];this.handleElement(i,r.elements[s].name,u)}return this.postProcess(i)}};var tb=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"ply"},e.prototype.getLoader=function(){return new Jy},Object.defineProperties(e.prototype,i),e}(Zy);Pu.add("ply",tb);var eb=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.delimiter=Oa(r.delimiter,","),this.comment=Oa(r.comment,"#"),this.columnNames=Oa(r.columnNames,!1),this.table={name:this.name,path:this.path,columnNames:[],data:[]}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"csv"},i.__objName.get=function(){return"table"},e.prototype._parse=function(){var t=this,e=this.table.data,i=new RegExp("\\s*"+this.delimiter+"\\s*"),r=0;this.streamer.eachChunkOfLines(function(n){for(var o=n.length,a=0;a<o;++a){var s=n[a].trim();if(!s.startsWith(t.comment)){var c=s.split(i);0===r?t.table.columnNames=c:s&&e.push(c),++r}}})},Object.defineProperties(e.prototype,i),e}(Vv);Pu.add("csv",eb);var ib=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.string=Oa(r.string,!1),this.json={name:this.name,path:this.path,data:{}}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"json"},i.__objName.get=function(){return"json"},e.prototype._parse=function(){this.streamer.isBinary()||this.string?this.json.data=JSON.parse(this.streamer.asText()):this.json.data=this.streamer.data},Object.defineProperties(e.prototype,i),e}(Vv);Pu.add("json",ib);var rb=function(t){function e(e,i){t.call(this,e,i),this.text={name:this.name,path:this.path,data:""}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"text"},i.__objName.get=function(){return"text"},e.prototype._parse=function(){this.text.data=this.streamer.asText()},Object.defineProperties(e.prototype,i),e}(Vv);Pu.add("txt",rb),Pu.add("text",rb);var nb=/^['"]|['"]$/g,ob=/^<([\w-:.]+)\s*/,ab=/^([^<]*)/,sb=/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/;function cb(t){return t=t.trim().replace(//g,""),{declaration:e(),root:i()};function e(){if(n(/^<\?xml\s*/)){for(var t={attributes:{}};!o()&&!a("?>");){var e=r();if(!e)return t;t.attributes[e.name]=e.value}return n(/\?>\s*/),t}}function i(){var t=n(ob);if(t){for(var e,s={name:t[1],attributes:{},children:[]};!(o()||a(">")||a("?>")||a("/>"));){var c=r();if(!c)return s;s.attributes[c.name]=c.value}if(n(/^\s*\/>\s*/))return s;for(n(/\??>\s*/),s.content=function(){var t=n(ab);if(t)return t[1];return""}();e=i();)s.children.push(e);return n(/^<\/[\w-:.]+>\s*/),s}}function r(){var t,e=n(sb);if(e)return{name:e[1],value:(t=e[2],t.replace(nb,""))}}function n(e){var i=t.match(e);if(i)return t=t.slice(i[0].length),i}function o(){return 0===t.length}function a(e){return 0===t.indexOf(e)}}var ub=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.useDomParser=Oa(r.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"xml"},i.__objName.get=function(){return"xml"},e.prototype.__xmlParser=function(t){return cb(t)},e.prototype.__domParser=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")},e.prototype._parse=function(){xu&&bu.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof window.Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),xu&&bu.timeEnd("XmlParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(Vv);function hb(t,e,i){var r=t.icode.value,n=t.chain.value,o=t.altcode.value,a=t.resnum.value;return r.trim()&&(a+="^"+r),n.trim()&&(a+=":"+n),e&&(a+="."+e),i&&o.trim()&&(a+="%"+o),a+="/"+(parseInt(t.model.value)-1)}function lb(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function pb(t,e){return void 0!==t&&t.value===e}function db(t,e,i){for(var r=0,n=e.getElementsByTagName("clash"),o=0,a=n.length;o<a;++o)if(t[n[o].attributes.cid.value]){r+=1;break}return e.getElementsByTagName("angle-outlier").length>0&&(r+=1),e.getElementsByTagName("bond-outlier").length>0&&(r+=1),e.getElementsByTagName("plane-outlier").length>0&&(r+=1),pb(i.rota,"OUTLIER")&&(r+=1),pb(i.rama,"OUTLIER")&&(r+=1),pb(i.RNApucker,"outlier")&&(r+=1),r}Pu.add("xml",ub);var fb=function(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"},mb={type:{}};mb.type.get=function(){return"validation"},fb.prototype.fromXml=function(t){xu&&bu.time("Validation.fromXml");var e=this.rsrzDict,i=this.rsccDict,r=this.clashDict,n=this.clashArray,o=this.geoDict,a=this.geoAtomDict,s=this.atomDict,c=t.getElementsByTagName("ModelledSubgroup"),u={},h=[];xu&&bu.time("Validation.fromXml#clashDict");for(var l=0,p=c.length;l<p;++l){var d=c[l],f=d.attributes,m=hb(f);void 0!==f.rsrz&&(e[m]=parseFloat(f.rsrz.value)),void 0!==f.rscc&&(i[m]=parseFloat(f.rscc.value)),f.sele=m;for(var g=d.getElementsByTagName("clash"),v=0,y=g.length;v<y;++v){var b=g[v].attributes,x=b.atom.value;if("H"!==rf(x)){var _=b.cid.value,w=hb(f,x,!0);if(s[w]=!0,void 0===u[_])u[_]={sele1:w,res1:m};else{var S=u[_];S.res1!==m&&(S.sele2=w,S.res2=m,h.push(S.res1,m),r[_]=S,n.push(S))}}}}xu&&bu.timeEnd("Validation.fromXml#clashDict");for(var A=0,M=c.length;A<M;++A){var P=c[A],T=P.attributes,E=T.sele;if("."!==T.seq.value){var C=db(r,P,T);C>0&&(o[E]=C)}else{var I=P.getElementsByTagName("clash"),R=P.getElementsByTagName("mog-bond-outlier"),L=P.getElementsByTagName("mog-angle-outlier");if(R.length>0||L.length>0||I.length>0){var O={};a[E]=O;for(var N=0,D=I.length;N<D;++N){var k=I[N].attributes;r[k.cid.value]&&lb(O,k.atom.value,1)}for(var F=0,B=R.length;F<B;++F){R[F].attributes.atoms.value.split(",").forEach(function(t){lb(O,t,2)})}for(var z=0,U=L.length;z<U;++z){L[z].attributes.atoms.value.split(",").forEach(function(t){lb(O,t,4)})}}}}this.clashSele=h.length?h.join(" OR "):"NONE",xu&&bu.timeEnd("Validation.fromXml")},fb.prototype.getClashData=function(t){xu&&bu.time("Validation.getClashData");var e=t||{},i=e.structure,r=i.atomSet,n=new mi(Oa(e.color,"#f0027f")),o=i.getAtomProxy(),a=i.getAtomProxy(),s=new Me,c=new Me,u=new Me,h=this.clashArray,l=h.length,p=new Float32Array(3*l),d=new Float32Array(3*l),f=lh(l,n.r,n.g,n.b),m=new Float32Array(l),g=new Float32Array(l);xu&&bu.time("Validation.getClashData#atomDict");var v=this.atomDict;i.eachAtom(function(t){var e=function(t){var e=t.inscode,i=t.chainname,r=t.atomname,n=t.altloc,o=t.resno;return e&&(o+="^"+e),i&&(o+=":"+i),r&&(o+="."+r),n&&(o+="%"+n),o+="/"+t.modelIndex}(t);!0===v[e]&&(v[e]=t.index)}),xu&&bu.timeEnd("Validation.getClashData#atomDict");var y=0;return h.forEach(function(t,e){if(o.index=v[t.sele1],a.index=v[t.sele2],void 0!==o.index&&void 0!==a.index&&r.isSet(o.index,a.index)){s.subVectors(a,o).setLength(o.vdw),c.copy(o).add(s),s.subVectors(o,a).setLength(a.vdw),u.copy(a).add(s);var i=o.distanceTo(a)/2,n=Math.sqrt(o.vdw*o.vdw-i*i),h=Math.sqrt(a.vdw*a.vdw-i*i);c.toArray(p,3*y),u.toArray(d,3*y),m[y]=(n+h)/2,g[y]=e,++y}}),xu&&bu.timeEnd("Validation.getClashData"),{position1:p.subarray(0,3*y),position2:d.subarray(0,3*y),color:f.subarray(0,3*y),color2:f.subarray(0,3*y),radius:m.subarray(0,y),picking:new tp(g.subarray(0,y),this,i)}},Object.defineProperties(fb.prototype,mb);var gb=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.useDomParser=!0,this.validation=new fb(this.name,this.path)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__objName:{}};return i.__objName.get=function(){return"validation"},e.prototype._parse=function(){t.prototype._parse.call(this),xu&&bu.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),xu&&bu.timeEnd("ValidationParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(ub);function vb(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)}function yb(t,e,i,r,n){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+r),n);else for(var o=0;o<r;o++)t[n+o]=e[i+o]}function bb(t,e,i,r){for(var n=65535&t|0,o=t>>>16&65535|0,a=0;0!==i;){i-=a=i>2e3?2e3:i;do{o=o+(n=n+e[r++]|0)|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}Pu.add("validation",gb);var xb=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();function _b(t,e,i,r){var n=xb,o=r+i;t^=-1;for(var a=r;a<o;a++)t=t>>>8^n[255&(t^e[a])];return-1^t}var wb=30,Sb=12;function Ab(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P;i=t.state,r=t.next_in,M=t.input,n=r+(t.avail_in-5),o=t.next_out,P=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),c=i.dmax,u=i.wsize,h=i.whave,l=i.wnext,p=i.window,d=i.hold,f=i.bits,m=i.lencode,g=i.distcode,v=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;t:do{f<15&&(d+=M[r++]<<f,f+=8,d+=M[r++]<<f,f+=8),b=m[d&v];e:for(;;){if(d>>>=x=b>>>24,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)-1)];continue e}if(32&x){i.mode=Sb;break t}t.msg="invalid literal/length code",i.mode=wb;break t}_=65535&b,(x&=15)&&(f<x&&(d+=M[r++]<<f,f+=8),_+=d&(1<<x)-1,d>>>=x,f-=x),f<15&&(d+=M[r++]<<f,f+=8,d+=M[r++]<<f,f+=8),b=g[d&y];i:for(;;){if(d>>>=x=b>>>24,f-=x,!(16&(x=b>>>16&255))){if(0===(64&x)){b=g[(65535&b)+(d&(1<<x)-1)];continue i}t.msg="invalid distance code",i.mode=wb;break t}if(w=65535&b,f<(x&=15)&&(d+=M[r++]<<f,(f+=8)<x&&(d+=M[r++]<<f,f+=8)),(w+=d&(1<<x)-1)>c){t.msg="invalid distance too far back",i.mode=wb;break t}if(d>>>=x,f-=x,w>(x=o-a)){if((x=w-x)>h&&i.sane){t.msg="invalid distance too far back",i.mode=wb;break t}if(S=0,A=p,0===l){if(S+=u-x,x<_){_-=x;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}}else if(l<x){if(S+=u+l-x,(x-=l)<_){_-=x;do{P[o++]=p[S++]}while(--x);if(S=0,l<_){_-=x=l;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}}}else if(S+=l-x,x<_){_-=x;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}for(;_>2;)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(r<n&&o<s);r-=_=f>>3,d&=(1<<(f-=_<<3))-1,t.next_in=r,t.next_out=o,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=o<s?s-o+257:257-(o-s),i.hold=d,i.bits=f}var Mb=15,Pb=852,Tb=592,Eb=0,Cb=1,Ib=2,Rb=[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],Lb=[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],Ob=[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],Nb=[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];function Db(t,e,i,r,n,o,a,s){var c,u,h,l,p,d,f,m,g,v=s.bits,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,P=0,T=0,E=null,C=0,I=new Uint16Array(Mb+1),R=new Uint16Array(Mb+1),L=null,O=0;for(y=0;y<=Mb;y++)I[y]=0;for(b=0;b<r;b++)I[e[i+b]]++;for(w=v,_=Mb;_>=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(w<x&&(w=x),M=1,y=1;y<=Mb;y++)if(M<<=1,(M-=I[y])<0)return-1;if(M>0&&(t===Eb||1!==_))return-1;for(R[1]=0,y=1;y<Mb;y++)R[y+1]=R[y]+I[y];for(b=0;b<r;b++)0!==e[i+b]&&(a[R[e[i+b]]++]=b);if(t===Eb?(E=L=a,d=19):t===Cb?(E=Rb,C-=257,L=Lb,O-=257,d=256):(E=Ob,L=Nb,d=-1),T=0,b=0,y=x,p=o,S=w,A=0,h=-1,l=(P=1<<w)-1,t===Cb&&P>Pb||t===Ib&&P>Tb)return 1;for(;;){0,f=y-A,a[b]<d?(m=0,g=a[b]):a[b]>d?(m=L[O+a[b]],g=E[C+a[b]]):(m=96,g=0),c=1<<y-A,x=u=1<<S;do{n[p+(T>>A)+(u-=c)]=f<<24|m<<16|g|0}while(0!==u);for(c=1<<y-1;T&c;)c>>=1;if(0!==c?(T&=c-1,T+=c):T=0,b++,0===--I[y]){if(y===_)break;y=e[i+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(P+=1<<S,t===Cb&&P>Pb||t===Ib&&P>Tb)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}var kb=0,Fb=1,Bb=2,zb=4,Ub=5,jb=6,Gb=0,Vb=1,$b=2,Hb=-2,Wb=-3,Xb=-4,qb=-5,Yb=8,Zb=1,Kb=2,Qb=3,Jb=4,tx=5,ex=6,ix=7,rx=8,nx=9,ox=10,ax=11,sx=12,cx=13,ux=14,hx=15,lx=16,px=17,dx=18,fx=19,mx=20,gx=21,vx=22,yx=23,bx=24,xx=25,_x=26,wx=27,Sx=28,Ax=29,Mx=30,Px=31,Tx=32,Ex=852,Cx=592;function Ix(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function Rx(){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 Lx(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Zb,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Ex),e.distcode=e.distdyn=new Int32Array(Cx),e.sane=1,e.back=-1,Gb):Hb}(t)):Hb}function Ox(t,e){var i,r;return t?(r=new Rx,t.state=r,r.window=null,(i=function(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Hb:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,Lx(t))):Hb}(t,e))!==Gb&&(t.state=null),i):Hb}var Nx,Dx,kx=!0;function Fx(t){if(kx){var e;for(Nx=new Int32Array(512),Dx=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(Db(Fb,t.lens,0,288,Nx,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Db(Bb,t.lens,0,32,Dx,0,t.work,{bits:5}),kx=!1}t.lencode=Nx,t.lenbits=9,t.distcode=Dx,t.distbits=5}function Bx(t,e,i,r){var n,o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),r>=o.wsize?(yb(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((n=o.wsize-o.wnext)>r&&(n=r),yb(o.window,e,i-r,n,o.wnext),(r-=n)?(yb(o.window,e,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0}function zx(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P=0,T=new Uint8Array(4),E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return Hb;(i=t.state).mode===sx&&(i.mode=cx),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,r=t.input,s=t.avail_in,u=i.hold,h=i.bits,l=s,p=c,S=Gb;t:for(;;)switch(i.mode){case Zb:if(0===i.wrap){i.mode=cx;break}for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(2&i.wrap&&35615===u){i.check=0,T[0]=255&u,T[1]=u>>>8&255,i.check=_b(i.check,T,2,0),u=0,h=0,i.mode=Kb;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",i.mode=Mx;break}if((15&u)!==Yb){t.msg="unknown compression method",i.mode=Mx;break}if(h-=4,w=8+(15&(u>>>=4)),0===i.wbits)i.wbits=w;else if(w>i.wbits){t.msg="invalid window size",i.mode=Mx;break}i.dmax=1<<w,t.adler=i.check=1,i.mode=512&u?ox:sx,u=0,h=0;break;case Kb:for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(i.flags=u,(255&i.flags)!==Yb){t.msg="unknown compression method",i.mode=Mx;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=Mx;break}i.head&&(i.head.text=u>>8&1),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,i.check=_b(i.check,T,2,0)),u=0,h=0,i.mode=Qb;case Qb:for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.head&&(i.head.time=u),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,i.check=_b(i.check,T,4,0)),u=0,h=0,i.mode=Jb;case Jb:for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.head&&(i.head.xflags=255&u,i.head.os=u>>8),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,i.check=_b(i.check,T,2,0)),u=0,h=0,i.mode=tx;case tx:if(1024&i.flags){for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.length=u,i.head&&(i.head.extra_len=u),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,i.check=_b(i.check,T,2,0)),u=0,h=0}else i.head&&(i.head.extra=null);i.mode=ex;case ex:if(1024&i.flags&&((d=i.length)>s&&(d=s),d&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),yb(i.head.extra,r,o,d,w)),512&i.flags&&(i.check=_b(i.check,r,d,o)),s-=d,o+=d,i.length-=d),i.length))break t;i.length=0,i.mode=ix;case ix:if(2048&i.flags){if(0===s)break t;d=0;do{w=r[o+d++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&d<s);if(512&i.flags&&(i.check=_b(i.check,r,d,o)),s-=d,o+=d,w)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=rx;case rx:if(4096&i.flags){if(0===s)break t;d=0;do{w=r[o+d++],i.head&&w&&i.length<65536&&(i.head.comment+=String.fromCharCode(w))}while(w&&d<s);if(512&i.flags&&(i.check=_b(i.check,r,d,o)),s-=d,o+=d,w)break t}else i.head&&(i.head.comment=null);i.mode=nx;case nx:if(512&i.flags){for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u!==(65535&i.check)){t.msg="header crc mismatch",i.mode=Mx;break}u=0,h=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=sx;break;case ox:for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}t.adler=i.check=Ix(u),u=0,h=0,i.mode=ax;case ax:if(0===i.havedict)return t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,$b;t.adler=i.check=1,i.mode=sx;case sx:if(e===Ub||e===jb)break t;case cx:if(i.last){u>>>=7&h,h-=7&h,i.mode=wx;break}for(;h<3;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}switch(i.last=1&u,h-=1,3&(u>>>=1)){case 0:i.mode=ux;break;case 1:if(Fx(i),i.mode=mx,e===jb){u>>>=2,h-=2;break t}break;case 2:i.mode=px;break;case 3:t.msg="invalid block type",i.mode=Mx}u>>>=2,h-=2;break;case ux:for(u>>>=7&h,h-=7&h;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if((65535&u)!==(u>>>16^65535)){t.msg="invalid stored block lengths",i.mode=Mx;break}if(i.length=65535&u,u=0,h=0,i.mode=hx,e===jb)break t;case hx:i.mode=lx;case lx:if(d=i.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break t;yb(n,r,o,d,a),s-=d,o+=d,c-=d,a+=d,i.length-=d;break}i.mode=sx;break;case px:for(;h<14;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(i.nlen=257+(31&u),u>>>=5,h-=5,i.ndist=1+(31&u),u>>>=5,h-=5,i.ncode=4+(15&u),u>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Mx;break}i.have=0,i.mode=dx;case dx:for(;i.have<i.ncode;){for(;h<3;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.lens[E[i.have++]]=7&u,u>>>=3,h-=3}for(;i.have<19;)i.lens[E[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=Db(kb,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid code lengths set",i.mode=Mx;break}i.have=0,i.mode=fx;case fx:for(;i.have<i.nlen+i.ndist;){for(;v=(P=i.lencode[u&(1<<i.lenbits)-1])>>>16&255,y=65535&P,!((g=P>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(y<16)u>>>=g,h-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u>>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=Mx;break}w=i.lens[i.have-1],d=3+(3&u),u>>>=2,h-=2}else if(17===y){for(M=g+3;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}h-=g,w=0,d=3+(7&(u>>>=g)),u>>>=3,h-=3}else{for(M=g+7;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}h-=g,w=0,d=11+(127&(u>>>=g)),u>>>=7,h-=7}if(i.have+d>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Mx;break}for(;d--;)i.lens[i.have++]=w}}if(i.mode===Mx)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Mx;break}if(i.lenbits=9,A={bits:i.lenbits},S=Db(Fb,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid literal/lengths set",i.mode=Mx;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=Db(Bb,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){t.msg="invalid distances set",i.mode=Mx;break}if(i.mode=mx,e===jb)break t;case mx:i.mode=gx;case gx:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,Ab(t,p),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,r=t.input,s=t.avail_in,u=i.hold,h=i.bits,i.mode===sx&&(i.back=-1);break}for(i.back=0;v=(P=i.lencode[u&(1<<i.lenbits)-1])>>>16&255,y=65535&P,!((g=P>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(v&&0===(240&v)){for(b=g,x=v,_=y;v=(P=i.lencode[_+((u&(1<<b+x)-1)>>b)])>>>16&255,y=65535&P,!(b+(g=P>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}u>>>=b,h-=b,i.back+=b}if(u>>>=g,h-=g,i.back+=g,i.length=y,0===v){i.mode=_x;break}if(32&v){i.back=-1,i.mode=sx;break}if(64&v){t.msg="invalid literal/length code",i.mode=Mx;break}i.extra=15&v,i.mode=vx;case vx:if(i.extra){for(M=i.extra;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.length+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=yx;case yx:for(;v=(P=i.distcode[u&(1<<i.distbits)-1])>>>16&255,y=65535&P,!((g=P>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(0===(240&v)){for(b=g,x=v,_=y;v=(P=i.distcode[_+((u&(1<<b+x)-1)>>b)])>>>16&255,y=65535&P,!(b+(g=P>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}u>>>=b,h-=b,i.back+=b}if(u>>>=g,h-=g,i.back+=g,64&v){t.msg="invalid distance code",i.mode=Mx;break}i.offset=y,i.extra=15&v,i.mode=bx;case bx:if(i.extra){for(M=i.extra;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.offset+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Mx;break}i.mode=xx;case xx:if(0===c)break t;if(d=p-c,i.offset>d){if((d=i.offset-d)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Mx;break}d>i.wnext?(d-=i.wnext,f=i.wsize-d):f=i.wnext-d,d>i.length&&(d=i.length),m=i.window}else m=n,f=a-i.offset,d=i.length;d>c&&(d=c),c-=d,i.length-=d;do{n[a++]=m[f++]}while(--d);0===i.length&&(i.mode=gx);break;case _x:if(0===c)break t;n[a++]=i.length,c--,i.mode=gx;break;case wx:if(i.wrap){for(;h<32;){if(0===s)break t;s--,u|=r[o++]<<h,h+=8}if(p-=c,t.total_out+=p,i.total+=p,p&&(t.adler=i.check=i.flags?_b(i.check,n,p,a-p):bb(i.check,n,p,a-p)),p=c,(i.flags?u:Ix(u))!==i.check){t.msg="incorrect data check",i.mode=Mx;break}u=0,h=0}i.mode=Sx;case Sx:if(i.wrap&&i.flags){for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=Mx;break}u=0,h=0}i.mode=Ax;case Ax:S=Vb;break t;case Mx:S=Wb;break t;case Px:return Xb;case Tx:default:return Hb}return t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,(i.wsize||p!==t.avail_out&&i.mode<Mx&&(i.mode<wx||e!==zb))&&Bx(t,t.output,t.next_out,p-t.avail_out)?(i.mode=Px,Xb):(l-=t.avail_in,p-=t.avail_out,t.total_in+=l,t.total_out+=p,i.total+=p,i.wrap&&p&&(t.adler=i.check=i.flags?_b(i.check,n,p,t.next_out-p):bb(i.check,n,p,t.next_out-p)),t.data_type=i.bits+(i.last?64:0)+(i.mode===sx?128:0)+(i.mode===mx||i.mode===hx?256:0),(0===l&&0===p||e===zb)&&S===Gb&&(S=qb),S)}function Ux(t,e){var i,r=e.length;return t&&t.state?0!==(i=t.state).wrap&&i.mode!==ax?Hb:i.mode===ax&&bb(1,e,r,0)!==i.check?Wb:Bx(t,e,r,r)?(i.mode=Px,Xb):(i.havedict=1,Gb):Hb}var jx=!0,Gx=!0;try{String.fromCharCode.apply(null,[0])}catch(a_){jx=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(a_){Gx=!1}for(var Vx=new Uint8Array(256),$x=0;$x<256;$x++)Vx[$x]=$x>=252?6:$x>=248?5:$x>=240?4:$x>=224?3:$x>=192?2:1;function Hx(t){var e,i,r,n,o,a=t.length,s=0;for(n=0;n<a;n++)55296===(64512&(i=t.charCodeAt(n)))&&n+1<a&&56320===(64512&(r=t.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),s+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(s),o=0,n=0;o<s;n++)55296===(64512&(i=t.charCodeAt(n)))&&n+1<a&&56320===(64512&(r=t.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),i<128?e[o++]=i:i<2048?(e[o++]=192|i>>>6,e[o++]=128|63&i):i<65536?(e[o++]=224|i>>>12,e[o++]=128|i>>>6&63,e[o++]=128|63&i):(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63,e[o++]=128|i>>>6&63,e[o++]=128|63&i);return e}function Wx(t,e){var i,r,n,o,a=e||t.length,s=new Array(2*a);for(r=0,i=0;i<a;)if((n=t[i++])<128)s[r++]=n;else if((o=Vx[n])>4)s[r++]=65533,i+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&i<a;)n=n<<6|63&t[i++],o--;o>1?s[r++]=65533:n<65536?s[r++]=n:(n-=65536,s[r++]=55296|n>>10&1023,s[r++]=56320|1023&n)}return function(t,e){if(e<65537&&(t.subarray&&Gx||!t.subarray&&jx))return String.fromCharCode.apply(null,vb(t,e));for(var i="",r=0;r<e;r++)i+=String.fromCharCode(t[r]);return i}(s,r)}function Xx(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;i>=0&&128===(192&t[i]);)i--;return i<0?e:0===i?e:i+Vx[t[i]]>e?i:e}Vx[254]=Vx[254]=1;var qx=0,Yx={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Zx(){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 Kx(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Qx=Object.prototype.toString;function Jx(t){if(!(this instanceof Jx))return new Jx(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!==typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0===(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zx,this.strm.avail_out=0;var i=Ox(this.strm,e.windowBits);if(i!==qx)throw new Error(Yx[i]);this.header=new Kx,function(t,e){var i;t&&t.state&&(0===(2&(i=t.state).wrap)||(i.head=e,e.done=!1))}(this.strm,this.header)}Jx.prototype.push=function(t,e){var i,r,n,o,a,s,c=this.strm,u=this.options.chunkSize,h=this.options.dictionary,l=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"===typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i<r;i++)e[i]=t.charCodeAt(i);return e}(t):"[object ArrayBuffer]"===Qx.call(t)?c.input=new Uint8Array(t):c.input=t,c.next_in=0,c.avail_in=c.input.length;do{if(0===c.avail_out&&(c.output=new Uint8Array(u),c.next_out=0,c.avail_out=u),2===(i=zx(c,0))&&h&&(s="string"===typeof h?Hx(h):"[object ArrayBuffer]"===Qx.call(h)?new Uint8Array(h):h,i=Ux(this.strm,s)),-5===i&&!0===l&&(i=qx,l=!1),1!==i&&i!==qx)return this.onEnd(i),this.ended=!0,!1;c.next_out&&(0!==c.avail_out&&1!==i&&(0!==c.avail_in||4!==r&&2!==r)||("string"===this.options.to?(n=Xx(c.output,c.next_out),o=c.next_out-n,a=Wx(c.output,n),c.next_out=o,c.avail_out=u-o,o&&yb(c.output,c.output,n,o,0),this.onData(a)):this.onData(vb(c.output,c.next_out)))),0===c.avail_in&&0===c.avail_out&&(l=!0)}while((c.avail_in>0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(t){if(!t||!t.state)return Hb;var e=t.state;return e.window&&(e.window=null),t.state=null,Gb}(this.strm),this.onEnd(i),this.ended=!0,i===qx):2!==r||(this.onEnd(qx),c.avail_out=0,!0)},Jx.prototype.onData=function(t){this.chunks.push(t)},Jx.prototype.onEnd=function(t){t===qx&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,r,n,o,a;for(r=0,e=0,i=t.length;e<i;e++)r+=t[e].length;for(a=new Uint8Array(r),n=0,e=0,i=t.length;e<i;e++)o=t[e],a.set(o,n),n+=o.length;return a}(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},Eu.add("gz",function(t){var e;t instanceof ArrayBuffer&&(t=new Uint8Array(t));try{e=function(t,e){var i=new Jx(e);if(i.push(t,!0),i.err)throw i.msg;return i.result}(t)}catch(i){e=t}return e});var t_="//files.rcsb.org/download/",e_="//mmtf.rcsb.org/v1.0/full/",i_="//mmtf.rcsb.org/v1.0/reduced/";Au.add("rcsb",new function(){this.getUrl=function(t){var e,i=ka(t),r=i.name.substr(0,4);return!["pdb","cif"].includes(i.ext)||!1!==i.compressed&&"gz"!==i.compressed?"mmtf"===i.ext?e=i.base.endsWith(".bb")?i_+r:e_+r:i.ext?(bu.warn("unsupported ext",i.ext),e=e_+r):e=e_+r:e=t_+i.path,Na()+e},this.getExt=function(t){var e=ka(t);if("mmtf"===e.ext||!e.ext)return"mmtf"}});var r_="//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/",n_="/SDF?record_type=3d";function o_(){this.getUrl=function(t){return t}}Au.add("pubchem",new function(){this.getUrl=function(t){var e,i=ka(t),r=i.name;return i.ext&&"sdf"!==i.ext?(bu.warn("unsupported ext",i.ext),e=r_+r+n_):e=r_+r+n_,Na()+e},this.getExt=function(t){var e=ka(t);if(!e.ext||"sdf"===e.ext)return"sdf"}}),Au.add("ftp",new o_),Au.add("http",new o_),Au.add("https",new o_);"undefined"===typeof window||window.Promise||(window.Promise=s)}).call(this,i(242).setImmediate)},242:function(t,e,i){(function(t){var r="undefined"!==typeof t&&t||"undefined"!==typeof self&&self||window,n=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(n.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(n.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},i(243),e.setImmediate="undefined"!==typeof self&&self.setImmediate||"undefined"!==typeof t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!==typeof self&&self.clearImmediate||"undefined"!==typeof t&&t.clearImmediate||this&&this.clearImmediate}).call(this,i(83))},243:function(t,e,i){(function(t,e){!function(t,i){"use strict";if(!t.setImmediate){var r,n=1,o={},a=!1,s=t.document,c=Object.getPrototypeOf&&Object.getPrototypeOf(t);c=c&&c.setTimeout?c:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick(function(){h(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?function(){var e="setImmediate$"+Math.random()+"$",i=function(i){i.source===t&&"string"===typeof i.data&&0===i.data.indexOf(e)&&h(+i.data.slice(e.length))};t.addEventListener?t.addEventListener("message",i,!1):t.attachEvent("onmessage",i),r=function(i){t.postMessage(e+i,"*")}}():t.MessageChannel?function(){var t=new MessageChannel;t.port1.onmessage=function(t){h(t.data)},r=function(e){t.port2.postMessage(e)}}():s&&"onreadystatechange"in s.createElement("script")?function(){var t=s.documentElement;r=function(e){var i=s.createElement("script");i.onreadystatechange=function(){h(e),i.onreadystatechange=null,t.removeChild(i),i=null},t.appendChild(i)}}():r=function(t){setTimeout(h,0,t)},c.setImmediate=function(t){"function"!==typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),i=0;i<e.length;i++)e[i]=arguments[i+1];var a={callback:t,args:e};return o[n]=a,r(n),n++},c.clearImmediate=u}function u(t){delete o[t]}function h(t){if(a)setTimeout(h,0,t);else{var e=o[t];if(e){a=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(i,r)}}(e)}finally{u(t),a=!1}}}}}("undefined"===typeof self?"undefined"===typeof t?this:t:self)}).call(this,i(83),i(182))}}]);

//# sourceMappingURL=../16-fdf7e3d6-chunk.js.map?action=raw&ctype=text/javascript