win-chart 2.12.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,4 +19,4 @@ var ji={},Xi={};var Yi,Zi=function(){function e(e,t,n){var r=this;this._sleepAft
19
19
  * LICENSE file in the root directory of this source tree.
20
20
  */"production"===process.env.NODE_ENV?pU.exports=function(){if(dU)return fU;dU=1;var t=e,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,l={},u=null,c=null;for(s in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,s)&&!a.hasOwnProperty(s)&&(l[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===l[s]&&(l[s]=t[s]);return{$$typeof:n,type:e,key:u,ref:c,props:l,_owner:o.current}}return fU.Fragment=r,fU.jsx=s,fU.jsxs=s,fU}():pU.exports=(gU||(gU=1,"production"!==process.env.NODE_ENV&&function(){var t,n=e,r=Symbol.for("react.element"),i=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),m=Symbol.iterator,v=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];!function(e,t,n){var r=v.ReactDebugCurrentFrame.getStackAddendum();""!==r&&(t+="%s",n=n.concat([r]));var i=n.map((function(e){return String(e)}));i.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,i)}("error",e,n)}function _(e){return e.displayName||"Context"}function x(e){if(null==e)return null;if("number"==typeof e.tag&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case o:return"Fragment";case i:return"Portal";case s:return"Profiler";case a:return"StrictMode";case h:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case u:return _(e)+".Consumer";case l:return _(e._context)+".Provider";case c:return function(e,t,n){var r=e.displayName;if(r)return r;var i=t.displayName||t.name||"";return""!==i?n+"("+i+")":n}(e,e.render,"ForwardRef");case p:var t=e.displayName||null;return null!==t?t:x(e.type)||"Memo";case f:var n=e,r=n._payload,g=n._init;try{return x(g(r))}catch(e){return null}}return null}t=Symbol.for("react.module.reference");var b,w,S,T,M,C,D,A=Object.assign,I=0;function E(){}E.__reactDisabledLog=!0;var L,N=v.ReactCurrentDispatcher;function P(e,t,n){if(void 0===L)try{throw Error()}catch(e){var r=e.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return"\n"+L+e}var O,R=!1,k="function"==typeof WeakMap?WeakMap:Map;function z(e,t){if(!e||R)return"";var n,r=O.get(e);if(void 0!==r)return r;R=!0;var i,o=Error.prepareStackTrace;Error.prepareStackTrace=void 0,i=N.current,N.current=null,function(){if(0===I){b=console.log,w=console.info,S=console.warn,T=console.error,M=console.group,C=console.groupCollapsed,D=console.groupEnd;var e={configurable:!0,enumerable:!0,value:E,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(e){n=e}Reflect.construct(e,[],a)}else{try{a.call()}catch(e){n=e}e.call(a.prototype)}}else{try{throw Error()}catch(e){n=e}e()}}catch(t){if(t&&n&&"string"==typeof t.stack){for(var s=t.stack.split("\n"),l=n.stack.split("\n"),u=s.length-1,c=l.length-1;u>=1&&c>=0&&s[u]!==l[c];)c--;for(;u>=1&&c>=0;u--,c--)if(s[u]!==l[c]){if(1!==u||1!==c)do{if(u--,--c<0||s[u]!==l[c]){var h="\n"+s[u].replace(" at new "," at ");return e.displayName&&h.includes("<anonymous>")&&(h=h.replace("<anonymous>",e.displayName)),"function"==typeof e&&O.set(e,h),h}}while(u>=1&&c>=0);break}}}finally{R=!1,N.current=i,function(){if(0==--I){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:b}),info:A({},e,{value:w}),warn:A({},e,{value:S}),error:A({},e,{value:T}),group:A({},e,{value:M}),groupCollapsed:A({},e,{value:C}),groupEnd:A({},e,{value:D})})}I<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=o}var d=e?e.displayName||e.name:"",p=d?P(d):"";return"function"==typeof e&&O.set(e,p),p}function V(e,t,n){if(null==e)return"";if("function"==typeof e)return z(e,!(!(r=e.prototype)||!r.isReactComponent));var r;if("string"==typeof e)return P(e);switch(e){case h:return P("Suspense");case d:return P("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return z(e.render,!1);case p:return V(e.type,t,n);case f:var i=e,o=i._payload,a=i._init;try{return V(a(o),t,n)}catch(e){}}return""}O=new k;var B=Object.prototype.hasOwnProperty,F={},G=v.ReactDebugCurrentFrame;function H(e){if(e){var t=e._owner,n=V(e.type,e._source,t?t.type:null);G.setExtraStackFrame(n)}else G.setExtraStackFrame(null)}var U=Array.isArray;function W(e){return U(e)}function j(e){return""+e}function X(e){if(function(e){try{return j(e),!1}catch(e){return!0}}(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),j(e)}var Y,Z,q=v.ReactCurrentOwner,K={key:!0,ref:!0,__self:!0,__source:!0};function $(e,t,n,i,o){var a,s={},l=null,u=null;for(a in void 0!==n&&(X(n),l=""+n),function(e){if(B.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(X(t.key),l=""+t.key),function(e){if(B.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(u=t.ref,function(e){"string"==typeof e.ref&&q.current}(t)),t)B.call(t,a)&&!K.hasOwnProperty(a)&&(s[a]=t[a]);if(e&&e.defaultProps){var c=e.defaultProps;for(a in c)void 0===s[a]&&(s[a]=c[a])}if(l||u){var h="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var n=function(){Y||(Y=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(s,h),u&&function(e,t){var n=function(){Z||(Z=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(s,h)}return function(e,t,n,i,o,a,s){var l={$$typeof:r,type:e,key:t,ref:n,props:s,_owner:a,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,u,o,i,q.current,s)}var J,Q=v.ReactCurrentOwner,ee=v.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,n=V(e.type,e._source,t?t.type:null);ee.setExtraStackFrame(n)}else ee.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function re(){if(Q.current){var e=x(Q.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}J=!1;var ie={};function oe(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var t=re();if(!t){var n="string"==typeof e?e:e.displayName||e.name;n&&(t="\n\nCheck the top-level render call using <"+n+">.")}return t}(t);if(!ie[n]){ie[n]=!0;var r="";e&&e._owner&&e._owner!==Q.current&&(r=" It was passed a child from "+x(e._owner.type)+"."),te(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),te(null)}}}function ae(e,t){if("object"==typeof e)if(W(e))for(var n=0;n<e.length;n++){var r=e[n];ne(r)&&oe(r,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var i=function(e){if(null===e||"object"!=typeof e)return null;var t=m&&e[m]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof i&&i!==e.entries)for(var o,a=i.call(e);!(o=a.next()).done;)ne(o.value)&&oe(o.value,t)}}function se(e){var t,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)t=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==p)return;t=n.propTypes}if(t){var r=x(n);!function(e,t,n,r,i){var o=Function.call.bind(B);for(var a in e)if(o(e,a)){var s=void 0;try{if("function"!=typeof e[a]){var l=Error((r||"React class")+": "+n+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}s=e[a](t,a,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(H(i),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,a,typeof s),H(null)),s instanceof Error&&!(s.message in F)&&(F[s.message]=!0,H(i),y("Failed %s type: %s",n,s.message),H(null))}}(t,e.props,"prop",r,e)}else void 0===n.PropTypes||J||(J=!0,y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x(n)||"Unknown"));"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var le={};function ue(e,n,i,m,v,_){var b=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===s||e===a||e===h||e===d||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===p||e.$$typeof===l||e.$$typeof===u||e.$$typeof===c||e.$$typeof===t||void 0!==e.getModuleId)}(e);if(!b){var w,S="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),S+=re(),null===e?w="null":W(e)?w="array":void 0!==e&&e.$$typeof===r?(w="<"+(x(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,S)}var T=$(e,n,i,v,_);if(null==T)return T;if(b){var M=n.children;if(void 0!==M)if(m)if(W(M)){for(var C=0;C<M.length;C++)ae(M[C],e);Object.freeze&&Object.freeze(M)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ae(M,e)}if(B.call(n,"key")){var D=x(e),A=Object.keys(n).filter((function(e){return"key"!==e})),I=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";le[D+I]||(y('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',I,D,A.length>0?"{"+A.join(": ..., ")+": ...}":"{}",D),le[D+I]=!0)}return e===o?function(e){for(var t=Object.keys(e.props),n=0;n<t.length;n++){var r=t[n];if("children"!==r&&"key"!==r){te(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),te(null);break}}null!==e.ref&&(te(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(T):se(T),T}var ce=function(e,t,n){return ue(e,t,n,!1)},he=function(e,t,n){return ue(e,t,n,!0)};mU.Fragment=o,mU.jsx=ce,mU.jsxs=he}()),mU);var vU=pU.exports;function yU(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var _U=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,xU=yU((function(e){return _U.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),bU="-ms-",wU="-moz-",SU="-webkit-",TU="comm",MU="rule",CU="decl",DU="@keyframes",AU=Math.abs,IU=String.fromCharCode,EU=Object.assign;function LU(e){return e.trim()}function NU(e,t){return(e=t.exec(e))?e[0]:e}function PU(e,t,n){return e.replace(t,n)}function OU(e,t,n){return e.indexOf(t,n)}function RU(e,t){return 0|e.charCodeAt(t)}function kU(e,t,n){return e.slice(t,n)}function zU(e){return e.length}function VU(e){return e.length}function BU(e,t){return t.push(e),e}function FU(e,t){return e.filter((function(e){return!NU(e,t)}))}var GU=1,HU=1,UU=0,WU=0,jU=0,XU="";function YU(e,t,n,r,i,o,a,s){return{value:e,root:t,parent:n,type:r,props:i,children:o,line:GU,column:HU,length:a,return:"",siblings:s}}function ZU(e,t){return EU(YU("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function qU(e){for(;e.root;)e=ZU(e.root,{children:[e]});BU(e,e.siblings)}function KU(){return jU=WU>0?RU(XU,--WU):0,HU--,10===jU&&(HU=1,GU--),jU}function $U(){return jU=WU<UU?RU(XU,WU++):0,HU++,10===jU&&(HU=1,GU++),jU}function JU(){return RU(XU,WU)}function QU(){return WU}function eW(e,t){return kU(XU,e,t)}function tW(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function nW(e){return LU(eW(WU-1,oW(91===e?e+2:40===e?e+1:e)))}function rW(e){for(;(jU=JU())&&jU<33;)$U();return tW(e)>2||tW(jU)>3?"":" "}function iW(e,t){for(;--t&&$U()&&!(jU<48||jU>102||jU>57&&jU<65||jU>70&&jU<97););return eW(e,QU()+(t<6&&32==JU()&&32==$U()))}function oW(e){for(;$U();)switch(jU){case e:return WU;case 34:case 39:34!==e&&39!==e&&oW(jU);break;case 40:41===e&&oW(e);break;case 92:$U()}return WU}function aW(e,t){for(;$U()&&e+jU!==57&&(e+jU!==84||47!==JU()););return"/*"+eW(t,WU-1)+"*"+IU(47===e?e:$U())}function sW(e){for(;!tW(JU());)$U();return eW(e,WU)}function lW(e){return function(e){return XU="",e}(uW("",null,null,null,[""],e=function(e){return GU=HU=1,UU=zU(XU=e),WU=0,[]}(e),0,[0],e))}function uW(e,t,n,r,i,o,a,s,l){for(var u=0,c=0,h=a,d=0,p=0,f=0,g=1,m=1,v=1,y=0,_="",x=i,b=o,w=r,S=_;m;)switch(f=y,y=$U()){case 40:if(108!=f&&58==RU(S,h-1)){-1!=OU(S+=PU(nW(y),"&","&\f"),"&\f",AU(u?s[u-1]:0))&&(v=-1);break}case 34:case 39:case 91:S+=nW(y);break;case 9:case 10:case 13:case 32:S+=rW(f);break;case 92:S+=iW(QU()-1,7);continue;case 47:switch(JU()){case 42:case 47:BU(hW(aW($U(),QU()),t,n,l),l);break;default:S+="/"}break;case 123*g:s[u++]=zU(S)*v;case 125*g:case 59:case 0:switch(y){case 0:case 125:m=0;case 59+c:-1==v&&(S=PU(S,/\f/g,"")),p>0&&zU(S)-h&&BU(p>32?dW(S+";",r,n,h-1,l):dW(PU(S," ","")+";",r,n,h-2,l),l);break;case 59:S+=";";default:if(BU(w=cW(S,t,n,u,c,i,s,_,x=[],b=[],h,o),o),123===y)if(0===c)uW(S,t,w,w,x,o,h,s,b);else switch(99===d&&110===RU(S,3)?100:d){case 100:case 108:case 109:case 115:uW(e,w,w,r&&BU(cW(e,w,w,0,0,i,s,_,i,x=[],h,b),b),i,b,h,s,r?x:b);break;default:uW(S,w,w,w,[""],b,0,s,b)}}u=c=p=0,g=v=1,_=S="",h=a;break;case 58:h=1+zU(S),p=f;default:if(g<1)if(123==y)--g;else if(125==y&&0==g++&&125==KU())continue;switch(S+=IU(y),y*g){case 38:v=c>0?1:(S+="\f",-1);break;case 44:s[u++]=(zU(S)-1)*v,v=1;break;case 64:45===JU()&&(S+=nW($U())),d=JU(),c=h=zU(_=S+=sW(QU())),y++;break;case 45:45===f&&2==zU(S)&&(g=0)}}return o}function cW(e,t,n,r,i,o,a,s,l,u,c,h){for(var d=i-1,p=0===i?o:[""],f=VU(p),g=0,m=0,v=0;g<r;++g)for(var y=0,_=kU(e,d+1,d=AU(m=a[g])),x=e;y<f;++y)(x=LU(m>0?p[y]+" "+_:PU(_,/&\f/g,p[y])))&&(l[v++]=x);return YU(e,t,n,0===i?MU:s,l,u,c,h)}function hW(e,t,n,r){return YU(e,t,n,TU,IU(jU),kU(e,2,-2),0,r)}function dW(e,t,n,r,i){return YU(e,t,n,CU,kU(e,0,r),kU(e,r+1,-1),r,i)}function pW(e,t,n){switch(function(e,t){return 45^RU(e,0)?(((t<<2^RU(e,0))<<2^RU(e,1))<<2^RU(e,2))<<2^RU(e,3):0}(e,t)){case 5103:return SU+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return SU+e+e;case 4789:return wU+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return SU+e+wU+e+bU+e+e;case 5936:switch(RU(e,t+11)){case 114:return SU+e+bU+PU(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return SU+e+bU+PU(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return SU+e+bU+PU(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return SU+e+bU+e+e;case 6165:return SU+e+bU+"flex-"+e+e;case 5187:return SU+e+PU(e,/(\w+).+(:[^]+)/,SU+"box-$1$2"+bU+"flex-$1$2")+e;case 5443:return SU+e+bU+"flex-item-"+PU(e,/flex-|-self/g,"")+(NU(e,/flex-|baseline/)?"":bU+"grid-row-"+PU(e,/flex-|-self/g,""))+e;case 4675:return SU+e+bU+"flex-line-pack"+PU(e,/align-content|flex-|-self/g,"")+e;case 5548:return SU+e+bU+PU(e,"shrink","negative")+e;case 5292:return SU+e+bU+PU(e,"basis","preferred-size")+e;case 6060:return SU+"box-"+PU(e,"-grow","")+SU+e+bU+PU(e,"grow","positive")+e;case 4554:return SU+PU(e,/([^-])(transform)/g,"$1"+SU+"$2")+e;case 6187:return PU(PU(PU(e,/(zoom-|grab)/,SU+"$1"),/(image-set)/,SU+"$1"),e,"")+e;case 5495:case 3959:return PU(e,/(image-set\([^]*)/,SU+"$1$`$1");case 4968:return PU(PU(e,/(.+:)(flex-)?(.*)/,SU+"box-pack:$3"+bU+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+SU+e+e;case 4200:if(!NU(e,/flex-|baseline/))return bU+"grid-column-align"+kU(e,t)+e;break;case 2592:case 3360:return bU+PU(e,"template-","")+e;case 4384:case 3616:return n&&n.some((function(e,n){return t=n,NU(e.props,/grid-\w+-end/)}))?~OU(e+(n=n[t].value),"span",0)?e:bU+PU(e,"-start","")+e+bU+"grid-row-span:"+(~OU(n,"span",0)?NU(n,/\d+/):+NU(n,/\d+/)-+NU(e,/\d+/))+";":bU+PU(e,"-start","")+e;case 4896:case 4128:return n&&n.some((function(e){return NU(e.props,/grid-\w+-start/)}))?e:bU+PU(PU(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return PU(e,/(.+)-inline(.+)/,SU+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(zU(e)-1-t>6)switch(RU(e,t+1)){case 109:if(45!==RU(e,t+4))break;case 102:return PU(e,/(.+:)(.+)-([^]+)/,"$1"+SU+"$2-$3$1"+wU+(108==RU(e,t+3)?"$3":"$2-$3"))+e;case 115:return~OU(e,"stretch",0)?pW(PU(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return PU(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,(function(t,n,r,i,o,a,s){return bU+n+":"+r+s+(i?bU+n+"-span:"+(o?a:+a-+r)+s:"")+e}));case 4949:if(121===RU(e,t+6))return PU(e,":",":"+SU)+e;break;case 6444:switch(RU(e,45===RU(e,14)?18:11)){case 120:return PU(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+SU+(45===RU(e,14)?"inline-":"")+"box$3$1"+SU+"$2$3$1"+bU+"$2box$3")+e;case 100:return PU(e,":",":"+bU)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return PU(e,"scroll-","scroll-snap-")+e}return e}function fW(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function gW(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case CU:return e.return=e.return||e.value;case TU:return"";case DU:return e.return=e.value+"{"+fW(e.children,r)+"}";case MU:if(!zU(e.value=e.props.join(",")))return""}return zU(n=fW(e.children,r))?e.return=e.value+"{"+n+"}":""}function mW(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case CU:return void(e.return=pW(e.value,e.length,n));case DU:return fW([ZU(e,{value:PU(e.value,"@","@"+SU)})],r);case MU:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,(function(t){switch(NU(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":qU(ZU(e,{props:[PU(t,/:(read-\w+)/,":-moz-$1")]})),qU(ZU(e,{props:[t]})),EU(e,{props:FU(n,r)});break;case"::placeholder":qU(ZU(e,{props:[PU(t,/:(plac\w+)/,":"+SU+"input-$1")]})),qU(ZU(e,{props:[PU(t,/:(plac\w+)/,":-moz-$1")]})),qU(ZU(e,{props:[PU(t,/:(plac\w+)/,bU+"input-$1")]})),qU(ZU(e,{props:[t]})),EU(e,{props:FU(n,r)})}return""}))}}var vW={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},yW="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",_W="active",xW="data-styled-version",bW="6.1.14",wW="/*!sc*/\n",SW="undefined"!=typeof window&&"HTMLElement"in window,TW=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),MW=/invalid hook call/i,CW=new Set,DW=function(e,n){if("production"!==process.env.NODE_ENV){var r=n?' with the id of "'.concat(n,'"'):"",i="The component ".concat(e).concat(r," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",o=console.error;try{var a=!0;console.error=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];MW.test(e)?(a=!1,CW.delete(i)):o.apply(void 0,c([e],t,!1))},t(),a&&!CW.has(i)&&(console.warn(i),CW.add(i))}catch(e){MW.test(e.message)&&CW.delete(i)}finally{console.error=o}}},AW=Object.freeze([]),IW=Object.freeze({});var EW=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),LW=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,NW=/(^-|-$)/g;function PW(e){return e.replace(LW,"-").replace(NW,"")}var OW=/(a)(d)/gi,RW=function(e){return String.fromCharCode(e+(e>25?39:97))};function kW(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=RW(t%52)+n;return(RW(t%52)+n).replace(OW,"$1-$2")}var zW,VW=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},BW=function(e){return VW(5381,e)};function FW(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function GW(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var HW="function"==typeof Symbol&&Symbol.for,UW=HW?Symbol.for("react.memo"):60115,WW=HW?Symbol.for("react.forward_ref"):60112,jW={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},XW={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},YW={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ZW=((zW={})[WW]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},zW[UW]=YW,zW);function qW(e){return("type"in(t=e)&&t.type.$$typeof)===UW?YW:"$$typeof"in e?ZW[e.$$typeof]:jW;var t}var KW=Object.defineProperty,$W=Object.getOwnPropertyNames,JW=Object.getOwnPropertySymbols,QW=Object.getOwnPropertyDescriptor,ej=Object.getPrototypeOf,tj=Object.prototype;function nj(e,t,n){if("string"!=typeof t){if(tj){var r=ej(t);r&&r!==tj&&nj(e,r,n)}var i=$W(t);JW&&(i=i.concat(JW(t)));for(var o=qW(e),a=qW(t),s=0;s<i.length;++s){var l=i[s];if(!(l in XW||n&&n[l]||a&&l in a||o&&l in o)){var u=QW(t,l);try{KW(e,l,u)}catch(e){}}}}return e}function rj(e){return"function"==typeof e}function ij(e){return"object"==typeof e&&"styledComponentId"in e}function oj(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function aj(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function sj(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function lj(e,t,n){if(void 0===n&&(n=!1),!n&&!sj(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=lj(e[r],t[r]);else if(sj(t))for(var r in t)e[r]=lj(e[r],t[r]);return e}function uj(e,t){Object.defineProperty(e,"toString",{value:t})}var cj="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function hj(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],i=1,o=e.length;i<o;i+=1)r.push(e[i]);return r.forEach((function(e){n=n.replace(/%[a-z]/,e)})),n}function dj(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(e," for more information.").concat(t.length>0?" Args: ".concat(t.join(", ")):"")):new Error(hj.apply(void 0,c([cj[e]],t,!1)).trim())}var pj=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,i=r;e>=i;)if((i<<=1)<0)throw dj(16,"".concat(e));this.groupSizes=new Uint32Array(i),this.groupSizes.set(n),this.length=i;for(var o=r;o<i;o++)this.groupSizes[o]=0}for(var a=this.indexOfGroup(e+1),s=(o=0,t.length);o<s;o++)this.tag.insertRule(a,t[o])&&(this.groupSizes[e]++,a++)},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var i=n;i<r;i++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),i=r+n,o=r;o<i;o++)t+="".concat(this.tag.getRule(o)).concat(wW);return t},e}(),fj=1<<30,gj=new Map,mj=new Map,vj=1,yj=function(e){if(gj.has(e))return gj.get(e);for(;mj.has(vj);)vj++;var t=vj++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>fj))throw dj(16,"".concat(t));return gj.set(e,t),mj.set(t,e),t},_j=function(e,t){vj=t+1,gj.set(e,t),mj.set(t,e)},xj="style[".concat(yW,"][").concat(xW,'="').concat(bW,'"]'),bj=new RegExp("^".concat(yW,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),wj=function(e,t,n){for(var r,i=n.split(","),o=0,a=i.length;o<a;o++)(r=i[o])&&e.registerName(t,r)},Sj=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(wW),i=[],o=0,a=r.length;o<a;o++){var s=r[o].trim();if(s){var l=s.match(bj);if(l){var u=0|parseInt(l[1],10),c=l[2];0!==u&&(_j(c,u),wj(e,c,l[3]),e.getTag().insertRules(u,i)),i.length=0}else i.push(s)}}},Tj=function(e){for(var t=document.querySelectorAll(xj),n=0,r=t.length;n<r;n++){var i=t[n];i&&i.getAttribute(yW)!==_W&&(Sj(e,i),i.parentNode&&i.parentNode.removeChild(i))}};var Mj=function(e){var t=document.head,n=e||t,r=document.createElement("style"),i=function(e){var t=Array.from(e.querySelectorAll("style[".concat(yW,"]")));return t[t.length-1]}(n),o=void 0!==i?i.nextSibling:null;r.setAttribute(yW,_W),r.setAttribute(xW,bW);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,o),r},Cj=function(){function e(e){this.element=Mj(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var i=t[n];if(i.ownerNode===e)return i}throw dj(17)}(this.element),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Dj=function(){function e(e){this.element=Mj(e),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),Aj=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Ij=SW,Ej={isServer:!SW,useCSSOMInjection:!TW},Lj=function(){function e(e,t,n){void 0===e&&(e=IW),void 0===t&&(t={});var r=this;this.options=u(u({},Ej),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&SW&&Ij&&(Ij=!1,Tj(this)),uj(this,(function(){return function(e){for(var t=e.getTag(),n=t.length,r="",i=function(n){var i=function(e){return mj.get(e)}(n);if(void 0===i)return"continue";var o=e.names.get(i),a=t.getGroup(n);if(void 0===o||!o.size||0===a.length)return"continue";var s="".concat(yW,".g").concat(n,'[id="').concat(i,'"]'),l="";void 0!==o&&o.forEach((function(e){e.length>0&&(l+="".concat(e,","))})),r+="".concat(a).concat(s,'{content:"').concat(l,'"}').concat(wW)},o=0;o<n;o++)i(o);return r}(r)}))}return e.registerId=function(e){return yj(e)},e.prototype.rehydrate=function(){!this.server&&SW&&Tj(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(u(u({},this.options),t),this.gs,n&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new Aj(n):t?new Cj(n):new Dj(n)}(this.options),new pj(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(yj(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(yj(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(yj(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),Nj=/&/g,Pj=/^\s*\/\/.*$/gm;function Oj(e,t){return e.map((function(e){return"rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map((function(e){return"".concat(t," ").concat(e)}))),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Oj(e.children,t)),e}))}var Rj=new Lj,kj=function(){var e,t,n,r=IW,i=r.options,o=void 0===i?IW:i,a=r.plugins,s=void 0===a?AW:a,l=function(n,r,i){return i.startsWith(t)&&i.endsWith(t)&&i.replaceAll(t,"").length>0?".".concat(e):n},u=s.slice();u.push((function(e){e.type===MU&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(Nj,t).replace(n,l))})),o.prefix&&u.push(mW),u.push(gW);var c=function(r,i,a,s){void 0===i&&(i=""),void 0===a&&(a=""),void 0===s&&(s="&"),e=s,t=i,n=new RegExp("\\".concat(t,"\\b"),"g");var l=r.replace(Pj,""),c=lW(a||i?"".concat(a," ").concat(i," { ").concat(l," }"):l);o.namespace&&(c=Oj(c,o.namespace));var h,d=[];return fW(c,function(e){var t=VU(e);return function(n,r,i,o){for(var a="",s=0;s<t;s++)a+=e[s](n,r,i,o)||"";return a}}(u.concat((h=function(e){return d.push(e)},function(e){e.root||(e=e.return)&&h(e)})))),d};return c.hash=s.length?s.reduce((function(e,t){return t.name||dj(15),VW(e,t.name)}),5381).toString():"",c}(),zj=e.createContext({shouldForwardProp:void 0,styleSheet:Rj,stylis:kj});function Vj(){return i(zj)}zj.Consumer,e.createContext(void 0);var Bj=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=kj);var r=n.name+t.hash;e.hasNameForId(n.id,r)||e.insertRules(n.id,r,t(n.rules,r,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,uj(this,(function(){throw dj(12,String(n.name))}))}return e.prototype.getName=function(e){return void 0===e&&(e=kj),this.name+e.hash},e}(),Fj=function(e){return e>="A"&&e<="Z"};function Gj(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;Fj(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Hj=function(e){return null==e||!1===e||""===e},Uj=function(e){var t,n,r=[];for(var i in e){var o=e[i];e.hasOwnProperty(i)&&!Hj(o)&&(Array.isArray(o)&&o.isCss||rj(o)?r.push("".concat(Gj(i),":"),o,";"):sj(o)?r.push.apply(r,c(c(["".concat(i," {")],Uj(o),!1),["}"],!1)):r.push("".concat(Gj(i),": ").concat((t=i,null==(n=o)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in vW||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function Wj(e,t,n,r){if(Hj(e))return[];if(ij(e))return[".".concat(e.styledComponentId)];if(rj(e)){if(!rj(o=e)||o.prototype&&o.prototype.isReactComponent||!t)return[e];var i=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof i||Array.isArray(i)||i instanceof Bj||sj(i)||null===i||console.error("".concat(FW(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Wj(i,t,n,r)}var o;return e instanceof Bj?n?(e.inject(n,r),[e.getName(r)]):[e]:sj(e)?Uj(e):Array.isArray(e)?Array.prototype.concat.apply(AW,e.map((function(e){return Wj(e,t,n,r)}))):[e.toString()]}var jj=BW(bW),Xj=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&function(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(rj(n)&&!ij(n))return!1}return!0}(e),this.componentId=t,this.baseHash=VW(jj,t),this.baseStyle=n,Lj.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var r=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))r=oj(r,this.staticRulesId);else{var i=aj(Wj(this.rules,e,t,n)),o=kW(VW(this.baseHash,i)>>>0);if(!t.hasNameForId(this.componentId,o)){var a=n(i,".".concat(o),void 0,this.componentId);t.insertRules(this.componentId,o,a)}r=oj(r,o),this.staticRulesId=o}else{for(var s=VW(this.baseHash,n.hash),l="",u=0;u<this.rules.length;u++){var c=this.rules[u];if("string"==typeof c)l+=c,"production"!==process.env.NODE_ENV&&(s=VW(s,c));else if(c){var h=aj(Wj(c,e,t,n));s=VW(s,h+u),l+=h}}if(l){var d=kW(s>>>0);t.hasNameForId(this.componentId,d)||t.insertRules(this.componentId,d,n(l,".".concat(d),void 0,this.componentId)),r=oj(r,d)}}return r},e}(),Yj=e.createContext(void 0);Yj.Consumer;var Zj={},qj=new Set;function Kj(t,i,o){var a=ij(t),s=t,l=!GW(t),c=i.attrs,h=void 0===c?AW:c,d=i.componentId,p=void 0===d?function(e,t){var n="string"!=typeof e?"sc":PW(e);Zj[n]=(Zj[n]||0)+1;var r="".concat(n,"-").concat(function(e){return kW(BW(e)>>>0)}(bW+n+Zj[n]));return t?"".concat(t,"-").concat(r):r}(i.displayName,i.parentComponentId):d,f=i.displayName,g=void 0===f?function(e){return GW(e)?"styled.".concat(e):"Styled(".concat(FW(e),")")}(t):f,m=i.displayName&&i.componentId?"".concat(PW(i.displayName),"-").concat(i.componentId):i.componentId||p,v=a&&s.attrs?s.attrs.concat(h).filter(Boolean):h,y=i.shouldForwardProp;if(a&&s.shouldForwardProp){var _=s.shouldForwardProp;if(i.shouldForwardProp){var x=i.shouldForwardProp;y=function(e,t){return _(e,t)&&x(e,t)}}else y=_}var b=new Xj(o,m,a?s.componentStyle:void 0);function w(t,i){return function(t,i,o){var a=t.attrs,s=t.componentStyle,l=t.defaultProps,c=t.foldedComponentIds,h=t.styledComponentId,d=t.target,p=e.useContext(Yj),f=Vj(),g=t.shouldForwardProp||f.shouldForwardProp;"production"!==process.env.NODE_ENV&&n(h);var m=function(e,t,n){return void 0===n&&(n=IW),e.theme!==n.theme&&e.theme||t||n.theme}(i,p,l)||IW,v=function(e,t,n){for(var r,i=u(u({},t),{className:void 0,theme:n}),o=0;o<e.length;o+=1){var a=rj(r=e[o])?r(i):r;for(var s in a)i[s]="className"===s?oj(i[s],a[s]):"style"===s?u(u({},i[s]),a[s]):a[s]}return t.className&&(i.className=oj(i.className,t.className)),i}(a,i,m),y=v.as||d,_={};for(var x in v)void 0===v[x]||"$"===x[0]||"as"===x||"theme"===x&&v.theme===m||("forwardedAs"===x?_.as=v.forwardedAs:g&&!g(x,y)||(_[x]=v[x],g||"development"!==process.env.NODE_ENV||xU(x)||qj.has(x)||!EW.has(y)||(qj.add(x),console.warn('styled-components: it looks like an unknown prop "'.concat(x,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var b=function(e,t){var r=Vj(),i=e.generateAndInjectStyles(t,r.styleSheet,r.stylis);return"production"!==process.env.NODE_ENV&&n(i),i}(s,v);"production"!==process.env.NODE_ENV&&t.warnTooManyClasses&&t.warnTooManyClasses(b);var w=oj(c,h);return b&&(w+=" "+b),v.className&&(w+=" "+v.className),_[GW(y)&&!EW.has(y)?"class":"className"]=w,o&&(_.ref=o),r(y,_)}(S,t,i)}w.displayName=g;var S=e.forwardRef(w);return S.attrs=v,S.componentStyle=b,S.displayName=g,S.shouldForwardProp=y,S.foldedComponentIds=a?oj(s.foldedComponentIds,s.styledComponentId):"",S.styledComponentId=m,S.target=a?s.target:t,Object.defineProperty(S,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=a?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,i=t;r<i.length;r++)lj(e,i[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(DW(g,m),S.warnTooManyClasses=function(e,t){var n={},r=!1;return function(i){if(!r&&(n[i]=!0,Object.keys(n).length>=200)){var o=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(o,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),r=!0,n={}}}}(g,m)),uj(S,(function(){return".".concat(S.styledComponentId)})),l&&nj(S,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),S}function $j(e,t){for(var n=[e[0]],r=0,i=t.length;r<i;r+=1)n.push(t[r],e[r+1]);return n}var Jj=function(e){return Object.assign(e,{isCss:!0})};function Qj(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(rj(e)||sj(e))return Jj(Wj($j(AW,c([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?Wj(r):Jj(Wj($j(r,t)))}function eX(e,t,n){if(void 0===n&&(n=IW),!t)throw dj(1,t);var r=function(r){for(var i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];return e(t,n,Qj.apply(void 0,c([r],i,!1)))};return r.attrs=function(r){return eX(e,t,u(u({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return eX(e,t,u(u({},n),r))},r}var tX=function(e){return eX(Kj,e)},nX=tX;EW.forEach((function(e){nX[e]=tX(e)})),"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var rX="__sc-".concat(yW,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[rX]||(window[rX]=0),1===window[rX]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[rX]+=1);const iX=nX.div`
21
21
  height: 100%;
22
- `;var oX;!function(e){e[e.MINI_AREA=0]="MINI_AREA",e[e.AREA=1]="AREA",e[e.DUAL_LINE_BAR=2]="DUAL_LINE_BAR",e[e.STACK_DUAL_LINE_BAR=3]="STACK_DUAL_LINE_BAR",e[e.COLUMN=4]="COLUMN",e[e.STACK_COLUMN=5]="STACK_COLUMN",e[e.LINE=6]="LINE",e[e.BAR=7]="BAR",e[e.STACK_BAR=8]="STACK_BAR",e[e.FUNNEL=9]="FUNNEL",e[e.PIE=10]="PIE",e[e.CYCLE=11]="CYCLE",e[e.RADAR=12]="RADAR"}(oX||(oX={}));const aX=["#3D84FF","#00DCF0","#FCBC26","#00DB75","#BDB8FF","#40B4FF","#FFA101","#90ABE0","#6EE67A","#6B84FF","#FA6B69"],sX={grid:{top:24,left:0,right:12,bottom:32,containLabel:!0},color:aX,legend:{itemWidth:10,itemHeight:10,bottom:0,type:"scroll",icon:"circle"}};function lX(){return lX=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lX.apply(null,arguments)}function uX(e,t){return uX=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},uX(e,t)}function cX(e){return cX=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},cX(e)}function hX(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(hX=function(){return!!e})()}function dX(e){var t="function"==typeof Map?new Map:void 0;return dX=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(hX())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&uX(i,n.prototype),i}(e,arguments,cX(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),uX(n,e)},dX(e)}var pX={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function fX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=t[0],o=[];for(r=1;r<t.length;r+=1)o.push(t[r]);return o.forEach((function(e){i=i.replace(/%[a-z]/,e)})),i}var gX=function(e){function t(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];n=e.call(this,fX.apply(void 0,[pX[t]].concat(i)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,uX(e,t)}(t,e),t}(dX(Error));function mX(e){return Math.round(255*e)}function vX(e,t,n){return mX(e)+","+mX(t)+","+mX(n)}function yX(e,t,n,r){if(void 0===r&&(r=vX),0===t)return r(n,n,n);var i=(e%360+360)%360/60,o=(1-Math.abs(2*n-1))*t,a=o*(1-Math.abs(i%2-1)),s=0,l=0,u=0;i>=0&&i<1?(s=o,l=a):i>=1&&i<2?(s=a,l=o):i>=2&&i<3?(l=o,u=a):i>=3&&i<4?(l=a,u=o):i>=4&&i<5?(s=a,u=o):i>=5&&i<6&&(s=o,u=a);var c=n-o/2;return r(s+c,l+c,u+c)}var _X={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",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",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",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",rebeccapurple:"639",red:"f00",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:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var xX=/^#[a-fA-F0-9]{6}$/,bX=/^#[a-fA-F0-9]{8}$/,wX=/^#[a-fA-F0-9]{3}$/,SX=/^#[a-fA-F0-9]{4}$/,TX=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,MX=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,CX=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,DX=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function AX(e){if("string"!=typeof e)throw new gX(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return _X[t]?"#"+_X[t]:e}(e);if(t.match(xX))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(bX)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(wX))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(SX)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var i=TX.exec(t);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var o=MX.exec(t.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=CX.exec(t);if(a){var s="rgb("+yX(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",l=TX.exec(s);if(!l)throw new gX(4,t,s);return{red:parseInt(""+l[1],10),green:parseInt(""+l[2],10),blue:parseInt(""+l[3],10)}}var u=DX.exec(t.substring(0,50));if(u){var c="rgb("+yX(parseInt(""+u[1],10),parseInt(""+u[2],10)/100,parseInt(""+u[3],10)/100)+")",h=TX.exec(c);if(!h)throw new gX(4,t,c);return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10),alpha:parseFloat(""+u[4])>1?parseFloat(""+u[4])/100:parseFloat(""+u[4])}}throw new gX(5)}function IX(e){return function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,o=Math.max(n,r,i),a=Math.min(n,r,i),s=(o+a)/2;if(o===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var l=o-a,u=s>.5?l/(2-o-a):l/(o+a);switch(o){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;default:t=(n-r)/l+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:u,lightness:s,alpha:e.alpha}:{hue:t,saturation:u,lightness:s}}(AX(e))}var EX=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function LX(e){var t=e.toString(16);return 1===t.length?"0"+t:t}function NX(e){return LX(Math.round(255*e))}function PX(e,t,n){return EX("#"+NX(e)+NX(t)+NX(n))}function OX(e,t,n){return yX(e,t,n,PX)}function RX(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return EX("#"+LX(e)+LX(t)+LX(n));if("object"==typeof e&&void 0===t&&void 0===n)return EX("#"+LX(e.red)+LX(e.green)+LX(e.blue));throw new gX(6)}function kX(e,t,n,r){if("string"==typeof e&&"number"==typeof t){var i=AX(e);return"rgba("+i.red+","+i.green+","+i.blue+","+t+")"}if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?RX(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new gX(7)}function zX(e){if("object"!=typeof e)throw new gX(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return kX(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return RX(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return function(e,t,n,r){if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?OX(e.hue,e.saturation,e.lightness):"rgba("+yX(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new gX(2)}(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return function(e,t,n){if("object"==typeof e&&void 0===t&&void 0===n)return OX(e.hue,e.saturation,e.lightness);throw new gX(1)}(e);throw new gX(8)}function VX(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):VX(e,t,r)}}function BX(e){return VX(e,e.length,[])}function FX(e,t,n){return Math.max(e,Math.min(t,n))}BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{hue:n.hue+parseFloat(e)}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{lightness:FX(0,1,n.lightness-parseFloat(e))}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{saturation:FX(0,1,n.saturation-parseFloat(e))}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{lightness:FX(0,1,n.lightness+parseFloat(e))}))}));var GX=BX((function(e,t,n){if("transparent"===t)return n;if("transparent"===n)return t;if(0===e)return n;var r=AX(t),i=lX({},r,{alpha:"number"==typeof r.alpha?r.alpha:1}),o=AX(n),a=lX({},o,{alpha:"number"==typeof o.alpha?o.alpha:1}),s=i.alpha-a.alpha,l=2*parseFloat(e)-1,u=((l*s==-1?l:l+s)/(1+l*s)+1)/2,c=1-u;return kX({red:Math.floor(i.red*u+a.red*c),green:Math.floor(i.green*u+a.green*c),blue:Math.floor(i.blue*u+a.blue*c),alpha:i.alpha*parseFloat(e)+a.alpha*(1-parseFloat(e))})})),HX=GX;function UX(e){return Array.isArray(e)&&e.length>0}BX((function(e,t){if("transparent"===t)return t;var n=AX(t);return kX(lX({},n,{alpha:FX(0,1,(100*("number"==typeof n.alpha?n.alpha:1)+100*parseFloat(e))/100)}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{saturation:FX(0,1,n.saturation+parseFloat(e))}))})),BX((function(e,t){return"transparent"===t?t:zX(lX({},IX(t),{hue:parseFloat(e)}))})),BX((function(e,t){return"transparent"===t?t:zX(lX({},IX(t),{lightness:parseFloat(e)}))})),BX((function(e,t){return"transparent"===t?t:zX(lX({},IX(t),{saturation:parseFloat(e)}))})),BX((function(e,t){return"transparent"===t?t:HX(parseFloat(e),"rgb(0, 0, 0)",t)})),BX((function(e,t){return"transparent"===t?t:HX(parseFloat(e),"rgb(255, 255, 255)",t)})),BX((function(e,t){if("transparent"===t)return t;var n=AX(t);return kX(lX({},n,{alpha:FX(0,1,+(100*("number"==typeof n.alpha?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))}));const WX=(e,t=2)=>"number"==typeof e?`${Number((100*e).toFixed(t))}%`:"-%";function jX(e){return Array.isArray(e)?[...new Set(e)]:[]}const XX=e=>Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>{const n=Number(t);return e+(Object.is(n,NaN)?0:n)}),0):0,YX=e=>Array.isArray(e)?e.sort(((e,t)=>t.value-e.value)):e,ZX=e=>{let t=e.data;return(e=>Array.isArray(e)&&e.length>0)(t)||(t=e.extraData),{boundaryGap:!0,axisTick:{alignWithLabel:!0},data:jX(null==t?void 0:t.map((e=>e.label))),axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}}},qX=(e,t)=>(e.sort(((e,n)=>t.indexOf(e.label)-t.indexOf(n.label))),e);function KX(e,t){let n=null;return function(...r){clearTimeout(n),n=setTimeout((()=>{e.apply(globalThis,r)}),t)}}const $X=e=>"dark"===e.theme?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.7)";function JX(e){const t=e.reduce(((e,t)=>{const{label:n,value:r}=t;return e[n]||(e[n]=0),r&&(e[n]+=Number(r)),e}),{});return Object.values(t).map((e=>parseFloat(e.toFixed(2))))}const QX=e=>{const t=(e=>{const{data:t,extraData:n,sort:r}=e;if(t&&r){const a=(i=[...t],"asc"===(o=r)?i.sort(((e,t)=>e.value-t.value)):"desc"===o&&i.sort(((e,t)=>t.value-e.value)),i),s=jX(a.map((e=>e.label))),l=qX(a,s),u=qX([...null!=n?n:[]],s);return Object.assign(Object.assign({},e),{data:l,extraData:u})}var i,o;return e})(e);switch(t.chartType){case oX.MINI_AREA:return(e=>{var t,n,r;const i=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),o=e.color;return{color:o,grid:{top:4,left:0,right:0,bottom:0,containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{show:!1},xAxis:{show:!1,boundaryGap:!1,data:jX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label)))},yAxis:{show:!1,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},series:[...i.map(((t,n)=>{var r,i;const a=null!==(r=null==o?void 0:o[n])&&void 0!==r?r:aX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new yc(0,0,0,1,[{offset:0,color:kX(a,.5)},{offset:1,color:"dark"===e.theme?kX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(i=e.data)||void 0===i?void 0:i.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.AREA:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:ZX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:[...r.map(((t,n)=>{var r;const i=aX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new yc(0,0,0,1,[{offset:0,color:kX(i,.5)},{offset:1,color:"dark"===e.theme?kX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"},showSymbol:!0}),{data:null===(r=e.data)||void 0===r?void 0:r.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.LINE:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:ZX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!1,lineStyle:{width:2},showSymbol:!0,emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))}})(t);case oX.COLUMN:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})}))}})(t);case oX.STACK_COLUMN:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})}))}})(t);case oX.BAR:return(e=>{var t,n,r;const i=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:{},yAxis:{data:jX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:[0,500,500,0]}})))})}))}})(t);case oX.STACK_BAR:return(e=>{var t,n,r;const i=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{grid:Object.assign({},e.showStackTotal&&{right:32}),tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll",data:i},xAxis:{},yAxis:{data:jX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:[...i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&!e.showStackTotal&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),Object.assign(Object.assign({name:"总和",type:"bar",stack:"abc",barGap:"-100%",barMaxWidth:8,itemStyle:{normal:{color:"transparent"}},tooltip:{show:!1}},e.showStackTotal&&{label:{normal:{show:!0,position:"right",color:"#000"},formatter:t=>{var n;return String(Number(XX(null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.label===t.name)).map((e=>e.value))).toFixed(2)))}}}),{data:JX(e.data)})]}})(t);case oX.FUNNEL:return(e=>{var t,n;const r=null!==(n=null===(t=YX(e.data))||void 0===t?void 0:t.map((t=>{var n;return{value:null!==(n=t.value)&&void 0!==n?n:0,name:e.reserveValueWithLabelType?t.label:t.type}})))&&void 0!==n?n:[],i={type:"funnel",minSize:"20%",left:10,top:24,width:"76%",sort:"descending",data:r};return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[Object.assign(Object.assign({},i),{label:{show:!0,position:"outer",formatter:"{c}"}}),Object.assign(Object.assign({},i),{emphasis:{label:{fontSize:20}},label:{show:!0,position:"inner",color:"#fff",formatter:e=>{const t=e.dataIndex;if(0===t)return"100%";const n=r[t-1].value;return WX(e.value/n)}}})]}})(t);case oX.DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=jX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.STACK_DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=jX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.PIE:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:"50%",data:null===(n=YX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:$X(e),position:"outside",formatter:e=>WX(e.value/(r||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}})(t);case oX.CYCLE:return(e=>{var t,n,r,i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x;const b=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:["60%","48%"],data:null===(n=YX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:$X(e),position:"outside",formatter:e=>WX(e.value/(b||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}],graphic:[{type:"text",left:"center",top:null!==(o=null===(i=null===(r=e.cycleCenterConfig)||void 0===r?void 0:r.content)||void 0===i?void 0:i.top)&&void 0!==o?o:76,style:{text:null!==(l=null===(s=null===(a=e.cycleCenterConfig)||void 0===a?void 0:a.content)||void 0===s?void 0:s.value)&&void 0!==l?l:Number(b.toFixed(2)).toString(),fill:"dark"===e.theme?"#fff":"#12161F",fontFamily:"roboto",fontSize:null!==(h=null===(c=null===(u=e.cycleCenterConfig)||void 0===u?void 0:u.content)||void 0===c?void 0:c.fontSize)&&void 0!==h?h:28,fontWeight:"bold"}},{type:"text",left:"center",top:null!==(f=null===(p=null===(d=e.cycleCenterConfig)||void 0===d?void 0:d.title)||void 0===p?void 0:p.top)&&void 0!==f?f:112,style:{text:null!==(v=null===(m=null===(g=e.cycleCenterConfig)||void 0===g?void 0:g.title)||void 0===m?void 0:m.value)&&void 0!==v?v:"总计",fill:"dark"===e.theme?"#fff":"#394252 ",fontSize:null!==(x=null===(_=null===(y=e.cycleCenterConfig)||void 0===y?void 0:y.title)||void 0===_?void 0:_.fontSize)&&void 0!==x?x:14}}]}})(t);case oX.RADAR:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((t=>e.reserveValueWithLabelType?t.label:t.type)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},radar:{shape:"circle",radius:"60%",indicator:jX(null===(n=e.data)||void 0===n?void 0:n.map((t=>e.reserveValueWithLabelType?t.type:t.label))).map((e=>({name:e}))),axisName:{color:"#5d677a"},splitArea:{areaStyle:{color:["transparent"]}},axisLine:{lineStyle:{color:"rgba(226, 229, 235, .3)"}},splitLine:{lineStyle:{color:"#e2e5eb",type:"dashed",dashOffset:1.5}}},series:[{type:"radar",data:r.map(((t,n)=>{var r;return{name:t,value:null===(r=e.data)||void 0===r?void 0:r.filter((n=>e.reserveValueWithLabelType?n.label:n.type===t)).map((e=>e.value)),areaStyle:{color:kX(aX[n],.2)},label:{show:e.reserveValueWithLabelType,formatter:e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.toString()}}}})),emphasis:{lineStyle:{width:4}}}]}})(t);default:return{}}};var eY={color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"rgba(0,0,0,0)",textStyle:{},title:{textStyle:{color:"#272f3d"},subtextStyle:{color:"#394252"}},line:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},radar:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#dfe3eb"},symbolSize:4,symbol:"emptyCircle",smooth:!1,color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#828c9e"},emphasis:{iconStyle:{borderColor:"#394252"}}},legend:{textStyle:{color:"#828b9e"}},tooltip:{axisPointer:{lineStyle:{color:"#ccd1db",width:"1"},crossStyle:{color:"#ccd1db",width:"1"}}},timeline:{lineStyle:{color:"#eef0f5",width:2},itemStyle:{color:"#eef0f5",borderWidth:"1"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},checkpointStyle:{color:"#3379ff",borderColor:"#ffffff"},label:{color:"#b1b9c7"},emphasis:{itemStyle:{color:"#3379ff"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},label:{color:"#b1b9c7"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},tY={color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"transparent",textStyle:{},title:{textStyle:{color:"#ffffff"},subtextStyle:{color:"#ffffff"}},line:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},radar:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#ffffff"},symbolSize:"6",symbol:"emptyCircle",smooth:!0,color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#ffffff"},emphasis:{iconStyle:{borderColor:"#ffffff"}}},legend:{textStyle:{color:"#ffffff"}},tooltip:{axisPointer:{lineStyle:{color:"#ffffff",width:"1"},crossStyle:{color:"#ffffff",width:"1"}}},timeline:{lineStyle:{color:"#ffffff",width:2},itemStyle:{color:"#ffffff",borderWidth:"1"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},checkpointStyle:{color:"#5798ff",borderColor:"#ffffff"},label:{color:"#ffffff"},emphasis:{itemStyle:{color:"#5798ff"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},label:{color:"#ffffff"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},nY=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===rY}(e)}(e)};var rY="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function iY(e,t){return!1!==t.clone&&t.isMergeableObject(e)?uY((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function oY(e,t,n){return e.concat(t).map((function(e){return iY(e,n)}))}function aY(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function sY(e,t){try{return t in e}catch(e){return!1}}function lY(e,t,n){var r={};return n.isMergeableObject(e)&&aY(e).forEach((function(t){r[t]=iY(e[t],n)})),aY(t).forEach((function(i){(function(e,t){return sY(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(sY(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return uY;var n=t.customMerge(e);return"function"==typeof n?n:uY}(i,n)(e[i],t[i],n):r[i]=iY(t[i],n))})),r}function uY(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||oY,n.isMergeableObject=n.isMergeableObject||nY,n.cloneUnlessOtherwiseSpecified=iY;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):lY(e,t,n):iY(t,n)}uY.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return uY(e,n,t)}),{})};var cY=hU(uY);By("light",cY(eY,sX)),By("dark",cY(tY,sX));const hY={arrayMerge:(e,t)=>t},dY=e=>{const n=t(null),[r,i]=o();return a((()=>{var t;const r=Ry(n.current,null!==(t=e.theme)&&void 0!==t?t:"light");i(r);const o=KX(r.resize,500),a=()=>o();return globalThis.addEventListener("resize",a),()=>{globalThis.removeEventListener("resize",a)}}),[e.theme]),a((()=>{var t;if(r){const n=r.getHeight()-48,i=Object.assign(Object.assign({},e),e.chartType===oX.CYCLE&&!e.cycleCenterConfig&&{cycleCenterConfig:{title:{top:n/2+24},content:{top:n/2-8}}}),{extraOption:o={},extraSeriesOption:a}=i;r.clear();const s=cY(((e,t)=>(UX(e.series)&&UX(t)&&t.forEach((t=>{e.series=e.series.map((e=>Object.assign(Object.assign({},e),e.name===t.name&&t)))})),e))(QX(i),a),o,hY);r.setOption(s),null===(t=i.onLoad)||void 0===t||t.call(i,r);const l=setTimeout((()=>{r.resize()}),500);return()=>{clearTimeout(l)}}}),[r,e]),vU.jsx(iX,{ref:n,className:e.className,style:e.style})};function pY(e,t,n){"object"==typeof t&&(n=t,t=null);var r,i=this;if(!(e instanceof Function))for(var o in r=[],e)e.hasOwnProperty(o)&&r.push(o);var a=function(t){if(i.apply(this,arguments),e instanceof Function?fY(this,e.call(this,t)):function(e,t,n){for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}}(this,e,r),this.constructor===a)for(var n=a.__initializers__,o=0;o<n.length;o++)n[o].apply(this,arguments)};a.__super__=i,i.__initializers__?a.__initializers__=i.__initializers__.slice():a.__initializers__=[],t&&a.__initializers__.push(t);var s=function(){};return s.prototype=i.prototype,a.prototype=new s,a.prototype.constructor=a,fY(a.prototype,n),a.extend=i.extend,a.derive=i.extend,a}function fY(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}i_([kS,vH]),i_(mw);var gY={extend:pY,derive:pY};function mY(e,t){this.action=e,this.context=t}var vY={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,r=-1,i=arguments;switch(i.length){case 1:for(;++r<n;)t[r].action.call(t[r].context);return;case 2:for(;++r<n;)t[r].action.call(t[r].context,i[1]);return;case 3:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2]);return;case 4:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3]);return;case 5:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3],i[4]);return;default:for(;++r<n;)t[r].action.apply(t[r].context,Array.prototype.slice.call(i,1));return}}},on:function(e,t,n){if(e&&t){var r=this.__handlers__||(this.__handlers__={});if(r[e]){if(this.has(e,t))return}else r[e]=[];var i=new mY(t,n||this);return r[e].push(i),this}},once:function(e,t,n){if(e&&t){var r=this;return this.on(e,(function n(){r.off(e,n),t.apply(this,arguments)}),n)}},before:function(e,t,n){if(e&&t)return e="before"+e,this.on(e,t,n)},after:function(e,t,n){if(e&&t)return e="after"+e,this.on(e,t,n)},success:function(e,t){return this.once("success",e,t)},error:function(e,t){return this.once("error",e,t)},off:function(e,t){var n=this.__handlers__||(this.__handlers__={});if(t){if(n[e]){for(var r=n[e],i=[],o=0;o<r.length;o++)t&&r[o].action!==t&&i.push(r[o]);n[e]=i}return this}n[e]=[]},has:function(e,t){var n=this.__handlers__;if(!n||!n[e])return!1;for(var r=n[e],i=0;i<r.length;i++)if(r[i].action===t)return!0}},yY=0,_Y=Array.prototype.forEach,xY={genGUID:function(){return++yY},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;for(var n=e.split("/"),r=t.split("/"),i=n[0];"."===i||".."===i;)".."===i&&r.pop(),n.shift(),i=n[0];return r.join("/")+"/"+n.join("/")},extend:function(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},defaults:function(e,t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n]);return e},extendWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}return e},defaultsWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];null==e[i]&&(e[i]=t[i])}return e},each:function(e,t,n){if(e&&t)if(e.forEach&&e.forEach===_Y)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(n,e[o],o,e)},isObject:function(e){return e===Object(e)},isArray:function(e){return Array.isArray(e)},isArrayLike:function(e){return!!e&&e.length===+e.length},clone:function(e){if(xY.isObject(e)){if(xY.isArray(e))return e.slice();if(xY.isArrayLike(e)){for(var t=new e.constructor(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return xY.extend({},e)}return e}},bY=function(){this.__uid__=xY.genGUID()};bY.__initializers__=[function(e){xY.extend(this,e)}],xY.extend(bY,gY),xY.extend(bY.prototype,vY);var wY=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],SY=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];function TY(e){for(var t={},n={},r=0;r<wY.length;r++){o(wY[r])}for(r=0;r<SY.length;r++){var i=SY[r];n[i]=e.getParameter(e[i])}function o(n){if(e.getExtension){var r=e.getExtension(n);r||(r=e.getExtension("MOZ_"+n)),r||(r=e.getExtension("WEBKIT_"+n)),t[n]=r}}this.getExtension=function(e){return e in t||o(e),t[e]},this.getParameter=function(e){return n[e]}}var MY=256,CY=1024,DY=16384,AY=0,IY=1,EY=2,LY=3,NY=4,PY=5,OY=6,RY=35040,kY=35044,zY=35048,VY=1028,BY=1029,FY=1032,GY=2304,HY=2305,UY=5120,WY=5121,jY=5122,XY=5123,YY=5124,ZY=5125,qY=5126,KY=6402,$Y=6406,JY=6407,QY=6408,eZ=6409,tZ=6410,nZ=9728,rZ=9729,iZ=9984,oZ=9985,aZ=9986,sZ=9987,lZ=3553,uZ=34067,cZ=10497,hZ=33071,dZ=33648,pZ=36160,fZ=36161,gZ=34041,mZ=36064,vZ=36096,yZ=36128,_Z=33306;var xZ,bZ={get:function(e){var t=new XMLHttpRequest;t.open("get",e.url),t.responseType=e.responseType||"text",e.onprogress&&(t.onprogress=function(t){if(t.lengthComputable){var n=t.loaded/t.total;e.onprogress(n,t.loaded,t.total)}else e.onprogress(null)}),t.onload=function(n){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}},wZ={supportWebGL:function(){if(null==xZ)try{var e=document.createElement("canvas");if(!(e.getContext("webgl")||e.getContext("experimental-webgl")))throw new Error}catch(e){xZ=!1}return xZ}};wZ.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,wZ.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,wZ.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,wZ.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,wZ.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,wZ.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,wZ.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var SZ={};"undefined"!=typeof window?SZ=window:"undefined"!=typeof global&&(SZ=global),wZ.requestAnimationFrame=SZ.requestAnimationFrame||SZ.msRequestAnimationFrame||SZ.mozRequestAnimationFrame||SZ.webkitRequestAnimationFrame||function(e){setTimeout(e,16)},wZ.createCanvas=function(){return document.createElement("canvas")},wZ.createImage=function(){return new SZ.Image},wZ.request={get:bZ.get},wZ.addEventListener=function(e,t,n,r){e.addEventListener(t,n,r)},wZ.removeEventListener=function(e,t,n){e.removeEventListener(t,n)};var TZ=function(){this.head=null,this.tail=null,this._length=0};TZ.prototype.insert=function(e){var t=new TZ.Entry(e);return this.insertEntry(t),t},TZ.prototype.insertAt=function(e,t){if(!(e<0)){for(var n=this.head,r=0;n&&r!=e;)n=n.next,r++;if(n){var i=new TZ.Entry(t),o=n.prev;o?(o.next=i,i.prev=o):this.head=i,i.next=n,n.prev=i}else this.insert(t)}},TZ.prototype.insertBeforeEntry=function(e,t){var n=new TZ.Entry(e),r=t.prev;r?(r.next=n,n.prev=r):this.head=n,n.next=t,t.prev=n,this._length++},TZ.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},TZ.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._length--},TZ.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t?(this.remove(t),t.value):void 0}},TZ.prototype.getHead=function(){if(this.head)return this.head.value},TZ.prototype.getTail=function(){if(this.tail)return this.tail.value},TZ.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t.value}},TZ.prototype.indexOf=function(e){for(var t=this.head,n=0;t;){if(t.value===e)return n;t=t.next,n++}},TZ.prototype.length=function(){return this._length},TZ.prototype.isEmpty=function(){return 0===this._length},TZ.prototype.forEach=function(e,t){for(var n=this.head,r=0,i=void 0!==t;n;)i?e.call(t,n.value,r):e(n.value,r),n=n.next,r++},TZ.prototype.clear=function(){this.tail=this.head=null,this._length=0},TZ.Entry=function(e){this.value=e,this.next=null,this.prev=null};var MZ=function(e){this._list=new TZ,this._map={},this._maxSize=e||10};MZ.prototype.setMaxSize=function(e){this._maxSize=e},MZ.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){var n=this._list.length();if(n>=this._maxSize&&n>0){var r=this._list.head;this._list.remove(r),delete this._map[r.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},MZ.prototype.get=function(e){var t=this._map[e];if(this._map.hasOwnProperty(e))return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value},MZ.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},MZ.prototype.clear=function(){this._list.clear(),this._map={}};var CZ={},DZ={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function AZ(e){return(e=Math.round(e))<0?0:e>255?255:e}function IZ(e){return e<0?0:e>1?1:e}function EZ(e){return e.length&&"%"===e.charAt(e.length-1)?AZ(parseFloat(e)/100*255):AZ(parseInt(e,10))}function LZ(e){return e.length&&"%"===e.charAt(e.length-1)?IZ(parseFloat(e)/100):IZ(parseFloat(e))}function NZ(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function PZ(e,t,n){return e+(t-e)*n}function OZ(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function RZ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var kZ=new MZ(20),zZ=null;function VZ(e,t){zZ&&RZ(zZ,t),zZ=kZ.put(e,zZ||t.slice())}function BZ(e,t){var n=(parseFloat(e[0])%360+360)%360/360,r=LZ(e[1]),i=LZ(e[2]),o=i<=.5?i*(r+1):i+r-i*r,a=2*i-o;return OZ(t=t||[],AZ(255*NZ(a,o,n+1/3)),AZ(255*NZ(a,o,n)),AZ(255*NZ(a,o,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}CZ.parse=function(e,t){if(e){t=t||[];var n=kZ.get(e);if(n)return RZ(t,n);var r,i=(e+="").replace(/ /g,"").toLowerCase();if(i in DZ)return RZ(t,DZ[i]),VZ(e,t),t;if("#"===i.charAt(0))return 4===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=4095?(OZ(t,(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1),VZ(e,t),t):void OZ(t,0,0,0,1):7===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=16777215?(OZ(t,(16711680&r)>>16,(65280&r)>>8,255&r,1),VZ(e,t),t):void OZ(t,0,0,0,1):void 0;var o=i.indexOf("("),a=i.indexOf(")");if(-1!==o&&a+1===i.length){var s=i.substr(0,o),l=i.substr(o+1,a-(o+1)).split(","),u=1;switch(s){case"rgba":if(4!==l.length)return void OZ(t,0,0,0,1);u=LZ(l.pop());case"rgb":return 3!==l.length?void OZ(t,0,0,0,1):(OZ(t,EZ(l[0]),EZ(l[1]),EZ(l[2]),u),VZ(e,t),t);case"hsla":return 4!==l.length?void OZ(t,0,0,0,1):(l[3]=LZ(l[3]),BZ(l,t),VZ(e,t),t);case"hsl":return 3!==l.length?void OZ(t,0,0,0,1):(BZ(l,t),VZ(e,t),t);default:return}}OZ(t,0,0,0,1)}},CZ.parseToFloat=function(e,t){if(t=CZ.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},CZ.lift=function(e,t){var n=CZ.parse(e);if(n){for(var r=0;r<3;r++)n[r]=t<0?n[r]*(1-t)|0:(255-n[r])*t+n[r]|0;return CZ.stringify(n,4===n.length?"rgba":"rgb")}},CZ.toHex=function(e){var t=CZ.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},CZ.fastLerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){n=n||[];var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=t[i],s=t[o],l=r-i;return n[0]=AZ(PZ(a[0],s[0],l)),n[1]=AZ(PZ(a[1],s[1],l)),n[2]=AZ(PZ(a[2],s[2],l)),n[3]=IZ(PZ(a[3],s[3],l)),n}},CZ.fastMapToColor=CZ.fastLerp,CZ.lerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=CZ.parse(t[i]),s=CZ.parse(t[o]),l=r-i,u=CZ.stringify([AZ(PZ(a[0],s[0],l)),AZ(PZ(a[1],s[1],l)),AZ(PZ(a[2],s[2],l)),IZ(PZ(a[3],s[3],l))],"rgba");return n?{color:u,leftIndex:i,rightIndex:o,value:r}:u}},CZ.mapToColor=CZ.lerp,CZ.modifyHSL=function(e,t,n,r){if(e=CZ.parse(e))return e=function(e){if(e){var t,n,r=e[0]/255,i=e[1]/255,o=e[2]/255,a=Math.min(r,i,o),s=Math.max(r,i,o),l=s-a,u=(s+a)/2;if(0===l)t=0,n=0;else{n=u<.5?l/(s+a):l/(2-s-a);var c=((s-r)/6+l/2)/l,h=((s-i)/6+l/2)/l,d=((s-o)/6+l/2)/l;r===s?t=d-h:i===s?t=1/3+c-d:o===s&&(t=2/3+h-c),t<0&&(t+=1),t>1&&(t-=1)}var p=[360*t,n,u];return null!=e[3]&&p.push(e[3]),p}}(e),null!=t&&(e[0]=function(e){return(e=Math.round(e))<0?0:e>360?360:e}(t)),null!=n&&(e[1]=LZ(n)),null!=r&&(e[2]=LZ(r)),CZ.stringify(BZ(e),"rgba")},CZ.modifyAlpha=function(e,t){if((e=CZ.parse(e))&&null!=t)return e[3]=IZ(t),CZ.stringify(e,"rgba")},CZ.stringify=function(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}};var FZ=CZ.parseToFloat,GZ={};function HZ(e){var t=Object.keys(e);t.sort();for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e[i];null===o?n.push(i):n.push(i+" "+o.toString())}return n.join("\n")}var UZ,WZ=bY.extend((function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}}),(function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)}),{precision:"highp",setUniform:function(e,t){void 0===t&&console.warn('Uniform value "'+e+'" is undefined');var n=this.uniforms[e];n&&("string"==typeof t&&(t=FZ(t)||t),n.value=t,this.autoUpdateTextureStatus&&"t"===n.type&&(t?this.enableTexture(e):this.disableTexture(e)))},setUniforms:function(e){for(var t in e){var n=e[t];this.setUniform(t,n)}},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if("object"==typeof e)for(var n in e){var r=e[n];this.setUniform(n,r)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var r=this.uniforms;this._enabledUniforms=Object.keys(r),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter((function(e){var t=this.uniforms[e].type;return"t"===t||"tv"===t}),this);var i=this.vertexDefines,o=this.fragmentDefines;if(this.vertexDefines=xY.clone(e.vertexDefines),this.fragmentDefines=xY.clone(e.fragmentDefines),t){for(var a in n)r[a]&&(r[a].value=n[a].value);xY.defaults(this.vertexDefines,i),xY.defaults(this.fragmentDefines,o)}var s={};for(var l in e.textures)s[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:!(!t||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=xY.clone(this.vertexDefines),e.fragmentDefines=xY.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,n){var r=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(n=t,t=e,e="both"),n=null!=n?n:null,"vertex"!==e&&"both"!==e||r[t]!==n&&(r[t]=n,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==n&&(i[t]=n,"both"!==e&&(this._programKey=""))},undefine:function(e,t){"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<2&&(t=e,e="both"),"vertex"!==e&&"both"!==e||this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),"fragment"!==e&&"both"!==e||this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],"both"!==e&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return void 0!==this.vertexDefines[t];case"fragment":return void 0!==this.fragmentDefines[t]}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.enableTexture(e[t]);else{var n=this._textureStatus[e];if(n)n.enabled||(n.enabled=!0,this._programKey="")}},enableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!0;this._programKey=""},disableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.disableTexture(e[t]);else{var n=this._textureStatus[e];if(n)!n.enabled||(n.enabled=!1,this._programKey="")}},disableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!1;this._programKey=""},isTextureEnabled:function(e){var t=this._textureStatus;return!!t[e]&&t[e].enabled},getEnabledTextures:function(){var e=[],t=this._textureStatus;for(var n in t)t[n].enabled&&e.push(n);return e},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(e,t,n){n.sort();for(var r=[],i=0;i<n.length;i++){var o=n[i];r.push(o)}var a=HZ(e)+"\n"+HZ(t)+"\n"+r.join("\n");if(GZ[a])return GZ[a];var s=xY.genGUID();return GZ[a]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),jZ=1e-6,XZ=Array,YZ=Math.random,ZZ={};ZZ.create=function(){var e=new XZ(2);return e[0]=0,e[1]=0,e},ZZ.clone=function(e){var t=new XZ(2);return t[0]=e[0],t[1]=e[1],t},ZZ.fromValues=function(e,t){var n=new XZ(2);return n[0]=e,n[1]=t,n},ZZ.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},ZZ.set=function(e,t,n){return e[0]=t,e[1]=n,e},ZZ.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},ZZ.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},ZZ.sub=ZZ.subtract,ZZ.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},ZZ.mul=ZZ.multiply,ZZ.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},ZZ.div=ZZ.divide,ZZ.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},ZZ.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},ZZ.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},ZZ.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},ZZ.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},ZZ.dist=ZZ.distance,ZZ.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},ZZ.sqrDist=ZZ.squaredDistance,ZZ.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},ZZ.len=ZZ.length,ZZ.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},ZZ.sqrLen=ZZ.squaredLength,ZZ.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},ZZ.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},ZZ.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},ZZ.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},ZZ.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},ZZ.lerp=function(e,t,n,r){var i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e},ZZ.random=function(e,t){t=t||1;var n=2*GLMAT_RANDOM()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},ZZ.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},ZZ.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},ZZ.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},ZZ.transformMat4=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},ZZ.forEach=(UZ=ZZ.create(),function(e,t,n,r,i,o){var a,s;for(t||(t=2),n||(n=0),s=r?Math.min(r*t+n,e.length):e.length,a=n;a<s;a+=t)UZ[0]=e[a],UZ[1]=e[a+1],i(UZ,UZ,o),e[a]=UZ[0],e[a+1]=UZ[1];return e});var qZ=function(e,t){e=e||0,t=t||0,this.array=ZZ.fromValues(e,t),this._dirty=!0};if(qZ.prototype={constructor:qZ,add:function(e){return ZZ.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t){return this.array[0]=e,this.array[1]=t,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this._dirty=!0,this},clone:function(){return new qZ(this.x,this.y)},copy:function(e){return ZZ.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return ZZ.cross(e.array,this.array,t.array),e._dirty=!0,this},dist:function(e){return ZZ.dist(this.array,e.array)},distance:function(e){return ZZ.distance(this.array,e.array)},div:function(e){return ZZ.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return ZZ.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return ZZ.dot(this.array,e.array)},len:function(){return ZZ.len(this.array)},length:function(){return ZZ.length(this.array)},lerp:function(e,t,n){return ZZ.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return ZZ.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return ZZ.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return ZZ.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return ZZ.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return ZZ.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return ZZ.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return ZZ.random(this.array,e),this._dirty=!0,this},scale:function(e){return ZZ.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return ZZ.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return ZZ.sqrDist(this.array,e.array)},squaredDistance:function(e){return ZZ.squaredDistance(this.array,e.array)},sqrLen:function(){return ZZ.sqrLen(this.array)},squaredLength:function(){return ZZ.squaredLength(this.array)},sub:function(e){return ZZ.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return ZZ.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat2:function(e){return ZZ.transformMat2(this.array,this.array,e.array),this._dirty=!0,this},transformMat2d:function(e){return ZZ.transformMat2d(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return ZZ.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return ZZ.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var KZ=qZ.prototype;Object.defineProperty(KZ,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Object.defineProperty(KZ,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}})}qZ.add=function(e,t,n){return ZZ.add(e.array,t.array,n.array),e._dirty=!0,e},qZ.set=function(e,t,n){return ZZ.set(e.array,t,n),e._dirty=!0,e},qZ.copy=function(e,t){return ZZ.copy(e.array,t.array),e._dirty=!0,e},qZ.cross=function(e,t,n){return ZZ.cross(e.array,t.array,n.array),e._dirty=!0,e},qZ.distance=qZ.dist=function(e,t){return ZZ.distance(e.array,t.array)},qZ.div=function(e,t,n){return ZZ.divide(e.array,t.array,n.array),e._dirty=!0,e},qZ.divide=qZ.div,qZ.dot=function(e,t){return ZZ.dot(e.array,t.array)},qZ.len=function(e){return ZZ.length(e.array)},qZ.lerp=function(e,t,n,r){return ZZ.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},qZ.min=function(e,t,n){return ZZ.min(e.array,t.array,n.array),e._dirty=!0,e},qZ.max=function(e,t,n){return ZZ.max(e.array,t.array,n.array),e._dirty=!0,e},qZ.mul=function(e,t,n){return ZZ.multiply(e.array,t.array,n.array),e._dirty=!0,e},qZ.multiply=qZ.mul,qZ.negate=function(e,t){return ZZ.negate(e.array,t.array),e._dirty=!0,e},qZ.normalize=function(e,t){return ZZ.normalize(e.array,t.array),e._dirty=!0,e},qZ.random=function(e,t){return ZZ.random(e.array,t),e._dirty=!0,e},qZ.scale=function(e,t,n){return ZZ.scale(e.array,t.array,n),e._dirty=!0,e},qZ.scaleAndAdd=function(e,t,n,r){return ZZ.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},qZ.squaredDistance=qZ.sqrDist=function(e,t){return ZZ.sqrDist(e.array,t.array)},qZ.squaredLength=qZ.sqrLen=function(e){return ZZ.sqrLen(e.array)},qZ.sub=function(e,t,n){return ZZ.subtract(e.array,t.array,n.array),e._dirty=!0,e},qZ.subtract=qZ.sub,qZ.transformMat2=function(e,t,n){return ZZ.transformMat2(e.array,t.array,n.array),e._dirty=!0,e},qZ.transformMat2d=function(e,t,n){return ZZ.transformMat2d(e.array,t.array,n.array),e._dirty=!0,e},qZ.transformMat3=function(e,t,n){return ZZ.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},qZ.transformMat4=function(e,t,n){return ZZ.transformMat4(e.array,t.array,n.array),e._dirty=!0,e};var $Z={};function JZ(e){for(var t=e.split("\n"),n=0,r=t.length;n<r;n++)t[n]=n+1+": "+t[n];return t.join("\n")}function QZ(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),JZ(n)].join("\n")}var eq=new wZ.Float32Array(16),tq=bY.extend({uniformSemantics:{},attributes:{}},(function(){this._locations={},this._textureSlot=0,this._program=null}),{bind:function(e){this._textureSlot=0,e.gl.useProgram(this._program)},hasUniform:function(e){var t=this._locations[e];return null!=t},useTextureSlot:function(e,t,n){t&&(e.gl.activeTexture(e.gl.TEXTURE0+n),t.isRenderable()?t.bind(e):t.unbind(e))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(e){this._textureSlot=e||0},takeCurrentTextureSlot:function(e,t){var n=this._textureSlot;return this.useTextureSlot(e,t,n),this._textureSlot++,n},setUniform:function(e,t,n,r){var i=this._locations[n];if(null==i)return!1;switch(t){case"m4":if(!(r instanceof Float32Array)){for(var o=0;o<r.length;o++)eq[o]=r[o];r=eq}e.uniformMatrix4fv(i,!1,r);break;case"2i":e.uniform2i(i,r[0],r[1]);break;case"2f":e.uniform2f(i,r[0],r[1]);break;case"3i":e.uniform3i(i,r[0],r[1],r[2]);break;case"3f":e.uniform3f(i,r[0],r[1],r[2]);break;case"4i":e.uniform4i(i,r[0],r[1],r[2],r[3]);break;case"4f":e.uniform4f(i,r[0],r[1],r[2],r[3]);break;case"1i":e.uniform1i(i,r);break;case"1f":e.uniform1f(i,r);break;case"1fv":e.uniform1fv(i,r);break;case"1iv":e.uniform1iv(i,r);break;case"2iv":e.uniform2iv(i,r);break;case"2fv":e.uniform2fv(i,r);break;case"3iv":e.uniform3iv(i,r);break;case"3fv":e.uniform3fv(i,r);break;case"4iv":e.uniform4iv(i,r);break;case"4fv":e.uniform4fv(i,r);break;case"m2":case"m2v":e.uniformMatrix2fv(i,!1,r);break;case"m3":case"m3v":e.uniformMatrix3fv(i,!1,r);break;case"m4v":if(Array.isArray(r)&&Array.isArray(r[0])){var a=new wZ.Float32Array(16*r.length),s=0;for(o=0;o<r.length;o++)for(var l=r[o],u=0;u<16;u++)a[s++]=l[u];e.uniformMatrix4fv(i,!1,a)}else e.uniformMatrix4fv(i,!1,r)}return!0},setUniformOfSemantic:function(e,t,n){var r=this.uniformSemantics[t];return!!r&&this.setUniform(e,r.type,r.symbol,n)},enableAttributes:function(e,t,n){var r,i=e.gl,o=this._program,a=this._locations;(r=n?n.__enabledAttributeList:$Z[e.__uid__])||(r=n?n.__enabledAttributeList=[]:$Z[e.__uid__]=[]);for(var s=[],l=0;l<t.length;l++){var u=t[l];if(this.attributes[u]){var c=a[u];if(null==c){if(-1===(c=i.getAttribLocation(o,u))){s[l]=-1;continue}a[u]=c}s[l]=c,r[c]?r[c]=2:r[c]=1}else s[l]=-1}for(l=0;l<r.length;l++)switch(r[l]){case 1:i.enableVertexAttribArray(l),r[l]=3;break;case 2:r[l]=3;break;case 3:i.disableVertexAttribArray(l),r[l]=0}return s},getAttribLocation:function(e,t){var n=this._locations,r=n[t];return null==r&&(r=e.getAttribLocation(this._program,t),n[t]=r),r},buildProgram:function(e,t,n,r){var i=e.createShader(e.VERTEX_SHADER),o=e.createProgram();e.shaderSource(i,n),e.compileShader(i);var a=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(a,r),e.compileShader(a);var s=QZ(e,i,n);if(s)return s;if(s=QZ(e,a,r))return s;if(e.attachShader(o,i),e.attachShader(o,a),t.attributeSemantics.POSITION)e.bindAttribLocation(o,0,t.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);e.bindAttribLocation(o,0,l[0])}if(e.linkProgram(o),e.deleteShader(i),e.deleteShader(a),this._program=o,this.vertexCode=n,this.fragmentCode=r,!e.getProgramParameter(o,e.LINK_STATUS))return"Could not link program\n"+e.getProgramInfoLog(o);for(var u=0;u<t.uniforms.length;u++){var c=t.uniforms[u];this._locations[c]=e.getUniformLocation(o,c)}}}),nq=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function rq(e,t,n){var r={};for(var i in n)r[i+"_COUNT"]=n[i];return e.replace(nq,(function(e,n,i,o){var a="";isNaN(n)&&(n=n in t?t[n]:r[n]),isNaN(i)&&(i=i in t?t[i]:r[i]);for(var s=parseInt(n);s<parseInt(i);s++)a+="{"+o.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return a}))}function iq(e,t,n){var r=[];if(t)for(var i in t){var o=t[i];o>0&&r.push("#define "+i.toUpperCase()+"_COUNT "+o)}if(n)for(var a=0;a<n.length;a++){var s=n[a];r.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in e){var l=e[s];null===l?r.push("#define "+s):r.push("#define "+s+" "+l.toString())}return r.join("\n")}function oq(e){this._renderer=e,this._cache={}}oq.prototype.getProgram=function(e,t,n){var r=this._cache,i=e.isSkinnedMesh&&e.isSkinnedMesh(),o=e.isInstancedMesh&&e.isInstancedMesh(),a="s"+t.shader.shaderID+"m"+t.getProgramKey();if(n&&(a+="se"+n.getProgramKey(e.lightGroup)),i&&(a+=",sk"+e.joints.length),o&&(a+=",is"),y=r[a])return y;var s=n?n.getLightsNumbers(e.lightGroup):{},l=this._renderer,u=l.gl,c=t.getEnabledTextures(),h="";if(i){var d={SKINNING:null,JOINT_COUNT:e.joints.length};e.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),h+="\n"+iq(d)+"\n"}o&&(h+="\n#define INSTANCING\n");var p=h+iq(t.vertexDefines,s,c),f=h+iq(t.fragmentDefines,s,c),g=p+"\n"+t.shader.vertex,m=["OES_standard_derivatives","EXT_shader_texture_lod"].filter((function(e){return null!=l.getGLExtension(e)}));m.indexOf("EXT_shader_texture_lod")>=0&&(f+="\n#define SUPPORT_TEXTURE_LOD"),m.indexOf("OES_standard_derivatives")>=0&&(f+="\n#define SUPPORT_STANDARD_DERIVATIVES");var v,y,_=function(e){for(var t=[],n=0;n<e.length;n++)t.push("#extension GL_"+e[n]+" : enable");return t.join("\n")}(m)+"\n"+(["precision",v=t.precision,"float"].join(" ")+";\n"+["precision",v,"int"].join(" ")+";\n"+["precision",v,"sampler2D"].join(" ")+";\n\n")+f+"\n"+t.shader.fragment,x=rq(g,t.vertexDefines,s),b=rq(_,t.fragmentDefines,s);(y=new tq).uniformSemantics=t.shader.uniformSemantics,y.attributes=t.shader.attributes;var w=y.buildProgram(u,t.shader,x,b);return y.__error=w,r[a]=y,y};var aq=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,sq=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,lq=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,uq={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"};function cq(e){for(var t=[],n=0;n<e;n++)t[n]=0;return t}var hq={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return cq(2)},vec3:function(){return cq(3)},vec4:function(){return cq(4)},ivec2:function(){return cq(2)},ivec3:function(){return cq(3)},ivec4:function(){return cq(4)},mat2:function(){return cq(4)},mat3:function(){return cq(9)},mat4:function(){return cq(16)},array:function(){return[]}},dq=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],pq=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],fq=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],gq={vec4:4,vec3:3,vec2:2,float:1},mq={},vq={};function yq(e){return e.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function _q(){console.error("Wrong uniform/attributes syntax")}function xq(e,t){for(var n=/[,=\(\):]/,r=t.replace(/:\s*\[\s*(.*)\s*\]/g,"="+e+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),i=[],o=0;o<r.length;o++)r[o].match(n)?i.push(r[o].charAt(0),r[o].slice(1)):i.push(r[o]);var a,s=0,l={},u=null;function c(e){e||_q();var t=e.match(/\[(.*?)\]/);a=e.replace(/\[(.*?)\]/,""),l[a]={},t&&(l[a].isArray=!0,l[a].arraySize=t[1])}c((r=i)[0]);for(o=1;o<r.length;o++){var h=r[o];if(h)if("="!==h)if(":"!==h)if(","!==h)if(")"!==h)if("("!==h)if(h.indexOf("vec")>=0){if(1!==s&&4!==s){_q();break}s=2,u=[]}else if(1!==s)if(4!==s)c(h),s=0;else{var d=h;dq.indexOf(d)>=0||pq.indexOf(d)>=0||fq.indexOf(d)>=0?l[a].semantic=d:"ignore"===d||"unconfigurable"===d?l[a].ignore=!0:l[a].value="bool"===e?"true"===d:parseFloat(d)}else l[a].value="bool"===e?"true"===h:parseFloat(h),u=null;else{if(2!==s){_q();break}if(!(u instanceof Array)){_q();break}u.push(+r[++o])}else l[a].value=new wZ.Float32Array(u),u=null,s=5;else if(2===s){if(!(u instanceof Array)){_q();break}u.push(+r[++o])}else s=5;else s=4;else{if(0!==s&&3!==s){_q();break}s=1}}return l}function bq(e,t){"object"==typeof e&&(t=e.fragment,e=e.vertex),e=yq(e),t=yq(t),this._shaderID=function(e,t){var n="vertex:"+e+"fragment:"+t;if(mq[n])return mq[n];var r=xY.genGUID();return mq[n]=r,vq[r]={vertex:e,fragment:t},r}(e,t),this._vertexCode=bq.parseImport(e),this._fragmentCode=bq.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}bq.prototype={constructor:bq,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},_parseImport:function(){this._vertexCode=bq.parseImport(this.vertex),this._fragmentCode=bq.parseImport(this.fragment)},_addSemanticUniform:function(e,t,n){if(dq.indexOf(n)>=0)this.attributeSemantics[n]={symbol:e,type:t};else if(fq.indexOf(n)>=0){var r=!1,i=n;n.match(/TRANSPOSE$/)&&(r=!0,i=n.slice(0,-9)),this.matrixSemantics[n]={symbol:e,type:t,isTranspose:r,semanticNoTranspose:i}}else pq.indexOf(n)>=0&&(this.uniformSemantics[n]={symbol:e,type:t})},_addMaterialUniform:function(e,t,n,r,i,o){o[e]={type:n,value:i?hq.array:r||hq[t],semantic:null}},_parseUniforms:function(){var e={},t=this,n="vertex";function r(e){return null!=e?function(){return e}:null}function i(i,o,a){var s=xq(o,a),l=[];for(var u in s){var c=s[u],h=c.semantic,d=u,p=uq[o],f=r(s[u].value);s[u].isArray&&(d+="["+s[u].arraySize+"]",p+="v"),l.push(d),t._uniformList.push(u),c.ignore||("sampler2D"!==o&&"samplerCube"!==o||(t.textures[u]={shaderType:n,type:o}),h?t._addSemanticUniform(u,p,h):t._addMaterialUniform(u,o,p,f,s[u].isArray,e))}return l.length>0?"uniform "+o+" "+l.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(aq,i),n="fragment",this._fragmentCode=this._fragmentCode.replace(aq,i),t.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(sq,(function(n,r,i){var o=xq(r,i),a=gq[r]||1,s=[];for(var l in o){var u=o[l].semantic;if(e[l]={type:"float",size:a,semantic:u||null},u){if(dq.indexOf(u)<0)throw new Error('Unkown semantic "'+u+'"');t.attributeSemantics[u]={symbol:l,type:r}}s.push(l)}return"attribute "+r+" "+s.join(",")+";\n"})),this.attributes=e},_parseDefines:function(){var e=this,t="vertex";function n(n,r,i){var o="vertex"===t?e.vertexDefines:e.fragmentDefines;return o[r]||(o[r]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(lq,n),t="fragment",this._fragmentCode=this._fragmentCode.replace(lq,n)},clone:function(){var e=vq[this._shaderID];return new bq(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(bq.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(bq.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(bq.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(bq.prototype,"uniforms",{get:function(){return this._uniformList}}));var wq=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;bq.parseImport=function(e){return e=e.replace(wq,(function(e,t,n){return(e=bq.source(n))?bq.parseImport(e):(console.error('Shader chunk "'+n+'" not existed in library'),"")}))};var Sq=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;bq.import=function(e){e.replace(Sq,(function(e,t,n,r){if(r=r.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var i,o=n.split("."),a=bq.codes,s=0;s<o.length-1;)a[i=o[s++]]||(a[i]={}),a=a[i];a[i=o[s]]=r}return r}))},bq.codes={},bq.source=function(e){for(var t=e.split("."),n=bq.codes,r=0;n&&r<t.length;){n=n[t[r++]]}return"string"!=typeof n?(console.error('Shader "'+e+'" not existed in library'),""):n};var Tq="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end",Mq={create:function(){var e=new XZ(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},clone:function(e){var t=new XZ(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(i*A-r*I-o*D)*E,e[2]=(g*S-m*w+v*b)*E,e[3]=(d*w-h*S-p*b)*E,e[4]=(l*C-a*I-u*M)*E,e[5]=(n*I-i*C+o*M)*E,e[6]=(m*x-f*S-v*_)*E,e[7]=(c*S-d*x+p*_)*E,e[8]=(a*A-s*C+u*T)*E,e[9]=(r*C-n*A-o*T)*E,e[10]=(f*w-g*x+v*y)*E,e[11]=(h*x-c*w-p*y)*E,e[12]=(s*M-a*D-l*T)*E,e[13]=(n*D-r*M+i*T)*E,e[14]=(g*_-f*b-m*y)*E,e[15]=(c*b-h*_+d*y)*E,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15];return e[0]=s*(d*v-p*m)-h*(l*v-u*m)+g*(l*p-u*d),e[1]=-(r*(d*v-p*m)-h*(i*v-o*m)+g*(i*p-o*d)),e[2]=r*(l*v-u*m)-s*(i*v-o*m)+g*(i*u-o*l),e[3]=-(r*(l*p-u*d)-s*(i*p-o*d)+h*(i*u-o*l)),e[4]=-(a*(d*v-p*m)-c*(l*v-u*m)+f*(l*p-u*d)),e[5]=n*(d*v-p*m)-c*(i*v-o*m)+f*(i*p-o*d),e[6]=-(n*(l*v-u*m)-a*(i*v-o*m)+f*(i*u-o*l)),e[7]=n*(l*p-u*d)-a*(i*p-o*d)+c*(i*u-o*l),e[8]=a*(h*v-p*g)-c*(s*v-u*g)+f*(s*p-u*h),e[9]=-(n*(h*v-p*g)-c*(r*v-o*g)+f*(r*p-o*h)),e[10]=n*(s*v-u*g)-a*(r*v-o*g)+f*(r*u-o*s),e[11]=-(n*(s*p-u*h)-a*(r*p-o*h)+c*(r*u-o*s)),e[12]=-(a*(h*m-d*g)-c*(s*m-l*g)+f*(s*d-l*h)),e[13]=n*(h*m-d*g)-c*(r*m-i*g)+f*(r*d-i*h),e[14]=-(n*(s*m-l*g)-a*(r*m-i*g)+f*(r*l-i*s)),e[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],g=e[14],m=e[15];return(t*a-n*o)*(h*m-d*g)-(t*s-r*o)*(c*m-d*f)+(t*l-i*o)*(c*g-h*f)+(n*s-r*a)*(u*m-d*p)-(n*l-i*a)*(u*g-h*p)+(r*l-i*s)*(u*f-c*p)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],g=t[12],m=t[13],v=t[14],y=t[15],_=n[0],x=n[1],b=n[2],w=n[3];return e[0]=_*r+x*s+b*h+w*g,e[1]=_*i+x*l+b*d+w*m,e[2]=_*o+x*u+b*p+w*v,e[3]=_*a+x*c+b*f+w*y,_=n[4],x=n[5],b=n[6],w=n[7],e[4]=_*r+x*s+b*h+w*g,e[5]=_*i+x*l+b*d+w*m,e[6]=_*o+x*u+b*p+w*v,e[7]=_*a+x*c+b*f+w*y,_=n[8],x=n[9],b=n[10],w=n[11],e[8]=_*r+x*s+b*h+w*g,e[9]=_*i+x*l+b*d+w*m,e[10]=_*o+x*u+b*p+w*v,e[11]=_*a+x*c+b*f+w*y,_=n[12],x=n[13],b=n[14],w=n[15],e[12]=_*r+x*s+b*h+w*g,e[13]=_*i+x*l+b*d+w*m,e[14]=_*o+x*u+b*p+w*v,e[15]=_*a+x*c+b*f+w*y,e},multiplyAffine:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[4],s=t[5],l=t[6],u=t[8],c=t[9],h=t[10],d=t[12],p=t[13],f=t[14],g=n[0],m=n[1],v=n[2];return e[0]=g*r+m*a+v*u,e[1]=g*i+m*s+v*c,e[2]=g*o+m*l+v*h,g=n[4],m=n[5],v=n[6],e[4]=g*r+m*a+v*u,e[5]=g*i+m*s+v*c,e[6]=g*o+m*l+v*h,g=n[8],m=n[9],v=n[10],e[8]=g*r+m*a+v*u,e[9]=g*i+m*s+v*c,e[10]=g*o+m*l+v*h,g=n[12],m=n[13],v=n[14],e[12]=g*r+m*a+v*u+d,e[13]=g*i+m*s+v*c+p,e[14]=g*o+m*l+v*h+f,e}};Mq.mul=Mq.multiply,Mq.mulAffine=Mq.multiplyAffine,Mq.translate=function(e,t,n){var r,i,o,a,s,l,u,c,h,d,p,f,g=n[0],m=n[1],v=n[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*v+t[12],e[13]=t[1]*g+t[5]*m+t[9]*v+t[13],e[14]=t[2]*g+t[6]*m+t[10]*v+t[14],e[15]=t[3]*g+t[7]*m+t[11]*v+t[15]):(r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*g+s*m+h*v+t[12],e[13]=i*g+l*m+d*v+t[13],e[14]=o*g+u*m+p*v+t[14],e[15]=a*g+c*m+f*v+t[15]),e},Mq.scale=function(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Mq.rotate=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x,b,w,S,T,M,C,D,A=r[0],I=r[1],E=r[2],L=Math.sqrt(A*A+I*I+E*E);return Math.abs(L)<jZ?null:(A*=L=1/L,I*=L,E*=L,i=Math.sin(n),a=1-(o=Math.cos(n)),s=t[0],l=t[1],u=t[2],c=t[3],h=t[4],d=t[5],p=t[6],f=t[7],g=t[8],m=t[9],v=t[10],y=t[11],_=A*A*a+o,x=I*A*a+E*i,b=E*A*a-I*i,w=A*I*a-E*i,S=I*I*a+o,T=E*I*a+A*i,M=A*E*a+I*i,C=I*E*a-A*i,D=E*E*a+o,e[0]=s*_+h*x+g*b,e[1]=l*_+d*x+m*b,e[2]=u*_+p*x+v*b,e[3]=c*_+f*x+y*b,e[4]=s*w+h*S+g*T,e[5]=l*w+d*S+m*T,e[6]=u*w+p*S+v*T,e[7]=c*w+f*S+y*T,e[8]=s*M+h*C+g*D,e[9]=l*M+d*C+m*D,e[10]=u*M+p*C+v*D,e[11]=c*M+f*C+y*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},Mq.rotateX=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+u*r,e[5]=a*i+c*r,e[6]=s*i+h*r,e[7]=l*i+d*r,e[8]=u*i-o*r,e[9]=c*i-a*r,e[10]=h*i-s*r,e[11]=d*i-l*r,e},Mq.rotateY=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-u*r,e[1]=a*i-c*r,e[2]=s*i-h*r,e[3]=l*i-d*r,e[8]=o*r+u*i,e[9]=a*r+c*i,e[10]=s*r+h*i,e[11]=l*r+d*i,e},Mq.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},Mq.fromRotationTranslation=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,p=i*l,f=i*u,g=o*u,m=a*s,v=a*l,y=a*u;return e[0]=1-(p+g),e[1]=h+y,e[2]=d-v,e[3]=0,e[4]=h-y,e[5]=1-(c+g),e[6]=f+m,e[7]=0,e[8]=d+v,e[9]=f-m,e[10]=1-(c+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},Mq.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[1]=c+v,e[2]=d-m,e[3]=0,e[4]=c-v,e[5]=1-u-f,e[6]=p+g,e[7]=0,e[8]=d+m,e[9]=p-g,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Mq.frustum=function(e,t,n,r,i,o,a){var s=1/(n-t),l=1/(i-r),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},Mq.perspective=function(e,t,n,r,i){var o=1/Math.tan(t/2),a=1/(r-i);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*a,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*a,e[15]=0,e},Mq.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},Mq.lookAt=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f=t[0],g=t[1],m=t[2],v=r[0],y=r[1],_=r[2],x=n[0],b=n[1],w=n[2];return Math.abs(f-x)<jZ&&Math.abs(g-b)<jZ&&Math.abs(m-w)<jZ?Mq.identity(e):(c=f-x,h=g-b,d=m-w,i=y*(d*=p=1/Math.sqrt(c*c+h*h+d*d))-_*(h*=p),o=_*(c*=p)-v*d,a=v*h-y*c,(p=Math.sqrt(i*i+o*o+a*a))?(i*=p=1/p,o*=p,a*=p):(i=0,o=0,a=0),s=h*a-d*o,l=d*i-c*a,u=c*o-h*i,(p=Math.sqrt(s*s+l*l+u*u))?(s*=p=1/p,l*=p,u*=p):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*f+o*g+a*m),e[13]=-(s*f+l*g+u*m),e[14]=-(c*f+h*g+d*m),e[15]=1,e)},Mq.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))};var Cq={create:function(){var e=new XZ(3);return e[0]=0,e[1]=0,e[2]=0,e},clone:function(e){var t=new XZ(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},fromValues:function(e,t,n){var r=new XZ(3);return r[0]=e,r[1]=t,r[2]=n,r},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set:function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}};Cq.sub=Cq.subtract,Cq.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e},Cq.mul=Cq.multiply,Cq.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},Cq.div=Cq.divide,Cq.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e},Cq.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e},Cq.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},Cq.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},Cq.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},Cq.dist=Cq.distance,Cq.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},Cq.sqrDist=Cq.squaredDistance,Cq.length=function(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)},Cq.len=Cq.length,Cq.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},Cq.sqrLen=Cq.squaredLength,Cq.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Cq.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Cq.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o),e},Cq.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},Cq.cross=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e},Cq.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e},Cq.random=function(e,t){t=t||1;var n=2*YZ()*Math.PI,r=2*YZ()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e},Cq.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e},Cq.transformMat3=function(e,t,n){var r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e},Cq.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},Cq.rotateX=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Cq.rotateY=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Cq.rotateZ=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Cq.forEach=function(){var e=Cq.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=3),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}(),Cq.angle=function(e,t){var n=Cq.fromValues(e[0],e[1],e[2]),r=Cq.fromValues(t[0],t[1],t[2]);Cq.normalize(n,n),Cq.normalize(r,r);var i=Cq.dot(n,r);return i>1?0:Math.acos(i)},bq.import(Tq);var Dq=Mq.create,Aq={};function Iq(e){return e.material}function Eq(e,t,n){return t.uniforms[n].value}function Lq(e,t,n,r){return n!==r}function Nq(e){return!0}function Pq(){}var Oq={float:qY,byte:UY,ubyte:WY,short:jY,ushort:XY};function Rq(e,t,n){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=n,this.vao=null}function kq(e){var t,n;this.bind=function(e){t||((t=wZ.createCanvas()).width=t.height=1,t.getContext("2d"));var r=e.gl,i=!n;i&&(n=r.createTexture()),r.bindTexture(r.TEXTURE_2D,n),i&&r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},this.unbind=function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var zq=bY.extend((function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}}),(function(){this.canvas||(this.canvas=wZ.createCanvas());var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new TY(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}this._programMgr=new oq(this),this._placeholderTexture=new kq}),{resize:function(e,t){var n=this.canvas,r=this.devicePixelRatio;null!=e?(n.style&&(n.style.width=e+"px",n.style.height=t+"px"),n.width=e*r,n.height=t*r,this._width=e,this._height=t):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,n,r,i){if("object"==typeof e){var o=e;e=o.x,t=o.y,n=o.width,r=o.height,i=o.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,r*i),this.viewport={x:e,y:t,width:n,height:r,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,n,r){var i=this.gl,o=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var a=this.viewport,s=!1,l=a.devicePixelRatio;(a.width!==this._width||a.height!==this._height||l&&l!==this.devicePixelRatio||a.x||a.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(a.x*l,a.y*l,a.width*l,a.height*l)),i.clearColor(o[0],o[1],o[2],o[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(n||e.update(!1),e.updateLights(),t=t||e.getMainCamera()){t.update();var u=e.updateRenderList(t,!0);this._sceneRendering=e;var c=u.opaque,h=u.transparent,d=e.material;e.trigger("beforerender",this,e,t,u),r?(this.renderPreZ(c,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var p=Dq(),f=Cq.create(),g=0;g<h.length;g++){var m=h[g];Mq.multiplyAffine(p,t.viewMatrix.array,m.worldTransform.array),Cq.transformMat4(f,m.position.array,p),m.__depth=f[2]}this.renderPass(c,t,{getMaterial:function(e){return d||e.material},sortCompare:this.opaqueSortCompare}),this.renderPass(h,t,{getMaterial:function(e){return d||e.material},sortCompare:this.transparentSortCompare}),e.trigger("afterrender",this,e,t,u),this._sceneRendering=null}else console.error("Can't find camera in the scene.")},getProgram:function(e,t,n){return t=t||e.material,this._programMgr.getProgram(e,t,n)},validateProgram:function(e){if(e.__error){var t=e.__error;if(Aq[e.__uid__])return;if(Aq[e.__uid__]=!0,this.throwError)throw new Error(t);this.trigger("error",t)}},updatePrograms:function(e,t,n){var r=n&&n.getMaterial||Iq;t=t||null;for(var i=0;i<e.length;i++){var o=e[i],a=r.call(this,o);if(i>0){var s=e[i-1],l=s.joints?s.joints.length:0;if((o.joints?o.joints.length:0)===l&&o.material===s.material&&o.lightGroup===s.lightGroup){o.__program=s.__program;continue}}var u=this._programMgr.getProgram(o,a,t);this.validateProgram(u),o.__program=u}},renderPass:function(e,t,n){this.trigger("beforerenderpass",this,e,t,n),(n=n||{}).getMaterial=n.getMaterial||Iq,n.getUniform=n.getUniform||Eq,n.isMaterialChanged=n.isMaterialChanged||Lq,n.beforeRender=n.beforeRender||Pq,n.afterRender=n.afterRender||Pq;var r=n.ifRender||Nq;this.updatePrograms(e,this._sceneRendering,n),n.sortCompare&&e.sort(n.sortCompare);var i=this.viewport,o=i.devicePixelRatio,a=[i.x*o,i.y*o,i.width*o,i.height*o],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],u=[a[2],a[3]],c=Date.now();t?(Mq.copy(Vq.VIEW,t.viewMatrix.array),Mq.copy(Vq.PROJECTION,t.projectionMatrix.array),Mq.copy(Vq.VIEWINVERSE,t.worldTransform.array)):(Mq.identity(Vq.VIEW),Mq.identity(Vq.PROJECTION),Mq.identity(Vq.VIEWINVERSE)),Mq.multiply(Vq.VIEWPROJECTION,Vq.PROJECTION,Vq.VIEW),Mq.invert(Vq.PROJECTIONINVERSE,Vq.PROJECTION),Mq.invert(Vq.VIEWPROJECTIONINVERSE,Vq.VIEWPROJECTION);for(var h,d,p,f,g,m,v,y,_,x,b,w,S=this.gl,T=this._sceneRendering,M=0;M<e.length;M++){var C,D=e[M],A=null!=D.worldTransform;if(r(D)){A&&(C=D.isSkinnedMesh&&D.isSkinnedMesh()?D.offsetMatrix?D.offsetMatrix.array:Vq.IDENTITY:D.worldTransform.array);var I=D.geometry,E=n.getMaterial.call(this,D),L=D.__program,N=E.shader,P=I.__uid__+"-"+L.__uid__,O=P!==x;x=P,A&&(Mq.copy(Vq.WORLD,C),Mq.multiply(Vq.WORLDVIEWPROJECTION,Vq.VIEWPROJECTION,C),Mq.multiplyAffine(Vq.WORLDVIEW,Vq.VIEW,C),(N.matrixSemantics.WORLDINVERSE||N.matrixSemantics.WORLDINVERSETRANSPOSE)&&Mq.invert(Vq.WORLDINVERSE,C),(N.matrixSemantics.WORLDVIEWINVERSE||N.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Mq.invert(Vq.WORLDVIEWINVERSE,Vq.WORLDVIEW),(N.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||N.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Mq.invert(Vq.WORLDVIEWPROJECTIONINVERSE,Vq.WORLDVIEWPROJECTION)),D.beforeRender&&D.beforeRender(this),n.beforeRender.call(this,D,E,h);var R=L!==d;R?(L.bind(this),L.setUniformOfSemantic(S,"VIEWPORT",a),L.setUniformOfSemantic(S,"WINDOW_SIZE",l),t&&(L.setUniformOfSemantic(S,"NEAR",t.near),L.setUniformOfSemantic(S,"FAR",t.far)),L.setUniformOfSemantic(S,"DEVICEPIXELRATIO",o),L.setUniformOfSemantic(S,"TIME",c),L.setUniformOfSemantic(S,"VIEWPORT_SIZE",u),T&&T.setLightUniforms(L,D.lightGroup,this)):L=d,(R||n.isMaterialChanged(D,p,E,h))&&(E.depthTest!==f&&(E.depthTest?S.enable(S.DEPTH_TEST):S.disable(S.DEPTH_TEST),f=E.depthTest),E.depthMask!==g&&(S.depthMask(E.depthMask),g=E.depthMask),E.transparent!==_&&(E.transparent?S.enable(S.BLEND):S.disable(S.BLEND),_=E.transparent),E.transparent&&(E.blend?E.blend(S):(S.blendEquationSeparate(S.FUNC_ADD,S.FUNC_ADD),S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA))),w=this._bindMaterial(D,E,L,p||null,h||null,d||null,n.getUniform),h=E);var k=N.matrixSemanticKeys;if(A)for(var z=0;z<k.length;z++){var V=k[z],B=N.matrixSemantics[V],F=Vq[V];if(B.isTranspose){var G=Vq[B.semanticNoTranspose];Mq.transpose(F,G)}L.setUniform(S,B.type,B.symbol,F)}D.cullFace!==v&&(v=D.cullFace,S.cullFace(v)),D.frontFace!==y&&(y=D.frontFace,S.frontFace(y)),D.culling!==m&&((m=D.culling)?S.enable(S.CULL_FACE):S.disable(S.CULL_FACE)),this._updateSkeleton(D,L,w),O&&(b=this._bindVAO(null,N,I,L)),this._renderObject(D,b,L),n.afterRender(this,D),D.afterRender&&D.afterRender(this),d=L,p=D}}this.trigger("afterrenderpass",this,e,t,n)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(e,t,n){var r=this.gl,i=e.skeleton;if(i)if(i.update(),e.joints.length>this.getMaxJointNumber()){var o=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,o,n),t.setUniform(r,"1i","skinMatricesTexture",n),t.setUniform(r,"1f","skinMatricesTextureSize",o.width)}else{var a=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(r,"SKIN_MATRIX",a)}},_renderObject:function(e,t,n){var r=this.gl,i=e.geometry,o=e.mode;null==o&&(o=4);var a=null,s=e.isInstancedMesh&&e.isInstancedMesh();if(!s||(a=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(e,n,a)),t.indicesBuffer){var u=this.getGLExtension("OES_element_index_uint")&&i.indices instanceof Uint32Array?r.UNSIGNED_INT:r.UNSIGNED_SHORT;s?a.drawElementsInstancedANGLE(o,t.indicesBuffer.count,u,0,e.getInstanceCount()):r.drawElements(o,t.indicesBuffer.count,u,0)}else s?a.drawArraysInstancedANGLE(o,0,i.vertexCount,e.getInstanceCount()):r.drawArrays(o,0,i.vertexCount);if(s)for(var c=0;c<l.length;c++)r.disableVertexAttribArray(l[c])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(e,t,n){for(var r=this.gl,i=e.getInstancedAttributesBuffers(this),o=[],a=0;a<i.length;a++){var s=i[a],l=t.getAttribLocation(r,s.symbol);if(!(l<0)){var u=Oq[s.type]||r.FLOAT;r.enableVertexAttribArray(l),r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.vertexAttribPointer(l,s.size,u,!1,0,0),n.vertexAttribDivisorANGLE(l,s.divisor),o.push(l)}}return o},_bindMaterial:function(e,t,n,r,i,o,a){for(var s=this.gl,l=o===n,u=n.currentTextureSlot(),c=t.getEnabledUniforms(),h=t.getTextureUniforms(),d=this._placeholderTexture,p=0;p<h.length;p++){var f=a(e,t,v=h[p]);if("t"===(m=t.uniforms[v].type)&&f)f.__slot=-1;else if("tv"===m)for(var g=0;g<f.length;g++)f[g]&&(f[g].__slot=-1)}d.__slot=-1;for(p=0;p<c.length;p++){var m,v=c[p],y=t.uniforms[v],_=(f=a(e,t,v),"t"===(m=y.type));if(_&&(f&&f.isRenderable()||(f=d)),i&&l){var x=a(r,i,v);if(_&&(x&&x.isRenderable()||(x=d)),x===f){if(_)n.takeCurrentTextureSlot(this,null);else if("tv"===m&&f)for(g=0;g<f.length;g++)n.takeCurrentTextureSlot(this,null);continue}}if(null!=f)if(_)if(f.__slot<0){var b=n.currentTextureSlot();n.setUniform(s,"1i",v,b)&&(n.takeCurrentTextureSlot(this,f),f.__slot=b)}else n.setUniform(s,"1i",v,f.__slot);else if(Array.isArray(f)){if(0===f.length)continue;if("tv"===m){if(!n.hasUniform(v))continue;var w=[];for(g=0;g<f.length;g++){var S=f[g];if(S.__slot<0){b=n.currentTextureSlot();w.push(b),n.takeCurrentTextureSlot(this,S),S.__slot=b}else w.push(S.__slot)}n.setUniform(s,"1iv",v,w)}else n.setUniform(s,y.type,v,f)}else n.setUniform(s,y.type,v,f)}var T=n.currentTextureSlot();return n.resetTextureSlot(u),T},_bindVAO:function(e,t,n,r){var i=!n.dynamic,o=this.gl,a=this.__uid__+"-"+r.__uid__,s=n.__vaoCache[a];if(!s){var l=n.getBufferChunks(this);if(!l||!l.length)return;for(var u=l[0],c=u.attributeBuffers,h=u.indicesBuffer,d=[],p=[],f=0;f<c.length;f++){var g,m=(w=c[f]).name,v=w.semantic;if(v){var y=t.attributeSemantics[v];g=y&&y.symbol}else g=m;g&&r.attributes[g]&&(d.push(w),p.push(g))}s=new Rq(d,p,h),i&&(n.__vaoCache[a]=s)}var _=!0;e&&i&&(null==s.vao?s.vao=e.createVertexArrayOES():_=!1,e.bindVertexArrayOES(s.vao));d=s.availableAttributes,h=s.indicesBuffer;if(_){var x=r.enableAttributes(this,s.availableAttributeSymbols,e&&i&&s);for(f=0;f<d.length;f++){var b=x[f];if(-1!==b){var w,S=(w=d[f]).buffer,T=w.size,M=Oq[w.type]||o.FLOAT;o.bindBuffer(o.ARRAY_BUFFER,S),o.vertexAttribPointer(b,T,M,!1,0,0)}}n.isUseIndices()&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.buffer)}return s},renderPreZ:function(e,t,n){var r=this.gl,i=this._prezMaterial||new WZ({shader:new bq(bq.source("clay.prez.vertex"),bq.source("clay.prez.fragment"))});this._prezMaterial=i,r.colorMask(!1,!1,!1,!1),r.depthMask(!0),this.renderPass(e,n,{ifRender:function(e){return!e.ignorePreZ},isMaterialChanged:function(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)},getUniform:function(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)},getMaterial:function(){return i},sort:this.opaqueSortCompare}),r.colorMask(!0,!0,!0,!0),r.depthMask(!0)},disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){e.getParent()&&e.getParent().remove(e);var r={};e.traverse((function(e){var i=e.material;if(e.geometry&&t&&e.geometry.dispose(this),n&&i&&!r[i.__uid__]){for(var o=i.getTextureUniforms(),a=0;a<o.length;a++){var s=o[a],l=i.uniforms[s].value,u=i.uniforms[s].type;if(l)if("t"===u)l.dispose&&l.dispose(this);else if("tv"===u)for(var c=0;c<l.length;c++)l[c]&&l[c].dispose&&l[c].dispose(this)}r[i.__uid__]=!0}e.dispose&&e.dispose(this)}),this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new qZ),t=this._height-t;var r=this.viewport,i=n.array;return i[0]=(e-r.x)/r.width,i[0]=2*i[0]-1,i[1]=(t-r.y)/r.height,i[1]=2*i[1]-1,n}});zq.opaqueSortCompare=zq.prototype.opaqueSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.renderOrder-t.renderOrder},zq.transparentSortCompare=zq.prototype.transparentSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var Vq={IDENTITY:Dq(),WORLD:Dq(),VIEW:Dq(),PROJECTION:Dq(),WORLDVIEW:Dq(),VIEWPROJECTION:Dq(),WORLDVIEWPROJECTION:Dq(),WORLDINVERSE:Dq(),VIEWINVERSE:Dq(),PROJECTIONINVERSE:Dq(),WORLDVIEWINVERSE:Dq(),VIEWPROJECTIONINVERSE:Dq(),WORLDVIEWPROJECTIONINVERSE:Dq(),WORLDTRANSPOSE:Dq(),VIEWTRANSPOSE:Dq(),PROJECTIONTRANSPOSE:Dq(),WORLDVIEWTRANSPOSE:Dq(),VIEWPROJECTIONTRANSPOSE:Dq(),WORLDVIEWPROJECTIONTRANSPOSE:Dq(),WORLDINVERSETRANSPOSE:Dq(),VIEWINVERSETRANSPOSE:Dq(),PROJECTIONINVERSETRANSPOSE:Dq(),WORLDVIEWINVERSETRANSPOSE:Dq(),VIEWPROJECTIONINVERSETRANSPOSE:Dq(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Dq()};zq.COLOR_BUFFER_BIT=DY,zq.DEPTH_BUFFER_BIT=MY,zq.STENCIL_BUFFER_BIT=CY;var Bq=function(e,t,n){e=e||0,t=t||0,n=n||0,this.array=Cq.fromValues(e,t,n),this._dirty=!0};Bq.prototype={constructor:Bq,add:function(e){return Cq.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new Bq(this.x,this.y,this.z)},copy:function(e){return Cq.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return Cq.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return Cq.dist(this.array,e.array)},distance:function(e){return Cq.distance(this.array,e.array)},div:function(e){return Cq.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return Cq.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return Cq.dot(this.array,e.array)},len:function(){return Cq.len(this.array)},length:function(){return Cq.length(this.array)},lerp:function(e,t,n){return Cq.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return Cq.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return Cq.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return Cq.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return Cq.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return Cq.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Cq.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return Cq.random(this.array,e),this._dirty=!0,this},scale:function(e){return Cq.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return Cq.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return Cq.sqrDist(this.array,e.array)},squaredDistance:function(e){return Cq.squaredDistance(this.array,e.array)},sqrLen:function(){return Cq.sqrLen(this.array)},squaredLength:function(){return Cq.squaredLength(this.array)},sub:function(e){return Cq.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return Cq.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return Cq.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return Cq.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return Cq.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(0===(e=e.array)[15]){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){Bq.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){Bq.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Fq=Object.defineProperty;if(Fq){var Gq=Bq.prototype;Fq(Gq,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Fq(Gq,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Fq(Gq,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}function Hq(e,t,n){return e<t?t:e>n?n:e}Bq.add=function(e,t,n){return Cq.add(e.array,t.array,n.array),e._dirty=!0,e},Bq.set=function(e,t,n,r){Cq.set(e.array,t,n,r),e._dirty=!0},Bq.copy=function(e,t){return Cq.copy(e.array,t.array),e._dirty=!0,e},Bq.cross=function(e,t,n){return Cq.cross(e.array,t.array,n.array),e._dirty=!0,e},Bq.distance=Bq.dist=function(e,t){return Cq.distance(e.array,t.array)},Bq.div=function(e,t,n){return Cq.divide(e.array,t.array,n.array),e._dirty=!0,e},Bq.divide=Bq.div,Bq.dot=function(e,t){return Cq.dot(e.array,t.array)},Bq.len=function(e){return Cq.length(e.array)},Bq.lerp=function(e,t,n,r){return Cq.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},Bq.min=function(e,t,n){return Cq.min(e.array,t.array,n.array),e._dirty=!0,e},Bq.max=function(e,t,n){return Cq.max(e.array,t.array,n.array),e._dirty=!0,e},Bq.mul=function(e,t,n){return Cq.multiply(e.array,t.array,n.array),e._dirty=!0,e},Bq.multiply=Bq.mul,Bq.negate=function(e,t){return Cq.negate(e.array,t.array),e._dirty=!0,e},Bq.normalize=function(e,t){return Cq.normalize(e.array,t.array),e._dirty=!0,e},Bq.random=function(e,t){return Cq.random(e.array,t),e._dirty=!0,e},Bq.scale=function(e,t,n){return Cq.scale(e.array,t.array,n),e._dirty=!0,e},Bq.scaleAndAdd=function(e,t,n,r){return Cq.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},Bq.squaredDistance=Bq.sqrDist=function(e,t){return Cq.sqrDist(e.array,t.array)},Bq.squaredLength=Bq.sqrLen=function(e){return Cq.sqrLen(e.array)},Bq.sub=function(e,t,n){return Cq.subtract(e.array,t.array,n.array),e._dirty=!0,e},Bq.subtract=Bq.sub,Bq.transformMat3=function(e,t,n){return Cq.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},Bq.transformMat4=function(e,t,n){return Cq.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},Bq.transformQuat=function(e,t,n){return Cq.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var Uq=Math.atan2,Wq=Math.asin,jq=Math.abs;Bq.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=t[0],o=t[1],a=t[2],s=t[3],l=i*i,u=o*o,c=a*a,h=s*s;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=Uq(2*(i*s-o*a),h-l-u+c),r[1]=Wq(Hq(2*(i*a+o*s),-1,1)),r[2]=Uq(2*(a*s-i*o),h+l-u-c);break;case"YXZ":r[0]=Wq(Hq(2*(i*s-o*a),-1,1)),r[1]=Uq(2*(i*a+o*s),h-l-u+c),r[2]=Uq(2*(i*o+a*s),h-l+u-c);break;case"ZXY":r[0]=Wq(Hq(2*(i*s+o*a),-1,1)),r[1]=Uq(2*(o*s-a*i),h-l-u+c),r[2]=Uq(2*(a*s-i*o),h-l+u-c);break;case"ZYX":r[0]=Uq(2*(i*s+a*o),h-l-u+c),r[1]=Wq(Hq(2*(o*s-i*a),-1,1)),r[2]=Uq(2*(i*o+a*s),h+l-u-c);break;case"YZX":r[0]=Uq(2*(i*s-a*o),h-l+u-c),r[1]=Uq(2*(o*s-i*a),h+l-u-c),r[2]=Wq(Hq(2*(i*o+a*s),-1,1));break;case"XZY":r[0]=Uq(2*(i*s+o*a),h-l+u-c),r[1]=Uq(2*(i*a+o*s),h+l-u-c),r[2]=Wq(Hq(2*(a*s-i*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},Bq.eulerFromMat3=function(e,t,n){var r=t.array,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],u=r[7],c=r[2],h=r[5],d=r[8],p=e.array;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":p[1]=Wq(Hq(a,-1,1)),jq(a)<.99999?(p[0]=Uq(-u,d),p[2]=Uq(-o,i)):(p[0]=Uq(h,l),p[2]=0);break;case"YXZ":p[0]=Wq(-Hq(u,-1,1)),jq(u)<.99999?(p[1]=Uq(a,d),p[2]=Uq(s,l)):(p[1]=Uq(-c,i),p[2]=0);break;case"ZXY":p[0]=Wq(Hq(h,-1,1)),jq(h)<.99999?(p[1]=Uq(-c,d),p[2]=Uq(-o,l)):(p[1]=0,p[2]=Uq(s,i));break;case"ZYX":p[1]=Wq(-Hq(c,-1,1)),jq(c)<.99999?(p[0]=Uq(h,d),p[2]=Uq(s,i)):(p[0]=0,p[2]=Uq(-o,l));break;case"YZX":p[2]=Wq(Hq(s,-1,1)),jq(s)<.99999?(p[0]=Uq(-u,l),p[1]=Uq(-c,i)):(p[0]=0,p[1]=Uq(a,d));break;case"XZY":p[2]=Wq(-Hq(o,-1,1)),jq(o)<.99999?(p[0]=Uq(h,l),p[1]=Uq(a,i)):(p[0]=Uq(-u,d),p[1]=0);break;default:console.warn("Unkown order: "+n)}return e._dirty=!0,e},Object.defineProperties(Bq,{POSITIVE_X:{get:function(){return new Bq(1,0,0)}},NEGATIVE_X:{get:function(){return new Bq(-1,0,0)}},POSITIVE_Y:{get:function(){return new Bq(0,1,0)}},NEGATIVE_Y:{get:function(){return new Bq(0,-1,0)}},POSITIVE_Z:{get:function(){return new Bq(0,0,1)}},NEGATIVE_Z:{get:function(){return new Bq(0,0,-1)}},UP:{get:function(){return new Bq(0,1,0)}},ZERO:{get:function(){return new Bq}}});var Xq,Yq,Zq,qq,Kq=function(e,t){this.origin=e||new Bq,this.direction=t||new Bq};Kq.prototype={constructor:Kq,intersectPlane:function(e,t){var n=e.normal.array,r=e.distance,i=this.origin.array,o=this.direction.array,a=Cq.dot(n,o);if(0===a)return null;t||(t=new Bq);var s=(Cq.dot(n,i)-r)/a;return Cq.scaleAndAdd(t.array,i,o,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=Cq.dot(e.normal.array,this.direction.array);Cq.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=Cq.create();return function(t){Cq.sub(e,t,this.origin.array);var n=Cq.dot(e,this.direction.array);if(n<0)return Cq.distance(this.origin.array,t);var r=Cq.lenSquared(e);return Math.sqrt(r-n*n)}}(),intersectSphere:function(){var e=Cq.create();return function(t,n,r){var i=this.origin.array,o=this.direction.array;t=t.array,Cq.sub(e,t,i);var a=Cq.dot(e,o),s=Cq.squaredLength(e)-a*a,l=n*n;if(!(s>l)){var u=Math.sqrt(l-s),c=a-u,h=a+u;return r||(r=new Bq),c<0?h<0?null:(Cq.scaleAndAdd(r.array,i,o,h),r):(Cq.scaleAndAdd(r.array,i,o,c),r)}}}(),intersectBoundingBox:function(e,t){var n,r,i,o,a,s,l=this.direction.array,u=this.origin.array,c=e.min.array,h=e.max.array,d=1/l[0],p=1/l[1],f=1/l[2];if(d>=0?(n=(c[0]-u[0])*d,r=(h[0]-u[0])*d):(r=(c[0]-u[0])*d,n=(h[0]-u[0])*d),p>=0?(i=(c[1]-u[1])*p,o=(h[1]-u[1])*p):(o=(c[1]-u[1])*p,i=(h[1]-u[1])*p),n>o||i>r)return null;if((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),f>=0?(a=(c[2]-u[2])*f,s=(h[2]-u[2])*f):(s=(c[2]-u[2])*f,a=(h[2]-u[2])*f),n>s||a>r)return null;if((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0)return null;var g=n>=0?n:r;return t||(t=new Bq),Cq.scaleAndAdd(t.array,u,l,g),t},intersectTriangle:(Xq=Cq.create(),Yq=Cq.create(),Zq=Cq.create(),qq=Cq.create(),function(e,t,n,r,i,o){var a=this.direction.array,s=this.origin.array;e=e.array,t=t.array,n=n.array,Cq.sub(Xq,t,e),Cq.sub(Yq,n,e),Cq.cross(qq,Yq,a);var l=Cq.dot(Xq,qq);if(r){if(l>-1e-5)return null}else if(l>-1e-5&&l<1e-5)return null;Cq.sub(Zq,s,e);var u=Cq.dot(qq,Zq)/l;if(u<0||u>1)return null;Cq.cross(qq,Xq,Zq);var c=Cq.dot(a,qq)/l;if(c<0||c>1||u+c>1)return null;Cq.cross(qq,Xq,Yq);var h=-Cq.dot(Zq,qq)/l;return h<0?null:(i||(i=new Bq),o&&Bq.set(o,1-u-c,u,c),Cq.scaleAndAdd(i.array,s,a,h),i)}),applyTransform:function(e){Bq.add(this.direction,this.direction,this.origin),Bq.transformMat4(this.origin,this.origin,e),Bq.transformMat4(this.direction,this.direction,e),Bq.sub(this.direction,this.direction,this.origin),Bq.normalize(this.direction,this.direction)},copy:function(e){Bq.copy(this.origin,e.origin),Bq.copy(this.direction,e.direction)},clone:function(){var e=new Kq;return e.copy(this),e}};var $q={create:function(){var e=new XZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},clone:function(e){var t=new XZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues:function(e,t,n,r){var i=new XZ(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},set:function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}};$q.sub=$q.subtract,$q.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},$q.mul=$q.multiply,$q.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},$q.div=$q.divide,$q.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},$q.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},$q.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},$q.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},$q.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return Math.sqrt(n*n+r*r+i*i+o*o)},$q.dist=$q.distance,$q.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+i*i+o*o},$q.sqrDist=$q.squaredDistance,$q.length=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)},$q.len=$q.length,$q.squaredLength=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i},$q.sqrLen=$q.squaredLength,$q.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},$q.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},$q.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e[3]=t[3]*a),e},$q.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},$q.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e[3]=s+r*(n[3]-s),e},$q.random=function(e,t){return t=t||1,e[0]=YZ(),e[1]=YZ(),e[2]=YZ(),e[3]=YZ(),$q.normalize(e,e),$q.scale(e,e,t),e},$q.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e},$q.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},$q.forEach=function(){var e=$q.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=4),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var Jq={create:function(){var e=new XZ(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromMat4:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},clone:function(e){var t=new XZ(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*a-s*u,d=-c*o+s*l,p=u*o-a*l,f=n*h+r*d+i*p;return f?(f=1/f,e[0]=h*f,e[1]=(-c*r+i*u)*f,e[2]=(s*r-i*a)*f,e[3]=d*f,e[4]=(c*n-i*l)*f,e[5]=(-s*n+i*o)*f,e[6]=p*f,e[7]=(-u*n+r*l)*f,e[8]=(a*n-r*o)*f,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8];return t*(u*o-a*l)+n*(-u*i+a*s)+r*(l*i-o*s)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1],f=n[2],g=n[3],m=n[4],v=n[5],y=n[6],_=n[7],x=n[8];return e[0]=d*r+p*a+f*u,e[1]=d*i+p*s+f*c,e[2]=d*o+p*l+f*h,e[3]=g*r+m*a+v*u,e[4]=g*i+m*s+v*c,e[5]=g*o+m*l+v*h,e[6]=y*r+_*a+x*u,e[7]=y*i+_*s+x*c,e[8]=y*o+_*l+x*h,e}};Jq.mul=Jq.multiply,Jq.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+p*a+u,e[7]=d*i+p*s+c,e[8]=d*o+p*l+h,e},Jq.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=Math.sin(n),p=Math.cos(n);return e[0]=p*r+d*a,e[1]=p*i+d*s,e[2]=p*o+d*l,e[3]=p*a-d*r,e[4]=p*s-d*i,e[5]=p*l-d*o,e[6]=u,e[7]=c,e[8]=h,e},Jq.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},Jq.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},Jq.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[3]=c-v,e[6]=d+m,e[1]=c+v,e[4]=1-u-f,e[7]=p-g,e[2]=d-m,e[5]=p+g,e[8]=1-u-h,e},Jq.normalFromMat4=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(l*C-a*I-u*M)*E,e[2]=(a*A-s*C+u*T)*E,e[3]=(i*A-r*I-o*D)*E,e[4]=(n*I-i*C+o*M)*E,e[5]=(r*C-n*A-o*T)*E,e[6]=(g*S-m*w+v*b)*E,e[7]=(m*x-f*S-v*_)*E,e[8]=(f*w-g*x+v*y)*E,e):null},Jq.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))};var Qq,eK,tK,nK,rK={};rK.create=function(){var e=new XZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},rK.rotationTo=(Qq=Cq.create(),eK=Cq.fromValues(1,0,0),tK=Cq.fromValues(0,1,0),function(e,t,n){var r=Cq.dot(t,n);return r<-.999999?(Cq.cross(Qq,eK,t),Cq.length(Qq)<1e-6&&Cq.cross(Qq,tK,t),Cq.normalize(Qq,Qq),rK.setAxisAngle(e,Qq,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Cq.cross(Qq,t,n),e[0]=Qq[0],e[1]=Qq[1],e[2]=Qq[2],e[3]=1+r,rK.normalize(e,e))}),rK.setAxes=(nK=Jq.create(),function(e,t,n,r){return nK[0]=n[0],nK[3]=n[1],nK[6]=n[2],nK[1]=r[0],nK[4]=r[1],nK[7]=r[2],nK[2]=-t[0],nK[5]=-t[1],nK[8]=-t[2],rK.normalize(e,rK.fromMat3(e,nK))}),rK.clone=$q.clone,rK.fromValues=$q.fromValues,rK.copy=$q.copy,rK.set=$q.set,rK.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},rK.setAxisAngle=function(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e},rK.add=$q.add,rK.multiply=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*c+a*s+i*u-o*l,e[1]=i*c+a*l+o*s-r*u,e[2]=o*c+a*u+r*l-i*s,e[3]=a*c-r*s-i*l-o*u,e},rK.mul=rK.multiply,rK.scale=$q.scale,rK.rotateX=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e},rK.rotateY=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e},rK.rotateZ=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},rK.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},rK.dot=$q.dot,rK.lerp=$q.lerp,rK.slerp=function(e,t,n,r){var i,o,a,s,l,u=t[0],c=t[1],h=t[2],d=t[3],p=n[0],f=n[1],g=n[2],m=n[3];return(o=u*p+c*f+h*g+d*m)<0&&(o=-o,p=-p,f=-f,g=-g,m=-m),1-o>1e-6?(i=Math.acos(o),a=Math.sin(i),s=Math.sin((1-r)*i)/a,l=Math.sin(r*i)/a):(s=1-r,l=r),e[0]=s*u+l*p,e[1]=s*c+l*f,e[2]=s*h+l*g,e[3]=s*d+l*m,e},rK.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=o*s,e},rK.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},rK.length=$q.length,rK.len=rK.length,rK.squaredLength=$q.squaredLength,rK.sqrLen=rK.squaredLength,rK.normalize=$q.normalize,rK.fromMat3=function(e,t){var n,r=t[0]+t[4]+t[8];if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*o+o]-t[3*a+a]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*o+a]-t[3*a+o])*n,e[o]=(t[3*o+i]+t[3*i+o])*n,e[a]=(t[3*a+i]+t[3*i+a])*n}return e};var iK=function(){this._axisX=new Bq,this._axisY=new Bq,this._axisZ=new Bq,this.array=Mq.create(),this._dirty=!0};iK.prototype={constructor:iK,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return Mq.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new iK).copy(this)},copy:function(e){return Mq.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Mq.determinant(this.array)},fromQuat:function(e){return Mq.fromQuat(this.array,e.array),this._dirty=!0,this},fromRotationTranslation:function(e,t){return Mq.fromRotationTranslation(this.array,e.array,t.array),this._dirty=!0,this},fromMat2d:function(e){return iK.fromMat2d(this,e),this},frustum:function(e,t,n,r,i,o){return Mq.frustum(this.array,e,t,n,r,i,o),this._dirty=!0,this},identity:function(){return Mq.identity(this.array),this._dirty=!0,this},invert:function(){return Mq.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(e,t,n){return Mq.lookAt(this.array,e.array,t.array,n.array),this._dirty=!0,this},mul:function(e){return Mq.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Mq.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Mq.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Mq.multiply(this.array,e.array,this.array),this._dirty=!0,this},ortho:function(e,t,n,r,i,o){return Mq.ortho(this.array,e,t,n,r,i,o),this._dirty=!0,this},perspective:function(e,t,n,r){return Mq.perspective(this.array,e,t,n,r),this._dirty=!0,this},rotate:function(e,t){return Mq.rotate(this.array,this.array,e,t.array),this._dirty=!0,this},rotateX:function(e){return Mq.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return Mq.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return Mq.rotateZ(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Mq.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Mq.translate(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return Mq.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:function(){var e=Cq.create(),t=Cq.create(),n=Cq.create(),r=Jq.create();return function(i,o,a){var s=this.array;Cq.set(e,s[0],s[1],s[2]),Cq.set(t,s[4],s[5],s[6]),Cq.set(n,s[8],s[9],s[10]);var l=Cq.length(e),u=Cq.length(t),c=Cq.length(n);this.determinant()<0&&(l=-l),i&&i.set(l,u,c),a.set(s[12],s[13],s[14]),Jq.fromMat4(r,s),r[0]/=l,r[1]/=l,r[2]/=l,r[3]/=u,r[4]/=u,r[5]/=u,r[6]/=c,r[7]/=c,r[8]/=c,rK.fromMat3(o.array,r),rK.normalize(o.array,o.array),o._dirty=!0,a._dirty=!0}}(),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var oK=Object.defineProperty;if(oK){var aK=iK.prototype;oK(aK,"z",{get:function(){var e=this.array;return this._axisZ.set(e[8],e[9],e[10]),this._axisZ},set:function(e){var t=this.array;e=e.array,t[8]=e[0],t[9]=e[1],t[10]=e[2],this._dirty=!0}}),oK(aK,"y",{get:function(){var e=this.array;return this._axisY.set(e[4],e[5],e[6]),this._axisY},set:function(e){var t=this.array;e=e.array,t[4]=e[0],t[5]=e[1],t[6]=e[2],this._dirty=!0}}),oK(aK,"x",{get:function(){var e=this.array;return this._axisX.set(e[0],e[1],e[2]),this._axisX},set:function(e){var t=this.array;e=e.array,t[0]=e[0],t[1]=e[1],t[2]=e[2],this._dirty=!0}})}iK.adjoint=function(e,t){return Mq.adjoint(e.array,t.array),e._dirty=!0,e},iK.copy=function(e,t){return Mq.copy(e.array,t.array),e._dirty=!0,e},iK.determinant=function(e){return Mq.determinant(e.array)},iK.identity=function(e){return Mq.identity(e.array),e._dirty=!0,e},iK.ortho=function(e,t,n,r,i,o,a){return Mq.ortho(e.array,t,n,r,i,o,a),e._dirty=!0,e},iK.perspective=function(e,t,n,r,i){return Mq.perspective(e.array,t,n,r,i),e._dirty=!0,e},iK.lookAt=function(e,t,n,r){return Mq.lookAt(e.array,t.array,n.array,r.array),e._dirty=!0,e},iK.invert=function(e,t){return Mq.invert(e.array,t.array),e._dirty=!0,e},iK.mul=function(e,t,n){return Mq.mul(e.array,t.array,n.array),e._dirty=!0,e},iK.multiply=iK.mul,iK.fromQuat=function(e,t){return Mq.fromQuat(e.array,t.array),e._dirty=!0,e},iK.fromRotationTranslation=function(e,t,n){return Mq.fromRotationTranslation(e.array,t.array,n.array),e._dirty=!0,e},iK.fromMat2d=function(e,t){e._dirty=!0;t=t.array;return(e=e.array)[0]=t[0],e[4]=t[2],e[12]=t[4],e[1]=t[1],e[5]=t[3],e[13]=t[5],e},iK.rotate=function(e,t,n,r){return Mq.rotate(e.array,t.array,n,r.array),e._dirty=!0,e},iK.rotateX=function(e,t,n){return Mq.rotateX(e.array,t.array,n),e._dirty=!0,e},iK.rotateY=function(e,t,n){return Mq.rotateY(e.array,t.array,n),e._dirty=!0,e},iK.rotateZ=function(e,t,n){return Mq.rotateZ(e.array,t.array,n),e._dirty=!0,e},iK.scale=function(e,t,n){return Mq.scale(e.array,t.array,n.array),e._dirty=!0,e},iK.transpose=function(e,t){return Mq.transpose(e.array,t.array),e._dirty=!0,e},iK.translate=function(e,t,n){return Mq.translate(e.array,t.array,n.array),e._dirty=!0,e};var sK,lK=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=void 0===r?1:r,this.array=rK.fromValues(e,t,n,r),this._dirty=!0};lK.prototype={constructor:lK,add:function(e){return rK.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return rK.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new lK(this.x,this.y,this.z,this.w)},conjugate:function(){return rK.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return rK.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return rK.dot(this.array,e.array)},fromMat3:function(e){return rK.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:(sK=Jq.create(),function(e){return Jq.fromMat4(sK,e.array),Jq.transpose(sK,sK),rK.fromMat3(this.array,sK),this._dirty=!0,this}),identity:function(){return rK.identity(this.array),this._dirty=!0,this},invert:function(){return rK.invert(this.array,this.array),this._dirty=!0,this},len:function(){return rK.len(this.array)},length:function(){return rK.length(this.array)},lerp:function(e,t,n){return rK.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},mul:function(e){return rK.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return rK.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return rK.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return rK.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return rK.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return rK.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return rK.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return rK.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return rK.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,n){return rK.setAxes(this.array,e.array,t.array,n.array),this._dirty=!0,this},setAxisAngle:function(e,t){return rK.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,n){return rK.slerp(this.array,e.array,t.array,n),this._dirty=!0,this},sqrLen:function(){return rK.sqrLen(this.array)},squaredLength:function(){return rK.squaredLength(this.array)},fromEuler:function(e,t){return lK.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var uK=Object.defineProperty;if(uK){var cK=lK.prototype;uK(cK,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),uK(cK,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),uK(cK,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),uK(cK,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}lK.add=function(e,t,n){return rK.add(e.array,t.array,n.array),e._dirty=!0,e},lK.set=function(e,t,n,r,i){rK.set(e.array,t,n,r,i),e._dirty=!0},lK.copy=function(e,t){return rK.copy(e.array,t.array),e._dirty=!0,e},lK.calculateW=function(e,t){return rK.calculateW(e.array,t.array),e._dirty=!0,e},lK.conjugate=function(e,t){return rK.conjugate(e.array,t.array),e._dirty=!0,e},lK.identity=function(e){return rK.identity(e.array),e._dirty=!0,e},lK.invert=function(e,t){return rK.invert(e.array,t.array),e._dirty=!0,e},lK.dot=function(e,t){return rK.dot(e.array,t.array)},lK.len=function(e){return rK.length(e.array)},lK.lerp=function(e,t,n,r){return rK.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},lK.slerp=function(e,t,n,r){return rK.slerp(e.array,t.array,n.array,r),e._dirty=!0,e},lK.mul=function(e,t,n){return rK.multiply(e.array,t.array,n.array),e._dirty=!0,e},lK.multiply=lK.mul,lK.rotateX=function(e,t,n){return rK.rotateX(e.array,t.array,n),e._dirty=!0,e},lK.rotateY=function(e,t,n){return rK.rotateY(e.array,t.array,n),e._dirty=!0,e},lK.rotateZ=function(e,t,n){return rK.rotateZ(e.array,t.array,n),e._dirty=!0,e},lK.setAxisAngle=function(e,t,n){return rK.setAxisAngle(e.array,t.array,n),e._dirty=!0,e},lK.normalize=function(e,t){return rK.normalize(e.array,t.array),e._dirty=!0,e},lK.squaredLength=lK.sqrLen=function(e){return rK.sqrLen(e.array)},lK.fromMat3=function(e,t){return rK.fromMat3(e.array,t.array),e._dirty=!0,e},lK.setAxes=function(e,t,n,r){return rK.setAxes(e.array,t.array,n.array,r.array),e._dirty=!0,e},lK.rotationTo=function(e,t,n){return rK.rotationTo(e.array,t.array,n.array),e._dirty=!0,e},lK.fromEuler=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=Math.cos(t[0]/2),o=Math.cos(t[1]/2),a=Math.cos(t[2]/2),s=Math.sin(t[0]/2),l=Math.sin(t[1]/2),u=Math.sin(t[2]/2);switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"YXZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"ZXY":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"ZYX":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"YZX":r[0]=s*o*a+i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a-s*l*u;break;case"XZY":r[0]=s*o*a-i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a+s*l*u}};var hK,dK,pK,fK,gK,mK,vK=Cq.set,yK=Cq.copy,_K=function(e,t){this.min=e||new Bq(1/0,1/0,1/0),this.max=t||new Bq(-1/0,-1/0,-1/0),this.vertices=null};_K.prototype={constructor:_K,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,r=t.array,i=n.array;yK(r,e[0]),yK(i,e[0]);for(var o=1;o<e.length;o++){var a=e[o];a[0]<r[0]&&(r[0]=a[0]),a[1]<r[1]&&(r[1]=a[1]),a[2]<r[2]&&(r[2]=a[2]),a[0]>i[0]&&(i[0]=a[0]),a[1]>i[1]&&(i[1]=a[1]),a[2]>i[2]&&(i[2]=a[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return Cq.min(t.array,t.array,e.min.array),Cq.max(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return Cq.max(t.array,t.array,e.min.array),Cq.min(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]<r[0]||n[1]<r[1]||n[2]<r[2])},containBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min.array,n=this.max.array,r=e.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]>=r[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:(hK=Cq.create(),dK=Cq.create(),pK=Cq.create(),fK=Cq.create(),gK=Cq.create(),mK=Cq.create(),function(e,t){var n=e.min.array,r=e.max.array,i=t.array;return hK[0]=i[0]*n[0],hK[1]=i[1]*n[0],hK[2]=i[2]*n[0],dK[0]=i[0]*r[0],dK[1]=i[1]*r[0],dK[2]=i[2]*r[0],pK[0]=i[4]*n[1],pK[1]=i[5]*n[1],pK[2]=i[6]*n[1],fK[0]=i[4]*r[1],fK[1]=i[5]*r[1],fK[2]=i[6]*r[1],gK[0]=i[8]*n[2],gK[1]=i[9]*n[2],gK[2]=i[10]*n[2],mK[0]=i[8]*r[2],mK[1]=i[9]*r[2],mK[2]=i[10]*r[2],n=this.min.array,r=this.max.array,n[0]=Math.min(hK[0],dK[0])+Math.min(pK[0],fK[0])+Math.min(gK[0],mK[0])+i[12],n[1]=Math.min(hK[1],dK[1])+Math.min(pK[1],fK[1])+Math.min(gK[1],mK[1])+i[13],n[2]=Math.min(hK[2],dK[2])+Math.min(pK[2],fK[2])+Math.min(gK[2],mK[2])+i[14],r[0]=Math.max(hK[0],dK[0])+Math.max(pK[0],fK[0])+Math.max(gK[0],mK[0])+i[12],r[1]=Math.max(hK[1],dK[1])+Math.max(pK[1],fK[1])+Math.max(gK[1],mK[1])+i[13],r[2]=Math.max(hK[2],dK[2])+Math.max(pK[2],fK[2])+Math.max(gK[2],mK[2])+i[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(e){var t=this.min.array,n=this.max.array,r=e.array,i=t[0],o=t[1],a=t[2],s=n[0],l=n[1],u=t[2],c=n[0],h=n[1],d=n[2];if(1===r[15])t[0]=r[0]*i+r[12],t[1]=r[5]*o+r[13],n[2]=r[10]*a+r[14],n[0]=r[0]*c+r[12],n[1]=r[5]*h+r[13],t[2]=r[10]*d+r[14];else{var p=-1/a;t[0]=r[0]*i*p,t[1]=r[5]*o*p,n[2]=(r[10]*a+r[14])*p,p=-1/u,n[0]=r[0]*s*p,n[1]=r[5]*l*p,p=-1/d,t[2]=(r[10]*d+r[14])*p}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=Cq.fromValues(0,0,0);this.vertices=e}var n=this.min.array,r=this.max.array;return vK(e[0],n[0],n[1],n[2]),vK(e[1],n[0],r[1],n[2]),vK(e[2],r[0],n[1],n[2]),vK(e[3],r[0],r[1],n[2]),vK(e[4],n[0],n[1],r[2]),vK(e[5],n[0],r[1],r[2]),vK(e[6],r[0],n[1],r[2]),vK(e[7],r[0],r[1],r[2]),this},copy:function(e){var t=this.min,n=this.max;return yK(t.array,e.min.array),yK(n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new _K;return e.copy(this),e}};var xK,bK,wK=0,SK=bY.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},(function(){this.name||(this.name=(this.type||"NODE")+"_"+wK++),this.position||(this.position=new Bq),this.rotation||(this.rotation=new lK),this.scale||(this.scale=new Bq(1,1,1)),this.worldTransform=new iK,this.localTransform=new iK,this._children=[]}),{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t<e.length;t++)e[t]._parent=null,this._scene&&e[t].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(e){e._scene.removeFromScene(e),e._scene=null},_addSelfToScene:function(e){this._scene.addToScene(e),e._scene=this._scene},isAncestor:function(e){for(var t=e._parent;t;){if(t===this)return!0;t=t._parent}return!1},children:function(){return this._children.slice()},childAt:function(e){return this._children[e]},getChildByName:function(e){for(var t=this._children,n=0;n<t.length;n++)if(t[n].name===e)return t[n]},getDescendantByName:function(e){for(var t=this._children,n=0;n<t.length;n++){var r=t[n];if(r.name===e)return r;var i=r.getDescendantByName(e);if(i)return i}},queryNode:function(e){if(e){for(var t=e.split("/"),n=this,r=0;r<t.length;r++){var i=t[r];if(i){for(var o=!1,a=n._children,s=0;s<a.length;s++){var l=a[s];if(l.name===i){n=l,o=!0;break}}if(!o)return}}return n}},getPath:function(e){if(!this._parent)return"/";for(var t=this._parent,n=this.name;t._parent&&(n=t.name+"/"+n,t._parent!=e);)t=t._parent;return!t._parent&&e?null:n},traverse:function(e,t){e.call(t,this);for(var n=this._children,r=0,i=n.length;r<i;r++)n[r].traverse(e,t)},eachChild:function(e,t){for(var n=this._children,r=0,i=n.length;r<i;r++){var o=n[r];e.call(t,o,r)}},setLocalTransform:function(e){Mq.copy(this.localTransform.array,e.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(e){var t=e?null:this.scale;this.localTransform.decomposeMatrix(t,this.rotation,this.position)},setWorldTransform:function(e){Mq.copy(this.worldTransform.array,e.array),this.decomposeWorldTransform()},decomposeWorldTransform:(xK=Mq.create(),function(e){var t=this.localTransform,n=this.worldTransform;this._parent?(Mq.invert(xK,this._parent.worldTransform.array),Mq.multiply(t.array,xK,n.array)):Mq.copy(t.array,n.array);var r=e?null:this.scale;t.decomposeMatrix(r,this.rotation,this.position)}),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var e=this.position,t=this.rotation,n=this.scale;if(this.transformNeedsUpdate()){var r=this.localTransform.array;Mq.fromRotationTranslation(r,t.array,e.array),Mq.scale(r,r,n.array),t._dirty=!1,n._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var e=this.localTransform.array,t=this.worldTransform.array;this._parent?Mq.multiplyAffine(t,this._parent.worldTransform.array,e):Mq.copy(t,e)},updateWorldTransform:function(){for(var e=this;e&&e.getParent()&&e.getParent().transformNeedsUpdate();)e=e.getParent();e.update()},update:function(e){this.autoUpdateLocalTransform?this.updateLocalTransform():e=!0,(e||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),e=!0,this._needsUpdateWorldTransform=!1);for(var t=this._children,n=0,r=t.length;n<r;n++)t[n].update(e)},getBoundingBox:function(){function e(e){return!e.invisible&&e.geometry}var t=new _K,n=new iK,r=new iK;return function(i,o){return o=o||new _K,this._parent?iK.invert(r,this._parent.worldTransform):iK.identity(r),this.traverse((function(e){e.geometry&&e.geometry.boundingBox&&(t.copy(e.geometry.boundingBox),iK.multiply(n,r,e.worldTransform),t.applyTransform(n),o.union(t))}),this,e),o}}(),getWorldPosition:function(e){this.transformNeedsUpdate()&&this.updateWorldTransform();var t=this.worldTransform.array;if(e){var n=e.array;return n[0]=t[12],n[1]=t[13],n[2]=t[14],e}return new Bq(t[12],t[13],t[14])},clone:function(){var e=new this.constructor,t=this._children;e.setName(this.name),e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale);for(var n=0;n<t.length;n++)e.add(t[n].clone());return e},rotateAround:function(){var e=new Bq,t=new iK;return function(n,r,i){e.copy(this.position).subtract(n);var o=this.localTransform;o.identity(),o.translate(n),o.rotate(i,r),t.fromRotationTranslation(this.rotation,e),o.multiply(t),o.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var e=new iK;return function(t,n){e.lookAt(this.position,t,n||this.localTransform.y).invert(),this.setLocalTransform(e),this.target=t}}()}),TK=SK.extend({material:null,geometry:null,mode:NY,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:BY,frontFace:HY,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=SK.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:(bK=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var e=SK.prototype.clone.call(this);e.geometry=this.geometry,e.material=this.material;for(var t=0;t<bK.length;t++){var n=bK[t];e[n]!==this[n]&&(e[n]=this[n])}return e})});TK.POINTS=AY,TK.LINES=IY,TK.LINE_LOOP=EY,TK.LINE_STRIP=LY,TK.TRIANGLES=NY,TK.TRIANGLE_STRIP=PY,TK.TRIANGLE_FAN=OY,TK.BACK=BY,TK.FRONT=VY,TK.FRONT_AND_BACK=FY,TK.CW=GY,TK.CCW=HY;var MK=bY.extend({scene:null,camera:null,renderer:null},(function(){this._ray=new Kq,this._ndc=new qZ}),{pick:function(e,t,n){return this.pickAll(e,t,[],n)[0]||null},pickAll:function(e,t,n,r){return this.renderer.screenToNDC(e,t,this._ndc),this.camera.castRay(this._ndc,this._ray),n=n||[],this._intersectNode(this.scene,n,r||!1),n.sort(this._intersectionCompareFunc),n},_intersectNode:function(e,t,n){e instanceof TK&&e.isRenderable()&&(e.ignorePicking&&!n||!(e.mode===NY&&e.geometry.isUseIndices()||e.geometry.pickByRay||e.geometry.pick)||this._intersectRenderable(e,t));for(var r=0;r<e._children.length;r++)this._intersectNode(e._children[r],t,n)},_intersectRenderable:function(){var e=new Bq,t=new Bq,n=new Bq,r=new Kq,i=new iK;return function(o,a){var s=o.isSkinnedMesh();r.copy(this._ray),iK.invert(i,o.worldTransform),s||r.applyTransform(i);var l=o.geometry,u=s?o.skeleton.boundingBox:l.boundingBox;if(!u||r.intersectBoundingBox(u))if(l.pick)l.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,o,a);else if(l.pickByRay)l.pickByRay(r,o,a);else{var c,h,d=o.cullFace===BY&&o.frontFace===HY||o.cullFace===VY&&o.frontFace===GY,p=l.indices,f=l.attributes.position,g=l.attributes.weight,m=l.attributes.joint,v=[];if(f&&f.value&&p){if(s){h=o.skeleton.getSubSkinMatrices(o.__uid__,o.joints);for(var y=0;y<o.joints.length;y++){v[y]=v[y]||[];for(var _=0;_<16;_++)v[y][_]=h[16*y+_]}var x=[],b=[],w=[],S=[],T=[],M=l.attributes.skinnedPosition;M&&M.value||(l.createAttribute("skinnedPosition","f",3),(M=l.attributes.skinnedPosition).init(l.vertexCount));for(y=0;y<l.vertexCount;y++){f.get(y,x),g.get(y,b),m.get(y,w),b[3]=1-b[0]-b[1]-b[2],Cq.set(S,0,0,0);for(_=0;_<4;_++)w[_]>=0&&b[_]>1e-4&&(Cq.transformMat4(T,x,v[w[_]]),Cq.scaleAndAdd(S,S,T,b[_]));M.set(y,S)}}for(y=0;y<p.length;y+=3){var C=p[y],D=p[y+1],A=p[y+2],I=s?l.attributes.skinnedPosition:f;if(I.get(C,e.array),I.get(D,t.array),I.get(A,n.array),c=d?r.intersectTriangle(e,t,n,o.culling):r.intersectTriangle(e,n,t,o.culling)){var E=new Bq;s?Bq.copy(E,c):Bq.transformMat4(E,c,o.worldTransform),a.push(new MK.Intersection(c,E,o,[C,D,A],y/3,Bq.dist(E,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});MK.Intersection=function(e,t,n,r,i,o){this.point=e,this.pointWorld=t,this.target=n,this.triangle=r,this.triangleIndex=i,this.distance=o};var CK="__dt__",DK=function(){this._contextId=0,this._caches=[],this._context={}};DK.prototype={use:function(e,t){var n=this._caches;n[e]||(n[e]={},t&&(n[e]=t())),this._contextId=e,this._context=n[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){var t=CK+(e=e||"");this.put(t,!0)},dirtyAll:function(e){for(var t=CK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!0)},fresh:function(e){var t=CK+(e=e||"");this.put(t,!1)},freshAll:function(e){for(var t=CK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!1)},isDirty:function(e){var t=CK+(e=e||""),n=this._context;return!n.hasOwnProperty(t)||!0===n[t]},deleteContext:function(e){delete this._caches[e],this._context={}},delete:function(e){delete this._context[e]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(e,t){Object.keys(this._caches).forEach((function(n){e&&e.call(t,n)}))},miss:function(e){return!this._context.hasOwnProperty(e)}},DK.prototype.constructor=DK;var AK=bY.extend({width:512,height:512,type:WY,format:QY,wrapS:cZ,wrapT:cZ,minFilter:sZ,magFilter:rZ,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},(function(){this._cache=new DK}),{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__uid__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===KY&&(this.useMipmap=!1);var n=e.getGLExtension("EXT_sRGB");this.format!==AK.SRGB||n||(this.format=AK.RGB),this.format!==AK.SRGB_ALPHA||n||(this.format=AK.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?hZ:this.wrapS},getAvailableWrapT:function(){return this.NPOT?hZ:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===iZ||e===aZ?nZ:e===sZ||e===oZ?rZ:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(AK.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(AK.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),AK.BYTE=UY,AK.UNSIGNED_BYTE=WY,AK.SHORT=jY,AK.UNSIGNED_SHORT=XY,AK.INT=YY,AK.UNSIGNED_INT=ZY,AK.FLOAT=qY,AK.HALF_FLOAT=36193,AK.UNSIGNED_INT_24_8_WEBGL=34042,AK.DEPTH_COMPONENT=KY,AK.DEPTH_STENCIL=gZ,AK.ALPHA=$Y,AK.RGB=JY,AK.RGBA=QY,AK.LUMINANCE=eZ,AK.LUMINANCE_ALPHA=tZ,AK.SRGB=35904,AK.SRGB_ALPHA=35906,AK.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,AK.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,AK.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,AK.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,AK.NEAREST=nZ,AK.LINEAR=rZ,AK.NEAREST_MIPMAP_NEAREST=iZ,AK.LINEAR_MIPMAP_NEAREST=oZ,AK.NEAREST_MIPMAP_LINEAR=aZ,AK.LINEAR_MIPMAP_LINEAR=sZ,AK.REPEAT=cZ,AK.CLAMP_TO_EDGE=hZ,AK.MIRRORED_REPEAT=dZ;var IK=TK.extend({skeleton:null,joints:null},(function(){this.joints||(this.joints=[])}),{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var e=TK.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});IK.POINTS=AY,IK.LINES=IY,IK.LINE_LOOP=EY,IK.LINE_STRIP=LY,IK.TRIANGLES=NY,IK.TRIANGLE_STRIP=PY,IK.TRIANGLE_FAN=OY,IK.BACK=BY,IK.FRONT=VY,IK.FRONT_AND_BACK=FY,IK.CW=GY,IK.CCW=HY;var EK={isPowerOfTwo:function(e){return!(e&e-1)},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}},LK=EK.isPowerOfTwo;function NK(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}var PK=AK.extend((function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}}),{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==AK.REPEAT&&this.wrapT!==AK.REPEAT||!this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var o=e.getGLExtension("EXT_texture_filter_anisotropic");(o&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,o.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=qY));if(this.mipmaps.length)for(var a=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var u=this.mipmaps[l];this._updateTextureData(t,u,l,a,s,n,r,!1),a/=2,s/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r,i),!this.useMipmap||this.NPOT&&!i||t.generateMipmap(t.TEXTURE_2D);t.bindTexture(t.TEXTURE_2D,null)},_updateTextureData:function(e,t,n,r,i,o,a,s){if(t.image){var l=t.image;s&&(this._potCanvas=function(e,t){var n=NK(e.width),r=NK(e.height);return(t=t||document.createElement("canvas")).width=n,t.height=r,t.getContext("2d").drawImage(e.image,0,0,n,r),t}(this,this._potCanvas),l=this._potCanvas),e.texImage2D(e.TEXTURE_2D,n,o,o,a,l)}else o<=AK.COMPRESSED_RGBA_S3TC_DXT5_EXT&&o>=AK.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,r,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,r,i,0,o,a,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return LK(this.width)&&LK(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var n=wZ.createImage();t&&(n.crossOrigin=t);var r=this;return n.onload=function(){r.dirty(),r.trigger("success",r)},n.onerror=function(){r.trigger("error",r)},n.src=e,this.image=n,this}});function OK(e){return{byte:wZ.Int8Array,ubyte:wZ.Uint8Array,short:wZ.Int16Array,ushort:wZ.Uint16Array}[e]||wZ.Float32Array}function RK(e){return"attr_"+e}function kK(e,t,n,r){switch(this.name=e,this.type=t,this.size=n,this.semantic=r||"",this.value=null,n){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t},this.copy=function(e,t){this.value[e]=this.value[e]};break;case 2:this.get=function(e,t){var n=this.value;return t[0]=n[2*e],t[1]=n[2*e+1],t},this.set=function(e,t){var n=this.value;n[2*e]=t[0],n[2*e+1]=t[1]},this.copy=function(e,t){var n=this.value;t*=2,n[e*=2]=n[t],n[e+1]=n[t+1]};break;case 3:this.get=function(e,t){var n=3*e,r=this.value;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t},this.set=function(e,t){var n=3*e,r=this.value;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2]},this.copy=function(e,t){var n=this.value;t*=3,n[e*=3]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2]};break;case 4:this.get=function(e,t){var n=this.value,r=4*e;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t},this.set=function(e,t){var n=this.value,r=4*e;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2],n[r+3]=t[3]},this.copy=function(e,t){var n=this.value;t*=4,n[e*=4]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2],n[e+3]=n[t+3]}}}function zK(e,t,n,r,i){this.name=e,this.type=t,this.buffer=n,this.size=r,this.semantic=i,this.symbol="",this.needsRemove=!1}function VK(e){this.buffer=e,this.count=0}Object.defineProperty(PK.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(PK.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),kK.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=OK(this.type);this.value=new t(e*this.size)}},kK.prototype.fromArray=function(e){var t,n=OK(this.type);if(e[0]&&e[0].length){var r=0,i=this.size;t=new n(e.length*i);for(var o=0;o<e.length;o++)for(var a=0;a<i;a++)t[r++]=e[o][a]}else t=new n(e);this.value=t},kK.prototype.clone=function(e){var t=new kK(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t};var BK=bY.extend((function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}}),(function(){this._cache=new DK,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}}),{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t<e.length;t++)this.dirtyAttribute(e[t]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(e){this._cache.dirtyAll(RK(e)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(e,t){if(e<this.triangleCount&&e>=0){t||(t=[]);var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?wZ.Uint32Array:wZ.Uint16Array;if(e[0]&&e[0].length){var r=0;t=new n(3*e.length);for(var i=0;i<e.length;i++)for(var o=0;o<3;o++)t[r++]=e[i][o]}else t=new n(e);this.indices=t},createAttribute:function(e,t,n,r){var i=new kK(e,t,n,r);return this.attributes[e]&&this.removeAttribute(e),this.attributes[e]=i,this._attributeList.push(e),i},removeAttribute:function(e){var t=this._attributeList,n=t.indexOf(e);return n>=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],r=this.vertexCount,i=0;i<t.length;i++){var o=t[i],a=this.attributes[o];a.value&&a.value.length===r*a.size&&n.push(o)}return this._enabledAttributes=n,n},getBufferChunks:function(e){var t=this._cache;t.use(e.__uid__);var n=t.isDirty("attributes"),r=t.isDirty("indices");if(n||r){this._updateBuffer(e.gl,n,r);for(var i=this.getEnabledAttributes(),o=0;o<i.length;o++)t.fresh(RK(i[o]));t.fresh("attributes"),t.fresh("indices")}return t.fresh("any"),t.get("chunks")},_updateBuffer:function(e,t,n){var r=this._cache,i=r.get("chunks"),o=!1;i||((i=[])[0]={attributeBuffers:[],indicesBuffer:null},r.put("chunks",i),o=!0);var a=i[0],s=a.attributeBuffers,l=a.indicesBuffer;if(t||o){var u=this.getEnabledAttributes(),c={};if(!o)for(var h=0;h<s.length;h++)c[s[h].name]=s[h];for(var d=0;d<u.length;d++){var p,f,g=u[d],m=this.attributes[g];o||(p=c[g]),f=p?p.buffer:e.createBuffer(),r.isDirty(RK(g))&&(e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,m.value,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW)),s[d]=new zK(g,m.type,f,m.size,m.semantic)}for(h=d;h<s.length;h++)e.deleteBuffer(s[h].buffer);s.length=d}this.isUseIndices()&&(n||o)&&(l||(l=new VK(e.createBuffer()),a.indicesBuffer=l),l.count=this.indices.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.buffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW))},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});Object.defineProperty&&(Object.defineProperty(BK.prototype,"vertexCount",{enumerable:!1,get:function(){var e=this.attributes[this.mainAttribute];return e||(e=this.attributes[this._attributeList[0]]),e&&e.value?e.value.length/e.size:0}}),Object.defineProperty(BK.prototype,"triangleCount",{enumerable:!1,get:function(){var e=this.indices;return e?e.length/3:0}})),BK.STATIC_DRAW=kY,BK.DYNAMIC_DRAW=zY,BK.STREAM_DRAW=RY,BK.AttributeBuffer=zK,BK.IndicesBuffer=VK,BK.Attribute=kK;var FK=Cq.create,GK=Cq.add,HK=Cq.set,UK=BK.Attribute,WK=BK.extend((function(){return{attributes:{position:new UK("position","float",3,"POSITION"),texcoord0:new UK("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new UK("texcoord1","float",2,"TEXCOORD_1"),normal:new UK("normal","float",3,"NORMAL"),tangent:new UK("tangent","float",4,"TANGENT"),color:new UK("color","float",4,"COLOR"),weight:new UK("weight","float",3,"WEIGHT"),joint:new UK("joint","float",4,"JOINT"),barycentric:new UK("barycentric","float",3,null)},boundingBox:null}}),{mainAttribute:"position",updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new _K);var t=this.attributes.position.value;if(t&&t.length){var n=e.min,r=e.max,i=n.array,o=r.array;Cq.set(i,t[0],t[1],t[2]),Cq.set(o,t[0],t[1],t[2]);for(var a=3;a<t.length;){var s=t[a++],l=t[a++],u=t[a++];s<i[0]&&(i[0]=s),l<i[1]&&(i[1]=l),u<i[2]&&(i[2]=u),s>o[0]&&(o[0]=s),l>o[1]&&(o[1]=l),u>o[2]&&(o[2]=u)}n._dirty=!0,r._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value;if(r&&r.length===n.length)for(var i=0;i<r.length;i++)r[i]=0;else r=t.normal.value=new wZ.Float32Array(n.length);for(var o,a,s,l=FK(),u=FK(),c=FK(),h=FK(),d=FK(),p=FK(),f=e?e.length:this.vertexCount,g=0;g<f;){e?(o=e[g++],a=e[g++],s=e[g++]):(o=g++,a=g++,s=g++),HK(l,n[3*o],n[3*o+1],n[3*o+2]),HK(u,n[3*a],n[3*a+1],n[3*a+2]),HK(c,n[3*s],n[3*s+1],n[3*s+2]),Cq.sub(h,l,u),Cq.sub(d,u,c),Cq.cross(p,h,d);for(i=0;i<3;i++)r[3*o+i]=r[3*o+i]+p[i],r[3*a+i]=r[3*a+i]+p[i],r[3*s+i]=r[3*s+i]+p[i]}for(i=0;i<r.length;)HK(p,r[i],r[i+1],r[i+2]),Cq.normalize(p,p),r[i++]=p[0],r[i++]=p[1],r[i++]=p[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value,i=FK(),o=FK(),a=FK(),s=FK(),l=FK(),u=FK();r||(r=t.normal.value=new Float32Array(n.length));for(var c,h,d,p=e?e.length:this.vertexCount,f=0;f<p;){e?(c=e[f++],h=e[f++],d=e[f++]):(c=f++,h=f++,d=f++),HK(i,n[3*c],n[3*c+1],n[3*c+2]),HK(o,n[3*h],n[3*h+1],n[3*h+2]),HK(a,n[3*d],n[3*d+1],n[3*d+2]),Cq.sub(s,i,o),Cq.sub(l,o,a),Cq.cross(u,s,l),Cq.normalize(u,u);for(var g=0;g<3;g++)r[3*c+g]=u[g],r[3*h+g]=u[g],r[3*d+g]=u[g]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var e=this.vertexCount,t=this.attributes;t.tangent.value||(t.tangent.value=new Float32Array(4*e));var n=t.texcoord0.value,r=t.position.value,i=t.tangent.value,o=t.normal.value;if(n){for(var a=[],s=[],l=0;l<e;l++)a[l]=[0,0,0],s[l]=[0,0,0];var u,c,h,d=[0,0,0],p=[0,0,0],f=this.indices,g=f?f.length:this.vertexCount;for(l=0;l<g;){f?(u=f[l++],c=f[l++],h=f[l++]):(u=l++,c=l++,h=l++);var m=n[2*u],v=n[2*c],y=n[2*h],_=n[2*u+1],x=n[2*c+1],b=n[2*h+1],w=r[3*u],S=r[3*c],T=r[3*h],M=r[3*u+1],C=r[3*c+1],D=r[3*h+1],A=r[3*u+2],I=S-w,E=T-w,L=C-M,N=D-M,P=r[3*c+2]-A,O=r[3*h+2]-A,R=v-m,k=y-m,z=x-_,V=b-_,B=1/(R*V-z*k);d[0]=(V*I-z*E)*B,d[1]=(V*L-z*N)*B,d[2]=(V*P-z*O)*B,p[0]=(R*E-k*I)*B,p[1]=(R*N-k*L)*B,p[2]=(R*O-k*P)*B,GK(a[u],a[u],d),GK(a[c],a[c],d),GK(a[h],a[h],d),GK(s[u],s[u],p),GK(s[c],s[c],p),GK(s[h],s[h],p)}var F=FK(),G=FK(),H=FK();for(l=0;l<e;l++){H[0]=o[3*l],H[1]=o[3*l+1],H[2]=o[3*l+2];var U=a[l];Cq.scale(F,H,Cq.dot(H,U)),Cq.sub(F,U,F),Cq.normalize(F,F),Cq.cross(G,H,U),i[4*l]=F[0],i[4*l+1]=F[1],i[4*l+2]=F[2],i[4*l+3]=Cq.dot(G,s[l])<0?-1:1}this.dirty()}else console.warn("Geometry without texcoords can't generate tangents.")}},isUniqueVertex:function(){return!this.isUseIndices()||this.vertexCount===this.indices.length},generateUniqueVertex:function(){if(this.vertexCount&&this.indices){this.indices.length>65535&&(this.indices=new wZ.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),r={},i=0;i<n.length;i++){r[l=n[i]]=e[l].value,e[l].init(this.indices.length)}for(var o=0,a=0;a<t.length;a++){var s=t[a];for(i=0;i<n.length;i++)for(var l,u=e[l=n[i]].value,c=e[l].size,h=0;h<c;h++)u[o*c+h]=r[l][s*c+h];t[a]=o,o++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.attributes,t=e.barycentric.value,n=this.indices;if(!t||t.length!==3*n.length){t=e.barycentric.value=new Float32Array(3*n.length);for(var r=0;r<(n?n.length:this.vertexCount/3);)for(var i=0;i<3;i++){t[3*(n?n[r++]:3*r+i)+i]=1}this.dirty()}}},applyTransform:function(e){var t=this.attributes,n=t.position.value,r=t.normal.value,i=t.tangent.value;e=e.array;var o=Mq.create();Mq.invert(o,e),Mq.transpose(o,o);var a=Cq.transformMat4,s=Cq.forEach;s(n,3,0,null,a,e),r&&s(r,3,0,null,a,o),i&&s(i,4,0,null,a,o),this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});WK.STATIC_DRAW=BK.STATIC_DRAW,WK.DYNAMIC_DRAW=BK.DYNAMIC_DRAW,WK.STREAM_DRAW=BK.STREAM_DRAW,WK.AttributeBuffer=BK.AttributeBuffer,WK.IndicesBuffer=BK.IndicesBuffer,WK.Attribute=UK;var jK="uniform vec3 ",XK="uniform float ",YK="@export clay.header.",ZK="@end",qK=":unconfigurable;",KK=[YK+"directional_light",jK+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+qK,jK+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+qK,ZK,YK+"ambient_light",jK+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+qK,ZK,YK+"ambient_sh_light",jK+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+qK,jK+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+qK,"vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}",ZK,YK+"ambient_cubemap_light",jK+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+qK,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+qK,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+qK,ZK,YK+"point_light",jK+"pointLightPosition[POINT_LIGHT_COUNT]"+qK,XK+"pointLightRange[POINT_LIGHT_COUNT]"+qK,jK+"pointLightColor[POINT_LIGHT_COUNT]"+qK,ZK,YK+"spot_light",jK+"spotLightPosition[SPOT_LIGHT_COUNT]"+qK,jK+"spotLightDirection[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightRange[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+qK,jK+"spotLightColor[SPOT_LIGHT_COUNT]"+qK,ZK].join("\n");bq.import(KK);var $K,JK,QK,e$,t$=SK.extend((function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}}),{type:"",clone:function(){var e=SK.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}}),n$=function(e,t){this.normal=e||new Bq(0,1,0),this.distance=t||0};n$.prototype={constructor:n$,distanceToPoint:function(e){return Cq.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new Bq);var n=this.distanceToPoint(e);return Cq.scaleAndAdd(t.array,e.array,this.normal.array,-n),t._dirty=!0,t},normalize:function(){var e=1/Cq.len(this.normal.array);Cq.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,n=this.normal.array,r=Cq.dot(t[0].array,n)>this.distance,i=1;i<8;i++)if(Cq.dot(t[i].array,n)>this.distance!=r)return!0},intersectLine:(e$=Cq.create(),function(e,t,n){var r=this.distanceToPoint(e),i=this.distanceToPoint(t);if(r>0&&i>0||r<0&&i<0)return null;var o=this.normal.array,a=this.distance,s=e.array;Cq.sub(e$,t.array,e.array),Cq.normalize(e$,e$);var l=Cq.dot(o,e$);if(0===l)return null;n||(n=new Bq);var u=(Cq.dot(o,s)-a)/l;return Cq.scaleAndAdd(n.array,s,e$,-u),n._dirty=!0,n}),applyTransform:($K=Mq.create(),JK=$q.create(),QK=$q.create(),QK[3]=1,function(e){e=e.array,Cq.scale(QK,this.normal.array,this.distance),$q.transformMat4(QK,QK,e),this.distance=Cq.dot(QK,this.normal.array),Mq.invert($K,e),Mq.transpose($K,$K),JK[3]=0,Cq.copy(JK,this.normal.array),$q.transformMat4(JK,JK,$K),Cq.copy(this.normal.array,JK)}),copy:function(e){Cq.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new n$;return e.copy(this),e}};var r$,i$=Cq.set,o$=Cq.copy,a$=Cq.transformMat4,s$=Math.min,l$=Math.max,u$=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new n$);this.boundingBox=new _K,this.vertices=[];for(e=0;e<8;e++)this.vertices[e]=Cq.fromValues(0,0,0)};u$.prototype={setFromProjection:function(e){var t=this.planes,n=e.array,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],d=n[9],p=n[10],f=n[11],g=n[12],m=n[13],v=n[14],y=n[15];i$(t[0].normal.array,a-r,c-s,f-h),t[0].distance=-(y-g),t[0].normalize(),i$(t[1].normal.array,a+r,c+s,f+h),t[1].distance=-(y+g),t[1].normalize(),i$(t[2].normal.array,a+i,c+l,f+d),t[2].distance=-(y+m),t[2].normalize(),i$(t[3].normal.array,a-i,c-l,f-d),t[3].distance=-(y-m),t[3].normalize(),i$(t[4].normal.array,a-o,c-u,f-p),t[4].distance=-(y-v),t[4].normalize(),i$(t[5].normal.array,a+o,c+u,f+p),t[5].distance=-(y+v),t[5].normalize();var _=this.boundingBox,x=this.vertices;if(0===y){var b=l/r,w=-v/(p-1),S=-v/(p+1),T=-S/l,M=-w/l;_.min.set(-T*b,-T,S),_.max.set(T*b,T,w),i$(x[0],-T*b,-T,S),i$(x[1],-T*b,T,S),i$(x[2],T*b,-T,S),i$(x[3],T*b,T,S),i$(x[4],-M*b,-M,w),i$(x[5],-M*b,M,w),i$(x[6],M*b,-M,w),i$(x[7],M*b,M,w)}else{var C=(-1-g)/r,D=(1-g)/r,A=(1-m)/l,I=(-1-m)/l,E=(-1-v)/p,L=(1-v)/p;_.min.set(Math.min(C,D),Math.min(I,A),Math.min(L,E)),_.max.set(Math.max(D,C),Math.max(A,I),Math.max(E,L));var N=_.min.array,P=_.max.array;i$(x[0],N[0],N[1],N[2]),i$(x[1],N[0],P[1],N[2]),i$(x[2],P[0],N[1],N[2]),i$(x[3],P[0],P[1],N[2]),i$(x[4],N[0],N[1],P[2]),i$(x[5],N[0],P[1],P[2]),i$(x[6],P[0],N[1],P[2]),i$(x[7],P[0],P[1],P[2])}},getTransformedBoundingBox:(r$=Cq.create(),function(e,t){var n=this.vertices,r=t.array,i=e.min,o=e.max,a=i.array,s=o.array,l=n[0];a$(r$,l,r),o$(a,r$),o$(s,r$);for(var u=1;u<8;u++)l=n[u],a$(r$,l,r),a[0]=s$(r$[0],a[0]),a[1]=s$(r$[1],a[1]),a[2]=s$(r$[2],a[2]),s[0]=l$(r$[0],s[0]),s[1]=l$(r$[1],s[1]),s[2]=l$(r$[2],s[2]);return i._dirty=!0,o._dirty=!0,e})};var c$,h$=SK.extend((function(){return{projectionMatrix:new iK,invProjectionMatrix:new iK,viewMatrix:new iK,frustum:new u$}}),(function(){this.update(!0)}),{update:function(e){SK.prototype.update.call(this,e),iK.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),iK.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){iK.copy(this.viewMatrix,e),iK.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){iK.copy(this.projectionMatrix,e),iK.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(c$=$q.create(),function(e,t){var n=void 0!==t?t:new Kq,r=e.array[0],i=e.array[1];return $q.set(c$,r,i,-1,1),$q.transformMat4(c$,c$,this.invProjectionMatrix.array),$q.transformMat4(c$,c$,this.worldTransform.array),Cq.scale(n.origin.array,c$,1/c$[3]),$q.set(c$,r,i,1,1),$q.transformMat4(c$,c$,this.invProjectionMatrix.array),$q.transformMat4(c$,c$,this.worldTransform.array),Cq.scale(c$,c$,1/c$[3]),Cq.sub(n.direction.array,c$,n.origin.array),Cq.normalize(n.direction.array,n.direction.array),n.direction._dirty=!0,n.origin._dirty=!0,n})}),d$=Mq.create(),p$=Mq.create(),f$={};function g$(e){var t=[],n=Object.keys(e);n.sort();for(var r=0;r<n.length;r++){var i=n[r];t.push(i+" "+e[i])}var o=t.join("\n");if(f$[o])return f$[o];var a=xY.genGUID();return f$[o]=a,a}function m$(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}m$.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},m$.prototype.add=function(e,t){t?this.transparent[this._transparentCount++]=e:this.opaque[this._opaqueCount++]=e},m$.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var v$,y$,_$=SK.extend((function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new _K,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new MZ(20)}}),(function(){this._scene=this}),{addToScene:function(e){e instanceof h$?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof t$&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof h$?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof t$&&(t=this.lights.indexOf(e))>=0&&this.lights.splice(t,1),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},n=0;n<e.length;n++){var r=e[n];if(!r.invisible){var i=r.group;t[i]||(t[i]={}),t[i][r.type]=t[i][r.type]||0,t[i][r.type]++}}for(var o in this._lightNumber=t,t)this._lightProgramKeys[o]=g$(t[o]);this._updateLightUniforms()},cloneNode:function(e){var t=e.clone(),n={};return function e(t,r){n[t.__uid__]=r;for(var i=0;i<t._children.length;i++){e(t._children[i],r._children[i])}}(e,t),t.traverse((function(e){e.skeleton&&(e.skeleton=e.skeleton.clone(n)),e.material&&(e.material=e.material.clone())})),t},updateRenderList:function(e,t){var n=e.__uid__,r=this._renderLists.get(n);r||(r=new m$,this._renderLists.put(n,r)),r.startCount(),t&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var i=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,e,i,r,t),r.endCount(),r},getRenderList:function(e){return this._renderLists.get(e.__uid__)},_doUpdateRenderList:function(e,t,n,r,i){if(!e.invisible)for(var o=0;o<e._children.length;o++){var a=e._children[o];if(a.isRenderable()){var s=a.isSkinnedMesh()?d$:a.worldTransform.array,l=a.geometry;Mq.multiplyAffine(p$,t.viewMatrix.array,s),(i&&!l.boundingBox||!this.isFrustumCulled(a,t,p$))&&r.add(a,a.material.transparent||n)}a._children.length>0&&this._doUpdateRenderList(a,t,n,r,i)}},isFrustumCulled:(v$=new _K,y$=new iK,function(e,t,n){var r=e.boundingBox;if(r||(r=e.skeleton&&e.skeleton.boundingBox?e.skeleton.boundingBox:e.geometry.boundingBox),!r)return!1;if(y$.array=n,v$.transformFrom(r,y$),e.castShadow&&this.viewBoundingBoxLastFrame.union(v$),e.frustumCulling){if(!v$.intersectBoundingBox(t.frustum.boundingBox))return!0;y$.array=t.projectionMatrix.array,v$.max.array[2]>0&&v$.min.array[2]<0&&(v$.max.array[2]=-1e-20),v$.applyProjection(y$);var i=v$.min.array,o=v$.max.array;if(o[0]<-1||i[0]>1||o[1]<-1||i[1]>1||o[2]<-1||i[2]>1)return!0}return!1}),_updateLightUniforms:function(){var e=this.lights;e.sort(x$);var t=this._lightUniforms;for(var n in t)for(var r in t[n])t[n][r].value.length=0;for(var i=0;i<e.length;i++){var o=e[i];if(!o.invisible){n=o.group;for(var r in o.uniformTemplates){var a=o.uniformTemplates[r],s=a.value(o);if(null!=s){t[n]||(t[n]={}),t[n][r]||(t[n][r]={type:"",value:[]});var l=t[n][r];switch(l.type=a.type+"v",a.type){case"1i":case"1f":case"t":l.value.push(s);break;case"2f":case"3f":case"4f":for(var u=0;u<s.length;u++)l.value.push(s[u]);break;default:console.error("Unkown light uniform type "+a.type)}}}}}},getLightGroups:function(){var e=[];for(var t in this._lightNumber)e.push(t);return e},getNumberChangedLightGroups:function(){var e=[];for(var t in this._lightNumber)this.isLightNumberChanged(t)&&e.push(t);return e},isLightNumberChanged:function(e){var t=this._previousLightNumber,n=this._lightNumber;for(var r in n[e]){if(!t[e])return!0;if(n[e][r]!==t[e][r])return!0}for(var r in t[e]){if(!n[e])return!0;if(n[e][r]!==t[e][r])return!0}return!1},getLightsNumbers:function(e){return this._lightNumber[e]},getProgramKey:function(e){return this._lightProgramKeys[e]},setLightUniforms:function(){function e(e,t,n){for(var r in e){var i=e[r];if("tv"===i.type){if(!t.hasUniform(r))continue;for(var o=[],a=0;a<i.value.length;a++){var s=i.value[a],l=t.takeCurrentTextureSlot(n,s);o.push(l)}t.setUniform(n.gl,"1iv",r,o)}else t.setUniform(n.gl,i.type,r,i.value)}}return function(t,n,r){e(this._lightUniforms[n],t,r),e(this.shadowUniforms,t,r)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});function x$(e,t){if(t.castShadow&&!e.castShadow)return!0}var b$=EK.isPowerOfTwo,w$=["px","nx","py","ny","pz","nz"],S$=AK.extend((function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}}),{textureType:"textureCube",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=qY));if(this.mipmaps.length)for(var o=this.width,a=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(t,l,s,o,a,n,r),o/=2,a/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r),!this.NPOT&&this.useMipmap&&t.generateMipmap(t.TEXTURE_CUBE_MAP);t.bindTexture(t.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(e,t,n,r,i,o,a){for(var s=0;s<6;s++){var l=w$[s],u=t.image&&t.image[l];u?e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,o,a,u):e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,r,i,0,o,a,t.pixels&&t.pixels[l])}},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_CUBE_MAP))},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?b$(this.image.px.width)&&b$(this.image.px.height):b$(this.width)&&b$(this.height)},isRenderable:function(){return this.image.px?T$(this.image.px)&&T$(this.image.nx)&&T$(this.image.py)&&T$(this.image.ny)&&T$(this.image.pz)&&T$(this.image.nz):!(!this.width||!this.height)},load:function(e,t){var n=0,r=this;return xY.each(e,(function(e,i){var o=wZ.createImage();t&&(o.crossOrigin=t),o.onload=function(){0===--n&&(r.dirty(),r.trigger("success",r))},o.onerror=function(){n--},n++,o.src=e,r.image[i]=o})),this}});function T$(e){return e.width>0&&e.height>0}Object.defineProperty(S$.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(S$.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}});var M$=h$.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=h$.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),C$="framebuffer",D$="renderbuffer",A$=D$+"_width",I$=D$+"_height",E$=D$+"_attached",L$="depthtexture_attached",N$=pZ,P$=fZ,O$=vZ,R$=mZ,k$=bY.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},(function(){this._cache=new DK,this._textures={}}),{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(e){if(e.__currentFrameBuffer){if(e.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}e.__currentFrameBuffer=this;var t=e.gl;t.bindFramebuffer(N$,this._getFrameBufferGL(e)),this._boundRenderer=e;var n=this._cache;n.put("viewport",e.viewport);var r,i,o=!1;for(var a in this._textures){o=!0;var s=this._textures[a];s&&(r=s.texture.width,i=s.texture.height,this._doAttach(e,s.texture,a,s.target))}this._width=r,this._height=i,!o&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?e.setViewport(this.viewport):e.setViewport(0,0,r,i,1);var l=n.get("attached_textures");if(l)for(var a in l)if(!this._textures[a]){var u=l[a];this._doDetach(t,a,u)}if(!n.get(L$)&&this.depthBuffer){n.miss(D$)&&n.put(D$,t.createRenderbuffer());var c=n.get(D$);r===n.get(A$)&&i===n.get(I$)||(t.bindRenderbuffer(P$,c),t.renderbufferStorage(P$,t.DEPTH_COMPONENT16,r,i),n.put(A$,r),n.put(I$,i),t.bindRenderbuffer(P$,null)),n.get(E$)||(t.framebufferRenderbuffer(N$,O$,P$,c),n.put(E$,!0))}},unbind:function(e){e.__currentFrameBuffer=null,e.gl.bindFramebuffer(N$,null),this._boundRenderer=null,this._cache.use(e.__uid__);var t=this._cache.get("viewport");t&&e.setViewport(t),this.updateMipmap(e)},updateMipmap:function(e){var t=e.gl;for(var n in this._textures){var r=this._textures[n];if(r){var i=r.texture;if(!i.NPOT&&i.useMipmap&&i.minFilter===AK.LINEAR_MIPMAP_LINEAR){var o="textureCube"===i.textureType?uZ:lZ;t.bindTexture(o,i.getWebGLTexture(e)),t.generateMipmap(o),t.bindTexture(o,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(N$)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(C$)&&t.put(C$,e.gl.createFramebuffer()),t.get(C$)},attach:function(e,t,n){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||R$,n=n||lZ;var r,i=this._boundRenderer;if(i&&i.gl){var o=this._cache;o.use(i.__uid__),r=o.get("attached_textures")}var a=this._textures[t];if(!a||a.target!==n||a.texture!==e||!r||null==r[t]){var s=!0;i&&(s=this._doAttach(i,e,t,n),this.viewport||i.setViewport(0,0,e.width,e.height,1)),s&&(this._textures[t]=this._textures[t]||{},this._textures[t].texture=e,this._textures[t].target=n)}},_doAttach:function(e,t,n,r){var i=e.gl,o=t.getWebGLTexture(e),a=this._cache.get("attached_textures");if(a&&a[n]){var s=a[n];if(s.texture===t&&s.target===r)return}var l=!0;if(((n=+n)===O$||n===_Z)&&(e.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==KY&&t.format!==gZ&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var u=this._cache.get(D$);u&&(i.framebufferRenderbuffer(N$,O$,P$,null),i.deleteRenderbuffer(u),this._cache.put(D$,!1)),this._cache.put(E$,!1),this._cache.put(L$,!0)}return i.framebufferTexture2D(N$,n,r,o,0),a||(a={},this._cache.put("attached_textures",a)),a[n]=a[n]||{},a[n].texture=t,a[n].target=r,l},_doDetach:function(e,t,n){e.framebufferTexture2D(N$,t,n,null,0);var r=this._cache.get("attached_textures");r&&r[t]&&(r[t]=null),t!==O$&&t!==_Z||this._cache.put(L$,!1)},detach:function(e,t){(this._textures[e]=null,this._boundRenderer)&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,e,t))},dispose:function(e){var t=e.gl,n=this._cache;n.use(e.__uid__);var r=n.get(D$);r&&t.deleteRenderbuffer(r);var i=n.get(C$);i&&t.deleteFramebuffer(i),n.deleteContext(e.__uid__),this._textures={}}});k$.DEPTH_ATTACHMENT=O$,k$.COLOR_ATTACHMENT0=R$,k$.STENCIL_ATTACHMENT=yZ,k$.DEPTH_STENCIL_ATTACHMENT=_Z;var z$=["px","nx","py","ny","pz","nz"],V$=bY.extend((function(){var e={position:new Bq,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new M$({fov:90}),nx:new M$({fov:90}),py:new M$({fov:90}),ny:new M$({fov:90}),pz:new M$({fov:90}),nz:new M$({fov:90})};return t.px.lookAt(Bq.POSITIVE_X,Bq.NEGATIVE_Y),t.nx.lookAt(Bq.NEGATIVE_X,Bq.NEGATIVE_Y),t.py.lookAt(Bq.POSITIVE_Y,Bq.POSITIVE_Z),t.ny.lookAt(Bq.NEGATIVE_Y,Bq.NEGATIVE_Z),t.pz.lookAt(Bq.POSITIVE_Z,Bq.NEGATIVE_Y),t.nz.lookAt(Bq.NEGATIVE_Z,Bq.NEGATIVE_Y),e._frameBuffer=new k$,e}),{getCamera:function(e){return this._cameras[e]},render:function(e,t,n){var r=e.gl;n||t.update();for(var i=this.texture.width,o=2*Math.atan(i/(i-.5))/Math.PI*180,a=0;a<6;a++){var s=z$[a],l=this._cameras[s];if(Bq.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=o,this.shadowMapPass){l.update();var u=t.getBoundingBox();u.applyTransform(l.viewMatrix),t.viewBoundingBoxLastFrame.copy(u),this.shadowMapPass.render(e,t,l,!0)}this._frameBuffer.attach(this.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a),this._frameBuffer.bind(e),e.render(t,l,!0),this._frameBuffer.unbind(e)}},dispose:function(e){this._frameBuffer.dispose(e)}}),B$=WK.extend({dynamic:!1,widthSegments:1,heightSegments:1},(function(){this.build()}),{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,r=[],i=[],o=[],a=[],s=0;s<=e;s++)for(var l=s/e,u=0;u<=t;u++){var c=u/t;if(r.push([2*c-1,2*l-1,0]),i.push([c,l]),o.push([0,0,1]),u<t&&s<e){var h=u+s*(t+1);a.push([h,h+1,h+t+1]),a.push([h+t+1,h+1,h+t+2])}}n.position.fromArray(r),n.texcoord0.fromArray(i),n.normal.fromArray(o),this.initIndicesFromArray(a),this.boundingBox=new _K,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),F$=new iK,G$=WK.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},(function(){this.build()}),{build:function(){var e={px:H$("px",this.depthSegments,this.heightSegments),nx:H$("nx",this.depthSegments,this.heightSegments),py:H$("py",this.widthSegments,this.depthSegments),ny:H$("ny",this.widthSegments,this.depthSegments),pz:H$("pz",this.widthSegments,this.heightSegments),nz:H$("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],n=0,r=0;for(var i in e)n+=e[i].vertexCount,r+=e[i].indices.length;for(var o=0;o<t.length;o++)this.attributes[t[o]].init(n);this.indices=new wZ.Uint16Array(r);var a=0,s=0;for(var i in e){var l=e[i];for(o=0;o<t.length;o++)for(var u=t[o],c=l.attributes[u].value,h=l.attributes[u].size,d="normal"===u,p=0;p<c.length;p++){var f=c[p];this.inside&&d&&(f=-f),this.attributes[u].value[p+h*s]=f}var g=l.indices.length;for(p=0;p<l.indices.length;p++)this.indices[p+a]=s+l.indices[this.inside?g-p-1:p];a+=l.indices.length,s+=l.vertexCount}this.boundingBox=new _K,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});function H$(e,t,n){F$.identity();var r=new B$({widthSegments:t,heightSegments:n});switch(e){case"px":iK.translate(F$,F$,Bq.POSITIVE_X),iK.rotateY(F$,F$,Math.PI/2);break;case"nx":iK.translate(F$,F$,Bq.NEGATIVE_X),iK.rotateY(F$,F$,-Math.PI/2);break;case"py":iK.translate(F$,F$,Bq.POSITIVE_Y),iK.rotateX(F$,F$,-Math.PI/2);break;case"ny":iK.translate(F$,F$,Bq.NEGATIVE_Y),iK.rotateX(F$,F$,Math.PI/2);break;case"pz":iK.translate(F$,F$,Bq.POSITIVE_Z);break;case"nz":iK.translate(F$,F$,Bq.NEGATIVE_Z),iK.rotateY(F$,F$,Math.PI)}return r.applyTransform(F$),r}bq.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");var U$=IK.extend((function(){var e=new bq({vertex:bq.source("clay.skybox.vertex"),fragment:bq.source("clay.skybox.fragment")}),t=new WZ({shader:e,depthMask:!1});return{scene:null,geometry:new G$,material:t,environmentMap:null,culling:!1,_dummyCamera:new M$}}),(function(){var e=this.scene;e&&this.attachScene(e),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)}),{attachScene:function(e){this.scene&&this.detachScene(),e.skybox=this,this.scene=e,e.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(e){this.detachScene(),this.geometry.dispose(e)},setEnvironmentMap:function(e){"texture2D"===e.textureType?(this.material.define("EQUIRECTANGULAR"),e.minFilter=AK.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,n){this.renderSkybox(e,n)},renderSkybox:function(e,t){var n=this._dummyCamera;n.aspect=e.getViewportAspect(),n.fov=t.fov||50,n.updateProjectionMatrix(),iK.invert(n.invProjectionMatrix,n.projectionMatrix),n.worldTransform.copy(t.worldTransform),n.viewMatrix.copy(t.viewMatrix),this.position.copy(t.getWorldPosition()),this.update(),e.gl.disable(e.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],n)}});function W$(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var j$=W$("DXT1"),X$=W$("DXT3"),Y$=W$("DXT5"),Z$=function(e,t){var n=new Int32Array(e,0,31);if(542327876!==n[0])return null;if(4&!n(20))return null;var r,i,o=n(21),a=n[4],s=n[3],l=512&n[28],u=131072&n[2];switch(o){case j$:r=8,i=AK.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case X$:r=16,i=AK.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case Y$:r=16,i=AK.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var c=n[1]+4,h=l?6:1,d=1;u&&(d=Math.max(1,n[7]));for(var p=[],f=0;f<h;f++){var g=a,m=s;p[f]=new PK({width:g,height:m,format:i});for(var v=[],y=0;y<d;y++){var _=Math.max(4,g)/4*Math.max(4,m)/4*r,x=new Uint8Array(e,c,_);c+=_,g*=.5,m*=.5,v[y]=x}p[f].pixels=v[0],u&&(p[f].mipmaps=v)}if(!t)return p[0];t.width=p[0].width,t.height=p[0].height,t.format=p[0].format,t.pixels=p[0].pixels,t.mipmaps=p[0].mipmaps},q$=String.fromCharCode;function K$(e,t,n,r){if(e[3]>0){var i=Math.pow(2,e[3]-128-8+r);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function $$(e,t,n,r){for(var i,o,a=0,s=0,l=r;l>0;)if(e[s][0]=t[n++],e[s][1]=t[n++],e[s][2]=t[n++],e[s][3]=t[n++],1===e[s][0]&&1===e[s][1]&&1===e[s][2]){for(var u=e[s][3]<<a>>>0;u>0;u--)i=e[s-1],(o=e[s])[0]=i[0],o[1]=i[1],o[2]=i[2],o[3]=i[3],s++,l--;a+=8}else s++,l--,a=0;return n}function J$(e,t,n,r){if(r<8|r>32767)return $$(e,t,n,r);if(2!=(i=t[n++]))return $$(e,t,n-1,r);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==r)return null;for(var i=0;i<4;i++)for(var o=0;o<r;){var a=t[n++];if(a>128){a=(127&a)>>>0;for(var s=t[n++];a--;)e[o++][i]=s}else for(;a--;)e[o++][i]=t[n++]}return n}var Q$=function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),i=r.length;if("#?"===function(e,t,n){for(var r="",i=t;i<n;i++)r+=q$(e[i]);return r}(r,0,2)){for(var o=2;o<i&&("\n"!==q$(r[o])||"\n"!==q$(r[o+1]));o++);if(!(o>=i)){o+=2;for(var a="";o<i;o++){var s=q$(r[o]);if("\n"===s)break;a+=s}var l=a.split(" "),u=parseInt(l[1]),c=parseInt(l[3]);if(c&&u){for(var h=o+1,d=[],p=0;p<c;p++){d[p]=[];for(var f=0;f<4;f++)d[p][f]=0}for(var g=new Float32Array(c*u*4),m=0,v=0;v<u;v++){if(!(h=J$(d,r,h,c)))return null;for(p=0;p<c;p++)K$(d[p],g,m,n),m+=4}return t||(t=new PK),t.width=c,t.height=u,t.pixels=g,t.type=AK.FLOAT,t}}}},eJ={loadTexture:function(e,t,n,r){var i;if("function"==typeof t?(r=n=t,t={}):t=t||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===t.fileType)return i=new PK({width:0,height:0,sRGB:!1}),eJ._fetchTexture(e,(function(e){Q$(e,i,t.exposure),i.dirty(),n&&n(i)}),r),i;e.match(/.dds$/)||"dds"===t.fileType?(i=new PK({width:0,height:0}),eJ._fetchTexture(e,(function(e){Z$(e,i),i.dirty(),n&&n(i)}),r)):((i=new PK).load(e),i.success(n),i.error(r))}else"object"==typeof e&&void 0!==e.px&&((i=new S$).load(e),i.success(n),i.error(r));return i},loadPanorama:function(e,t,n,r,i,o){var a=this;"function"==typeof r?(o=i=r,r={}):r=r||{},eJ.loadTexture(t,r,(function(t){t.flipY=r.flipY||!1,a.panoramaToCubeMap(e,t,n,r),t.dispose(e),i&&i(n)}),o)},panoramaToCubeMap:function(e,t,n,r){var i=new V$,o=new U$({scene:new _$});return o.setEnvironmentMap(t),(r=r||{}).encodeRGBM&&o.material.define("fragment","RGBM_ENCODE"),n.sRGB=t.sRGB,i.texture=n,i.render(e,o.scene),i.texture=null,i.dispose(e),n},heightToNormal:function(e,t){var n=document.createElement("canvas"),r=n.width=e.width,i=n.height=e.height,o=n.getContext("2d");o.drawImage(e,0,0,r,i),t=t||!1;for(var a=o.getImageData(0,0,r,i),s=o.createImageData(r,i),l=0;l<a.data.length;l+=4){if(t){var u=a.data[l],c=a.data[l+1],h=a.data[l+2];if(Math.abs(u-c)+Math.abs(c-h)>20)return console.warn("Given image is not a height map"),e}var d,p,f,g;l%(4*r)==0?(d=a.data[l],f=a.data[l+4]):l%(4*r)==4*(r-1)?(d=a.data[l-4],f=a.data[l]):(d=a.data[l-4],f=a.data[l+4]),l<4*r?(p=a.data[l],g=a.data[l+4*r]):l>r*(i-1)*4?(p=a.data[l-4*r],g=a.data[l]):(p=a.data[l-4*r],g=a.data[l+4*r]),s.data[l]=d-f+127,s.data[l+1]=p-g+127,s.data[l+2]=255,s.data[l+3]=255}return o.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var r=document.createElement("canvas"),i=r.getContext("2d"),o=t||32;n=n||20,r.width=r.height=o,i.drawImage(e,0,0,o,o);for(var a=i.getImageData(0,0,o,o),s=0;s<a.data.length;s+=4){var l=a.data[s],u=a.data[s+1],c=a.data[s+2];if(Math.abs(l-u)+Math.abs(u-c)>n)return!1}return!0},_fetchTexture:function(e,t,n){wZ.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,r){e=e||512,t=t||64,n=n||"black",r=r||"white";var i=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var a=o.getContext("2d");a.fillStyle=r,a.fillRect(0,0,e,e),a.fillStyle=n;for(var s=0;s<i;s++)for(var l=0;l<i;l++){(l%2?s%2:s%2-1)&&a.fillRect(s*t,l*t,t,t)}return new PK({image:o,anisotropic:8})},createBlank:function(e){var t=document.createElement("canvas");t.width=1,t.height=1;var n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,1,1),new PK({image:t})}},tJ=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function nJ(e){return"_on"+e}var rJ=function(e){var t=this;this._texture=new PK({anisotropic:32,flipY:!1,surface:this,dispose:function(e){t.dispose(),PK.prototype.dispose.call(this,e)}}),tJ.forEach((function(e){this[nJ(e)]=function(t){t.triangle&&this._meshes.forEach((function(n){this.dispatchEvent(e,n,t.triangle,t.point)}),this)}}),this),this._meshes=[],e&&this.setECharts(e),this.onupdate=null};rJ.prototype={constructor:rJ,getTexture:function(){return this._texture},setECharts:function(e){this._chart=e;var t=e.getDom();if(t instanceof HTMLCanvasElement){var n=this,r=e.getZr(),i=r.__oldRefreshImmediately||r.refreshImmediately;r.refreshImmediately=function(){i.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},r.__oldRefreshImmediately=i}else console.error("ECharts must init on canvas if it is used as texture."),t=document.createElement("canvas");this._texture.image=t,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var e=new Bq,t=new Bq,n=new Bq,r=new qZ,i=new qZ,o=new qZ,a=new qZ,s=new Bq;return function(l,u,c,h){var d=u.geometry,p=d.attributes.position,f=d.attributes.texcoord0,g=Bq.dot,m=Bq.cross;p.get(c[0],e.array),p.get(c[1],t.array),p.get(c[2],n.array),f.get(c[0],r.array),f.get(c[1],i.array),f.get(c[2],o.array),m(s,t,n);var v=g(e,s),y=g(h,s)/v;m(s,n,e);var _=g(h,s)/v;m(s,e,t);var x=g(h,s)/v;qZ.scale(a,r,y),qZ.scaleAndAdd(a,a,i,_),qZ.scaleAndAdd(a,a,o,x);var b=a.x*this._chart.getWidth(),w=a.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:b,zrY:w})}}(),attachToMesh:function(e){this._meshes.indexOf(e)>=0||(tJ.forEach((function(t){e.on(t,this[nJ(t)],this)}),this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),tJ.forEach((function(t){e.off(t,this[nJ(t)])}),this)},dispose:function(){this._meshes.forEach((function(e){this.detachFromMesh(e)}),this)}};var iJ=h$.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=h$.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});bq.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var oJ=new B$,aJ=new IK({geometry:oJ,frustumCulling:!1}),sJ=new iJ,lJ=bY.extend((function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}}),(function(){var e=new bq(bq.source("clay.compositor.vertex"),this.fragment),t=new WZ({shader:e});t.enableTexturesAll(),this.material=t}),{setUniform:function(e,t){this.material.setUniform(e,t)},getUniform:function(e){var t=this.material.uniforms[e];if(t)return t.value},attachOutput:function(e,t){this.outputs||(this.outputs={}),t=t||mZ,this.outputs[t]=e},detachOutput:function(e){for(var t in this.outputs)this.outputs[t]===e&&(this.outputs[t]=null)},bind:function(e,t){if(this.outputs)for(var n in this.outputs){var r=this.outputs[n];r&&t.attach(r,n)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var n=e.gl;if(t){this.bind(e,t);var r=e.getGLExtension("EXT_draw_buffers");if(r&&this.outputs){var i=[];for(var o in this.outputs)(o=+o)>=n.COLOR_ATTACHMENT0&&o<=n.COLOR_ATTACHMENT0+8&&i.push(o);r.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var a=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){a|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(a),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){aJ.material=this.material,e.renderPass([aJ],sJ)},dispose:function(e){}}),uJ={},cJ=["px","nx","py","ny","pz","nz"];uJ.prefilterEnvironmentMap=function(e,t,n,r,i){i&&r||(r=uJ.generateNormalDistribution(),i=uJ.integrateBRDF(e,r));var o=(n=n||{}).width||64,a=n.height||64,s=n.type||t.type,l=new S$({width:o,height:a,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var u=Math.min(o,a),c=Math.log(u)/Math.log(2)+1,h=new WZ({shader:new bq({vertex:bq.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});h.set("normalDistribution",r),n.encodeRGBM&&h.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&h.define("fragment","RGBM_DECODE");var d,p=new _$;if("texture2D"===t.textureType){var f=new S$({width:o,height:a,type:s===AK.FLOAT?AK.HALF_FLOAT:s});eJ.panoramaToCubeMap(e,t,f,{encodeRGBM:n.decodeRGBM}),t=f}(d=new U$({scene:p,material:h})).material.set("environmentMap",t);var g=new V$({texture:l});n.encodeRGBM&&(s=l.type=AK.UNSIGNED_BYTE);for(var m=new PK({width:o,height:a,type:s}),v=new k$({depthBuffer:!1}),y=wZ[s===AK.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],_=0;_<c;_++){l.mipmaps[_]={pixels:{}},d.material.set("roughness",_/(c-1));for(var x=m.width,b=2*Math.atan(x/(x-.5))/Math.PI*180,w=0;w<cJ.length;w++){var S=new y(m.width*m.height*4);v.attach(m),v.bind(e);var T=g.getCamera(cJ[w]);T.fov=b,e.render(p,T),e.gl.readPixels(0,0,m.width,m.height,AK.RGBA,s,S),v.unbind(e),l.mipmaps[_].pixels[cJ[w]]=S}m.width/=2,m.height/=2,m.dirty()}return v.dispose(e),m.dispose(e),d.dispose(e),r.dispose(e),{environmentMap:l,brdfLookup:i,normalDistribution:r,maxMipmapLevel:c}},uJ.integrateBRDF=function(e,t){t=t||uJ.generateNormalDistribution();var n=new k$({depthBuffer:!1}),r=new lJ({fragment:"#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),i=new PK({width:512,height:256,type:AK.HALF_FLOAT,wrapS:AK.CLAMP_TO_EDGE,wrapT:AK.CLAMP_TO_EDGE,minFilter:AK.NEAREST,magFilter:AK.NEAREST,useMipmap:!1});return r.setUniform("normalDistribution",t),r.setUniform("viewportSize",[512,256]),r.attachOutput(i),r.render(e,n),n.dispose(e),i},uJ.generateNormalDistribution=function(e,t){for(var n=new PK({width:e=e||256,height:t=t||1024,type:AK.FLOAT,minFilter:AK.NEAREST,magFilter:AK.NEAREST,wrapS:AK.CLAMP_TO_EDGE,wrapT:AK.CLAMP_TO_EDGE,useMipmap:!1}),r=new Float32Array(t*e*4),i=[],o=0;o<e;o++){for(var a=o/e,s=a*a,l=0;l<t;l++){var u=(l<<16|l>>>16)>>>0;u=(((16711935&(u=((252645135&(u=((858993459&(u=((1431655765&u)<<1|(2863311530&u)>>>1)>>>0))<<2|(3435973836&u)>>>2)>>>0))<<4|(4042322160&u)>>>4)>>>0))<<8|(4278255360&u)>>>8)>>>0)/4294967296;var c=Math.sqrt((1-u)/(1+(s*s-1)*u));i[l]=c}for(l=0;l<t;l++){var h=4*(l*e+o),d=(c=i[l],Math.sqrt(1-c*c)),p=l/t,f=2*Math.PI*p;r[h]=d*Math.cos(f),r[h+1]=c,r[h+2]=d*Math.sin(f),r[h+3]=1}}return n.pixels=r,n};var hJ=t$.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){if(e.getGLExtension("EXT_shader_texture_lod")){this._brdfLookup||(this._normalDistribution=uJ.generateNormalDistribution(),this._brdfLookup=uJ.integrateBRDF(e,this._normalDistribution));var n=this.cubemap;if(!n.__prefiltered){var r=uJ.prefilterEnvironmentMap(e,n,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=r.environmentMap,this.cubemap.__prefiltered=!0,n.dispose(e)}}else console.warn("Device not support textureCubeLodEXT")},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}}),dJ=t$.extend({castShadow:!1,coefficients:[]},(function(){this._coefficientsTmpArr=new wZ.Float32Array(27)}),{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,n=0;n<e.coefficients.length;n++)t[n]=e.coefficients[n];return t}}}}),pJ={},fJ=["px","nx","py","ny","pz","nz"];function gJ(e,t){var n=e[0],r=e[1],i=e[2];return 0===t?1:1===t?n:2===t?r:3===t?i:4===t?n*i:5===t?r*i:6===t?n*r:7===t?3*i*i-1:n*n-r*r}var mJ={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};pJ.projectEnvironmentMap=function(e,t,n){var r;(n=n||{}).lod=n.lod||0;var i=new _$,o=64;"texture2D"===t.textureType||(o=t.image&&t.image.px?t.image.px.width:t.width),r=new U$({scene:i,environmentMap:t});var a=Math.ceil(o/Math.pow(2,n.lod)),s=Math.ceil(o/Math.pow(2,n.lod)),l=new PK({width:a,height:s}),u=new k$;r.material.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&r.material.define("fragment","RGBM_DECODE"),r.material.set("lod",n.lod);for(var c=new V$({texture:l}),h={},d=0;d<fJ.length;d++){h[fJ[d]]=new Uint8Array(a*s*4);var p=c.getCamera(fJ[d]);p.fov=90,u.attach(l),u.bind(e),e.render(i,p),e.gl.readPixels(0,0,a,s,AK.RGBA,AK.UNSIGNED_BYTE,h[fJ[d]]),u.unbind(e)}return r.dispose(e),u.dispose(e),l.dispose(e),function(e,t,n,r){for(var i=new wZ.Float32Array(27),o=Cq.create(),a=Cq.create(),s=Cq.create(),l=0;l<9;l++){for(var u=Cq.create(),c=0;c<fJ.length;c++){for(var h=t[fJ[c]],d=Cq.create(),p=0,f=0,g=mJ[fJ[c]],m=0;m<r;m++)for(var v=0;v<n;v++){o[0]=v/(n-1)*2-1,o[1]=m/(r-1)*2-1,o[2]=-1,Cq.normalize(o,o),s[0]=o[g[0]]*g[3],s[1]=o[g[1]]*g[4],s[2]=o[g[2]]*g[5],a[0]=h[f++]/255,a[1]=h[f++]/255,a[2]=h[f++]/255;var y=h[f++]/255*8.12;a[0]*=y,a[1]*=y,a[2]*=y,Cq.scaleAndAdd(d,d,a,gJ(s,l)*-o[2]),p+=-o[2]}Cq.scaleAndAdd(u,u,d,1/p)}i[3*l]=u[0]/6,i[3*l+1]=u[1]/6,i[3*l+2]=u[2]/6}return i}(0,h,a,s)};var vJ=function(){for(var e=0,t=arguments.length;e<t;e++)if(null!=arguments[e])return arguments[e]},yJ=function(e,t){return null!=t.dataIndexInside?t.dataIndexInside:null!=t.dataIndex?J(t.dataIndex)?j(t.dataIndex,(function(t){return e.indexOfRawIndex(t)})):e.indexOfRawIndex(t.dataIndex):null!=t.name?J(t.name)?j(t.name,(function(t){return e.indexOfName(t)})):e.indexOfName(t.name):void 0},_J=WK.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},(function(){this.build()}),{build:function(){var e=this.heightSegments,t=this.widthSegments,n=this.attributes.position,r=this.attributes.texcoord0,i=this.attributes.normal,o=(t+1)*(e+1);n.init(o),r.init(o),i.init(o);var a,s,l,u,c,h,d,p,f,g,m,v=o>65535?Uint32Array:Uint16Array,y=this.indices=new v(t*e*6),_=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,S=this.thetaLength,T=[],M=[],C=0,D=1/(_=this.radius);for(d=0;d<=e;d++)for(h=0;h<=t;h++)u=h/t,c=d/e,a=-_*Math.cos(x+u*b)*Math.sin(w+c*S),s=_*Math.cos(w+c*S),l=_*Math.sin(x+u*b)*Math.sin(w+c*S),T[0]=a,T[1]=s,T[2]=l,M[0]=u,M[1]=c,n.set(C,T),r.set(C,M),T[0]*=D,T[1]*=D,T[2]*=D,i.set(C,T),C++;var A=t+1,I=0;for(d=0;d<e;d++)for(h=0;h<t;h++)f=d*A+h,p=d*A+h+1,m=(d+1)*A+h+1,g=(d+1)*A+h,y[I++]=p,y[I++]=f,y[I++]=m,y[I++]=f,y[I++]=g,y[I++]=m;this.boundingBox=new _K,this.boundingBox.max.set(_,_,_),this.boundingBox.min.set(-_,-_,-_)}}),xJ=t$.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}}),bJ=t$.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Bq,e.__dir.copy(e.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=t$.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),wJ=t$.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(e){return e.range}},pointLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=t$.prototype.clone.call(this);return e.range=this.range,e}}),SJ=t$.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(e){return e.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(e){return e.falloffFactor}},spotLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Bq,e.__dir.copy(e.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=t$.prototype.clone.call(this);return e.range=this.range,e.umbraAngle=this.umbraAngle,e.penumbraAngle=this.penumbraAngle,e.falloffFactor=this.falloffFactor,e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),TJ=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=r||0,this.array=$q.fromValues(e,t,n,r),this._dirty=!0};TJ.prototype={constructor:TJ,add:function(e){return $q.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new TJ(this.x,this.y,this.z,this.w)},copy:function(e){return $q.copy(this.array,e.array),this._dirty=!0,this},dist:function(e){return $q.dist(this.array,e.array)},distance:function(e){return $q.distance(this.array,e.array)},div:function(e){return $q.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return $q.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return $q.dot(this.array,e.array)},len:function(){return $q.len(this.array)},length:function(){return $q.length(this.array)},lerp:function(e,t,n){return $q.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return $q.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return $q.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return $q.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return $q.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return $q.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return $q.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return $q.random(this.array,e),this._dirty=!0,this},scale:function(e){return $q.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return $q.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return $q.sqrDist(this.array,e.array)},squaredDistance:function(e){return $q.squaredDistance(this.array,e.array)},sqrLen:function(){return $q.sqrLen(this.array)},squaredLength:function(){return $q.squaredLength(this.array)},sub:function(e){return $q.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return $q.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return $q.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return $q.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var MJ=Object.defineProperty;if(MJ){var CJ=TJ.prototype;MJ(CJ,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),MJ(CJ,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),MJ(CJ,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),MJ(CJ,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}TJ.add=function(e,t,n){return $q.add(e.array,t.array,n.array),e._dirty=!0,e},TJ.set=function(e,t,n,r,i){$q.set(e.array,t,n,r,i),e._dirty=!0},TJ.copy=function(e,t){return $q.copy(e.array,t.array),e._dirty=!0,e},TJ.distance=TJ.dist=function(e,t){return $q.distance(e.array,t.array)},TJ.div=function(e,t,n){return $q.divide(e.array,t.array,n.array),e._dirty=!0,e},TJ.divide=TJ.div,TJ.dot=function(e,t){return $q.dot(e.array,t.array)},TJ.len=function(e){return $q.length(e.array)},TJ.lerp=function(e,t,n,r){return $q.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},TJ.min=function(e,t,n){return $q.min(e.array,t.array,n.array),e._dirty=!0,e},TJ.max=function(e,t,n){return $q.max(e.array,t.array,n.array),e._dirty=!0,e},TJ.mul=function(e,t,n){return $q.multiply(e.array,t.array,n.array),e._dirty=!0,e},TJ.multiply=TJ.mul,TJ.negate=function(e,t){return $q.negate(e.array,t.array),e._dirty=!0,e},TJ.normalize=function(e,t){return $q.normalize(e.array,t.array),e._dirty=!0,e},TJ.random=function(e,t){return $q.random(e.array,t),e._dirty=!0,e},TJ.scale=function(e,t,n){return $q.scale(e.array,t.array,n),e._dirty=!0,e},TJ.scaleAndAdd=function(e,t,n,r){return $q.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},TJ.squaredDistance=TJ.sqrDist=function(e,t){return $q.sqrDist(e.array,t.array)},TJ.squaredLength=TJ.sqrLen=function(e){return $q.sqrLen(e.array)},TJ.sub=function(e,t,n){return $q.subtract(e.array,t.array,n.array),e._dirty=!0,e},TJ.subtract=TJ.sub,TJ.transformMat4=function(e,t,n){return $q.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},TJ.transformQuat=function(e,t,n){return $q.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var DJ={create:function(){var e=new XZ(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},clone:function(e){var t=new XZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},transpose:function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(a=1/a,e[0]=o*a,e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null},adjoint:function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},determinant:function(e){return e[0]*e[3]-e[2]*e[1]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*s+o*l,e[1]=i*s+a*l,e[2]=r*u+o*c,e[3]=i*u+a*c,e}};DJ.mul=DJ.multiply,DJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l,e},DJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1];return e[0]=r*s,e[1]=i*s,e[2]=o*l,e[3]=a*l,e},DJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2))},DJ.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]};var AJ=function(){this.array=DJ.create(),this._dirty=!0};AJ.prototype={constructor:AJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new AJ).copy(this)},copy:function(e){return DJ.copy(this.array,e.array),this._dirty=!0,this},adjoint:function(){return DJ.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return DJ.determinant(this.array)},identity:function(){return DJ.identity(this.array),this._dirty=!0,this},invert:function(){return DJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return DJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return DJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return DJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return DJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return DJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return DJ.scale(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return DJ.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},AJ.adjoint=function(e,t){return DJ.adjoint(e.array,t.array),e._dirty=!0,e},AJ.copy=function(e,t){return DJ.copy(e.array,t.array),e._dirty=!0,e},AJ.determinant=function(e){return DJ.determinant(e.array)},AJ.identity=function(e){return DJ.identity(e.array),e._dirty=!0,e},AJ.invert=function(e,t){return DJ.invert(e.array,t.array),e._dirty=!0,e},AJ.mul=function(e,t,n){return DJ.mul(e.array,t.array,n.array),e._dirty=!0,e},AJ.multiply=AJ.mul,AJ.rotate=function(e,t,n){return DJ.rotate(e.array,t.array,n),e._dirty=!0,e},AJ.scale=function(e,t,n){return DJ.scale(e.array,t.array,n.array),e._dirty=!0,e},AJ.transpose=function(e,t){return DJ.transpose(e.array,t.array),e._dirty=!0,e};var IJ={create:function(){var e=new XZ(6);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},clone:function(e){var t=new XZ(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n*o-r*i;return l?(l=1/l,e[0]=o*l,e[1]=-r*l,e[2]=-i*l,e[3]=n*l,e[4]=(i*s-o*a)*l,e[5]=(r*a-n*s)*l,e):null},determinant:function(e){return e[0]*e[3]-e[1]*e[2]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1],h=n[2],d=n[3],p=n[4],f=n[5];return e[0]=r*u+o*c,e[1]=i*u+a*c,e[2]=r*h+o*d,e[3]=i*h+a*d,e[4]=r*p+o*f+s,e[5]=i*p+a*f+l,e}};IJ.mul=IJ.multiply,IJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=Math.sin(n),c=Math.cos(n);return e[0]=r*c+o*u,e[1]=i*c+a*u,e[2]=r*-u+o*c,e[3]=i*-u+a*c,e[4]=s,e[5]=l,e},IJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r*u,e[1]=i*u,e[2]=o*c,e[3]=a*c,e[4]=s,e[5]=l,e},IJ.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=r*u+o*c+s,e[5]=i*u+a*c+l,e},IJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+1)};var EJ=function(){this.array=IJ.create(),this._dirty=!0};EJ.prototype={constructor:EJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new EJ).copy(this)},copy:function(e){return IJ.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return IJ.determinant(this.array)},identity:function(){return IJ.identity(this.array),this._dirty=!0,this},invert:function(){return IJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return IJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return IJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return IJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return IJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return IJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return IJ.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return IJ.translate(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},EJ.copy=function(e,t){return IJ.copy(e.array,t.array),e._dirty=!0,e},EJ.determinant=function(e){return IJ.determinant(e.array)},EJ.identity=function(e){return IJ.identity(e.array),e._dirty=!0,e},EJ.invert=function(e,t){return IJ.invert(e.array,t.array),e._dirty=!0,e},EJ.mul=function(e,t,n){return IJ.mul(e.array,t.array,n.array),e._dirty=!0,e},EJ.multiply=EJ.mul,EJ.rotate=function(e,t,n){return IJ.rotate(e.array,t.array,n),e._dirty=!0,e},EJ.scale=function(e,t,n){return IJ.scale(e.array,t.array,n.array),e._dirty=!0,e},EJ.translate=function(e,t,n){return IJ.translate(e.array,t.array,n.array),e._dirty=!0,e};var LJ=function(){this.array=Jq.create(),this._dirty=!0};LJ.prototype={constructor:LJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return Jq.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new LJ).copy(this)},copy:function(e){return Jq.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Jq.determinant(this.array)},fromMat2d:function(e){return Jq.fromMat2d(this.array,e.array),this._dirty=!0,this},fromMat4:function(e){return Jq.fromMat4(this.array,e.array),this._dirty=!0,this},fromQuat:function(e){return Jq.fromQuat(this.array,e.array),this._dirty=!0,this},identity:function(){return Jq.identity(this.array),this._dirty=!0,this},invert:function(){return Jq.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return Jq.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Jq.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Jq.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Jq.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return Jq.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Jq.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Jq.translate(this.array,this.array,e.array),this._dirty=!0,this},normalFromMat4:function(e){return Jq.normalFromMat4(this.array,e.array),this._dirty=!0,this},transpose:function(){return Jq.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},LJ.adjoint=function(e,t){return Jq.adjoint(e.array,t.array),e._dirty=!0,e},LJ.copy=function(e,t){return Jq.copy(e.array,t.array),e._dirty=!0,e},LJ.determinant=function(e){return Jq.determinant(e.array)},LJ.identity=function(e){return Jq.identity(e.array),e._dirty=!0,e},LJ.invert=function(e,t){return Jq.invert(e.array,t.array),e},LJ.mul=function(e,t,n){return Jq.mul(e.array,t.array,n.array),e._dirty=!0,e},LJ.multiply=LJ.mul,LJ.fromMat2d=function(e,t){return Jq.fromMat2d(e.array,t.array),e._dirty=!0,e},LJ.fromMat4=function(e,t){return Jq.fromMat4(e.array,t.array),e._dirty=!0,e},LJ.fromQuat=function(e,t){return Jq.fromQuat(e.array,t.array),e._dirty=!0,e},LJ.normalFromMat4=function(e,t){return Jq.normalFromMat4(e.array,t.array),e._dirty=!0,e},LJ.rotate=function(e,t,n){return Jq.rotate(e.array,t.array,n),e._dirty=!0,e},LJ.scale=function(e,t,n){return Jq.scale(e.array,t.array,n.array),e._dirty=!0,e},LJ.transpose=function(e,t){return Jq.transpose(e.array,t.array),e._dirty=!0,e},LJ.translate=function(e,t,n){return Jq.translate(e.array,t.array,n.array),e._dirty=!0,e};var NJ={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(e,t){this._animators=this._animators||[];var n;if(e){for(var r=e.split("."),i=this,o=0,a=r.length;o<a;o++)i&&(i=i[r[o]]);i&&(n=i)}else n=this;if(null==n)throw new Error("Target "+e+" not exists");var s=this._animators,l=new Wr(n,t),u=this;return l.during((function(){u.__zr&&u.__zr.refresh()})).done((function(){var e=s.indexOf(l);e>=0&&s.splice(e,1)})),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,n=t.length,r=0;r<n;r++)t[r].stop(e);return t.length=0,this},addAnimatorsToZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.addAnimator(this._animators[t])},removeAnimatorsFromZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.removeAnimator(this._animators[t])}},PJ="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return 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 return 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}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end";function OJ(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}Object.assign(SK.prototype,NJ),bq.import(PJ),bq.import(Tq),bq.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),bq.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),bq.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),bq.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),bq.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),bq.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var RJ=_$.prototype.addToScene,kJ=_$.prototype.removeFromScene;_$.prototype.addToScene=function(e){if(RJ.call(this,e),this.__zr){var t=this.__zr;e.traverse((function(e){e.__zr=t,e.addAnimatorsToZr&&e.addAnimatorsToZr(t)}))}},_$.prototype.removeFromScene=function(e){kJ.call(this,e),e.traverse((function(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}))},WZ.prototype.setTextureImage=function(e,t,n,r){if(this.shader){var i,o,a=n.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(e),(o=t)&&"none"!==o&&(i=zJ.loadTexture(t,n,r,(function(t){s.enableTexture(e),a&&a.refresh()})),s.set(e,i)),i}};var zJ={};zJ.Renderer=zq,zJ.Node=SK,zJ.Mesh=IK,zJ.Shader=bq,zJ.Material=WZ,zJ.Texture=AK,zJ.Texture2D=PK,zJ.Geometry=WK,zJ.SphereGeometry=_J,zJ.PlaneGeometry=B$,zJ.CubeGeometry=G$,zJ.AmbientLight=xJ,zJ.DirectionalLight=bJ,zJ.PointLight=wJ,zJ.SpotLight=SJ,zJ.PerspectiveCamera=M$,zJ.OrthographicCamera=iJ,zJ.Vector2=qZ,zJ.Vector3=Bq,zJ.Vector4=TJ,zJ.Quaternion=lK,zJ.Matrix2=AJ,zJ.Matrix2d=EJ,zJ.Matrix3=LJ,zJ.Matrix4=iK,zJ.Plane=n$,zJ.Ray=Kq,zJ.BoundingBox=_K,zJ.Frustum=u$;var VJ=null;function BJ(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function FJ(e){if((e.wrapS===AK.REPEAT||e.wrapT===AK.REPEAT)&&e.image){var t=BJ(e.width),n=BJ(e.height);if(t!==e.width||n!==e.height){var r=document.createElement("canvas");r.width=t,r.height=n,r.getContext("2d").drawImage(e.image,0,0,t,n),e.image=r}}}zJ.loadTexture=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n=n||{};for(var i=Object.keys(n).sort(),o="",a=0;a<i.length;a++)o+=i[a]+"_"+n[i[a]]+"_";var s,l=t.__textureCache=t.__textureCache||new Un(20);if((s=e).getZr&&s.setOption){var u=e.__textureid__;if(h=l.get(o+u))h.texture.surface.setECharts(e),r&&r(h.texture);else{var c=new rJ(e);c.onupdate=function(){t.getZr().refresh()},h={texture:c.getTexture()};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_ec__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),r&&r(h.texture)}return h.texture}if(OJ(e)){var h;u=e.__textureid__;if(!(h=l.get(o+u))){h={texture:new zJ.Texture2D({image:e})};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_image__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),FJ(h.texture),r&&r(h.texture)}return h.texture}if(h=l.get(o+e))h.callbacks?h.callbacks.push(r):r&&r(h.texture);else if(e.match(/.hdr$|^data:application\/octet-stream/)){h={callbacks:[r]};var d=eJ.loadTexture(e,{exposure:n.exposure,fileType:"hdr"},(function(){d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null}));h.texture=d,l.put(o+e,h)}else{for(d=new zJ.Texture2D({image:new Image}),a=0;a<i.length;a++)d[i[a]]=n[i[a]];h={texture:d,callbacks:[r]};var p=d.image;p.onload=function(){d.image=p,FJ(d),d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null},p.crossOrigin="Anonymous",p.src=e,d.image=null!==VJ?VJ:VJ=eJ.createBlank("rgba(255,255,255,0)").image,l.put(o+e,h)}return h.texture},zJ.createAmbientCubemap=function(e,t,n,r){var i=(e=e||{}).texture,o=vJ(e.exposure,1),a=new hJ({intensity:vJ(e.specularIntensity,1)}),s=new dJ({intensity:vJ(e.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return a.cubemap=zJ.loadTexture(i,n,{exposure:o},(function(){if(a.cubemap.flipY=!1,"production"!==process.env.NODE_ENV)var e=Date.now();if(a.prefilter(t,32),"production"!==process.env.NODE_ENV){var n=Date.now()-e;console.log("Prefilter environment map: "+n+"ms")}s.coefficients=pJ.projectEnvironmentMap(t,a.cubemap,{lod:1}),r&&r()})),{specular:a,diffuse:s}},zJ.createBlankTexture=eJ.createBlank,zJ.isImage=OJ,zJ.additiveBlend=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)},zJ.parseColor=function(e,t){return e instanceof Array?(t||(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],e.length>3?t[3]=e[3]:t[3]=1,t):((t=nr(e||"#000",t)||[0,0,0,0])[0]/=255,t[1]/=255,t[2]/=255,t)},zJ.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,r=-t/180*Math.PI+Math.PI/2,i=[],o=Math.sin(n);return i[0]=o*Math.cos(r),i[1]=-Math.cos(n),i[2]=o*Math.sin(r),i},zJ.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096}return t},zJ.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],zJ.createShader=function(e){"ecgl.shadow"===e&&(e="ecgl.displayShadow");var t=bq.source(e+".vertex"),n=bq.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),n||console.error("Fragment shader of '%s' not exits",e);var r=new bq(t,n);return r.name=e,r},zJ.createMaterial=function(e,t){t instanceof Array||(t=[t]);var n=zJ.createShader(e),r=new WZ({shader:n});return t.forEach((function(e){"string"==typeof e&&r.define(e)})),r},zJ.setMaterialFromModel=function(e,t,n,r){t.autoUpdateTextureStatus=!1;var i=n.getModel(e+"Material"),o=i.get("detailTexture"),a=vJ(i.get("textureTiling"),1),s=vJ(i.get("textureOffset"),0);"number"==typeof a&&(a=[a,a]),"number"==typeof s&&(s=[s,s]);var l=a[0]>1||a[1]>1?zJ.Texture.REPEAT:zJ.Texture.CLAMP_TO_EDGE,u={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===e){var c=i.get("roughness"),h=i.get("metalness");null!=h?isNaN(h)&&(t.setTextureImage("metalnessMap",h,r,u),h=vJ(i.get("metalnessAdjust"),.5)):h=0,null!=c?isNaN(c)&&(t.setTextureImage("roughnessMap",c,r,u),c=vJ(i.get("roughnessAdjust"),.5)):c=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",o,r,u),t.setTextureImage("normalMap",d,r,u),t.set({roughness:c,metalness:h,detailUvRepeat:a,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("hatching"===e){var p=i.get("hatchingTextures")||[];p.length<6&&"production"!==process.env.NODE_ENV&&console.error("Invalid hatchingTextures.");for(var f=0;f<6;f++)t.setTextureImage("hatch"+(f+1),p[f],r,{anisotropic:8,wrapS:zJ.Texture.REPEAT,wrapT:zJ.Texture.REPEAT});t.set({detailUvRepeat:a,detailUvOffset:s})}},zJ.updateVertexAnimation=function(e,t,n,r){var i=r.get("animation"),o=r.get("animationDurationUpdate"),a=r.get("animationEasingUpdate"),s=n.shadowDepthMaterial;if(i&&t&&o>0&&t.geometry.vertexCount===n.geometry.vertexCount){n.material.define("vertex","VERTEX_ANIMATION"),n.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<e.length;l++)n.geometry.attributes[e[l][0]].value=t.geometry.attributes[e[l][1]].value;n.geometry.dirty(),n.__percent=0,n.material.set("percent",0),n.stopAnimation(),n.animate().when(o,{__percent:1}).during((function(){n.material.set("percent",n.__percent),s&&s.set("percent",n.__percent)})).done((function(){n.ignorePreZ=!1,n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")})).start(a)}else n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")};var GJ=function(e,t){this.id=e,this.zr=t;try{this.renderer=new zq({clearBit:0,devicePixelRatio:t.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(t.painter.getWidth(),t.painter.getHeight())}catch(e){return this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",void console.error(e)}this.onglobalout=this.onglobalout.bind(this),t.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var n=this.dom.style;n.position="absolute",n.left="0",n.top="0",this.views=[],this._picking=new MK({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new tl({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null,this._disposed=!1};function HJ(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}GJ.prototype.setUnpainted=function(){},GJ.prototype.addView=function(e){if(e.layer!==this){var t=this._viewsToDispose.indexOf(e);t>=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var n=this.zr;e.scene.traverse((function(e){e.__zr=n,e.addAnimatorsToZr&&e.addAnimatorsToZr(n)}))}},GJ.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(HJ,this),e.layer=null,this._viewsToDispose.push(e))}},GJ.prototype.removeViewsAll=function(){this.views.forEach((function(e){e.scene.traverse(HJ,this),e.layer=null,this._viewsToDispose.push(e)}),this),this.views.length=0},GJ.prototype.resize=function(e,t){this.renderer.resize(e,t)},GJ.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)},GJ.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},GJ.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},GJ.prototype.needsRefresh=function(){this.zr.refresh()},GJ.prototype.refresh=function(e){this._backgroundColor=e?zJ.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t<this.views.length;t++)this.views[t].prepareRender(this.renderer);this._doRender(!1),this._trackAndClean();for(t=0;t<this._viewsToDispose.length;t++)this._viewsToDispose[t].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()},GJ.prototype.renderToCanvas=function(e){this._startAccumulating(!0),e.drawImage(this.dom,0,0,e.canvas.width,e.canvas.height)},GJ.prototype._doRender=function(e){this.clear(),this.renderer.saveViewport();for(var t=0;t<this.views.length;t++)this.views[t].render(this.renderer,e);this.renderer.restoreViewport()},GJ.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var UJ=1;function WJ(e){for(var t=0;t<e.length;t++)e[t].__used__=0}function jJ(e,t){for(var n=0;n<t.length;n++)t[n].__used__||t[n].dispose(e)}function XJ(e,t){e.__used__=e.__used__||0,e.__used__++,1===e.__used__&&t.push(e)}function YJ(e,t,n){var r,i;e.traverse((function(e){if(e.isRenderable()){var o=e.geometry,a=e.material;if(a!==r)for(var s=a.getTextureUniforms(),l=0;l<s.length;l++){var u=s[l],c=a.uniforms[u].value;if(c)if(c instanceof AK)XJ(c,t);else if(c instanceof Array)for(var h=0;h<c.length;h++)c[h]instanceof AK&&XJ(c[h],t)}o!==i&&XJ(o,n),r=a,i=o}}));for(var o=0;o<e.lights.length;o++)e.lights[o].cubemap&&XJ(e.lights[o].cubemap,t)}GJ.prototype._startAccumulating=function(e){var t=this;this._stopAccumulating();for(var n=!1,r=0;r<this.views.length;r++)n=this.views[r].needsAccumulate()||n;function i(r){if(t._accumulatingId&&r===t._accumulatingId){for(var o=!0,a=0;a<t.views.length;a++)o=t.views[a].isAccumulateFinished()&&n;o||(t._doRender(!0),e?i(r):dn((function(){i(r)})))}}n&&(this._accumulatingId=UJ++,e?i(t._accumulatingId):this._accumulatingTimeout=setTimeout((function(){i(t._accumulatingId)}),50))},GJ.prototype._trackAndClean=function(){var e=[],t=[];this._textureList&&(WJ(this._textureList),WJ(this._geometriesList));for(var n=0;n<this.views.length;n++)YJ(this.views[n].scene,e,t);this._textureList&&(jJ(this.renderer,this._textureList),jJ(this.renderer,this._geometriesList)),this._textureList=e,this._geometriesList=t},GJ.prototype.dispose=function(){this._disposed||(this._stopAccumulating(),this._textureList&&(WJ(this._textureList),WJ(this._geometriesList),jJ(this.renderer,this._textureList),jJ(this.renderer,this._geometriesList)),this.zr.off("globalout",this.onglobalout),this._disposed=!0)},GJ.prototype.onmousedown=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mousedown",e,t),this._dispatchDataEvent("mousedown",e,t)),this._downX=e.offsetX,this._downY=e.offsetY}},GJ.prototype.onmousemove=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY),n=t&&t.target,r=this._hovered;this._hovered=t,r&&n!==r.target&&(r.relatedTarget=n,this._dispatchEvent("mouseout",e,r),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",e,t),t&&(this.zr.setCursorStyle("pointer"),r&&n===r.target||this._dispatchEvent("mouseover",e,t)),this._dispatchDataEvent("mousemove",e,t)}},GJ.prototype.onmouseup=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mouseup",e,t),this._dispatchDataEvent("mouseup",e,t)),this._upX=e.offsetX,this._upY=e.offsetY}},GJ.prototype.onclick=GJ.prototype.dblclick=function(e){if(!e.target||!e.target.__isGLToZRProxy){var t=this._upX-this._downX,n=this._upY-this._downY;if(!(Math.sqrt(t*t+n*n)>20)){e=e.event;var r=this.pickObject(e.offsetX,e.offsetY);r&&(this._dispatchEvent(e.type,e,r),this._dispatchDataEvent(e.type,e,r));var i=this._clickToSetFocusPoint(e);if(i)i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}},GJ.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,n=t.viewport,r=this.views.length-1;r>=0;r--){var i=this.views[r];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var o=this._picking.pick(e.offsetX,e.offsetY,!0);if(o)return o.view=i,o}}t.viewport=n},GJ.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},GJ.prototype.pickObject=function(e,t){for(var n=[],r=this.renderer,i=r.viewport,o=0;o<this.views.length;o++){var a=this.views[o];a.containPoint(e,t)&&(this._picking.scene=a.scene,this._picking.camera=a.camera,r.viewport=a.viewport,this._picking.pickAll(e,t,n))}return r.viewport=i,n.sort((function(e,t){return e.distance-t.distance})),n[0]},GJ.prototype._dispatchEvent=function(e,t,n){n||(n={});var r=n.target;for(n.cancelBubble=!1,n.event=t,n.type=e,n.offsetX=t.offsetX,n.offsetY=t.offsetY;r&&(r.trigger(e,n),r=r.getParent(),!n.cancelBubble););this._dispatchToView(e,n)},GJ.prototype._dispatchDataEvent=function(e,t,n){var r=n&&n.target,i=r&&r.dataIndex,o=r&&r.seriesIndex,a=r&&r.eventData,s=!1,l=this._zrEventProxy;l.x=t.offsetX,l.y=t.offsetY,l.update();var u={target:l};const c=vl(l);"mousemove"===e&&(null!=i?i!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0):null!=a&&a!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0),this._lastEventData=a,this._lastDataIndex=i,this._lastSeriesIndex=o),c.eventData=a,c.dataIndex=i,c.seriesIndex=o,(null!=a||parseInt(i,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,e,t),s&&this.zr.handler.dispatchToElement(u,"mouseover",t))},GJ.prototype._dispatchToView=function(e,t){for(var n=0;n<this.views.length;n++)this.views[n].containPoint(t.offsetX,t.offsetY)&&this.views[n].trigger(e,t)},Object.assign(GJ.prototype,vY);var ZJ=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function qJ(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var n=e[t].normal,r=e[t].emphasis;n&&(e[t]=n),r&&(e.emphasis=e.emphasis||{},e.emphasis[t]=r)}}function KJ(e){e&&(e instanceof Array||(e=[e]),W(e,(function(e){if(e.axisLabel){var t=e.axisLabel;Object.assign(t,t.textStyle),t.textStyle=null}})))}function $J(e){this._layers={},this._zr=e}$J.prototype.update=function(e,t){var n=this,r=t.getZr();if(r.getWidth()&&r.getHeight()){for(var i in this._layers)this._layers[i].removeViewsAll();e.eachComponent((function(n,r){if("series"!==n){var i=t.getViewOfComponentModel(r),s=r.coordinateSystem;if(i.__ecgl__){if(s){if(!s.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+r.id);l=s.viewGL}else{if(!r.viewGL)return void console.error("Can't find viewGL of component "+r.id);l=s.viewGL}var l=s.viewGL,u=o(r);u.addView(l),i.afterRender&&i.afterRender(r,e,t,u),a(i.groupGL,r.get("silent"))}}})),e.eachSeries((function(n){var r=t.getViewOfSeriesModel(n),i=n.coordinateSystem;if(r.__ecgl__){if(i&&!i.viewGL&&!r.viewGL)return void console.error("Can't find viewGL of series "+r.id);var s=i&&i.viewGL||r.viewGL,l=o(n);l.addView(s),r.afterRender&&r.afterRender(n,e,t,l),a(r.groupGL,n.get("silent"))}}))}else console.warn("Dom has no width or height");function o(e){var t;r.setSleepAfterStill(0),t=(e.coordinateSystem&&e.coordinateSystem.model,e.get("zlevel"));var i=n._layers,o=i[t];if(!o){if(o=i[t]=new GJ("gl-"+t,r),r.painter.isSingleCanvas()){o.virtual=!0;var a=new Zs({z:1e4,style:{image:o.renderer.canvas},silent:!0});o.__hostImage=a,r.add(a)}r.painter.insertLayer(t,o)}return o.__hostImage&&o.__hostImage.setStyle({width:o.renderer.getWidth(),height:o.renderer.getHeight()}),o}function a(e,t){e&&e.traverse((function(e){e.isRenderable&&e.isRenderable()&&(e.ignorePicking=null!=e.$ignorePicking?e.$ignorePicking:t)}))}},Hy((function(e){var t=e.getZr(),n=t.painter.dispose;t.painter.dispose=function(){"function"==typeof this.eachOtherLayer&&this.eachOtherLayer((function(e){e instanceof GJ&&e.dispose()})),n.call(this)},t.painter.getRenderedCanvas=function(e){if(e=e||{},this._singleCanvas)return this._layers[0].dom;var t=document.createElement("canvas"),n=e.pixelRatio||this.dpr;t.width=this.getWidth()*n,t.height=this.getHeight()*n;var r=t.getContext("2d");r.dpr=n,r.clearRect(0,0,t.width,t.height),e.backgroundColor&&(r.fillStyle=e.backgroundColor,r.fillRect(0,0,t.width,t.height));var i,o=this.storage.getDisplayList(!0),a={},s=this;function l(e,t){var n,i=s._zlevelList;null==e&&(e=-1/0);for(var o=0;o<i.length;o++){var a=i[o],l=s._layers[a];if(!l.__builtin__&&a>e&&a<t){n=l;break}}n&&n.renderToCanvas&&(r.save(),n.renderToCanvas(r),r.restore())}for(var u={ctx:r},c=0;c<o.length;c++){var h=o[c];h.zlevel!==i&&(l(i,h.zlevel),i=h.zlevel),this._doPaintEl(h,u,!0,null,a)}return l(i,1/0),t}})),Uy((function(e,t){var n=t.getZr();(n.__egl=n.__egl||new $J(n)).update(e,t)})),Fy((function(e){W(e.series,(function(t){F(ZJ,t.type)>=0&&(!function(e){qJ(e,"itemStyle"),qJ(e,"lineStyle"),qJ(e,"areaStyle"),qJ(e,"label")}(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))})),KJ(e.xAxis3D),KJ(e.yAxis3D),KJ(e.zAxis3D),KJ(e.grid3D),qJ(e.geo3D)}));var JJ={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(e){e=e||{},this.option.viewControl=this.option.viewControl||{},null!=e.alpha&&(this.option.viewControl.alpha=e.alpha),null!=e.beta&&(this.option.viewControl.beta=e.beta),null!=e.distance&&(this.option.viewControl.distance=e.distance),null!=e.center&&(this.option.viewControl.center=e.center)}},QJ={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},eQ={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}},tQ=$d.extend({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});R(tQ.prototype,JJ),R(tQ.prototype,QJ),R(tQ.prototype,eQ);var nQ=vJ,rQ={left:0,middle:1,right:2};function iQ(e){return e instanceof Array||(e=[e,e]),e}var oQ=bY.extend((function(){return{zr:null,viewGL:null,_center:new Bq,minDistance:.5,maxDistance:1.5,maxOrthographicSize:300,minOrthographicSize:30,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",_mode:"rotate",_camera:null,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new qZ,_panVelocity:new qZ,_distance:500,_zoomSpeed:0,_stillTimeout:0,_animators:[]}}),(function(){["_mouseDownHandler","_mouseWheelHandler","_mouseMoveHandler","_mouseUpHandler","_pinchHandler","_contextMenuHandler","_update"].forEach((function(e){this[e]=this[e].bind(this)}),this)}),{init:function(){var e=this.zr;e&&(e.on("mousedown",this._mouseDownHandler),e.on("globalout",this._mouseUpHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("pinch",this._pinchHandler),e.animation.on("frame",this._update),e.dom.addEventListener("contextmenu",this._contextMenuHandler))},dispose:function(){var e=this.zr;e&&(e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("pinch",this._pinchHandler),e.off("globalout",this._mouseUpHandler),e.dom.removeEventListener("contextmenu",this._contextMenuHandler),e.animation.off("frame",this._update)),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getOrthographicSize:function(){return this._orthoSize},setOrthographicSize:function(e){this._orthoSize=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setViewGL:function(e){this.viewGL=e},getCamera:function(){return this.viewGL.camera},setFromViewControlModel:function(e,t){var n=(t=t||{}).baseDistance||0,r=t.baseOrthoSize||1,i=e.get("projection");"perspective"!==i&&"orthographic"!==i&&"isometric"!==i&&("production"!==process.env.NODE_ENV&&console.error("Unkown projection type %s, use perspective projection instead.",i),i="perspective"),this._projection=i,this.viewGL.setProjection(i);var o=e.get("distance")+n,a=e.get("orthographicSize")+r;[["damping",.8],["autoRotate",!1],["autoRotateAfterStill",3],["autoRotateDirection","cw"],["autoRotateSpeed",10],["minDistance",30],["maxDistance",400],["minOrthographicSize",30],["maxOrthographicSize",300],["minAlpha",-90],["maxAlpha",90],["minBeta",-1/0],["maxBeta",1/0],["rotateSensitivity",1],["zoomSensitivity",1],["panSensitivity",1],["panMouseButton","left"],["rotateMouseButton","middle"]].forEach((function(t){this[t[0]]=nQ(e.get(t[0]),t[1])}),this),this.minDistance+=n,this.maxDistance+=n,this.minOrthographicSize+=r,this.maxOrthographicSize+=r;var s=e.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach((function(t){l[t]=nQ(e.get(t),s&&s.get(t))}));var u=nQ(t.alpha,e.get("alpha"))||0,c=nQ(t.beta,e.get("beta"))||0,h=nQ(t.center,e.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:u,beta:c,center:h,distance:o,orthographicSize:a,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(o),this.setAlpha(u),this.setBeta(c),this.setCenter(h),this.setOrthographicSize(a)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){"production"!==process.env.NODE_ENV&&(null==rQ[this.panMouseButton]&&console.error("Unkown panMouseButton %s. It should be left|middle|right",this.panMouseButton),null==rQ[this.rotateMouseButton]&&console.error("Unkown rotateMouseButton %s. It should be left|middle|right",this.rotateMouseButton),"cw"!==this.autoRotateDirection&&"ccw"!==this.autoRotateDirection&&console.error("Unkown autoRotateDirection %s. It should be cw|ccw",this.autoRotateDirection))},animateTo:function(e){var t=this.zr,n=this,r={},i={};return null!=e.distance&&(r.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(r.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(r.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(r.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(r.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(r).when(e.duration||1e3,i).during((function(){null!=r.alpha&&n.setAlpha(r.alpha),null!=r.beta&&n.setBeta(r.beta),null!=r.distance&&n.setDistance(r.distance),null!=r.center&&n.setCenter(r.center),null!=r.orthographicSize&&n.setOrthographicSize(r.orthographicSize),n._needsUpdate=!0}))).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e<this._animators.length;e++)this._animators[e].stop();this._animators.length=0},update:function(){this._needsUpdate=!0,this._update(20)},_isAnimating:function(){return this._animators.length>0},_update:function(e){if(this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),n=this._orthoSize,r=n/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-r/2,t.right=r/2,t.top=n/2,t.bottom=-n/2},_updatePan:function(e){var t=this._panVelocity,n=this._distance,r=this.getCamera(),i=r.worldTransform.y,o=r.worldTransform.x;this._center.scaleAndAdd(o,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new Bq,n=this._theta+Math.PI/2,r=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(r),t.y=-Math.cos(n),t.z=i*Math.sin(r),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout((function(){t._rotating=!0}),1e3*e))},_vectorDamping:function(e,t){var n=e.len();(n*=t)<1e-4&&(n=0),e.normalize().scale(n)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),n=Math.atan2(e.x,e.z);this._theta=t,this._phi=-n,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,n=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,n)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?1===e.event.targetTouches.length&&(this._mode="rotate"):e.event.button===rQ[this.rotateMouseButton]?this._mode="rotate":e.event.button===rQ[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy||this._isAnimating())){var t=iQ(this.panSensitivity),n=iQ(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*n[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*n[1]):"pan"===this._mode&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(0!==t){var n,r=e.offsetX,i=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,i))n="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*n*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.event.preventDefault()}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done((function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)})),e}});Object.defineProperty(oQ.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});var aQ={convertToDynamicArray:function(e){e&&this.resetOffset();var t=this.attributes;for(var n in t)e||!t[n].value?t[n].value=[]:t[n].value=Array.prototype.slice.call(t[n].value);e||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var e=this.attributes;for(var t in e)e[t].value&&e[t].value.length>0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},sQ={vec2:ZZ,vec3:Cq,vec4:$q,mat2:DJ,mat2d:IJ,mat3:Jq,mat4:Mq,quat:rK},lQ=sQ.vec3,uQ=[[0,0],[1,1]],cQ=WK.extend((function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new WK.Attribute("position","float",3,"POSITION"),positionPrev:new WK.Attribute("positionPrev","float",3),positionNext:new WK.Attribute("positionNext","float",3),prevPositionPrev:new WK.Attribute("prevPositionPrev","float",3),prevPosition:new WK.Attribute("prevPosition","float",3),prevPositionNext:new WK.Attribute("prevPositionNext","float",3),offset:new WK.Attribute("offset","float",1),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.positionPrev.init(e),t.positionNext.init(e),t.offset.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(lQ.dist(e,t)+lQ.dist(n,t)+lQ.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(uQ)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(uQ)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?0:2*Math.max(t-1,0)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=e[2],u=t[0],c=t[1],h=t[2],d=n[0],p=n[1],f=n[2],g=r[0],m=r[1],v=r[2],y=this._getCubicCurveApproxStep(e,t,n,r),_=y*y,x=_*y,b=3*y,w=3*_,S=6*_,T=6*x,M=a-2*u+d,C=s-2*c+p,D=l-2*h+f,A=3*(u-d)-a+g,I=3*(c-p)-s+m,E=3*(h-f)-l+v,L=a,N=s,P=l,O=(u-a)*b+M*w+A*x,R=(c-s)*b+C*w+I*x,k=(h-l)*b+D*w+E*x,z=M*S+A*T,V=C*S+I*T,B=D*S+E*T,F=A*T,G=I*T,H=E*T,U=0,W=0,j=Math.ceil(1/y),X=new Float32Array(3*(j+1)),Y=(X=[],0);for(W=0;W<j+1;W++)X[Y++]=L,X[Y++]=N,X[Y++]=P,L+=O,N+=R,P+=k,O+=z,R+=V,k+=B,z+=F,V+=G,B+=H,(U+=y)>1&&(L=O>0?Math.min(L,g):Math.max(L,g),N=R>0?Math.min(N,m):Math.max(N,m),P=k>0?Math.min(P,v):Math.max(P,v));return this.addPolyline(X,i,o)},addLine:function(e,t,n,r){return this.addPolyline([e,t],n,r)},addPolyline:function(e,t,n,r,i){if(e.length){var o="number"!=typeof e[0];if(null==i&&(i=o?e.length:e.length/3),!(i<2)){null==r&&(r=0),null==n&&(n=1),this._itemVertexOffsets.push(this._vertexOffset);var a,s,l=(o="number"!=typeof e[0])?"number"!=typeof t[0]:t.length/4===i,u=this.attributes.position,c=this.attributes.positionPrev,h=this.attributes.positionNext,d=this.attributes.color,p=this.attributes.offset,f=this.indices,g=this._vertexOffset;n=Math.max(n,.01);for(var m=r;m<i;m++){if(o)a=e[m],s=l?t[m]:t;else{var v=3*m;if((a=a||[])[0]=e[v],a[1]=e[v+1],a[2]=e[v+2],l){var y=4*m;(s=s||[])[0]=t[y],s[1]=t[y+1],s[2]=t[y+2],s[3]=t[y+3]}else s=t}if(this.useNativeLine?m>1&&(u.copy(g,g-1),d.copy(g,g-1),g++):(m<i-1&&(c.set(g+2,a),c.set(g+3,a)),m>0&&(h.set(g-2,a),h.set(g-1,a)),u.set(g,a),u.set(g+1,a),d.set(g,s),d.set(g+1,s),p.set(g,n/2),p.set(g+1,-n/2),g+=2),this.useNativeLine)d.set(g,s),u.set(g,a),g++;else if(m>0){var _=3*this._triangleOffset;(f=this.indices)[_]=g-4,f[_+1]=g-3,f[_+2]=g-2,f[_+3]=g-3,f[_+4]=g-1,f[_+5]=g-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*i;c.copy(x,x+2),c.copy(x+1,x+3),h.copy(b-1,b-3),h.copy(b-2,b-4)}return this._vertexOffset=g,this._vertexOffset}}},setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});function hQ(e,t,n,r,i,o,a){this._zr=e,this._x=0,this._y=0,this._rowHeight=0,this.width=r,this.height=i,this.offsetX=t,this.offsetY=n,this.dpr=a,this.gap=o}function dQ(e){(e=e||{}).width=e.width||512,e.height=e.height||512,e.devicePixelRatio=e.devicePixelRatio||1,e.gap=null==e.gap?2:e.gap;var t=document.createElement("canvas");t.width=e.width*e.devicePixelRatio,t.height=e.height*e.devicePixelRatio,this._canvas=t,this._texture=new PK({image:t,flipY:!1});var n=this;this._zr=qi(t);var r=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){r.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new hQ(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}function pQ(){}V(cQ.prototype,aQ),hQ.prototype={constructor:hQ,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(e,t,n){var r=e.getBoundingRect();null==t&&(t=r.width),null==n&&(n=r.height),t*=this.dpr,n*=this.dpr,this._fitElement(e,t,n);var i=this._x,o=this._y,a=this.width*this.dpr,s=this.height*this.dpr,l=this.gap;if(i+t+l>a&&(i=this._x=0,o+=this._rowHeight+l,this._y=o,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,n),o+n+l>s)return null;e.x+=this.offsetX*this.dpr+i,e.y+=this.offsetY*this.dpr+o,this._zr.add(e);var u=[this.offsetX/this.width,this.offsetY/this.height];return[[i/a+u[0],o/s+u[1]],[(i+t)/a+u[0],(o+n)/s+u[1]]]},_fitElement:function(e,t,n){var r=e.getBoundingRect(),i=t/r.width,o=n/r.height;e.x=-r.x*i,e.y=-r.y*o,e.scaleX=i,e.scaleY=o,e.update()}},dQ.prototype={clear:function(){for(var e=0;e<this._textureAtlasNodes.length;e++)this._textureAtlasNodes[e].clear();this._currentNodeIdx=0,this._zr.clear(),this._coords={}},getWidth:function(){return this._width},getHeight:function(){return this._height},getTexture:function(){return this._texture},getDevicePixelRatio:function(){return this._dpr},getZr:function(){return this._zr},_getCurrentNode:function(){return this._textureAtlasNodes[this._currentNodeIdx]},_expand:function(){if(this._currentNodeIdx++,this._textureAtlasNodes[this._currentNodeIdx])return this._textureAtlasNodes[this._currentNodeIdx];var e=4096/this._dpr,t=this._textureAtlasNodes.length,n=t*this._nodeWidth%e,r=Math.floor(t*this._nodeWidth/e)*this._nodeHeight;if(!(r>=e)){var i=(n+this._nodeWidth)*this._dpr,o=(r+this._nodeHeight)*this._dpr;try{this._zr.resize({width:i,height:o})}catch(e){this._canvas.width=i,this._canvas.height=o}var a=new hQ(this._zr,n,r,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(a),a}"production"!==process.env.NODE_ENV&&console.error("Too much labels. Some will be ignored.")},add:function(e,t,n){if(this._coords[e.id])return"production"!==process.env.NODE_ENV&&console.warn("Element already been add"),this._coords[e.id];var r=this._getCurrentNode().add(e,t,n);if(!r){var i=this._expand();if(!i)return;r=i.add(e,t,n)}return this._coords[e.id]=r,r},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]},dispose:function(){this._zr.dispose()}},pQ.prototype={constructor:pQ,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new zJ.DirectionalLight({shadowBias:.005}),this.ambientLight=new zJ.AmbientLight,e.add(this.mainLight),e.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(e){var t=this.mainLight,n=this.ambientLight,r=e.getModel("light"),i=r.getModel("main"),o=r.getModel("ambient");t.intensity=i.get("intensity"),n.intensity=o.get("intensity"),t.color=zJ.parseColor(i.get("color")).slice(0,3),n.color=zJ.parseColor(o.get("color")).slice(0,3);var a=i.get("alpha")||0,s=i.get("beta")||0;t.position.setArray(zJ.directionFromAlphaBeta(a,s)),t.lookAt(zJ.Vector3.ZERO),t.castShadow=i.get("shadow"),t.shadowResolution=zJ.getShadowResolution(i.get("shadowQuality"))},updateAmbientCubemap:function(e,t,n){var r=t.getModel("light.ambientCubemap"),i=r.get("texture");if(i){this._cubemapLightsCache=this._cubemapLightsCache||{};var o=this._cubemapLightsCache[i];if(!o){var a=this;o=this._cubemapLightsCache[i]=zJ.createAmbientCubemap(r.option,e,n,(function(){a._isSkyboxFromAmbientCubemap&&a._skybox.setEnvironmentMap(o.specular.cubemap),n.getZr().refresh()}))}this._lightRoot.add(o.diffuse),this._lightRoot.add(o.specular),this._currentCubemapLights=o}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(e,t,n){var r=t.get("environment"),i=this;var o=(i._skybox=i._skybox||new U$,i._skybox);if(r&&"none"!==r)if("auto"===r)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var a=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(a),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"==typeof r&&r.colorStops||"string"==typeof r&&nr(r)){this._isSkyboxFromAmbientCubemap=!1;var s=new zJ.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(s);var l=s.image=document.createElement("canvas");l.width=l.height=16,Ev(l.getContext("2d"),new tl({shape:{x:0,y:0,width:16,height:16},style:{fill:r}})),o.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;s=zJ.loadTexture(r,n,{anisotropic:8,flipY:!1});o.setEnvironmentMap(s),o.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var u=t.coordinateSystem;if(this._skybox)if(!u||!u.viewGL||"auto"===r||r.match&&r.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var c=u.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[c]("fragment","SRGB_DECODE")}}};var fQ=sQ.vec3,gQ=WK.extend((function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new WK.Attribute("position","float",3,"POSITION"),normal:new WK.Attribute("normal","float",3,"NORMAL"),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,n=this.getQuadVertexCount()*e,r=this.getQuadTriangleCount()*e;this.vertexCount!==n&&(t.position.init(n),t.normal.init(n),t.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=fQ.create(),t=fQ.create(),n=fQ.create(),r=[0,3,1,3,2,1];return function(i,o){var a=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;fQ.sub(e,i[1],i[0]),fQ.sub(t,i[2],i[1]),fQ.cross(n,e,t),fQ.normalize(n,n);for(var u=0;u<4;u++)a.set(this._vertexOffset+u,i[u]),l.set(this._vertexOffset+u,o),s.set(this._vertexOffset+u,n);var c=3*this._faceOffset;for(u=0;u<6;u++)this.indices[c+u]=r[u]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});V(gQ.prototype,aQ);var mQ=vJ,vQ={x:0,y:2,z:1};function yQ(e,t,n){this.rootNode=new zJ.Node;var r=new zJ.Mesh({geometry:new cQ({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new zJ.Mesh({geometry:new gQ,material:n,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(r),this.faceInfo=e,this.plane=new zJ.Plane,this.linesMesh=r,this.quadsMesh=i}yQ.prototype.update=function(e,t,n){var r=e.coordinateSystem,i=[r.getAxis(this.faceInfo[0]),r.getAxis(this.faceInfo[1])],o=this.linesMesh.geometry,a=this.quadsMesh.geometry;o.convertToDynamicArray(!0),a.convertToDynamicArray(!0),this._updateSplitLines(o,i,e,n),this._udpateSplitAreas(a,i,e,n),o.convertToTypedArray(),a.convertToTypedArray();var s=r.getAxis(this.faceInfo[2]);!function(e,t,n,r){var i=[0,0,0],o=r<0?n.getExtentMin():n.getExtentMax();i[vQ[n.dim]]=o,e.position.setArray(i),e.rotation.identity(),t.distance=-Math.abs(o),t.normal.set(0,0,0),"x"===n.dim?(e.rotation.rotateY(r*Math.PI/2),t.normal.x=-r):"z"===n.dim?(e.rotation.rotateX(-r*Math.PI/2),t.normal.y=-r):(r>0&&e.rotation.rotateY(Math.PI),t.normal.z=-r)}(this.rootNode,this.plane,s,this.faceInfo[3])},yQ.prototype._updateSplitLines=function(e,t,n,r){var i=r.getDevicePixelRatio();t.forEach((function(r,o){var a=r.model,s=t[1-o].getExtent();if(!r.scale.isBlank()){var l=a.getModel("splitLine",n.getModel("splitLine"));if(l.get("show")){var u=l.getModel("lineStyle"),c=u.get("color"),h=mQ(u.get("opacity"),1),d=mQ(u.get("width"),1);c=J(c)?c:[c];for(var p=r.getTicksCoords({tickModel:l}),f=0,g=0;g<p.length;g++){var m=p[g].coord,v=zJ.parseColor(c[f%c.length]);v[3]*=h;var y=[0,0,0],_=[0,0,0];y[o]=_[o]=m,y[1-o]=s[0],_[1-o]=s[1],e.addLine(y,_,v,d*i),f++}}}}))},yQ.prototype._udpateSplitAreas=function(e,t,n,r){t.forEach((function(r,i){var o=r.model,a=t[1-i].getExtent();if(!r.scale.isBlank()){var s=o.getModel("splitArea",n.getModel("splitArea"));if(s.get("show")){var l=s.getModel("areaStyle"),u=l.get("color"),c=mQ(l.get("opacity"),1);u=J(u)?u:[u];for(var h=r.getTicksCoords({tickModel:s,clamp:!0}),d=0,p=[0,0,0],f=[0,0,0],g=0;g<h.length;g++){var m=h[g].coord,v=[0,0,0],y=[0,0,0];if(v[i]=y[i]=m,v[1-i]=a[0],y[1-i]=a[1],0!==g){var _=zJ.parseColor(u[d%u.length]);_[3]*=c,e.addQuad([p,v,y,f],_),p=v,f=y,d++}else p=v,f=y}}}}))};var _Q=[0,1,2,0,2,3],xQ=WK.extend((function(){return{attributes:{position:new WK.Attribute("position","float",3,"POSITION"),texcoord:new WK.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new WK.Attribute("offset","float",2),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(e){this._spriteCount=e;var t=4*e,n=2*e;this.vertexCount!==t&&(this.attributes.position.init(t),this.attributes.offset.init(t),this.attributes.color.init(t)),this.triangleCount!==n&&(this.indices=t>65535?new Uint32Array(3*n):new Uint16Array(3*n))},setSpriteAlign:function(e,t,n,r,i){var o,a,s,l;switch(null==n&&(n="left"),null==r&&(r="top"),i=i||0,n){case"left":o=i,s=t[0]+i;break;case"center":case"middle":o=-t[0]/2,s=t[0]/2;break;case"right":o=-t[0]-i,s=-i}switch(r){case"bottom":a=i,l=t[1]+i;break;case"middle":a=-t[1]/2,l=t[1]/2;break;case"top":a=-t[1]-i,l=-i}var u=4*e,c=this.attributes.offset;c.set(u,[o,l]),c.set(u+1,[s,l]),c.set(u+2,[s,a]),c.set(u+3,[o,a])},addSprite:function(e,t,n,r,i,o){var a=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,n,r,i,o);for(var s=0;s<_Q.length;s++)this.indices[3*this._faceOffset+s]=_Q[s]+a;return this._faceOffset+=2,this._vertexOffset+=4,a/4},setSprite:function(e,t,n,r,i,o,a){for(var s=4*e,l=this.attributes,u=0;u<4;u++)l.position.set(s+u,t);var c=l.texcoord;c.set(s,[r[0][0],r[0][1]]),c.set(s+1,[r[1][0],r[0][1]]),c.set(s+2,[r[1][0],r[1][1]]),c.set(s+3,[r[0][0],r[1][1]]),this.setSpriteAlign(e,n,i,o,a)}});V(xQ.prototype,aQ);zJ.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");var bQ=zJ.Mesh.extend((function(){return{geometry:new xQ({dynamic:!0}),material:new zJ.Material({shader:zJ.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}})),wQ=vJ,SQ={x:0,y:2,z:1};function TQ(e,t){var n=new zJ.Mesh({geometry:new cQ({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),r=new bQ;r.material.depthMask=!1;var i=new zJ.Node;i.add(n),i.add(r),this.rootNode=i,this.dim=e,this.linesMesh=n,this.labelsMesh=r,this.axisLineCoords=null,this.labelElements=[]}var MQ={x:"y",y:"x",z:"y"};TQ.prototype.update=function(e,t,n){var r=e.coordinateSystem.getAxis(this.dim),i=this.linesMesh.geometry,o=this.labelsMesh.geometry;i.convertToDynamicArray(!0),o.convertToDynamicArray(!0);var a=r.model,s=r.getExtent(),l=n.getDevicePixelRatio(),u=a.getModel("axisLine",e.getModel("axisLine")),c=a.getModel("axisTick",e.getModel("axisTick")),h=a.getModel("axisLabel",e.getModel("axisLabel")),d=u.get("lineStyle.color");if(u.get("show")){var p=u.getModel("lineStyle"),f=[0,0,0];(T=[0,0,0])[M=SQ[r.dim]]=s[0],f[M]=s[1],this.axisLineCoords=[T,f];var g=zJ.parseColor(d),m=wQ(p.get("width"),1),v=wQ(p.get("opacity"),1);g[3]*=v,i.addLine(T,f,g,m*l)}if(c.get("show")){var y=c.getModel("lineStyle"),_=zJ.parseColor(wQ(y.get("color"),d));m=wQ(y.get("width"),1);_[3]*=wQ(y.get("opacity"),1);for(var x=r.getTicksCoords(),b=c.get("length"),w=0;w<x.length;w++){var S=x[w].coord,T=[0,0,0],M=(f=[0,0,0],SQ[r.dim]),C=SQ[MQ[r.dim]];T[M]=f[M]=S,f[C]=b,i.addLine(T,f,_,m*l)}}this.labelElements=[];l=n.getDevicePixelRatio();if(h.get("show")){x=r.getTicksCoords();var D=a.get("data"),A=h.get("margin"),I=r.getViewLabels();for(w=0;w<I.length;w++){var E=I[w].tickValue,L=I[w].formattedLabel,N=I[w].rawLabel,P=(S=r.dataToCoord(E),[0,0,0]);M=SQ[r.dim],C=SQ[MQ[r.dim]];P[M]=P[M]=S,P[C]=A;var O=h;D&&D[E]&&D[E].textStyle&&(O=new Fh(D[E].textStyle,h,a.ecModel));var R=wQ(O.get("color"),d),k=new il({style:yh(O,{text:L,fill:"function"==typeof R?R("category"===r.type?N:"value"===r.type?E+"":E,w):R,verticalAlign:"top",align:"left"})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),this.labelElements.push(k)}}if(a.get("name")){var B=a.getModel("nameTextStyle"),F=(P=[0,0,0],M=SQ[r.dim],C=SQ[MQ[r.dim]],wQ(B.get("color"),d)),G=B.get("borderColor");m=B.get("borderWidth");P[M]=P[M]=(s[0]+s[1])/2,P[C]=a.get("nameGap");k=new il({style:yh(B,{text:a.get("name"),fill:F,stroke:G,lineWidth:m})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),k.__idx=this.labelElements.length,this.nameLabelElement=k}this.labelsMesh.material.set("textureAtlas",t.getTexture()),this.labelsMesh.material.set("uvScale",t.getCoordsScale()),i.convertToTypedArray(),o.convertToTypedArray()},TQ.prototype.setSpriteAlign=function(e,t,n){for(var r=n.getDevicePixelRatio(),i=this.labelsMesh.geometry,o=0;o<this.labelElements.length;o++){var a=this.labelElements[o].getBoundingRect();i.setSpriteAlign(o,[a.width*r,a.height*r],e,t)}var s=this.nameLabelElement;if(s){a=s.getBoundingRect();i.setSpriteAlign(s.__idx,[a.width*r,a.height*r],e,t),i.dirty()}this.textAlign=e,this.textVerticalAlign=t};var CQ="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end",DQ=vJ;zJ.Shader.import(CQ);var AQ={x:0,y:2,z:1},IQ=Xg.extend({type:"grid3D",__ecgl__:!0,init:function(e,t){var n=new zJ.Material({shader:zJ.createShader("ecgl.color"),depthMask:!1,transparent:!0}),r=new zJ.Material({shader:zJ.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});n.define("fragment","DOUBLE_SIDED"),n.define("both","VERTEX_COLOR"),this.groupGL=new zJ.Node,this._control=new oQ({zr:t.getZr()}),this._control.init(),this._faces=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]].map((function(e){var t=new yQ(e,r,n);return this.groupGL.add(t.rootNode),t}),this),this._axes=["x","y","z"].map((function(e){var t=new TQ(e,r);return this.groupGL.add(t.rootNode),t}),this);var i=t.getDevicePixelRatio();this._axisLabelSurface=new dQ({width:256,height:256,devicePixelRatio:i}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new zJ.Mesh({geometry:new cQ({useNativeLine:!1}),material:r,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new dQ({width:128,height:128,devicePixelRatio:i}),this._axisPointerLabelsMesh=new bQ({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new zJ.Node,this._sceneHelper=new pQ,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,n){this._model=e,this._api=n;var r=e.coordinateSystem;r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._axisLabelSurface.clear(),i.off("update"),e.get("show")&&(this._faces.forEach((function(r){r.update(e,t,n)}),this),this._axes.forEach((function(t){t.update(e,this._axisLabelSurface,n)}),this)),i.on("update",this._onCameraChange.bind(this,e,n),this),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},showAxisPointer:function(e,t,n,r){this._doShowAxisPointer(),this._updateAxisPointer(r.value)},hideAxisPointer:function(e,t,n,r){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem.viewGL;e.get("show")&&e.get("axisPointer.show")?t.on("mousemove",this._updateAxisPointerOnMousePosition,this):t.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t,n=this._model.coordinateSystem,r=n.viewGL,i=r.castRay(e.offsetX,e.offsetY,new zJ.Ray),o=0;o<this._faces.length;o++){var a=this._faces[o];if(!a.rootNode.invisible){a.plane.normal.dot(r.camera.worldTransform.z)<0&&a.plane.normal.negate();var s=i.intersectPlane(a.plane);if(s){var l=n.getAxis(a.faceInfo[0]),u=n.getAxis(a.faceInfo[1]),c=AQ[a.faceInfo[0]],h=AQ[a.faceInfo[1]];l.contain(s.array[c])&&u.contain(s.array[h])&&(t=s)}}}if(t){var d=n.pointToData(t.array,[],!0);this._updateAxisPointer(d),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(e,t){e.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var n=this._control;t.dispatchAction({type:"grid3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),center:n.getCenter(),from:this.uid,grid3DId:e.id})},_updateFaceVisibility:function(){var e=this._control.getCamera(),t=new zJ.Vector3;e.update();for(var n=0;n<this._faces.length/2;n++){for(var r=[],i=0;i<2;i++){this._faces[2*n+i].rootNode.getWorldPosition(t),t.transformMat4(e.viewMatrix),r[i]=t.z}var o=r[0]>r[1]?0:1,a=this._faces[2*n+o],s=this._faces[2*n+1-o];a.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),n=e.getAxis("y"),r=e.getAxis("z"),i=r.getExtentMax(),o=r.getExtentMin(),a=t.getExtentMin(),s=t.getExtentMax(),l=n.getExtentMax(),u=n.getExtentMin(),c=this._axes[0].rootNode,h=this._axes[1].rootNode,d=this._axes[2].rootNode,p=this._faces,f=p[4].rootNode.invisible?u:l,g=p[2].rootNode.invisible?i:o,m=p[0].rootNode.invisible?a:s,v=p[2].rootNode.invisible?i:o,y=p[0].rootNode.invisible?s:a,_=p[4].rootNode.invisible?u:l;c.rotation.identity(),h.rotation.identity(),d.rotation.identity(),p[4].rootNode.invisible&&(this._axes[0].flipped=!0,c.rotation.rotateX(Math.PI)),p[0].rootNode.invisible&&(this._axes[1].flipped=!0,h.rotation.rotateZ(Math.PI)),p[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),c.position.set(0,g,f),h.position.set(m,v,0),d.position.set(y,0,_),c.update(),h.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new zJ.Vector4,new zJ.Vector4],n=new zJ.Vector4;this.groupGL.getWorldPosition(n),n.w=1,n.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),n.x/=n.w,n.y/=n.w,this._axes.forEach((function(r){var i=r.axisLineCoords;r.labelsMesh.geometry;for(var o=0;o<t.length;o++)t[o].setArray(i[o]),t[o].w=1,t[o].transformMat4(r.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),t[o].x/=t[o].w,t[o].y/=t[o].w;var a,s,l=t[1].x-t[0].x,u=t[1].y-t[0].y,c=(t[1].x+t[0].x)/2,h=(t[1].y+t[0].y)/2;Math.abs(u/l)<.5?(a="center",s=h>n.y?"bottom":"top"):(s="middle",a=c>n.x?"left":"right"),r.setSpriteAlign(a,s,this._api)}),this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){var t=this._model.coordinateSystem,n=t.dataToPoint(e),r=this._axisPointerLineMesh.geometry,i=this._model.getModel("axisPointer"),o=this._api.getDevicePixelRatio();function a(e){return vJ(e.model.get("axisPointer.show"),i.get("show"))}function s(e){var t=e.model.getModel("axisPointer",i).getModel("lineStyle"),n=zJ.parseColor(t.get("color")),r=DQ(t.get("width"),1),o=DQ(t.get("opacity"),1);return n[3]*=o,{color:n,lineWidth:r}}r.convertToDynamicArray(!0);for(var l=0;l<this._faces.length;l++){var u=this._faces[l];if(!u.rootNode.invisible){for(var c=u.faceInfo,h=c[3]<0?t.getAxis(c[2]).getExtentMin():t.getAxis(c[2]).getExtentMax(),d=AQ[c[2]],p=0;p<2;p++){var f=c[p],g=c[1-p],m=t.getAxis(f),v=t.getAxis(g);if(a(m)){var y=AQ[f],_=AQ[g];(w=[0,0,0])[y]=(b=[0,0,0])[y]=n[y],w[d]=b[d]=h,w[_]=v.getExtentMin(),b[_]=v.getExtentMax();var x=s(m);r.addLine(w,b,x.color,x.lineWidth*o)}}if(a(t.getAxis(c[2]))){var b,w=n.slice();(b=n.slice())[d]=h;x=s(t.getAxis(c[2]));r.addLine(w,b,x.color,x.lineWidth*o)}}}r.convertToTypedArray(),this._updateAxisPointerLabelsMesh(e),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(e){var t=this._model,n=this._axisPointerLabelsMesh,r=this._axisPointerLabelsSurface,i=t.coordinateSystem,o=t.getModel("axisPointer");n.geometry.convertToDynamicArray(!0),r.clear();var a={x:"y",y:"x",z:"y"};this._axes.forEach((function(t,s){var l=i.getAxis(t.dim),u=l.model.getModel("axisPointer",o),c=u.getModel("label"),h=u.get("lineStyle.color");if(c.get("show")&&u.get("show")){var d=e[s],p=c.get("formatter"),f=l.scale.getLabel({value:d});if(null!=p)f=p(f,e);else if("interval"===l.scale.type||"log"===l.scale.type){var g=oo(l.scale.getTicks()[0]);f=d.toFixed(g+2)}var m=c.get("color"),v=new il({style:yh(c,{text:f,fill:m||h,align:"left",verticalAlign:"top"})}),y=r.add(v),_=v.getBoundingRect(),x=this._api.getDevicePixelRatio(),b=t.rootNode.position.toArray();b[AQ[a[t.dim]]]+=(t.flipped?-1:1)*c.get("margin"),b[AQ[t.dim]]=l.dataToCoord(e[s]),n.geometry.addSprite(b,[_.width*x,_.height*x],y,t.textAlign,t.textVerticalAlign)}}),this),r.getZr().refreshImmediately(),n.material.set("uvScale",r.getCoordsScale()),n.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._axisLabelSurface.dispose(),this._axisPointerLabelsSurface.dispose()}});function EQ(e){MM.call(this,e),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}function LQ(e,t,n){Eb.call(this,e,t,n)}EQ.prototype={constructor:EQ,model:null,containPoint:function(e){return this.getAxis("x").contain(e[0])&&this.getAxis("y").contain(e[2])&&this.getAxis("z").contain(e[1])},containData:function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])&&this.getAxis("z").containData(e[2])},dataToPoint:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").dataToCoord(e[0],n),t[2]=this.getAxis("y").dataToCoord(e[1],n),t[1]=this.getAxis("z").dataToCoord(e[2],n),t},pointToData:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").coordToData(e[0],n),t[1]=this.getAxis("y").coordToData(e[2],n),t[2]=this.getAxis("z").coordToData(e[1],n),t}},G(EQ,MM),LQ.prototype={constructor:LQ,getExtentMin:function(){var e=this._extent;return Math.min(e[0],e[1])},getExtentMax:function(){var e=this._extent;return Math.max(e[0],e[1])},calculateCategoryInterval:function(){return Math.floor(this.scale.count()/8)}},G(LQ,Eb);var NQ=function(){this._pool={},this._allocatedTextures=[]};NQ.prototype={constructor:NQ,get:function(e){var t=RQ(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var n=this._pool[t];if(!n.length){var r=new PK(e);return this._allocatedTextures.push(r),r}return n.pop()},put:function(e){var t=RQ(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]),this._pool[t].push(e)},clear:function(e){for(var t=0;t<this._allocatedTextures.length;t++)this._allocatedTextures[t].dispose(e);this._pool={},this._allocatedTextures=[]}};var PQ={width:512,height:512,type:WY,format:QY,wrapS:hZ,wrapT:hZ,minFilter:sZ,magFilter:rZ,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},OQ=Object.keys(PQ);function RQ(e){xY.defaultsWithPropList(e,PQ,OQ),function(e){var t=(n=e.width,r=e.height,!(n&n-1||r&r-1));var n,r;e.format===KY&&(e.useMipmap=!1);t&&e.useMipmap||(e.minFilter==iZ||e.minFilter==aZ?e.minFilter=nZ:e.minFilter!=sZ&&e.minFilter!=oZ||(e.minFilter=rZ));t||(e.wrapS=hZ,e.wrapT=hZ)}(e);for(var t="",n=0;n<OQ.length;n++){t+=e[OQ[n]].toString()}return t}var kQ=["px","nx","py","ny","pz","nz"];function zQ(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)}function VQ(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)}bq.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");var BQ,FQ,GQ,HQ,UQ,WQ,jQ,XQ=bY.extend((function(){return{softShadow:XQ.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"highp",_lastRenderNotCastShadow:!1,_frameBuffer:new k$,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new NQ}}),(function(){this._gaussianPassH=new lJ({fragment:bq.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new lJ({fragment:bq.source("clay.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new lJ({fragment:bq.source("clay.sm.debug_depth")})}),{render:function(e,t,n,r){n||(n=t.getMainCamera()),this.trigger("beforerender",this,e,t,n),this._renderShadowPass(e,t,n,r),this.trigger("afterrender",this,e,t,n)},renderDebug:function(e,t){e.saveClear();var n=e.viewport,r=0,i=t||n.width/4,o=i;for(var a in this.softShadow===XQ.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[a];e.setViewport(r,0,i*s.width/s.height,o),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),r+=i*s.width/s.height}e.setViewport(n),e.restoreClear()},_updateReceivers:function(e,t){if(t.receiveShadow?(this._receivers.push(t),t.material.set("shadowEnabled",1),t.material.set("pcfKernel",this.kernelPCF)):t.material.set("shadowEnabled",0),this.softShadow===XQ.VSM)t.material.define("fragment","USE_VSM"),t.material.undefine("fragment","PCF_KERNEL_SIZE");else{t.material.undefine("fragment","USE_VSM");var n=this.kernelPCF;n&&n.length?t.material.define("fragment","PCF_KERNEL_SIZE",n.length/2):t.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(e,t){var n=this;t.traverse((function(t){t.isRenderable()&&n._updateReceivers(e,t)}));for(var r=0;r<t.lights.length;r++){var i=t.lights[r];i.castShadow&&!i.invisible&&this._lightsCastShadow.push(i)}},_renderShadowPass:function(e,t,n,r){for(var i in this._shadowMapNumber)this._shadowMapNumber[i]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var o=e.gl;if(r||t.update(),n&&n.update(),t.updateLights(),this._update(e,t),this._lightsCastShadow.length||!this._lastRenderNotCastShadow){this._lastRenderNotCastShadow=0===this._lightsCastShadow,o.enable(o.DEPTH_TEST),o.depthMask(!0),o.disable(o.BLEND),o.clearColor(1,1,1,1);for(var a,s=[],l=[],u=[],c=[],h=[],d=[],p=0;p<this._lightsCastShadow.length;p++){var f=this._lightsCastShadow[p];if("DIRECTIONAL_LIGHT"===f.type){if(a){console.warn("Only one direectional light supported with shadow cascade");continue}if(f.shadowCascade>4){console.warn("Support at most 4 cascade");continue}f.shadowCascade>1&&(a=f),this.renderDirectionalLightShadow(e,t,n,f,h,c,u)}else"SPOT_LIGHT"===f.type?this.renderSpotLightShadow(e,t,f,l,s):"POINT_LIGHT"===f.type&&this.renderPointLightShadow(e,t,f,d);this._shadowMapNumber[f.type]++}for(var g in this._shadowMapNumber){var m=this._shadowMapNumber[g],v=g+"_SHADOWMAP_COUNT";for(p=0;p<this._receivers.length;p++){(y=this._receivers[p].material).fragmentDefines[v]!==m&&(m>0?y.define("fragment",v,m):y.isDefined("fragment",v)&&y.undefine("fragment",v))}}for(p=0;p<this._receivers.length;p++){var y=this._receivers[p].material;a?y.define("fragment","SHADOW_CASCADE",a.shadowCascade):y.undefine("fragment","SHADOW_CASCADE")}var _=t.shadowUniforms;if(u.length>0){var x=u.map(T);if(_.directionalLightShadowMaps={value:u,type:"tv"},_.directionalLightMatrices={value:c,type:"m4v"},_.directionalLightShadowMapSizes={value:x,type:"1fv"},a){var b=h.slice(),w=h.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),c.reverse(),_.shadowCascadeClipsNear={value:b,type:"1fv"},_.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var S=s.map(T);(_=t.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},_.spotLightMatrices={value:l,type:"m4v"},_.spotLightShadowMapSizes={value:S,type:"1fv"}}d.length>0&&(_.pointLightShadowMaps={value:d,type:"tv"})}function T(e){return e.height}},renderDirectionalLightShadow:(BQ=new u$,FQ=new iK,GQ=new _K,HQ=new iK,UQ=new iK,WQ=new iK,jQ=new iK,function(e,t,n,r,i,o,a){var s=this._getDepthMaterial(r),l={getMaterial:function(e){return e.shadowDepthMaterial||s},isMaterialChanged:VQ,getUniform:zQ,ifRender:function(e){return e.castShadow},sortCompare:zq.opaqueSortCompare};if(!t.viewBoundingBoxLastFrame.isFinite()){var u=t.getBoundingBox();t.viewBoundingBoxLastFrame.copy(u).applyTransform(n.viewMatrix)}var c=Math.min(-t.viewBoundingBoxLastFrame.min.z,n.far),h=Math.max(-t.viewBoundingBoxLastFrame.max.z,n.near),d=this._getDirectionalLightCamera(r,t,n),p=WQ.array;jQ.copy(d.projectionMatrix),Mq.invert(UQ.array,d.worldTransform.array),Mq.multiply(UQ.array,UQ.array,n.worldTransform.array),Mq.multiply(p,jQ.array,UQ.array);for(var f=[],g=n instanceof M$,m=(n.near+n.far)/(n.near-n.far),v=2*n.near*n.far/(n.near-n.far),y=0;y<=r.shadowCascade;y++){var _=h*Math.pow(c/h,y/r.shadowCascade),x=h+(c-h)*y/r.shadowCascade,b=_*r.cascadeSplitLogFactor+x*(1-r.cascadeSplitLogFactor);f.push(b),i.push(-(-b*m+v)/-b)}var w=this._getTexture(r,r.shadowCascade);a.push(w);var S=e.viewport,T=e.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(e),T.clear(T.COLOR_BUFFER_BIT|T.DEPTH_BUFFER_BIT),y=0;y<r.shadowCascade;y++){var M=f[y],C=f[y+1];g?Mq.perspective(FQ.array,n.fov/180*Math.PI,n.aspect,M,C):Mq.ortho(FQ.array,n.left,n.right,n.bottom,n.top,M,C),BQ.setFromProjection(FQ),BQ.getTransformedBoundingBox(GQ,UQ),GQ.applyProjection(jQ);var D=GQ.min.array,A=GQ.max.array;D[0]=Math.max(D[0],-1),D[1]=Math.max(D[1],-1),A[0]=Math.min(A[0],1),A[1]=Math.min(A[1],1),HQ.ortho(D[0],A[0],D[1],A[1],1,-1),d.projectionMatrix.multiplyLeft(HQ);var I=r.shadowResolution||512;e.setViewport((r.shadowCascade-y-1)*I,0,I,I,1);var E=t.updateRenderList(d);e.renderPass(E.opaque,d,l),this.softShadow===XQ.VSM&&this._gaussianFilter(e,w,w.width);var L=new iK;L.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),o.push(L.array),d.projectionMatrix.copy(jQ)}this._frameBuffer.unbind(e),e.setViewport(S)}),renderSpotLightShadow:function(e,t,n,r,i){var o=this._getTexture(n),a=this._getSpotLightCamera(n),s=e.gl;this._frameBuffer.attach(o),this._frameBuffer.bind(e),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(n),u={getMaterial:function(e){return e.shadowDepthMaterial||l},isMaterialChanged:VQ,getUniform:zQ,ifRender:function(e){return e.castShadow},sortCompare:zq.opaqueSortCompare},c=t.updateRenderList(a);e.renderPass(c.opaque,a,u),this._frameBuffer.unbind(e),this.softShadow===XQ.VSM&&this._gaussianFilter(e,o,o.width);var h=new iK;h.copy(a.worldTransform).invert().multiplyLeft(a.projectionMatrix),i.push(o),r.push(h.array)},renderPointLightShadow:function(e,t,n,r){var i=this._getTexture(n),o=e.gl;r.push(i);var a=this._getDepthMaterial(n),s={getMaterial:function(e){return e.shadowDepthMaterial||a},getUniform:zQ,sortCompare:zq.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},u=new _K,c=n.getWorldPosition().array,h=new _K,d=n.range;h.min.setArray(c),h.max.setArray(c);var p=new Bq(d,d,d);h.max.add(p),h.min.sub(p);var f={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};t.traverse((function(e){if(e.isRenderable()&&e.castShadow){var t=e.geometry;if(!t.boundingBox){for(var n=0;n<kQ.length;n++)l[kQ[n]].push(e);return}if(u.transformFrom(t.boundingBox,e.worldTransform),!u.intersectBoundingBox(h))return;u.updateVertices();for(n=0;n<kQ.length;n++)f[kQ[n]]=!1;for(n=0;n<8;n++){var r=u.vertices[n],i=r[0]-c[0],o=r[1]-c[1],a=r[2]-c[2],s=Math.abs(i),d=Math.abs(o),p=Math.abs(a);s>d?s>p?f[i>0?"px":"nx"]=!0:f[a>0?"pz":"nz"]=!0:d>p?f[o>0?"py":"ny"]=!0:f[a>0?"pz":"nz"]=!0}for(n=0;n<kQ.length;n++)f[kQ[n]]&&l[kQ[n]].push(e)}}));for(var g=0;g<6;g++){var m=kQ[g],v=this._getPointLightCamera(n,m);this._frameBuffer.attach(i,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+g),this._frameBuffer.bind(e),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),e.renderPass(l[m],v,s)}this._frameBuffer.unbind(e)},_getDepthMaterial:function(e){var t=this._lightMaterials[e.__uid__],n="POINT_LIGHT"===e.type;if(!t){var r=n?"clay.sm.distance.":"clay.sm.depth.";t=new WZ({precision:this.precision,shader:new bq(bq.source(r+"vertex"),bq.source(r+"fragment"))}),this._lightMaterials[e.__uid__]=t}return null!=e.shadowSlopeScale&&t.setUniform("slopeScale",e.shadowSlopeScale),null!=e.shadowBias&&t.setUniform("bias",e.shadowBias),this.softShadow===XQ.VSM?t.define("fragment","USE_VSM"):t.undefine("fragment","USE_VSM"),n&&(t.set("lightPosition",e.getWorldPosition().array),t.set("range",e.range)),t},_gaussianFilter:function(e,t,n){var r={width:n,height:n,type:AK.FLOAT},i=this._texturePool.get(r);this._frameBuffer.attach(i),this._frameBuffer.bind(e),this._gaussianPassH.setUniform("texture",t),this._gaussianPassH.setUniform("textureWidth",n),this._gaussianPassH.render(e),this._frameBuffer.attach(t),this._gaussianPassV.setUniform("texture",i),this._gaussianPassV.setUniform("textureHeight",n),this._gaussianPassV.render(e),this._frameBuffer.unbind(e),this._texturePool.put(i)},_getTexture:function(e,t){var n=e.__uid__,r=this._textures[n],i=e.shadowResolution||512;return t=t||1,r||((r="POINT_LIGHT"===e.type?new S$:new PK).width=i*t,r.height=i,this.softShadow===XQ.VSM?(r.type=AK.FLOAT,r.anisotropic=4):(r.minFilter=nZ,r.magFilter=nZ,r.useMipmap=!1),this._textures[n]=r),r},_getPointLightCamera:function(e,t){this._lightCameras.point||(this._lightCameras.point={px:new M$,nx:new M$,py:new M$,ny:new M$,pz:new M$,nz:new M$});var n=this._lightCameras.point[t];switch(n.far=e.range,n.fov=90,n.position.set(0,0,0),t){case"px":n.lookAt(Bq.POSITIVE_X,Bq.NEGATIVE_Y);break;case"nx":n.lookAt(Bq.NEGATIVE_X,Bq.NEGATIVE_Y);break;case"py":n.lookAt(Bq.POSITIVE_Y,Bq.POSITIVE_Z);break;case"ny":n.lookAt(Bq.NEGATIVE_Y,Bq.NEGATIVE_Z);break;case"pz":n.lookAt(Bq.POSITIVE_Z,Bq.NEGATIVE_Y);break;case"nz":n.lookAt(Bq.NEGATIVE_Z,Bq.NEGATIVE_Y)}return e.getWorldPosition(n.position),n.update(),n},_getDirectionalLightCamera:function(){var e=new iK,t=new _K,n=new _K;return function(r,i,o){this._lightCameras.directional||(this._lightCameras.directional=new iJ);var a=this._lightCameras.directional;t.copy(i.viewBoundingBoxLastFrame),t.intersection(o.frustum.boundingBox),a.position.copy(t.min).add(t.max).scale(.5).transformMat4(o.worldTransform),a.rotation.copy(r.rotation),a.scale.copy(r.scale),a.updateWorldTransform(),iK.invert(e,a.worldTransform),iK.multiply(e,e,o.worldTransform),n.copy(t).applyTransform(e);var s=n.min.array,l=n.max.array;return a.position.set((s[0]+l[0])/2,(s[1]+l[1])/2,l[2]).transformMat4(a.worldTransform),a.near=0,a.far=-s[2]+l[2],isNaN(this.lightFrustumBias)?a.far*=4:a.far+=this.lightFrustumBias,a.left=s[0],a.right=l[0],a.top=l[1],a.bottom=s[1],a.update(!0),a}}(),_getSpotLightCamera:function(e){this._lightCameras.spot||(this._lightCameras.spot=new M$);var t=this._lightCameras.spot;return t.fov=2*e.penumbraAngle,t.far=e.range,t.worldTransform.copy(e.worldTransform),t.updateProjectionMatrix(),Mq.invert(t.viewMatrix.array,t.worldTransform.array),t},dispose:function(e){var t=e.gl||e;for(var n in this._frameBuffer&&this._frameBuffer.dispose(t),this._textures)this._textures[n].dispose(t);this._texturePool.clear(e.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var r=0;r<this._receivers.length;r++){var i=this._receivers[r];if(i.material){var o=i.material;o.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),o.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),o.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),o.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});XQ.VSM=1,XQ.PCF=2;var YQ=bY.extend((function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),{updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n=o.width instanceof Function?o.width.call(this,t):o.width,r=o.height instanceof Function?o.height.call(this,t):o.height,a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t.gl),a.width=n,a.height=r,a},setParameter:function(e,t){},getParameter:function(e){},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},render:function(){},getOutput:function(e,t){if(null==t)return t=e,this._outputTextures[t];var n=this.outputs[t];return n?this._rendered?n.outputLastFrame?this._prevOutputTextures[t]:this._outputTextures[t]:this._rendering?(this._prevOutputTextures[t]||(this._prevOutputTextures[t]=this._compositor.allocateTexture(n.parameters||{})),this._prevOutputTextures[t]):(this.render(e),this._outputTextures[t]):void 0},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.enableTexture(e)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(e){if(!this._rendering){for(var t in this._rendering=!0,this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){for(var e in this._rendered=!1,this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks){if(this._outputReferences[e]>0)this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}}),ZQ=bY.extend((function(){return{nodes:[]}}),{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t<this.nodes.length;t++)if(this.nodes[t].name===e)return this.nodes[t]},update:function(){for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear();for(e=0;e<this.nodes.length;e++){var t=this.nodes[e];if(t.inputs)for(var n in t.inputs)if(t.inputs[n])if(!t.pass||t.pass.material.isUniformEnabled(n)){var r=t.inputs[n],i=this.findPin(r);i?t.link(n,i.node,i.pin):"string"==typeof r?console.warn("Node "+r+" not exist"):console.warn("Pin of "+r.node+"."+r.pin+" not exist")}else console.warn("Pin "+t.name+"."+n+" not used.")}},findPin:function(e){var t;if(("string"==typeof e||e instanceof YQ)&&(e={node:e}),"string"==typeof e.node)for(var n=0;n<this.nodes.length;n++){var r=this.nodes[n];r.name===e.node&&(t=r)}else t=e.node;if(t){var i=e.pin;if(i||t.outputs&&(i=Object.keys(t.outputs)[0]),t.outputs[i])return{node:t,pin:i}}}}),qQ=ZQ.extend((function(){return{_outputs:[],_texturePool:new NQ,_frameBuffer:new k$({depthBuffer:!1})}}),{addNode:function(e){ZQ.prototype.addNode.call(this,e),e._compositor=this},render:function(e,t){if(this._dirty){this.update(),this._dirty=!1,this._outputs.length=0;for(var n=0;n<this.nodes.length;n++)this.nodes[n].outputs||this._outputs.push(this.nodes[n])}for(n=0;n<this.nodes.length;n++)this.nodes[n].beforeFrame();for(n=0;n<this._outputs.length;n++)this._outputs[n].updateReference();for(n=0;n<this._outputs.length;n++)this._outputs[n].render(e,t);for(n=0;n<this.nodes.length;n++)this.nodes[n].afterFrame()},allocateTexture:function(e){return this._texturePool.get(e)},releaseTexture:function(e){this._texturePool.put(e)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(e){this._texturePool.clear(e)}}),KQ=YQ.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},(function(){this.frameBuffer=new k$}),{render:function(e){this._rendering=!0;var t,n=e.gl;if(this.trigger("beforerender"),this.outputs){var r=this.frameBuffer;for(var i in this.outputs){var o=this.updateParameter(i,e),a=this.outputs[i],s=this._compositor.allocateTexture(o);this._outputTextures[i]=s,"string"==typeof(c=a.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),r.attach(s,c)}r.bind(e);var l=e.getGLExtension("EXT_draw_buffers");if(l){var u=[];for(var c in this.outputs)(c=parseInt(c))>=n.COLOR_ATTACHMENT0&&c<=n.COLOR_ATTACHMENT0+8&&u.push(c);l.drawBuffersEXT(u)}e.saveClear(),e.clearBit=MY|DY,t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),r.unbind(e)}else t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",t),this._rendering=!1,this._rendered=!0}}),$Q=YQ.extend((function(){return{texture:null,outputs:{color:{}}}}),(function(){}),{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),JQ=YQ.extend((function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),(function(){var e=new lJ({fragment:this.shader});this.pass=e}),{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var r in this.inputLinks){var i=(h=this.inputLinks[r]).node.getOutput(e,h.pin);this.pass.setUniform(r,i)}if(this.outputs){this.pass.outputs={};var o={};for(var a in this.outputs){var s=this.updateParameter(a,e);isNaN(s.width)&&this.updateParameter(a,e);var l=this.outputs[a],u=this._compositor.allocateTexture(s);this._outputTextures[a]=u,"string"==typeof(c=l.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),o[c]=u}for(var c in this._compositor.getFrameBuffer().bind(e),o)this._compositor.getFrameBuffer().attach(o[c],c);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var r in this.inputLinks){var h;(h=this.inputLinks[r]).node.removeReference(h.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n="function"==typeof o.width?o.width.call(this,t):o.width,r="function"==typeof o.height?o.height.call(this,t):o.height,n=Math.ceil(n),r=Math.ceil(r),a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t),a.width=n,a.height=r,a},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},clear:function(){YQ.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),QQ="@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n",e0="\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end",t0="@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",n0="@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n",r0="@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end",i0="\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end",o0="@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",a0="@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end",s0="@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";!function(e){e.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),e.import(QQ),e.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),e.import(e0),e.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),e.import(t0),e.import(n0),e.import(r0),e.import(i0),e.import(o0),e.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),e.import(a0),e.import(s0)}(bq);var l0=/^#source\((.*?)\)/;function u0(e,t){var n=new qQ;t=t||{};var r={textures:{},parameters:{}};for(var i in e.parameters){var o=e.parameters[i];r.parameters[i]=p0(o)}return function(e,t,n,r){if(!e.textures)return void r({});var i={},o=0,a=!1,s=n.textureRootPath;xY.each(e.textures,(function(e,t){var n,l=e.path,u=p0(e.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map((function(e){return xY.relative2absolute(e,s)}))),n=new S$(u);else{if("string"!=typeof l)return;s&&(l=xY.relative2absolute(l,s)),n=new PK(u)}n.load(l),o++,n.once("success",(function(){i[t]=n,0===--o&&(r(i),a=!0)}))})),0!==o||a||r(i)}(e,0,t,(function(i){r.textures=i,function(){for(var i=0;i<e.nodes.length;i++){var o=c0(e.nodes[i],r,t);o&&n.addNode(o)}}()})),n}function c0(e,t,n){var r,i,o,a,s=e.type||"filter";if("filter"===s){var l=e.shader.trim(),u=l0.exec(l);if(u?r=bq.source(u[1].trim()):"#"===l.charAt(0)&&(r=t.shaders[l.substr(1)]),r||(r=l),!r)return}if(e.inputs)for(var c in i={},e.inputs)"string"==typeof e.inputs[c]?i[c]=e.inputs[c]:i[c]={node:e.inputs[c].node,pin:e.inputs[c].pin};if(e.outputs)for(var c in o={},e.outputs){var h=e.outputs[c];o[c]={},null!=h.attachment&&(o[c].attachment=h.attachment),null!=h.keepLastFrame&&(o[c].keepLastFrame=h.keepLastFrame),null!=h.outputLastFrame&&(o[c].outputLastFrame=h.outputLastFrame),h.parameters&&(o[c].parameters=p0(h.parameters))}if(a="scene"===s?new KQ({name:e.name,scene:n.scene,camera:n.camera,outputs:o}):"texture"===s?new $Q({name:e.name,outputs:o}):new JQ({name:e.name,shader:r,inputs:i,outputs:o})){if(e.parameters)for(var c in e.parameters){"string"==typeof(d=e.parameters[c])?"#"===(d=d.trim()).charAt(0)?d=t.textures[d.substr(1)]:a.on("beforerender",f0(c,g0(d))):"function"==typeof d&&a.on("beforerender",d),a.setParameter(c,d)}if(e.defines&&a.pass)for(var c in e.defines){var d=e.defines[c];a.pass.material.define("fragment",c,d)}}return a}function h0(e,t){return e}function d0(e,t){return t}function p0(e){var t={};if(!e)return t;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach((function(n){var r=e[n];null!=r&&("string"==typeof r&&(r=AK[r]),t[n]=r)}));var n=e.scale||1;return["width","height"].forEach((function(r){if(null!=e[r]){var i=e[r];"string"==typeof i?(i=i.trim(),t[r]=function(e,t,n){return n=n||1,function(e){var r=e.getDevicePixelRatio(),i=e.getWidth()*n,o=e.getHeight()*n;return t(i,o,r)}}(0,g0(i),n)):t[r]=i}})),t.width||(t.width=h0),t.height||(t.height=d0),null!=e.useMipmap&&(t.useMipmap=e.useMipmap),t}function f0(e,t){return function(n){var r=n.getDevicePixelRatio(),i=n.getWidth(),o=n.getHeight(),a=t(i,o,r);this.setParameter(e,a)}}function g0(e){var t=/^expr\((.*)\)$/.exec(e);if(t)try{var n=new Function("width","height","dpr","return "+t[1]);return n(1,1),n}catch(e){throw new Error("Invalid expression.")}}function m0(e,t){for(var n=0,r=1/t,i=e;i>0;)n+=r*(i%t),i=Math.floor(i/t),r/=t;return n}function v0(e){for(var t=new Uint8Array(e*e*4),n=0,r=new Bq,i=0;i<e;i++)for(var o=0;o<e;o++)r.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),t[n++]=255*(.5*r.x+.5),t[n++]=255*(.5*r.y+.5),t[n++]=0,t[n++]=255;return t}function y0(e){return new PK({pixels:v0(e),wrapS:AK.REPEAT,wrapT:AK.REPEAT,width:e,height:e})}function _0(e,t,n){var r=new Float32Array(3*e);t=t||0;for(var i=0;i<e;i++){var o=m0(i+t,2)*(n?1:2)*Math.PI,a=m0(i+t,3)*Math.PI,s=Math.random(),l=Math.cos(o)*Math.sin(a)*s,u=Math.cos(a)*s,c=Math.sin(o)*Math.sin(a)*s;r[3*i]=l,r[3*i+1]=u,r[3*i+2]=c}return r}function x0(e){e=e||{},this._ssaoPass=new lJ({fragment:bq.source("ecgl.ssao.estimate")}),this._blurPass=new lJ({fragment:bq.source("ecgl.ssao.blur")}),this._framebuffer=new k$({depthBuffer:!1}),this._ssaoTexture=new PK,this._blurTexture=new PK,this._blurTexture2=new PK,this._depthTex=e.depthTexture,this._normalTex=e.normalTexture,this.setNoiseSize(4),this.setKernelSize(e.kernelSize||12),null!=e.radius&&this.setParameter("radius",e.radius),null!=e.power&&this.setParameter("power",e.power),this._normalTex||(this._ssaoPass.material.disableTexture("normalTex"),this._blurPass.material.disableTexture("normalTex")),this._depthTex||this._blurPass.material.disableTexture("depthTex"),this._blurPass.material.setUniform("normalTex",this._normalTex),this._blurPass.material.setUniform("depthTex",this._depthTex)}bq.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),x0.prototype.setDepthTexture=function(e){this._depthTex=e},x0.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},x0.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._ssaoPass,a=this._blurPass;o.setUniform("kernel",this._kernels[n%this._kernels.length]),o.setUniform("depthTex",this._depthTex),null!=this._normalTex&&o.setUniform("normalTex",this._normalTex),o.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new iK;iK.transpose(s,t.worldTransform),o.setUniform("projection",t.projectionMatrix.array),o.setUniform("projectionInv",t.invProjectionMatrix.array),o.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,u=this._blurTexture,c=this._blurTexture2;l.width=r/2,l.height=i/2,u.width=r,u.height=i,c.width=r,c.height=i,this._framebuffer.attach(l),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),o.render(e),a.setUniform("textureSize",[r/2,i/2]),a.setUniform("projection",t.projectionMatrix.array),this._framebuffer.attach(u),a.setUniform("direction",0),a.setUniform("ssaoTexture",l),a.render(e),this._framebuffer.attach(c),a.setUniform("textureSize",[r,i]),a.setUniform("direction",1),a.setUniform("ssaoTexture",u),a.render(e),this._framebuffer.unbind(e);var h=e.clearColor;e.gl.clearColor(h[0],h[1],h[2],h[3])},x0.prototype.getTargetTexture=function(){return this._blurTexture2},x0.prototype.setParameter=function(e,t){"noiseTexSize"===e?this.setNoiseSize(t):"kernelSize"===e?this.setKernelSize(t):"intensity"===e?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)},x0.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=_0(e,t*e,!!this._normalTex)},x0.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=v0(e),t.width=t.height=e,t.dirty()):(t=y0(e),this._ssaoPass.setUniform("noiseTex",y0(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},x0.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e),this._blurTexture2.dispose(e)};function b0(e){e=e||{},this._ssrPass=new lJ({fragment:bq.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new lJ({fragment:bq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new lJ({fragment:bq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new lJ({fragment:bq.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",e.normalTexture),this._ssrPass.setUniform("gBufferTexture2",e.depthTexture),this._blurPass1.setUniform("gBufferTexture1",e.normalTexture),this._blurPass1.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.setUniform("gBufferTexture1",e.normalTexture),this._blurPass2.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new PK({type:AK.HALF_FLOAT}),this._texture2=new PK({type:AK.HALF_FLOAT}),this._texture3=new PK({type:AK.HALF_FLOAT}),this._prevTexture=new PK({type:AK.HALF_FLOAT}),this._currentTexture=new PK({type:AK.HALF_FLOAT}),this._frameBuffer=new k$({depthBuffer:!1}),this._normalDistribution=null,this._totalSamples=256,this._samplePerFrame=4,this._ssrPass.material.define("fragment","SAMPLE_PER_FRAME",this._samplePerFrame),this._ssrPass.material.define("fragment","TOTAL_SAMPLES",this._totalSamples),this._downScale=1}bq.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),b0.prototype.setAmbientCubemap=function(e,t){this._ssrPass.material.set("specularCubemap",e),this._ssrPass.material.set("specularIntensity",t);var n=e&&t;this._ssrPass.material[n?"enableTexture":"disableTexture"]("specularCubemap")},b0.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._ssrTexture,s=this._texture2,l=this._texture3;a.width=this._prevTexture.width=this._currentTexture.width=i/this._downScale,a.height=this._prevTexture.height=this._currentTexture.height=o/this._downScale,s.width=l.width=i,s.height=l.height=o;var u=this._frameBuffer,c=this._ssrPass,h=this._blurPass1,d=this._blurPass2,p=this._blendPass,f=new iK,g=new iK;iK.transpose(f,t.worldTransform),iK.transpose(g,t.viewMatrix),c.setUniform("sourceTexture",n),c.setUniform("projection",t.projectionMatrix.array),c.setUniform("projectionInv",t.invProjectionMatrix.array),c.setUniform("toViewSpace",f.array),c.setUniform("toWorldSpace",g.array),c.setUniform("nearZ",t.near);var m=r/this._totalSamples*this._samplePerFrame;if(c.setUniform("jitterOffset",m),c.setUniform("sampleOffset",r*this._samplePerFrame),h.setUniform("textureSize",[a.width,a.height]),d.setUniform("textureSize",[i,o]),d.setUniform("sourceTexture",n),h.setUniform("projection",t.projectionMatrix.array),d.setUniform("projection",t.projectionMatrix.array),u.attach(a),u.bind(e),c.render(e),this._physicallyCorrect&&(u.attach(this._currentTexture),p.setUniform("texture1",this._prevTexture),p.setUniform("texture2",a),p.material.set({weight1:r>=1?.95:0,weight2:r>=1?.05:1}),p.render(e)),u.attach(s),h.setUniform("texture",this._physicallyCorrect?this._currentTexture:a),h.render(e),u.attach(l),d.setUniform("texture",s),d.render(e),u.unbind(e),this._physicallyCorrect){var v=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=v}},b0.prototype.getTargetTexture=function(){return this._texture3},b0.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},b0.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=uJ.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e},b0.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},b0.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},b0.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)};var w0=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925];function S0(e,t,n,r,i){var o=e.gl;t.setUniform(o,"1i",n,i),o.activeTexture(o.TEXTURE0+i),r.isRenderable()?r.bind(e):r.unbind(e)}function T0(e,t,n,r,i){var o,a,s,l,u=e.gl;return function(i,c,h){if(!l||l.material!==i.material){var d=i.material,p=i.__program,f=d.get("roughness");null==f&&(f=1);var g=d.get("normalMap")||t,m=d.get("roughnessMap"),v=d.get("bumpMap"),y=d.get("uvRepeat"),_=d.get("uvOffset"),x=d.get("detailUvRepeat"),b=d.get("detailUvOffset"),w=!!v&&d.isTextureEnabled("bumpMap"),S=!!m&&d.isTextureEnabled("roughnessMap"),T=d.isDefined("fragment","DOUBLE_SIDED");v=v||n,m=m||r,h!==c?(c.set("normalMap",g),c.set("bumpMap",v),c.set("roughnessMap",m),c.set("useBumpMap",w),c.set("useRoughnessMap",S),c.set("doubleSide",T),null!=y&&c.set("uvRepeat",y),null!=_&&c.set("uvOffset",_),null!=x&&c.set("detailUvRepeat",x),null!=b&&c.set("detailUvOffset",b),c.set("roughness",f)):(p.setUniform(u,"1f","roughness",f),o!==g&&S0(e,p,"normalMap",g,0),a!==v&&v&&S0(e,p,"bumpMap",v,1),s!==m&&m&&S0(e,p,"roughnessMap",m,2),null!=y&&p.setUniform(u,"2f","uvRepeat",y),null!=_&&p.setUniform(u,"2f","uvOffset",_),null!=x&&p.setUniform(u,"2f","detailUvRepeat",x),null!=b&&p.setUniform(u,"2f","detailUvOffset",b),p.setUniform(u,"1i","useBumpMap",+w),p.setUniform(u,"1i","useRoughnessMap",+S),p.setUniform(u,"1i","doubleSide",+T)),o=g,a=v,s=m,l=i}}}function M0(e){this._depthTex=new PK({format:AK.DEPTH_COMPONENT,type:AK.UNSIGNED_INT}),this._normalTex=new PK({type:AK.HALF_FLOAT}),this._framebuffer=new k$,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,k$.DEPTH_ATTACHMENT),this._normalMaterial=new WZ({shader:new bq(bq.source("ecgl.normal.vertex"),bq.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=eJ.createBlank("#000"),this._defaultBumpMap=eJ.createBlank("#000"),this._defaultRoughessMap=eJ.createBlank("#000"),this._debugPass=new lJ({fragment:bq.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}function C0(e){e=e||{},this._edgePass=new lJ({fragment:bq.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new PK({type:AK.HALF_FLOAT}),this._frameBuffer=new k$,this._frameBuffer.attach(this._targetTexture)}bq.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),M0.prototype.getDepthTexture=function(){return this._depthTex},M0.prototype.getNormalTexture=function(){return this._normalTex},M0.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._depthTex,a=this._normalTex,s=this._normalMaterial;o.width=r,o.height=i,a.width=r,a.height=i;var l=t.getRenderList(n).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,n,{getMaterial:function(){return s},ifRender:function(e){return e.renderNormal},beforeRender:T0(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},M0.prototype.renderDebug=function(e){this._debugPass.render(e)},M0.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},C0.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._targetTexture;a.width=i,a.height=o;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,o]),this._edgePass.setUniform("texture",n),this._edgePass.render(e),s.unbind(e)},C0.prototype.getTargetTexture=function(){return this._targetTexture},C0.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},C0.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};var D0={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]};function A0(e,t){return{color:{parameters:{width:e,height:t}}}}bq.import(QQ),bq.import(e0),bq.import(t0),bq.import(n0),bq.import(r0),bq.import(i0),bq.import(o0),bq.import(a0),bq.import(s0),bq.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),bq.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");var I0=["composite","FXAA"];function E0(){this._width,this._height,this._dpr,this._sourceTexture=new PK({type:AK.HALF_FLOAT}),this._depthTexture=new PK({format:AK.DEPTH_COMPONENT,type:AK.UNSIGNED_INT}),this._framebuffer=new k$,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,k$.DEPTH_ATTACHMENT),this._normalPass=new M0,this._compositor=u0(D0);var e=this._compositor.getNodeByName("source");e.texture=this._sourceTexture;var t=this._compositor.getNodeByName("coc");this._sourceNode=e,this._cocNode=t,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map((function(e){return this._compositor.getNodeByName(e)}),this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=I0.map((function(e){return this._compositor.getNodeByName(e)}),this);var n={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new x0(n),this._ssrPass=new b0(n),this._edgePass=new C0(n)}function L0(e){for(var t=[],n=0;n<30;n++)t.push([m0(n,2),m0(n,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new PK,this._sourceFb=new k$,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new PK,this._outputTex=new PK;var r=this._blendPass=new lJ({fragment:bq.source("clay.compositor.blend")});r.material.disableTexturesAll(),r.material.enableTexture(["texture1","texture2"]),this._blendFb=new k$({depthBuffer:!1}),this._outputPass=new lJ({fragment:bq.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}function N0(e){e=e||"perspective",this.layer=null,this.scene=new _$,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new E0,this._temporalSS=new L0,this._shadowMapPass=new XQ;for(var t=[],n=0,r=0;r<30;r++){for(var i=[],o=0;o<6;o++)i.push(4*m0(n,2)-2),i.push(4*m0(n,3)-2),n++;t.push(i)}this._pcfKernels=t,this.scene.on("beforerender",(function(e,t,n){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,n)}),this)}E0.prototype.resize=function(e,t,n){e*=n=n||1,t*=n;var r=this._sourceTexture,i=this._depthTexture;r.width=e,r.height=t,i.width=e,i.height=t;var o={getWidth:function(){return e},getHeight:function(){return t},getDevicePixelRatio:function(){return n}};function a(e,t){if("function"==typeof e[t]){var n=e[t].__original||e[t];e[t]=function(e){return n.call(this,o)},e[t].__original=n}}this._compositor.nodes.forEach((function(e){for(var t in e.outputs){var n=e.outputs[t].parameters;n&&(a(n,"width"),a(n,"height"))}for(var r in e.parameters)a(e.parameters,r)})),this._width=e,this._height=t,this._dpr=n},E0.prototype.getWidth=function(){return this._width},E0.prototype.getHeight=function(){return this._height},E0.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},E0.prototype._getPrevNode=function(e){for(var t=I0.indexOf(e.name)-1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t-=1,n=this._finalNodesChain[t];return n},E0.prototype._getNextNode=function(e){for(var t=I0.indexOf(e.name)+1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t+=1,n=this._finalNodesChain[t];return n},E0.prototype._addChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(e.inputs.texture=t.name,n?(e.outputs=A0(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},E0.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(n?(t.outputs=A0(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},E0.prototype.updateNormal=function(e,t,n,r){this._ifRenderNormalPass()&&this._normalPass.update(e,t,n)},E0.prototype.updateSSAO=function(e,t,n,r){this._ssaoPass.update(e,n,r)},E0.prototype.enableSSAO=function(){this._enableSSAO=!0},E0.prototype.disableSSAO=function(){this._enableSSAO=!1},E0.prototype.enableSSR=function(){this._enableSSR=!0},E0.prototype.disableSSR=function(){this._enableSSR=!1},E0.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},E0.prototype.getSourceFrameBuffer=function(){return this._framebuffer},E0.prototype.getSourceTexture=function(){return this._sourceTexture},E0.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},E0.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},E0.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},E0.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},E0.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},E0.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},E0.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},E0.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},E0.prototype.enableEdge=function(){this._enableEdge=!0},E0.prototype.disableEdge=function(){this._enableEdge=!1},E0.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)},E0.prototype.setSSAOParameter=function(e,t){switch(e){case"quality":var n={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",n);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/200);break;case"intensity":this._ssaoPass.setParameter(e,t);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown SSAO parameter "+e)}},E0.prototype.setDOFParameter=function(e,t){switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].setParameter("blurRadius",t);break;case"quality":var r={low:4,medium:8,high:16,ultra:32}[t]||8;this._dofBlurKernelSize=r;for(n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].pass.material.define("POISSON_KERNEL_SIZE",r);this._dofBlurKernel=new Float32Array(2*r);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown DOF parameter "+e)}},E0.prototype.setSSRParameter=function(e,t){if(null!=t)switch(e){case"quality":var n={low:10,medium:15,high:30,ultra:80}[t]||20,r={low:32,medium:16,high:8,ultra:4}[t]||16;this._ssrPass.setParameter("maxIteration",n),this._ssrPass.setParameter("pixelStride",r);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-t,1),0));break;case"physical":this.setPhysicallyCorrectSSR(t);break;default:console.warn("Unkown SSR parameter "+e)}},E0.prototype.setPhysicallyCorrectSSR=function(e){this._ssrPass.setPhysicallyCorrect(e)},E0.prototype.setEdgeColor=function(e){var t=zJ.parseColor(e);this._edgePass.setParameter("edgeColor",t)},E0.prototype.setExposure=function(e){this._compositeNode.setParameter("exposure",Math.pow(2,e))},E0.prototype.setColorLookupTexture=function(e,t){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?e:"none",t,{minFilter:zJ.Texture.NEAREST,magFilter:zJ.Texture.NEAREST,flipY:!1})},E0.prototype.setColorCorrection=function(e,t){this._compositeNode.setParameter(e,t)},E0.prototype.isSSREnabled=function(){return this._enableSSR},E0.prototype.composite=function(e,t,n,r,i){var o=this._sourceTexture,a=o;this._enableEdge&&(this._edgePass.update(e,n,o,i),o=a=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(e,n,o,i),a=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=a,this._cocNode.setParameter("depth",this._depthTexture);for(var s=this._dofBlurKernel,l=this._dofBlurKernelSize,u=i%Math.floor(w0.length/2/l),c=0;c<2*l;c++)s[c]=w0[c+u*l*2];for(c=0;c<this._dofBlurNodes.length;c++)this._dofBlurNodes[c].setParameter("percent",i/30),this._dofBlurNodes[c].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",n.near),this._cocNode.setParameter("zFar",n.far),this._compositor.render(e,r)},E0.prototype.dispose=function(e){this._sourceTexture.dispose(e),this._depthTexture.dispose(e),this._framebuffer.dispose(e),this._compositor.dispose(e),this._normalPass.dispose(e),this._ssaoPass.dispose(e)},L0.prototype={constructor:L0,jitterProjection:function(e,t){var n=e.viewport,r=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*r,o=n.height*r,a=this._haltonSequence[this._frame%this._haltonSequence.length],s=new iK;s.array[12]=(2*a[0]-1)/i,s.array[13]=(2*a[1]-1)/o,iK.mul(t.projectionMatrix,s,t.projectionMatrix),iK.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,n){var r=this._blendPass;0===this._frame?(r.setUniform("weight1",0),r.setUniform("weight2",1)):(r.setUniform("weight1",.9),r.setUniform("weight2",.1)),r.setUniform("texture1",this._prevFrameTex),r.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),r.render(e),this._blendFb.unbind(e),n||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},N0.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof M$||(this.camera=new M$,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof iJ||(this.camera=new iJ,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},N0.prototype.setViewport=function(e,t,n,r,i){this.camera instanceof M$&&(this.camera.aspect=n/r),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=n,this.viewport.height=r,this.viewport.devicePixelRatio=i,this._compositor.resize(n*i,r*i),this._temporalSS.resize(n*i,r*i)},N0.prototype.containPoint=function(e,t){var n=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var P0=new qZ;function O0(e,t){var n=Wd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=e.get("boxWidth"),i=e.get("boxHeight"),o=e.get("boxDepth");"production"!==process.env.NODE_ENV&&["x","y","z"].forEach((function(t){if(!this.getAxis(t))throw new Error("Grid"+e.id+" don't have "+t+"Axis")}),this),this.getAxis("x").setExtent(-r/2,r/2),this.getAxis("y").setExtent(o/2,-o/2),this.getAxis("z").setExtent(-i/2,i/2),this.size=[r,i,o]}function R0(e,t){var n={};e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData();["x","y","z"].forEach((function(e){t.mapDimensionsAll(e,!0).forEach((function(r){!function(e,t){n[e]=n[e]||[1/0,-1/0],n[e][0]=Math.min(t[0],n[e][0]),n[e][1]=Math.max(t[1],n[e][1])}(e,t.getDataExtent(r,!0))}))}))}}),this),["xAxis3D","yAxis3D","zAxis3D"].forEach((function(t){e.eachComponent(t,(function(e){var r=t.charAt(0),i=e.getReferringComponents("grid3D").models[0],o=i.coordinateSystem;if(o===this){var a=o.getAxis(r);if(a)"production"!==process.env.NODE_ENV&&console.warn("Can't have two %s in one grid3D",t);else{(a=new LQ(r,Jx(n[r]||[1/0,-1/0],e))).type=e.get("type");var s="category"===a.type;a.onBand=s&&e.get("boundaryGap"),a.inverse=e.get("inverse"),e.axis=a,a.model=e,a.getLabelModel=function(){return e.getModel("axisLabel",i.getModel("axisLabel"))},a.getTickModel=function(){return e.getModel("axisTick",i.getModel("axisTick"))},o.addAxis(a)}}}),this)}),this),this.resize(this.model,t)}N0.prototype.castRay=function(e,t,n){var r=this.layer.renderer,i=r.viewport;return r.viewport=this.viewport,r.screenToNDC(e,t,P0),this.camera.castRay(P0,n),r.viewport=i,n},N0.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t<e.transparent.length;t++){var n=e.transparent[t].geometry;n.needsSortVerticesProgressively&&n.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),n.needsSortTrianglesProgressively&&n.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},N0.prototype.render=function(e,t){this._doRender(e,t,this._frame),this._frame++},N0.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},N0.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"===e&&(e=this._enablePostEffect),e},N0.prototype.hasDOF=function(){return this._enableDOF},N0.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},N0.prototype._doRender=function(e,t,n){var r=this.scene,i=this.camera;n=n||0,this._updateTransparent(e,r,i,n),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,r,i,!0)),this._updateShadowPCFKernel(n);var o,a=e.clearColor;(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,r,i,this._temporalSS.getFrame())),this._updateSSAO(e,r,i,this._temporalSS.getFrame()),this._enablePostEffect)?((o=this._compositor.getSourceFrameBuffer()).bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(r,i,!0,!0),o.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,r,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,r,i,null,0))):this.needsTemporalSS()&&t?((o=this._temporalSS.getSourceFrameBuffer()).bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(r,i,!0,!0),e.restoreClear(),o.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),e.render(r,i,!0,!0))},N0.prototype._updateTransparent=function(e,t,n,r){for(var i=new Bq,o=new iK,a=n.getWorldPosition(),s=t.getRenderList(n).transparent,l=0;l<s.length;l++){var u=s[l],c=u.geometry;iK.invert(o,u.worldTransform),Bq.transformMat4(i,a,o),c.needsSortTriangles&&c.needsSortTriangles()&&c.doSortTriangles(i,r),c.needsSortVertices&&c.needsSortVertices()&&c.doSortVertices(i,r)}},N0.prototype._updateSSAO=function(e,t,n){var r=this._enableSSAO&&this._enablePostEffect;r&&this._compositor.updateSSAO(e,t,n,this._temporalSS.getFrame());for(var i=t.getRenderList(n),o=0;o<i.opaque.length;o++){var a=i.opaque[o];a.renderNormal&&a.material[r?"enableTexture":"disableTexture"]("ssaoMap"),r&&a.material.set("ssaoMap",this._compositor.getSSAOTexture())}},N0.prototype._updateShadowPCFKernel=function(e){for(var t=this._pcfKernels[e%this._pcfKernels.length],n=this.scene.getRenderList(this.camera).opaque,r=0;r<n.length;r++)n[r].receiveShadow&&(n[r].material.set("pcfKernel",t),n[r].material.define("fragment","PCF_KERNEL_SIZE",t.length/2))},N0.prototype.dispose=function(e){this._compositor.dispose(e.gl),this._temporalSS.dispose(e.gl),this._shadowMapPass.dispose(e)},N0.prototype.setPostEffect=function(e,t){var n=this._compositor;this._enablePostEffect=e.get("enable");var r=e.getModel("bloom"),i=e.getModel("edge"),o=e.getModel("DOF",e.getModel("depthOfField")),a=e.getModel("SSAO",e.getModel("screenSpaceAmbientOcclusion")),s=e.getModel("SSR",e.getModel("screenSpaceReflection")),l=e.getModel("FXAA"),u=e.getModel("colorCorrection");r.get("enable")?n.enableBloom():n.disableBloom(),o.get("enable")?n.enableDOF():n.disableDOF(),s.get("enable")?n.enableSSR():n.disableSSR(),u.get("enable")?n.enableColorCorrection():n.disableColorCorrection(),i.get("enable")?n.enableEdge():n.disableEdge(),l.get("enable")?n.enableFXAA():n.disableFXAA(),this._enableDOF=o.get("enable"),this._enableSSAO=a.get("enable"),this._enableSSAO?n.enableSSAO():n.disableSSAO(),n.setBloomIntensity(r.get("intensity")),n.setEdgeColor(i.get("color")),n.setColorLookupTexture(u.get("lookupTexture"),t),n.setExposure(u.get("exposure")),["radius","quality","intensity"].forEach((function(e){n.setSSAOParameter(e,a.get(e))})),["quality","maxRoughness","physical"].forEach((function(e){n.setSSRParameter(e,s.get(e))})),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach((function(e){n.setDOFParameter(e,o.get(e))})),["brightness","contrast","saturation"].forEach((function(e){n.setColorCorrection(e,u.get(e))}))},N0.prototype.setDOFFocusOnPoint=function(e){if(this._enablePostEffect){if(e>this.camera.far||e<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",e),!0}},N0.prototype.setTemporalSuperSampling=function(e){this._enableTemporalSS=e.get("enable")},N0.prototype.isLinearSpace=function(){return this._enablePostEffect},N0.prototype.setRootNode=function(e){if(this.rootNode!==e){for(var t=this.rootNode.children(),n=0;n<t.length;n++)e.add(t[n]);e!==this.scene&&this.scene.add(e),this.rootNode=e}},N0.prototype.add=function(e){this.rootNode.add(e)},N0.prototype.remove=function(e){this.rootNode.remove(e)},N0.prototype.removeAll=function(e){this.rootNode.removeAll(e)},Object.assign(N0.prototype,vY);var k0={dimensions:EQ.prototype.dimensions,create:function(e,t){var n=[];e.eachComponent("grid3D",(function(e){e.__viewGL=e.__viewGL||new N0;var t=new EQ;t.model=e,t.viewGL=e.__viewGL,e.coordinateSystem=t,n.push(t),t.resize=O0,t.update=R0}));var r=["xAxis3D","yAxis3D","zAxis3D"];return e.eachSeries((function(t){if("cartesian3D"===t.get("coordinateSystem")){if(null==(i=t.getReferringComponents("grid3D").models[0])){var n=function(e,t){return r.map((function(n){var r=e.getReferringComponents(n).models[0];if(null==r&&(r=t.getComponent(n)),"production"!==process.env.NODE_ENV&&!r)throw new Error(n+' "'+vJ(e.get(n+"Index"),e.get(n+"Id"),0)+'" not found');return r}))}(t,e),i=n[0].getCoordSysModel();n.forEach((function(e){var t=e.getCoordSysModel();if("production"!==process.env.NODE_ENV){if(!t)throw new Error('grid3D "'+vJ(e.get("gridIndex"),e.get("gridId"),0)+'" not found');if(t!==i)throw new Error("xAxis3D, yAxis3D, zAxis3D must use the same grid")}}))}var o=i.coordinateSystem;t.coordinateSystem=o}})),n}},z0=$d.extend({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});Qx(z0);var V0={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},B0=R({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},V0),F0=R({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},V0),G0=V({scale:!0,min:"dataMin",max:"dataMax"},F0),H0=V({logBase:10},F0);H0.scale=!0;var U0={categoryAxis3D:B0,valueAxis3D:F0,timeAxis3D:G0,logAxis3D:H0},W0=["value","category","time","log"];function j0(e,t){return t.type||(t.data?"category":"value")}i_((function(e){e.registerComponentModel(tQ),e.registerComponentView(IQ),e.registerCoordinateSystem("grid3D",k0),["x","y","z"].forEach((function(t){!function(e,t,n,r,i){W0.forEach((function(o){var a=n.extend({type:t+"Axis3D."+o,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){R(e,n.getTheme().get(o+"Axis3D")),R(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=W_.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:R(O(U0[o+"Axis3D"]),i,!0)});e.registerComponentModel(a)})),e.registerSubTypeDefaulter(t+"Axis3D",$(r,t))}(e,t,z0,j0,{name:t.toUpperCase()});const n=e.ComponentView.extend({type:t+"Axis3D"});e.registerComponentView(n)})),e.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"grid3D",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},(function(e,t){})),e.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},(function(e,t){}))}));var X0={defaultOption:{shading:null,realisticMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},lambertMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},colorMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},hatchingMaterial:{textureTiling:1,textureOffset:0,paperColor:"#fff"}}},Y0={getFilledRegions:function(e,t){var n,r=(e||[]).slice();if("string"==typeof t?n=(t=e_(t))&&t.geoJson:t&&t.features&&(n=t),!n)return"production"!==process.env.NODE_ENV&&(console.error("Map "+t+" not exists. You can download map file on http://echarts.baidu.com/download-map.html"),n.features||console.error("Invalid GeoJSON for map3D")),[];for(var i={},o=n.features,a=0;a<r.length;a++)i[r[a].name]=r[a];for(a=0;a<o.length;a++){var s=o[a].properties.name;i[s]||r.push({name:s})}return r},defaultOption:{show:!0,zlevel:-10,map:"",left:0,top:0,width:"100%",height:"100%",boxWidth:100,boxHeight:10,boxDepth:"auto",regionHeight:3,environment:"auto",groundPlane:{show:!1,color:"#aaa"},shading:"lambert",light:{main:{alpha:40,beta:30}},viewControl:{alpha:40,beta:0,distance:100,orthographicSize:60,minAlpha:5,minBeta:-80,maxBeta:80},label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}},Z0=$d.extend({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=N_(e.data||[],{coordDimensions:["value"],encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),n=new L_(t,this);n.initData(e.regions);var r={};n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,this._data=n},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Fh(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),n=this.coordinateSystem.getRegion(t);return n?n.geometries:[]},getFormattedLabel:function(e,t){var n=this._data.getName(e),r=this.getRegionModel(e),i=r.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=r.get(["label","formatter"]));var o={name:n};if("function"==typeof i)return o.status=t,i(o);if("string"==typeof i){var a=o.seriesName;return i.replace("{a}",null!=a?a:"")}return n},defaultOption:{regions:[]}});function q0(e,t,n){n=n||2;var r,i,o,a,s,l,u,c=t&&t.length,h=c?t[0]*n:e.length,d=K0(e,0,h,n,!0),p=[];if(!d)return p;if(c&&(d=function(e,t,n,r){var i,o,a,s=[];for(i=0,o=t.length;i<o;i++)(a=K0(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(a1(a));for(s.sort(r1),i=0;i<s.length;i++)i1(s[i],n),n=$0(n,n.next);return n}(e,t,d,n)),e.length>80*n){r=o=e[0],i=a=e[1];for(var f=n;f<h;f+=n)(s=e[f])<r&&(r=s),(l=e[f+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=Math.max(o-r,a-i)}return J0(d,p,n,r,i,u),p}function K0(e,t,n,r,i){var o,a;if(i===v1(e,t,n,r)>0)for(o=t;o<n;o+=r)a=f1(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=f1(o,e[o],e[o+1],a);return a&&c1(a,a.next)&&(g1(a),a=a.next),a}function $0(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!c1(r,r.next)&&0!==u1(r.prev,r,r.next))r=r.next;else{if(g1(r),(r=t=r.prev)===r.next)return null;n=!0}}while(n||r!==t);return t}function J0(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=o1(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<u&&(s++,r=r.nextZ);t++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?e1(e,r,i,o):Q0(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),g1(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?J0(e=t1(e,t,n),t,n,r,i,o,2):2===a&&n1(e,t,n,r,i,o):J0($0(e),t,n,r,i,o,1);break}}}function Q0(e){var t=e.prev,n=e,r=e.next;if(u1(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(s1(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&u1(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function e1(e,t,n,r){var i=e.prev,o=e,a=e.next;if(u1(i,o,a)>=0)return!1;for(var s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=o1(s,l,t,n,r),d=o1(u,c,t,n,r),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&s1(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&u1(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&s1(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&u1(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function t1(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!c1(i,o)&&h1(i,r,r.next,o)&&d1(i,o)&&d1(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),g1(r),g1(r.next),r=e=o),r=r.next}while(r!==e);return r}function n1(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&l1(a,s)){var l=p1(a,s);return a=$0(a,a.next),l=$0(l,l.next),J0(a,t,n,r,i,o),void J0(l,t,n,r,i,o)}s=s.next}a=a.next}while(a!==e)}function r1(e,t){return e.x-t.x}function i1(e,t){if(t=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===a)return n.prev;var l,u=n,c=n.x,h=n.y,d=1/0;r=n.next;for(;r!==u;)i>=r.x&&r.x>=c&&i!==r.x&&s1(o<h?i:a,o,c,h,o<h?a:i,o,r.x,r.y)&&((l=Math.abs(o-r.y)/(i-r.x))<d||l===d&&r.x>n.x)&&d1(r,e)&&(n=r,d=l),r=r.next;return n}(e,t),t){var n=p1(t,e);$0(n,n.next)}}function o1(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)/i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function a1(e){var t=e,n=e;do{t.x<n.x&&(n=t),t=t.next}while(t!==e);return n}function s1(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function l1(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&h1(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&d1(e,t)&&d1(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)}function u1(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function c1(e,t){return e.x===t.x&&e.y===t.y}function h1(e,t,n,r){return!!(c1(e,t)&&c1(n,r)||c1(e,r)&&c1(n,t))||u1(e,t,n)>0!=u1(e,t,r)>0&&u1(n,r,e)>0!=u1(n,r,t)>0}function d1(e,t){return u1(e.prev,e,e.next)<0?u1(e,t,e.next)>=0&&u1(e,e.prev,t)>=0:u1(e,t,e.prev)<0||u1(e,e.next,t)<0}function p1(e,t){var n=new m1(e.i,e.x,e.y),r=new m1(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function f1(e,t,n,r){var i=new m1(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function g1(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function m1(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function v1(e,t,n,r){for(var i=0,o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}function y1(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _1(e,t,n,r,i){var o=n,a=e[t];y1(e,t,r);for(var s=n;s<r;s++)i(e[s],a)<0&&(y1(e,s,o),o++);return y1(e,r,o),o}function x1(e,t,n,r){if(n<r){var i=_1(e,Math.floor((n+r)/2),n,r,t);x1(e,t,n,i-1),x1(e,t,i+1,r)}}function b1(){this._parts=[]}R(Z0.prototype,Y0),R(Z0.prototype,JJ),R(Z0.prototype,QJ),R(Z0.prototype,eQ),R(Z0.prototype,X0),q0.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,a=Math.abs(v1(e,0,o,n));if(i)for(var s=0,l=t.length;s<l;s++){var u=t[s]*n,c=s<l-1?t[s+1]*n:e.length;a-=Math.abs(v1(e,u,c,n))}var h=0;for(s=0;s<r.length;s+=3){var d=r[s]*n,p=r[s+1]*n,f=r[s+2]*n;h+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===a&&0===h?0:Math.abs((h-a)/a)},b1.prototype.step=function(e,t,n){var r=e.length;if(0===n){this._parts=[],this._sorted=!1;var i=Math.floor(r/2);this._parts.push({pivot:i,left:0,right:r-1}),this._currentSortPartIdx=0}if(!this._sorted){var o=this._parts;if(0===o.length)return this._sorted=!0,!0;if(o.length<512){for(var a=0;a<o.length;a++)o[a].pivot=_1(e,o[a].pivot,o[a].left,o[a].right,t);var s=[];for(a=0;a<o.length;a++){var l=o[a].left;(u=o[a].pivot-1)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u});var u;l=o[a].pivot+1;(u=o[a].right)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u})}o=this._parts=s}else for(a=0;a<Math.floor(o.length/10);a++){var c=o.length-1-this._currentSortPartIdx;if(x1(e,t,o[c].left,o[c].right),this._currentSortPartIdx++,this._currentSortPartIdx===o.length)return this._sorted=!0,!0}return!1}},b1.sort=x1;var w1=sQ.vec3,S1=w1.create(),T1=w1.create(),M1=w1.create(),C1={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(e,t){var n=this.indices;if(0===t){var r=this.attributes.position;e=e.array;this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new n.constructor(n.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,o=0,a=0;a<n.length;){r.get(n[a++],S1),r.get(n[a++],T1),r.get(n[a++],M1);var s=w1.sqrDist(S1,e),l=w1.sqrDist(T1,e),u=w1.sqrDist(M1,e),c=Math.min(s,l);c=Math.min(c,u),3===a?(i=c,c=0):c-=i,this._triangleZList[o++]=c}}var h=this._sortedTriangleIndices;for(a=0;a<h.length;a++)h[a]=a;if(this.triangleCount<2e4)0===t&&this._simpleSort(!0);else for(a=0;a<3;a++)this._progressiveQuickSort(3*t+a);var d=this._indicesTmp,p=this._triangleZListTmp,f=this._triangleZList;for(a=0;a<this.triangleCount;a++){var g=3*h[a],m=3*a;d[m++]=n[g++],d[m++]=n[g++],d[m]=n[g],p[a]=f[h[a]]}var v=this._indicesTmp;this._indicesTmp=this.indices,this.indices=v;v=this._triangleZListTmp;this._triangleZListTmp=this._triangleZList,this._triangleZList=v,this.dirtyIndices()},_simpleSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):b1.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;this._quickSort=this._quickSort||new b1,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}};function D1(e,t){const n=e.getItemVisual(t,"style");if(n){return n[e.getVisual("drawType")]}}function A1(e,t){const n=e.getItemVisual(t,"style");return n&&n.opacity}function I1(e,t,n){this._labelsMesh=new bQ,this._labelTextureSurface=new dQ({width:512,height:512,devicePixelRatio:n.getDevicePixelRatio(),onupdate:function(){n.getZr().refresh()}}),this._api=n,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}I1.prototype.getLabelPosition=function(e,t,n){return[0,0,0]},I1.prototype.getLabelDistance=function(e,t,n){return 0},I1.prototype.getMesh=function(){return this._labelsMesh},I1.prototype.updateData=function(e,t,n){null==t&&(t=0),null==n&&(n=e.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===n-t||(this._labelsVisibilitiesBits=new Uint8Array(n-t));for(var r=["label","show"],i=["emphasis","label","show"],o=t;o<n;o++){var a=e.getItemModel(o),s=a.get(r),l=a.get(i);null==l&&(l=s);var u=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[o-t]=u}this._start=t,this._end=n,this._data=e},I1.prototype.updateLabels=function(e){if(this._data){for(var t=(e=e||[]).length>0,n={},r=0;r<e.length;r++)n[e[r]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var i=["label"],o=["emphasis","label"],a=this._data.hostModel,s=this._data,l=a.getModel(i),u=a.getModel(o,l),c={left:"right",right:"left",top:"center",bottom:"center"},h={left:"middle",right:"middle",top:"bottom",bottom:"top"},d=this._start;d<this._end;d++){var p=!1;if(t&&n[d]&&(p=!0),this._labelsVisibilitiesBits[d-this._start]&(p?2:1)){var f=s.getItemModel(d).getModel(p?o:i,p?u:l),g=f.get("distance")||0,m=f.get("position"),v=this._api.getDevicePixelRatio(),y=a.getFormattedLabel(d,p?"emphasis":"normal");if(null==y||""===y)return;var _=new il({style:yh(f,{text:y,fill:f.get("color")||D1(s,d)||"#000",align:"left",verticalAlign:"top",opacity:vJ(f.get("opacity"),A1(s,d),1)})}),x=_.getBoundingRect();x.height*=1.2;var b=this._labelTextureSurface.add(_),w=c[m]||"center",S=h[m]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(d,m,g),[x.width*v,x.height*v],b,w,S,this.getLabelDistance(d,m,g)*v)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}},I1.prototype.dispose=function(){this._labelTextureSurface.dispose()};var E1=sQ.vec3;function L1(e){this.rootNode=new zJ.Node,this._triangulationResults={},this._shadersMap=zJ.COMMON_SHADERS.filter((function(e){return"shadow"!==e})).reduce((function(e,t){return e[t]=zJ.createShader("ecgl."+t),e}),{}),this._linesShader=zJ.createShader("ecgl.meshLines3D");var t={};zJ.COMMON_SHADERS.forEach((function(e){t[e]=new zJ.Material({shader:zJ.createShader("ecgl."+e)})})),this._groundMaterials=t,this._groundMesh=new zJ.Mesh({geometry:new zJ.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new I1(512,512,e),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=e}zJ.Shader.import(CQ),L1.prototype={constructor:L1,extrudeY:!0,update:function(e,t,n,r,i){var o=e.getData();null==r&&(r=0),null==i&&(i=o.count()),this._startIndex=r,this._endIndex=i-1,this._triangulation(e,r,i);var a=this._getShader(e.get("shading"));this._prepareMesh(e,a,n,r,i),this.rootNode.updateWorldTransform(),this._updateRegionMesh(e,n,r,i);var s=e.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(e,s,n);var l=this;this._labelsBuilder.updateData(o,r,i),this._labelsBuilder.getLabelPosition=function(e,t,n){var r=o.getName(e),i=n;if("geo3D"===s.type){var a=s.getRegion(r);return a?(c=a.getCenter(),s.dataToPoint([c[0],c[1],i])):[NaN,NaN,NaN]}var u=l._triangulationResults[e-l._startIndex],c=l.extrudeY?[(u.max[0]+u.min[0])/2,u.max[1]+i,(u.max[2]+u.min[2])/2]:[(u.max[0]+u.min[0])/2,(u.max[1]+u.min[1])/2,u.max[2]+i]},this._data=o,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(e),this._lastHoverDataIndex=0},_initMeshes:function(){var e=this;var t=function(){var t=new zJ.Mesh({name:"Polygon",material:new zJ.Material({shader:e._shadersMap.lambert}),geometry:new zJ.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return Object.assign(t.geometry,C1),t}(),n=new zJ.Mesh({material:new zJ.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new cQ({useNativeLine:!1})});this.rootNode.add(t),this.rootNode.add(n),t.material.define("both","VERTEX_COLOR"),t.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=t,this._linesMesh=n,this.rootNode.add(this._groundMesh)},_getShader:function(e){var t=this._shadersMap[e];return t||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+e),t=this._shadersMap.lambert),t.__shading=e,t},_prepareMesh:function(e,t,n,r,i){for(var o=0,a=0,s=0,l=0,u=r;u<i;u++){var c=this._getRegionPolygonInfo(u),h=this._getRegionLinesInfo(u,e,this._linesMesh.geometry);o+=c.vertexCount,a+=c.triangleCount,s+=h.vertexCount,l+=h.triangleCount}var d=this._polygonMesh,p=d.geometry;["position","normal","texcoord0","color"].forEach((function(e){p.attributes[e].init(o)})),p.indices=o>65535?new Uint32Array(3*a):new Uint16Array(3*a),d.material.shader!==t&&d.material.attachShader(t,!0),zJ.setMaterialFromModel(t.__shading,d.material,e,n),s>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(s),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(o),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-r))},_updateRegionMesh:function(e,t,n,r){for(var i=e.getData(),o=0,a=0,s=!1,l=this._polygonMesh,u=this._linesMesh,c=n;c<r;c++){var h=e.getRegionModel(c),d=h.getModel("itemStyle"),p=vJ(D1(i,c),d.get("color"),"#fff"),f=vJ(A1(i,c),d.get("opacity"),1),g=zJ.parseColor(p),m=zJ.parseColor(d.get("borderColor"));g[3]*=f,m[3]*=f;var v=g[3]<.99;l.material.set("color",[1,1,1,1]),s=s||v;for(var y=vJ(h.get("height",!0),e.get("regionHeight")),_=this._updatePolygonGeometry(e,l.geometry,c,y,o,a,g),x=o;x<_.vertexOffset;x++)this._dataIndexOfVertex[x]=c;this._vertexRangeOfDataIndex[2*(c-n)]=o,this._vertexRangeOfDataIndex[2*(c-n)+1]=_.vertexOffset,o=_.vertexOffset,a=_.triangleOffset;var b=d.get("borderWidth"),w=b>0;w&&(b*=t.getDevicePixelRatio(),this._updateLinesGeometry(u.geometry,e,c,y,b,e.coordinateSystem.transform)),u.invisible=!w,u.material.set({color:m})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?zJ.Mesh.CCW:zJ.Mesh.CW,l.material.get("normalMap")&&l.geometry.generateTangents(),l.seriesIndex=e.seriesIndex,l.on("mousemove",this._onmousemove,this),l.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(e){var t=e.getModel("debug.wireframe");if(t.get("show")){var n=zJ.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),r=vJ(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",n),i.material.set("wireframeLineWidth",r)}},_onmousemove:function(e){var t=this._dataIndexOfVertex[e.triangle[0]];null==t&&(t=-1),t!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(t),this._labelsBuilder.updateLabels([t])),this._lastHoverDataIndex=t,this._polygonMesh.dataIndex=t},_onmouseout:function(e){e.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(e,t,n){var r=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!r.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),o=this._groundMaterials[i];o||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+i),o=this._groundMaterials.lambert),zJ.setMaterialFromModel(i,o,r,n),o.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=o,this._groundMesh.material.set("color",zJ.parseColor(r.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,n){this._triangulationResults=[];for(var r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],o=e.coordinateSystem,a=t;a<n;a++){for(var s=[],l=e.getRegionPolygonCoords(a),u=0;u<l.length;u++){var c=l[u].exterior,h=l[u].interiors,d=[],p=[];if(!(c.length<3)){for(var f=0,g=0;g<c.length;g++){var m=c[g];d[f++]=m[0],d[f++]=m[1]}for(g=0;g<h.length;g++)if(!(h[g].length<3)){for(var v=d.length/2,y=0;y<h[g].length;y++){m=h[g][y];d.push(m[0]),d.push(m[1])}p.push(v)}var _=q0(d,p),x=new Float64Array(d.length/2*3),b=[],w=[1/0,1/0,1/0],S=[-1/0,-1/0,-1/0],T=0;for(g=0;g<d.length;)E1.set(b,d[g++],0,d[g++]),o&&o.transform&&E1.transformMat4(b,b,o.transform),E1.min(w,w,b),E1.max(S,S,b),x[T++]=b[0],x[T++]=b[1],x[T++]=b[2];E1.min(r,r,w),E1.max(i,i,S),s.push({points:x,indices:_,min:w,max:S})}}this._triangulationResults.push(s)}this._geoBoundingBox=[r,i]},_getRegionPolygonInfo:function(e){for(var t=this._triangulationResults[e-this._startIndex],n=0,r=0,i=0;i<t.length;i++)n+=t[i].points.length/3,r+=t[i].indices.length/3;return{vertexCount:2*n+4*n,triangleCount:2*r+2*n}},_updatePolygonGeometry:function(e,t,n,r,i,o,a){var s=e.get("projectUVOnGround"),l=t.attributes.position,u=t.attributes.normal,c=t.attributes.texcoord0,h=t.attributes.color,d=this._triangulationResults[n-this._startIndex],p=h.value&&a,f=t.indices,g=this.extrudeY?1:2,m=this.extrudeY?2:1,v=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],y=E1.mul([],this._geoBoundingBox[0],v),_=E1.mul([],this._geoBoundingBox[1],v),x=Math.max(_[0]-y[0],_[2]-y[2]);function b(e,t,n){var r=i;!function(e,t){for(var n=e.points,r=n.length,o=[],s=[],u=0;u<r;u+=3)o[0]=n[u],o[g]=t,o[m]=n[u+2],s[0]=(n[u]*v[0]-y[0])/x,s[1]=(n[u+2]*v[m]-y[2])/x,l.set(i,o),p&&h.set(i,a),c.set(i++,s)}(e,t);for(var s=e.indices.length,u=0;u<s;u++)f[3*o+u]=e.indices[u]+r;o+=e.indices.length/3}for(var w=this.extrudeY?[0,1,0]:[0,0,1],S=E1.negate([],w),T=0;T<d.length;T++){var M=i,C=d[T];b(C,0),b(C,r);for(var D=C.points.length/3,A=0;A<D;A++)u.set(M+A,S),u.set(M+A+D,w);var I=[0,3,1,1,3,2],E=[[],[],[],[]],L=[],N=[],P=[],O=[],R=0;for(A=0;A<D;A++){for(var k=(A+1)%D,z=(C.points[3*k]-C.points[3*A])*v[0],V=(C.points[3*k+2]-C.points[3*A+2])*v[m],B=Math.sqrt(z*z+V*V),F=0;F<4;F++){var G=0===F||3===F,H=3*(G?A:k);E[F][0]=C.points[H],E[F][g]=F>1?r:0,E[F][m]=C.points[H+2],l.set(i+F,E[F]),s?(O[0]=(C.points[H]*v[0]-y[0])/x,O[1]=(C.points[H+2]*v[m]-y[m])/x):(O[0]=(G?R:R+B)/x,O[1]=(E[F][g]*v[g]-y[g])/x),c.set(i+F,O)}E1.sub(L,E[1],E[0]),E1.sub(N,E[3],E[0]),E1.cross(P,L,N),E1.normalize(P,P);for(F=0;F<4;F++)u.set(i+F,P),p&&h.set(i+F,a);for(F=0;F<6;F++)f[3*o+F]=I[F]+i;i+=4,o+=2,R+=B}}return t.dirty(),{vertexOffset:i,triangleOffset:o}},_getRegionLinesInfo:function(e,t,n){var r=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach((function(e){var t=e.exterior,o=e.interiors;r+=n.getPolylineVertexCount(t),i+=n.getPolylineTriangleCount(t);for(var a=0;a<o.length;a++)r+=n.getPolylineVertexCount(o[a]),i+=n.getPolylineTriangleCount(o[a])}),this);return{vertexCount:r,triangleCount:i}},_updateLinesGeometry:function(e,t,n,r,i,o){function a(e){for(var t=new Float64Array(3*e.length),n=0,i=[],a=0;a<e.length;a++)i[0]=e[a][0],i[1]=r+.1,i[2]=e[a][1],o&&E1.transformMat4(i,i,o),t[n++]=i[0],t[n++]=i[1],t[n++]=i[2];return t}var s=[1,1,1,1];t.getRegionPolygonCoords(n).forEach((function(t){var n=t.exterior,r=t.interiors;e.addPolyline(a(n),s,i);for(var o=0;o<r.length;o++)e.addPolyline(a(r[o]),s,i)}))},highlight:function(e){var t=this._data;if(t){var n=t.getItemModel(e).getModel(["emphasis","itemStyle"]),r=n.get("color"),i=vJ(n.get("opacity"),A1(t,e),1);if(null==r)r=ir(D1(t,e),-.4);null==i&&(i=A1(t,e));var o=zJ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},downplay:function(e){var t=this._data;if(t){var n=t.getItemModel(e),r=vJ(D1(t,e),n.get(["itemStyle","color"]),"#fff"),i=vJ(A1(t,e),n.get(["itemStyle","opacity"]),1),o=zJ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},dispose:function(){this._labelsBuilder.dispose()},_setColorOfDataIndex:function(e,t,n){if(!(t<this._startIndex&&t>this._endIndex)){t-=this._startIndex;for(var r=this._vertexRangeOfDataIndex[2*t];r<this._vertexRangeOfDataIndex[2*t+1];r++)this._polygonMesh.geometry.attributes.color.set(r,n);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};var N1=Xg.extend({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new L1(t),this.groupGL=new zJ.Node,this._lightRoot=new zJ.Node,this._sceneHelper=new pQ(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new oQ({zr:t.getZr()}),this._control.init()},render:function(e,t,n){this.groupGL.add(this._geo3DBuilder.rootNode);var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")})),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"geo3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),center:i.getCenter(),from:this.uid,geo3DId:e.id})})),i.update()}},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},dispose:function(){this._control.dispose(),this._geo3DBuilder.dispose()}}),P1={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]};var O1=sQ.vec3,R1=sQ.mat4,k1=[dD,function(e,t){if("world"===e){var n=P1[t.name];if(n){var r=[n[0],n[1]];t.setCenter(r)}}}];function z1(e,t,n,r,i){this.name=e,this.map=t,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(n,r,i),this.transform=R1.identity(new Float64Array(16)),this.invTransform=R1.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}function V1(e,t){var n=Wd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=this.getGeoBoundingRect(),i=r.width/r.height*(e.get("aspectScale")||.75),o=e.get("boxWidth"),a=e.get("boxDepth"),s=e.get("boxHeight");null==s&&(s=5),isNaN(o)&&isNaN(a)&&(o=100),isNaN(a)?a=o/i:isNaN(o)&&(o=a/i),this.setSize(o,s,a),this.regionHeight=e.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(s-this.regionHeight,0))}function B1(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this&&"series.map3D"!==e.type){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),isFinite(n[1]-n[0])){var r=Jx(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Eb("altitude",r),this.resize(this.model,t)}}if(z1.prototype={constructor:z1,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(e,t,n){var r=pb;try{this.regions=e?r(e):[]}catch(e){throw"Invalid geoJson format\n"+e}t=t||{},n=n||{};for(var i=this.regions,o={},a=0;a<i.length;a++){var s=i[a].name;s=n[s]||s,i[a].name=s,o[s]=i[a],this.addGeoCoord(s,i[a].getCenter());var l=t[s];l&&i[a].transformTo(l.left,l.top,l.width,l.height)}this._regionsMap=o,this._geoRect=null,k1.forEach((function(e){e(this)}),this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var e,t=this.regions,n=0;n<t.length;n++){var r=t[n].getBoundingRect();(e=e||r.clone()).union(r)}return this._geoRect=e||new jt(0,0,0,0)},addGeoCoord:function(e,t){this._nameCoordMap[e]=t},getRegion:function(e){return this._regionsMap[e]},getRegionByCoord:function(e){for(var t=this.regions,n=0;n<t.length;n++)if(t[n].contain(e))return t[n]},setSize:function(e,t,n){this.size=[e,t,n];var r=this.getGeoBoundingRect(),i=e/r.width,o=-n/r.height,a=-e/2-r.x*i,s=n/2-r.y*o,l=this.extrudeY?[a,0,s]:[a,s,0],u=this.extrudeY?[i,1,o]:[i,o,1],c=this.transform;R1.identity(c),R1.translate(c,c,l),R1.scale(c,c,u),R1.invert(this.invTransform,c)},dataToPoint:function(e,t){t=t||[];var n=this.extrudeY?1:2,r=this.extrudeY?2:1,i=e[2];return isNaN(i)&&(i=0),t[0]=e[0],t[r]=e[1],this.altitudeAxis?t[n]=this.altitudeAxis.dataToCoord(i):t[n]=0,t[n]+=this.regionHeight,O1.transformMat4(t,t,this.transform),t},pointToData:function(e,t){}},"production"!==process.env.NODE_ENV)var F1=function(e){console.error("Map "+e+" not exists. You can download map file on http://echarts.baidu.com/download-map.html")};var G1=0,H1={dimensions:z1.prototype.dimensions,create:function(e,t){var n=[];if(!e_)throw new Error("geo3D component depends on geo component");function r(e,r){var i=H1.createGeo3D(e);e.__viewGL=e.__viewGL||new N0,i.viewGL=e.__viewGL,e.coordinateSystem=i,i.model=e,n.push(i),i.resize=V1,i.resize(e,t),i.update=B1}return e.eachComponent("geo3D",(function(e,t){r(e)})),e.eachSeriesByType("map3D",(function(e,t){var n=e.get("coordinateSystem");null==n&&(n="geo3D"),"geo3D"===n&&r(e)})),e.eachSeries((function(t){if("geo3D"===t.get("coordinateSystem")){if("series.map3D"===t.type)return;var n=t.getReferringComponents("geo3D").models[0];if(n||(n=e.getComponent("geo3D")),!n)throw new Error('geo "'+vJ(t.get("geo3DIndex"),t.get("geo3DId"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n},createGeo3D:function(e){var t,n=e.get("map");if("string"==typeof n?(t=n,n=e_(n)):n&&n.features&&(n={geoJson:n}),"production"!==process.env.NODE_ENV&&(n||F1(n),!n.geoJson.features))throw new Error("Invalid GeoJSON for map3D");return null==t&&(t="GEO_ANONYMOUS_"+G1++),new z1(t+G1++,t,n&&n.geoJson,n&&n.specialAreas,e.get("nameMap"))}};function U1(e){e.registerComponentModel(Z0),e.registerComponentView(N1),e.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"geo3D",query:e},(function(t){t.setView(e)}))})),e.registerCoordinateSystem("geo3D",H1)}function W1(e,t){e.id=e.id||e.name||t+""}i_(U1);var j1=$d.extend({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){j1.superApply(this,"init",arguments),W(this.option.layers,(function(e,t){R(e,this.defaultLayerOption),W1(e,t)}),this)},mergeOption:function(e){var t=this.option.layers;function n(e){return X(e,(function(e,t,n){return W1(t,n),e[t.id]=t,e}),{})}if(this.option.layers=null,j1.superApply(this,"mergeOption",arguments),t&&t.length){var r=n(e.layers),i=n(t);for(var o in r)i[o]?R(i[o],r[o],!0):t.push(e.layers[o]);this.option.layers=t}W(this.option.layers,(function(e){R(e,this.defaultLayerOption)}),this)},optionUpdated:function(){this.updateDisplacementHash()},defaultLayerOption:{show:!0,type:"overlay"},defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",baseColor:"#fff",baseTexture:"",heightTexture:"",displacementTexture:"",displacementScale:0,displacementQuality:"medium",globeRadius:100,globeOuterRadius:150,shading:"lambert",light:{main:{time:""}},atmosphere:{show:!1,offset:5,color:"#ffffff",glowPower:6,innerGlowPower:2},viewControl:{autoRotate:!0,panSensitivity:0,targetCoord:null},layers:[]},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},getDisplacementTexture:function(){return this.get("displacementTexture")||this.get("heightTexture")},getDisplacemenScale:function(){var e=this.getDisplacementTexture(),t=this.get("displacementScale");return e&&"none"!==e||(t=0),t},hasDisplacement:function(){return this.getDisplacemenScale()>0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var e=this.getDisplacementTexture(),t=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==e||this._displacementScale!==t,this._displacementTexture=e,this._displacementScale=t},isDisplacementChanged:function(){return this._displacementChanged}});R(j1.prototype,JJ),R(j1.prototype,QJ),R(j1.prototype,eQ),R(j1.prototype,X0);var X1=Math.PI,Y1=Math.sin,Z1=Math.cos,q1=Math.tan,K1=Math.asin,$1=Math.atan2,J1=X1/180;var Q1=23.4397*J1;function e2(e,t){return $1(Y1(e)*Z1(Q1)-q1(t)*Y1(Q1),Z1(e))}function t2(e,t,n){return $1(Y1(e),Z1(e)*Y1(t)-q1(n)*Z1(t))}function n2(e,t,n){return K1(Y1(t)*Y1(n)+Z1(t)*Z1(n)*Z1(e))}function r2(e){var t,n,r=function(e){return J1*(357.5291+.98560028*e)}(e),i=function(e){return e+J1*(1.9148*Y1(e)+.02*Y1(2*e)+3e-4*Y1(3*e))+102.9372*J1+X1}(r);return{dec:(t=i,n=0,K1(Y1(n)*Z1(Q1)+Z1(n)*Y1(Q1)*Y1(t))),ra:e2(i,0)}}var i2={};i2.getPosition=function(e,t,n){var r=J1*-n,i=J1*t,o=function(e){return function(e){return e.valueOf()/864e5-.5+2440588}(e)-2451545}(e),a=r2(o),s=function(e,t){return J1*(280.16+360.9856235*e)-t}(o,r)-a.ra;return{azimuth:t2(s,i,a.dec),altitude:n2(s,i,a.dec)}};zJ.Shader.import(PJ),zJ.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end");var o2=Xg.extend({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new zJ.Node,this._sphereGeometry=new zJ.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new zJ.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new zJ.PlaneGeometry,this._earthMesh=new zJ.Mesh({renderNormal:!0}),this._atmosphereMesh=new zJ.Mesh,this._atmosphereGeometry=new zJ.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.atmosphere.vertex"),zJ.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=zJ.Mesh.CW,this._lightRoot=new zJ.Node,this._sceneHelper=new pQ,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new oQ({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,n){var r=e.coordinateSystem,i=e.get("shading");r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL),this._sceneHelper.setScene(r.viewGL.scene),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var o=this._earthMesh;o.geometry=this._sphereGeometry;var a="ecgl."+i;o.material&&o.material.shader.name===a||(o.material=zJ.createMaterial(a)),zJ.setMaterialFromModel(i,o.material,e,n),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach((function(e){var t=o.material.get(e);t&&(t.flipY=!1)})),o.material.set("color",zJ.parseColor(e.get("baseColor")));var s=.99*r.radius;if(o.scale.set(s,s,s),e.get("atmosphere.show")){o.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:e.get("atmosphere.glowPower")||6,glowColor:e.get("atmosphere.color")||"#ffffff"}),o.material.setUniforms({glowPower:e.get("atmosphere.innerGlowPower")||2,glowColor:e.get("atmosphere.color")||"#ffffff"});var l=e.get("atmosphere.offset")||5;this._atmosphereMesh.scale.set(s+l,s+l,s+l)}else o.material.undefine("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!0;var u=o.material.setTextureImage("diffuseMap",e.get("baseTexture"),n,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(o);var c=o.material.setTextureImage("bumpMap",e.get("heightTexture"),n,{flipY:!1,anisotropic:8});c&&c.surface&&c.surface.attachToMesh(o),o.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,n),this._displaceVertices(e,n),this._updateViewControl(e,n),this._updateLayers(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},_updateLayers:function(e,t){var n=e.coordinateSystem,r=e.get("layers"),i=n.radius,o=[],a=[],s=[],l=[];W(r,(function(e){var r=new Fh(e),u=r.get("type"),c=zJ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8});if(c.surface&&c.surface.attachToMesh(this._earthMesh),"blend"===u){var h=r.get("blendTo"),d=vJ(r.get("intensity"),1);"emission"===h?(s.push(c),l.push(d)):(o.push(c),a.push(d))}else{var p=r.get("id"),f=this._layerMeshes[p];f||(f=this._layerMeshes[p]=new zJ.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===r.get("shading")?(f.material=f.__lambertMaterial||new zJ.Material({autoUpdateTextureStatus:!1,shader:zJ.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),f.__lambertMaterial=f.material):(f.material=f.__colorMaterial||new zJ.Material({autoUpdateTextureStatus:!1,shader:zJ.createShader("ecgl.color"),transparent:!0,depthMask:!1}),f.__colorMaterial=f.material),f.material.enableTexture("diffuseMap");var g=r.get("distance"),m=i+(null==g?n.radius/100:g);f.scale.set(m,m,m),i=m;var v=this._blankTexture||(this._blankTexture=zJ.createBlankTexture("rgba(255, 255, 255, 0)"));f.material.set("diffuseMap",v),zJ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8},(function(e){e.surface&&e.surface.attachToMesh(f),f.material.set("diffuseMap",e),t.getZr().refresh()})),r.get("show")?this.groupGL.add(f):this.groupGL.remove(f)}}),this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",o.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",s.length),u.set("layerDiffuseMap",o),u.set("layerDiffuseIntensity",a),u.set("layerEmissiveMap",s),u.set("layerEmissionIntensity",l);var c=e.getModel("debug.wireframe");if(c.get("show")){u.define("both","WIREFRAME_TRIANGLE");var h=zJ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),d=vJ(c.get("lineStyle.width"),1);u.set("wireframeLineWidth",d),u.set("wireframeLineColor",h)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){var n=e.coordinateSystem,r=e.getModel("viewControl");n.viewGL.camera;var i=this;var o=this._control;o.setViewGL(n.viewGL);var a,s,l=r.get("targetCoord");null!=l&&(s=l[0]+90,a=l[1]),o.setFromViewControlModel(r,{baseDistance:n.radius,alpha:a,beta:s}),o.off("update"),o.on("update",(function(){t.dispatchAction({type:"globeChangeCamera",alpha:o.getAlpha(),beta:o.getBeta(),distance:o.getDistance()-n.radius,center:o.getCenter(),from:i.uid,globeId:e.id})}))},_displaceVertices:function(e,t){var n=e.get("displacementQuality"),r=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||n!==this._displacementQuality||r!==this._showDebugWireframe){this._displacementQuality=n,this._showDebugWireframe=r;var o=this._sphereGeometry,a={low:100,medium:200,high:400,ultra:800}[n]||200,s=a/2;(o.widthSegments!==a||r)&&(o.widthSegments=a,o.heightSegments=s,o.build()),this._doDisplaceVertices(o,i),r&&o.generateBarycentric()}},_doDisplaceVertices:function(e,t){var n=e.attributes.position.value,r=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===n.length||((i=new Float32Array(n.length)).set(n),e.__originalPosition=i);for(var o=t.displacementWidth,a=t.displacementHeight,s=t.displacementData,l=0;l<e.vertexCount;l++){var u=3*l,c=2*l,h=i[u+1],d=i[u+2],p=i[u+3],f=r[c++],g=r[c++],m=Math.round(f*(o-1)),v=Math.round(g*(a-1)),y=s?s[v*o+m]:0;n[u+1]=h+h*y,n[u+2]=d+d*y,n[u+3]=p+p*y}e.generateVertexNormals(),e.dirty(),e.updateBoundingBox()},_updateLight:function(e,t){var n=this._earthMesh;this._sceneHelper.updateLight(e);var r=this._sceneHelper.mainLight,i=e.get("light.main.time")||new Date,o=i2.getPosition(fo(i),0,0),a=Math.cos(o.altitude);r.position.y=-a*Math.cos(o.azimuth),r.position.x=Math.sin(o.altitude),r.position.z=a*Math.sin(o.azimuth),r.lookAt(n.getWorldPosition())},dispose:function(e,t){this.groupGL.removeAll(),this._control.dispose()}}),a2=sQ.vec3;function s2(e){this.radius=e,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}function l2(e,t){var n=Wd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio()),this.radius=e.get("globeRadius");var r=e.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,r-this.radius)}function u2(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),isFinite(n[1]-n[0])){var r=Jx(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Eb("altitude",r),this.resize(this.model,t)}}s2.prototype={constructor:s2,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},_getDisplacementScale:function(e,t){var n=(e+180)/360*(this.displacementWidth-1),r=(90-t)/180*(this.displacementHeight-1),i=Math.round(n)+Math.round(r)*this.displacementWidth;return this.displacementData[i]},dataToPoint:function(e,t){var n=e[0],r=e[1],i=e[2]||0,o=this.radius;this.displacementData&&(o*=1+this._getDisplacementScale(n,r)),this.altitudeAxis&&(o+=this.altitudeAxis.dataToCoord(i)),n=n*Math.PI/180,r=r*Math.PI/180;var a=Math.cos(r)*o;return(t=t||[])[0]=-a*Math.cos(n+Math.PI),t[1]=Math.sin(r)*o,t[2]=a*Math.sin(n+Math.PI),t},pointToData:function(e,t){var n=e[0],r=e[1],i=e[2],o=a2.len(e);n/=o,r/=o,i/=o;var a=Math.asin(r),s=Math.atan2(i,-n);s<0&&(s=2*Math.PI+s);var l=180*a/Math.PI,u=180*s/Math.PI-180;return(t=t||[])[0]=u,t[1]=l,t[2]=o-this.radius,this.altitudeAxis&&(t[2]=this.altitudeAxis.coordToData(t[2])),t}};var c2={dimensions:s2.prototype.dimensions,create:function(e,t){var n=[];return e.eachComponent("globe",(function(e){e.__viewGL=e.__viewGL||new N0;var r=new s2;r.viewGL=e.__viewGL,e.coordinateSystem=r,r.model=e,n.push(r),r.resize=l2,r.resize(e,t),r.update=u2})),e.eachSeries((function(t){if("globe"===t.get("coordinateSystem")){var n=t.getReferringComponents("globe").models[0];if(n||(n=e.getComponent("globe")),!n)throw new Error('globe "'+vJ(t.get("globe3DIndex"),t.get("globe3DId"),0)+'" not found');var r=n.coordinateSystem;t.coordinateSystem=r}})),e.eachComponent("globe",(function(e,n){var r=e.coordinateSystem,i=e.getDisplacementTexture(),o=e.getDisplacemenScale();if(e.isDisplacementChanged()){if(e.hasDisplacement()){var a=!0;zJ.loadTexture(i,t,(function(n){var r=function(e,t){var n=document.createElement("canvas"),r=n.getContext("2d"),i=e.width,o=e.height;n.width=i,n.height=o,r.drawImage(e,0,0,i,o);for(var a=r.getImageData(0,0,i,o).data,s=new Float32Array(a.length/4),l=0;l<a.length/4;l++){var u=a[4*l];s[l]=u/255*t}return{data:s,width:i,height:o}}(n.image,o);e.setDisplacementData(r.data,r.width,r.height),a||t.dispatchAction({type:"globeUpdateDisplacment"})})),a=!1}else r.setDisplacementData(null,0,0);r.setDisplacementData(e.displacementData,e.displacementWidth,e.displacementHeight)}})),n}};i_((function(e){e.registerComponentModel(j1),e.registerComponentView(o2),e.registerCoordinateSystem("globe",c2),e.registerAction({type:"globeChangeCamera",event:"globecamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"globe",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"globeUpdateDisplacment",event:"globedisplacementupdated",update:"update"},(function(e,t){}))}));var h2=["zoom","center","pitch","bearing"],d2=$d.extend({type:"mapbox3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,style:"mapbox://styles/mapbox/light-v9",center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMapboxCameraOption:function(){var e=this;return h2.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMapboxCameraOption:function(e){null!=e&&h2.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMapbox:function(){return this._mapbox},setMapbox:function(e){this._mapbox=e}});function p2(e,t){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!mapboxgl)throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");this._mapbox=new mapboxgl.Map({container:this.dom}),this._initEvents()}R(d2.prototype,QJ),R(d2.prototype,eQ),p2.prototype.setUnpainted=function(){},p2.prototype.resize=function(){this._mapbox.resize()},p2.prototype.getMapbox=function(){return this._mapbox},p2.prototype.clear=function(){},p2.prototype.refresh=function(){this._mapbox.resize()};var f2=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];p2.prototype._initEvents=function(){var e=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},f2.forEach((function(t){this._handlers[t]=function(t){var n={};for(var r in t)n[r]=t[r];n.bubbles=!1;var i=new t.constructor(t.type,n);e.dispatchEvent(i)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},p2.prototype.dispose=function(){f2.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this)};var g2="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";zJ.Shader.import(g2);var m2=Xg.extend({type:"mapbox3D",__ecgl__:!0,init:function(e,t){var n=t.getZr();this._zrLayer=new p2("mapbox3D",n),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new zJ.Node,this._sceneHelper=new pQ(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMapbox(),i=this._dispatchInteractAction.bind(this,t,r);["zoom","rotate","drag","pitch","rotate","move"].forEach((function(e){r.on(e,i)})),this._groundMesh=new zJ.Mesh({geometry:new zJ.PlaneGeometry,material:new zJ.Material({shader:new zJ.Shader({vertex:zJ.Shader.source("ecgl.displayShadow.vertex"),fragment:zJ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(e,t,n){var r=this._zrLayer.getMapbox(),i=e.get("style"),o=JSON.stringify(i);o!==this._oldStyleStr&&i&&r.setStyle(i),this._oldStyleStr=o,r.setCenter(e.get("center")),r.setZoom(e.get("zoom")),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMapbox(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._mapbox3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){e.dispatchAction({type:"mapbox3DChangeCamera",pitch:t.getPitch(),zoom:t.getZoom(),center:t.getCenter().toArray(),bearing:t.getBearing(),mapbox3DId:this._mapbox3DModel&&this._mapbox3DModel.id})},_updateGroundMesh:function(){if(this._mapbox3DModel){var e=this._mapbox3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new zJ.Plane(new zJ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new zJ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new zJ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}}),v2=sQ.mat4,y2=512,_2=.6435011087932844,x2=Math.PI,b2=.1;function w2(){this.width=0,this.height=0,this.altitudeScale=1,this.boxHeight="auto",this.altitudeExtent,this.bearing=0,this.pitch=0,this.center=[0,0],this._origin,this.zoom=0,this._initialZoom,this.maxPitch=60,this.zoomOffset=0}function S2(){w2.apply(this,arguments)}function T2(e,t,n){function r(e,t){var n=t.getWidth(),r=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,n,r,i),this.width=n,this.height=r,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function i(e,t){if("auto"!==this.model.get("boxHeight")){var n=[1/0,-1/0];e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt")[0];if(r){var i=t.getDataExtent(r,!0);n[0]=Math.min(n[0],i[0]),n[1]=Math.max(n[1],i[1])}}}),this),isFinite(n[1]-n[0])&&(this.altitudeExtent=n)}}return{dimensions:t.prototype.dimensions,create:function(o,a){var s=[];return o.eachComponent(e,(function(e){var n=e.__viewGL;n||(n=e.__viewGL=new N0).setRootNode(new zJ.Node);var o=new t;o.viewGL=e.__viewGL,o.resize=r,o.resize(e,a),s.push(o),e.coordinateSystem=o,o.model=e,o.update=i})),o.eachSeries((function(t){if(t.get("coordinateSystem")===e){var n=t.getReferringComponents(e).models[0];if(n||(n=o.getComponent(e)),!n)throw new Error(e+' "'+vJ(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n&&n(s,o,a),s}}}w2.prototype={constructor:w2,dimensions:["lng","lat","alt"],containPoint:function(){},setCameraOption:function(e){this.bearing=e.bearing,this.pitch=e.pitch,this.center=e.center,this.zoom=e.zoom,this._origin||(this._origin=this.projectOnTileWithScale(this.center,y2)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var e=.5/Math.tan(_2/2)*this.height*b2,t=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,n=_2/2,r=Math.PI/2+t,i=Math.sin(n)*e/Math.sin(Math.PI-r-n),o=1.1*(Math.cos(Math.PI/2-t)*i+e);this.pitch>50&&(o=1e3);var a=[];v2.perspective(a,_2,this.width/this.height,1,o),this.viewGL.camera.projectionMatrix.setArray(a),this.viewGL.camera.decomposeProjectionMatrix();a=v2.identity([]);var s=this.dataToPoint(this.center);v2.scale(a,a,[1,-1,1]),v2.translate(a,a,[0,0,-e]),v2.rotateX(a,a,t),v2.rotateZ(a,a,-this.bearing/180*Math.PI),v2.translate(a,a,[-s[0]*this.getScale()*b2,-s[1]*this.getScale()*b2,0]),this.viewGL.camera.viewMatrix.array=a;var l=[];v2.invert(l,a),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var u,c=y2*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var h=this.altitudeExtent[1]-this.altitudeExtent[0];u=this.boxHeight/h*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else u=c/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*b2;this.viewGL.rootNode.scale.set(this.getScale()*b2,this.getScale()*b2,u)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,this.getScale()*y2,t)},projectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1]*x2/180,o=t*(r*x2/180+x2)/(2*x2),a=t*(x2-Math.log(Math.tan(x2/4+.5*i)))/(2*x2);return(n=n||[])[0]=o,n[1]=a,n},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,this.getScale()*y2,t)},unprojectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1],o=r/t*(2*x2)-x2,a=2*(Math.atan(Math.exp(x2-i/t*(2*x2)))-x2/4);return(n=n||[])[0]=180*o/x2,n[1]=180*a/x2,n},dataToPoint:function(e,t){return(t=this.projectOnTileWithScale(e,y2,t))[0]-=this._origin[0],t[1]-=this._origin[1],t[2]=isNaN(e[2])?0:e[2],isNaN(e[2])||(t[2]=e[2],this.altitudeExtent&&(t[2]-=this.altitudeExtent[0])),t}},S2.prototype=new w2,S2.prototype.constructor=S2,S2.prototype.type="mapbox3D";var M2=T2("mapbox3D",S2,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMapboxCameraOption())}))}));i_((function(e){e.registerComponentModel(d2),e.registerComponentView(m2),e.registerCoordinateSystem("mapbox3D",M2),e.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"mapbox3D",query:e},(function(t){t.setMapboxCameraOption(e)}))}))}));var C2=["zoom","center","pitch","bearing"],D2=$d.extend({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var e=this;return C2.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMaptalksCameraOption:function(e){null!=e&&C2.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});function A2(e,t,n,r){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:n,zoom:r,doubleClickZoom:!1,fog:!1}),this._initEvents()}R(D2.prototype,QJ),R(D2.prototype,eQ),A2.prototype.setUnpainted=function(){},A2.prototype.resize=function(){this._maptalks.checkSize()},A2.prototype.getMaptalks=function(){return this._maptalks},A2.prototype.clear=function(){},A2.prototype.refresh=function(){this._maptalks.checkSize()};var I2=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];A2.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},I2.forEach((function(t){this._handlers[t]=function(n){var r={};for(var i in n)r[i]=n[i];r.bubbles=!1;var o=new n.constructor(n.type,r);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(o):e.firstElementChild.dispatchEvent(o)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},A2.prototype.dispose=function(){I2.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this),this._maptalks.remove()},zJ.Shader.import(g2);var E2=Xg.extend({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new zJ.Mesh({geometry:new zJ.PlaneGeometry,material:new zJ.Material({shader:new zJ.Shader({vertex:zJ.Shader.source("ecgl.displayShadow.vertex"),fragment:zJ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var n=t.getZr();this._zrLayer=new A2("maptalks3D",n,e.get("center"),e.get("zoom")),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new zJ.Node,this._sceneHelper=new pQ(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,r);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach((function(e){r.on(e,i)}))},render:function(e,t,n){this._zrLayer||this._initMaptalksLayer(e,n);var r=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),o=r.getBaseLayer();i!==this._oldUrlTemplate&&(o?o.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(o=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),r.setBaseLayer(o))),this._oldUrlTemplate=i,r.setCenter(e.get("center")),r.setZoom(e.get("zoom"),{animation:!1}),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMaptalks(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){var r;e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:(r=t.getResolution(),19-Math.log(r/L2)/Math.LN2+1),center:t.getCenter().toArray(),bearing:t.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var e=this._maptalks3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new zJ.Plane(new zJ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new zJ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new zJ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}});const L2=12756274*Math.PI/(256*Math.pow(2,20));function N2(){w2.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}N2.prototype=new w2,N2.prototype.constructor=N2,N2.prototype.type="maptalks3D";var P2=T2("maptalks3D",N2,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMaptalksCameraOption())}))}));i_((function(e){e.registerComponentModel(D2),e.registerComponentView(E2),e.registerCoordinateSystem("maptalks3D",P2),e.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"maptalks3D",query:e},(function(t){t.setMaptalksCameraOption(e)}))}))}));var O2=sQ.vec3,R2=$x.isDimensionStacked;function k2(e,t,n){for(var r=e.getDataExtent(t),i=e.getDataExtent(n),o=r[1]-r[0]||r[0],a=i[1]-i[0]||i[0],s=new Uint8Array(2500),l=0;l<e.count();l++){var u=e.get(t,l),c=e.get(n,l),h=Math.floor((u-r[0])/o*49),d=50*Math.floor((c-i[0])/a*49)+h;s[d]=s[d]||1}var p=0;for(l=0;l<s.length;l++)s[l]&&p++;return p/s.length}var z2=sQ.vec3,V2=$x.isDimensionStacked;function B2(e,t){var n=V2(e,t[2]);return{dimension:n?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:n}}function F2(e){e.registerLayout((function(e,t){e.eachSeriesByType("bar3D",(function(e){var t=e.coordinateSystem,n=t&&t.type;if("globe"===n)!function(e,t){var n=e.getData(),r=e.get("minHeight")||0,i=e.get("barSize"),o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==i){var a=t.radius*Math.PI,s=k2(n,o[0],o[1]);i=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(i)||(i=[i,i]);var l=B2(n,o);n.each(o,(function(e,o,a,s){var u=n.get(l.dimension,s),c=l.isStacked?u-a:t.altitudeAxis.scale.getExtent()[0],h=Math.max(t.altitudeAxis.dataToCoord(a),r),d=t.dataToPoint([e,o,c]),p=t.dataToPoint([e,o,u]),f=z2.sub([],p,d);z2.normalize(f,f);var g=[i[0],h,i[1]];n.setItemLayout(s,[d,f,g])})),n.setLayout("orient",Bq.UP.array)}(e,t);else if("cartesian3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize");if(null==r){var i,o,a=t.size,s=t.getAxis("x"),l=t.getAxis("y");i="category"===s.type?.7*s.getBandWidth():.6*Math.round(a[0]/Math.sqrt(n.count())),o="category"===l.type?.7*l.getBandWidth():.6*Math.round(a[1]/Math.sqrt(n.count())),r=[i,o]}else J(r)||(r=[r,r]);var u=t.getAxis("z").scale.getExtent(),c=function(e){var t=e[0],n=e[1];return!(t>0&&n>0||t<0&&n<0)}(u),h=["x","y","z"].map((function(t){return e.coordDimToDataDim(t)[0]})),d=R2(n,h[2]),p=d?n.getCalculationInfo("stackResultDimension"):h[2];n.each(h,(function(e,i,o,a){var s=n.get(p,a),l=d?s-o:c?0:u[0],h=t.dataToPoint([e,i,l]),f=t.dataToPoint([e,i,s]),g=O2.dist(h,f),m=[0,f[1]<h[1]?-1:1,0];0===Math.abs(g)&&(g=.1);var v=[r[0],g,r[1]];n.setItemLayout(a,[h,m,v])})),n.setLayout("orient",[1,0,0])}(e,t);else if("geo3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize"),i=e.get("minHeight")||0,o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==r){var a=Math.min(t.size[0],t.size[2]),s=k2(n,o[0],o[1]);r=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(r)||(r=[r,r]);var l=[0,1,0],u=B2(n,o);n.each(o,(function(e,o,a,s){var c=n.get(u.dimension,s),h=u.isStacked?c-a:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(a),i),p=t.dataToPoint([e,o,h]),f=[r[0],d,r[1]];n.setItemLayout(s,[p,l,f])})),n.setLayout("orient",[1,0,0])}(e,t);else if("mapbox3D"===n||"maptalks3D"===n)!function(e,t){var n=e.getData(),r=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],o=e.coordDimToDataDim("alt")[0],a=e.get("barSize"),s=e.get("minHeight")||0;if(null==a){var l=n.getDataExtent(r),u=n.getDataExtent(i),c=t.dataToPoint([l[0],u[0]]),h=t.dataToPoint([l[1],u[1]]),d=Math.min(Math.abs(c[0]-h[0]),Math.abs(c[1]-h[1]))||1,p=k2(n,r,i);a=[d/Math.sqrt(n.count()/p),d/Math.sqrt(n.count()/p)]}else J(a)||(a=[a,a]),a[0]/=t.getScale()/16,a[1]/=t.getScale()/16;var f=[0,0,1],g=[r,i,o],m=B2(n,g);n.each(g,(function(e,r,i,o){var l=n.get(m.dimension,o),u=m.isStacked?l-i:0,c=t.dataToPoint([e,r,u]),h=t.dataToPoint([e,r,l]),d=Math.max(h[2]-c[2],s),p=[a[0],d,a[1]];n.setItemLayout(o,[c,f,p])})),n.setLayout("orient",[1,0,0])}(e,t);else if("production"!==process.env.NODE_ENV)throw t?new Error("bar3D doesn't support coordinate system "+t.type):new Error("bar3D doesn't have coordinate system.")}))}))}var G2={};function H2(e,t,n){var r=e.getData(),i=e.getRawValue(t),o=J(i)?function(e){var i=[],o=function(e,t){var n=[];return W(e.dimensions,(function(r){var i=e.getDimensionInfo(r),o=i.otherDims[t];null!=o&&!1!==o&&(n[o]=i.name)})),n}(r,"tooltip");function a(e,t){var o=r.getDimensionInfo(t);if(o&&!1!==o.otherDims.tooltip){var a=o.type,s="- "+(o.tooltipName||o.name)+": "+("ordinal"===a?e+"":"time"===a?n?"":kd("yyyy/MM/dd hh:mm:ss",e):Ad(e));s&&i.push(dt(s))}}return o.length?W(o,(function(e){a(r.get(e,t),e)})):W(e,a),"<br/>"+i.join("<br/>")}(i):dt(Ad(i)),a=r.getName(t),s=D1(r,t);re(s)&&s.colorStops&&(s=(s.colorStops[0]||{}).color);var l=Rd(s=s||"transparent"),u=e.name;return"\0-"===u&&(u=""),u=u?dt(u)+(n?": ":"<br/>"):"",n?l+u+o:u+l+(a?dt(a)+": "+o:o)}function U2(e,t,n){n=n||e.getSource();var r=t||Yy(e.get("coordinateSystem"))||["x","y","z"],i=N_(n,{dimensionsDefine:n.dimensionsDefine||e.get("dimensions"),encodeDefine:n.encodeDefine||e.get("encode"),coordDimensions:r.map((function(t){var n=e.getReferringComponents(t+"Axis3D").models[0];return{type:n&&"category"===n.get("type")?"ordinal":"float",name:t}}))});"cartesian3D"===e.get("coordinateSystem")&&i.forEach((function(t){if(r.indexOf(t.coordDim)>=0){var n=e.getReferringComponents(t.coordDim+"Axis3D").models[0];n&&"category"===n.get("type")&&(t.ordinalMeta=n.getOrdinalMeta())}}));var o=$x.enableDataStack(e,i,{byIndex:!0,stackedCoordDimension:"z"}),a=new L_(i,e);return a.setCalculationInfo(o),a.initData(n),a}G2.getFormattedLabel=function(e,t,n,r,i){n=n||"normal";var o=e.getData(r).getItemModel(t),a=e.getDataParams(t,r);null!=i&&a.value instanceof Array&&(a.value=a.value[i]);var s,l=o.get("normal"===n?["label","formatter"]:["emphasis","label","formatter"]);return null==l&&(l=o.get(["label","formatter"])),"function"==typeof l?(a.status=n,s=l(a)):"string"==typeof l&&(s=Od(l,a)),s},G2.normalizeToArray=function(e){return e instanceof Array?e:null==e?[]:[e]};var W2=Vg.extend({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(e,t){return U2(this)},getFormattedLabel:function(e,t,n,r){var i=G2.getFormattedLabel(this,e,t,n,r);return null==i&&(i=this.getData().get("z",e)),i},formatTooltip:function(e){return H2(this,e)},defaultOption:{coordinateSystem:"cartesian3D",globeIndex:0,grid3DIndex:0,zlevel:-10,bevelSize:0,bevelSmoothness:2,onGridPlane:"xy",shading:"color",minHeight:0,itemStyle:{opacity:1},label:{show:!1,distance:2,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},emphasis:{label:{show:!0}},animationDurationUpdate:500}});R(W2.prototype,X0);var j2,X2,Y2,Z2,q2,K2,$2,J2,Q2=sQ.vec3,e3=sQ.mat3,t3=WK.extend((function(){return{attributes:{position:new WK.Attribute("position","float",3,"POSITION"),normal:new WK.Attribute("normal","float",3,"NORMAL"),color:new WK.Attribute("color","float",4,"COLOR"),prevPosition:new WK.Attribute("prevPosition","float",3),prevNormal:new WK.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(e){var t=this.enableNormal,n=this.getBarVertexCount()*e,r=this.getBarTriangleCount()*e;this.vertexCount!==n&&(this.attributes.position.init(n),t?this.attributes.normal.init(n):this.attributes.normal.value=null,this.attributes.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r),this._dataIndices=new Uint32Array(n))},getBarVertexCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarVertexCount(e):this.enableNormal?24:8},getBarTriangleCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarTriangleCount(e):12},_getBevelBarVertexCount:function(e){return 4*(e+1)*(e+1)*2},_getBevelBarTriangleCount:function(e){return(4*e+3+1)*(2*e+1)*2+4},setColor:function(e,t){for(var n=this.getBarVertexCount(),r=n*(e+1),i=n*e;i<r;i++)this.attributes.color.set(i,t);this.dirtyAttribute("color")},getDataIndexOfVertex:function(e){return this._dataIndices?this._dataIndices[e]:null},addBar:function(){for(var e=Q2.create,t=Q2.scaleAndAdd,n=e(),r=e(),i=e(),o=e(),a=e(),s=e(),l=e(),u=[],c=[],h=0;h<8;h++)u[h]=e();var d=[[0,1,5,4],[2,3,7,6],[4,5,6,7],[3,2,1,0],[0,4,7,3],[1,2,6,5]],p=[0,1,2,0,2,3],f=[];for(h=0;h<d.length;h++)for(var g=d[h],m=0;m<2;m++){for(var v=[],y=0;y<3;y++)v.push(g[p[3*m+y]]);f.push(v)}return function(e,h,g,m,v,y){var _=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(e,h,g,m,this.bevelSize,this.bevelSegments,v);else{Q2.copy(i,h),Q2.normalize(i,i),Q2.cross(o,g,i),Q2.normalize(o,o),Q2.cross(r,i,o),Q2.normalize(o,o),Q2.negate(a,r),Q2.negate(s,i),Q2.negate(l,o),t(u[0],e,r,m[0]/2),t(u[0],u[0],o,m[2]/2),t(u[1],e,r,m[0]/2),t(u[1],u[1],l,m[2]/2),t(u[2],e,a,m[0]/2),t(u[2],u[2],l,m[2]/2),t(u[3],e,a,m[0]/2),t(u[3],u[3],o,m[2]/2),t(n,e,i,m[1]),t(u[4],n,r,m[0]/2),t(u[4],u[4],o,m[2]/2),t(u[5],n,r,m[0]/2),t(u[5],u[5],l,m[2]/2),t(u[6],n,a,m[0]/2),t(u[6],u[6],l,m[2]/2),t(u[7],n,a,m[0]/2),t(u[7],u[7],o,m[2]/2);var x=this.attributes;if(this.enableNormal){c[0]=r,c[1]=a,c[2]=i,c[3]=s,c[4]=o,c[5]=l;for(var b=this._vertexOffset,w=0;w<d.length;w++){for(var S=3*this._triangleOffset,T=0;T<6;T++)this.indices[S++]=b+p[T];b+=4,this._triangleOffset+=2}for(w=0;w<d.length;w++){var M=c[w];for(T=0;T<4;T++){var C=d[w][T];x.position.set(this._vertexOffset,u[C]),x.normal.set(this._vertexOffset,M),x.color.set(this._vertexOffset++,v)}}}else{for(w=0;w<f.length;w++){for(S=3*this._triangleOffset,T=0;T<3;T++)this.indices[S+T]=f[w][T]+this._vertexOffset;this._triangleOffset++}for(w=0;w<u.length;w++)x.position.set(this._vertexOffset,u[w]),x.color.set(this._vertexOffset++,v)}}var D=this._vertexOffset;for(w=_;w<D;w++)this._dataIndices[w]=y}}(),_addBevelBar:(j2=Q2.create(),X2=Q2.create(),Y2=Q2.create(),Z2=e3.create(),q2=[],K2=[1,-1,-1,1],$2=[1,1,-1,-1],J2=[2,0],function(e,t,n,r,i,o,a){Q2.copy(X2,t),Q2.normalize(X2,X2),Q2.cross(Y2,n,X2),Q2.normalize(Y2,Y2),Q2.cross(j2,X2,Y2),Q2.normalize(Y2,Y2),Z2[0]=j2[0],Z2[1]=j2[1],Z2[2]=j2[2],Z2[3]=X2[0],Z2[4]=X2[1],Z2[5]=X2[2],Z2[6]=Y2[0],Z2[7]=Y2[1],Z2[8]=Y2[2],i=Math.min(r[0],r[2])/2*i;for(var s=0;s<3;s++)q2[s]=Math.max(r[s]-2*i,0);var l=(r[0]-q2[0])/2,u=(r[1]-q2[1])/2,c=(r[2]-q2[2])/2,h=[],d=[],p=this._vertexOffset,f=[];for(s=0;s<2;s++){f[s]=f[s]=[];for(var g=0;g<=o;g++)for(var m=0;m<4;m++){(0===g&&0===s||1===s&&g===o)&&f[s].push(p);for(var v=0;v<=o;v++){var y=v/o*Math.PI/2+Math.PI/2*m,_=g/o*Math.PI/2+Math.PI/2*s;d[0]=l*Math.cos(y)*Math.sin(_),d[1]=u*Math.cos(_),d[2]=c*Math.sin(y)*Math.sin(_),h[0]=d[0]+K2[m]*q2[0]/2,h[1]=d[1]+u+J2[s]*q2[1]/2,h[2]=d[2]+$2[m]*q2[2]/2,Math.abs(l-u)<1e-6&&Math.abs(u-c)<1e-6||(d[0]/=l*l,d[1]/=u*u,d[2]/=c*c),Q2.normalize(d,d),Q2.transformMat3(h,h,Z2),Q2.transformMat3(d,d,Z2),Q2.add(h,h,e),this.attributes.position.set(p,h),this.enableNormal&&this.attributes.normal.set(p,d),this.attributes.color.set(p,a),p++}}}var x=4*o+3,b=2*o+1,w=x+1;for(m=0;m<b;m++)for(s=0;s<=x;s++){var S=m*w+s+this._vertexOffset,T=m*w+(s+1)%w+this._vertexOffset,M=(m+1)*w+(s+1)%w+this._vertexOffset,C=(m+1)*w+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[M,S,T]),this.setTriangleIndices(this._triangleOffset++,[M,C,S])}this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][2],f[0][1]]),this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][3],f[0][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][1],f[1][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][2],f[1][3]]),this._vertexOffset=p})});V(t3.prototype,aQ),V(t3.prototype,C1);var n3=sQ.vec3,r3=Kg.extend({type:"bar3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._api=t,this._labelsBuilder=new I1(256,256,t);var n=this;this._labelsBuilder.getLabelPosition=function(e,t,r){if(n._data){var i=n._data.getItemLayout(e),o=i[0],a=i[1],s=i[2][1];return n3.scaleAndAdd([],o,a,r+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(e,t,n){var r=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=r,this._barMesh||(this._barMesh=new zJ.Mesh({geometry:new t3,shadowDepthMaterial:new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.sm.depth.vertex"),zJ.Shader.source("ecgl.sm.depth.fragment"))}),culling:"cartesian3D"===e.coordinateSystem.type,renderOrder:10,renderNormal:!0})),this.groupGL.remove(this._prevBarMesh),this.groupGL.add(this._barMesh),this.groupGL.add(this._labelsBuilder.getMesh());var i=e.coordinateSystem;if(this._doRender(e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[o]("fragment","SRGB_DECODE")}this._data=e.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(e)},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,e)},_doRender:function(e,t){var n=e.getData(),r=e.get("shading"),i="color"!==r,o=this,a=this._barMesh,s="ecgl."+r;a.material&&a.material.shader.name===s||(a.material=zJ.createMaterial(s,["VERTEX_COLOR"])),zJ.setMaterialFromModel(r,a.material,e,t),a.geometry.enableNormal=i,a.geometry.resetOffset();var l=e.get("bevelSize"),u=e.get("bevelSmoothness");a.geometry.bevelSegments=u,a.geometry.bevelSize=l;var c=[],h=new Float32Array(4*n.count()),d=0,p=0,f=!1;n.each((function(e){if(n.hasValue(e)){var t=D1(n,e),r=A1(n,e);null==r&&(r=1),zJ.parseColor(t,c),c[3]*=r,h[d++]=c[0],h[d++]=c[1],h[d++]=c[2],h[d++]=c[3],c[3]>0&&(p++,c[3]<.99&&(f=!0))}})),a.geometry.setBarCount(p);var g=n.getLayout("orient"),m=this._barIndexOfData=new Int32Array(n.count());p=0;n.each((function(e){if(n.hasValue(e)){var t=n.getItemLayout(e),r=t[0],i=t[1],a=t[2],s=4*e;c[0]=h[s++],c[1]=h[s++],c[2]=h[s++],c[3]=h[s++],c[3]>0&&(o._barMesh.geometry.addBar(r,i,g,a,c,e),m[e]=p++)}else m[e]=-1})),a.geometry.dirty(),a.geometry.updateBoundingBox();var v=a.material;v.transparent=f,v.depthMask=!f,a.geometry.sortTriangles=f,this._initHandler(e,t)},_initHandler:function(e,t){var n=e.getData(),r=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=r.geometry.getDataIndexOfVertex(e.triangle[0]);a!==o&&(this._downplay(o),this._highlight(a),this._labelsBuilder.updateLabels([a]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",a),n.get("y",a),n.get("z",a,!0)]})),o=a,r.dataIndex=a}),this),r.on("mouseout",(function(e){this._downplay(o),this._labelsBuilder.updateLabels(),o=-1,r.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_highlight:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=t.getItemModel(e).getModel("emphasis.itemStyle"),i=r.get("color"),o=r.get("opacity");if(null==i)i=ir(D1(t,e),-.4);null==o&&(o=A1(t,e));var a=zJ.parseColor(i);a[3]*=o,this._barMesh.geometry.setColor(n,a),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=D1(t,e),i=A1(t,e),o=zJ.parseColor(r);o[3]*=i,this._barMesh.geometry.setColor(n,o),this._api.getZr().refresh()}}},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=yJ(o,i),s=this;null!=a?W(G2.normalizeToArray(a),(function(t){"highlight"===e?this._highlight(t):this._downplay(t)}),this):o.each((function(t){"highlight"===e?s._highlight(t):s._downplay(t)}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this._labelsBuilder.dispose(),this.groupGL.removeAll()}});i_((function(e){e.registerChartView(r3),e.registerSeriesModel(W2),F2(e),e.registerProcessor((function(e,t){e.eachSeriesByType("bar3d",(function(e){var t=e.getData();t.filterSelf((function(e){return t.hasValue(e)}))}))}))}));var i3=Vg.extend({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){return U2(this)},formatTooltip:function(e){return H2(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}}),o3=sQ.vec3;zJ.Shader.import(CQ);var a3=Kg.extend({type:"line3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._api=t},render:function(e,t,n){var r=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=r,this._line3DMesh||(this._line3DMesh=new zJ.Mesh({geometry:new cQ({useNativeLine:!1,sortTriangles:!0}),material:new zJ.Material({shader:zJ.createShader("ecgl.meshLines3D")}),renderOrder:10}),this._line3DMesh.geometry.pick=this._pick.bind(this)),this.groupGL.remove(this._prevLine3DMesh),this.groupGL.add(this._line3DMesh);var i=e.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[o]("fragment","SRGB_DECODE")}this._doRender(e,n),this._data=e.getData(),this._camera=i.viewGL.camera,this.updateCamera(),this._updateAnimation(e)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(e,t){var n=e.getData(),r=this._line3DMesh;r.geometry.resetOffset();var i=n.getLayout("points"),o=[],a=new Float32Array(i.length/3*4),s=0,l=!1;n.each((function(e){var t=D1(n,e),r=A1(n,e);null==r&&(r=1),zJ.parseColor(t,o),o[3]*=r,a[s++]=o[0],a[s++]=o[1],a[s++]=o[2],a[s++]=o[3],o[3]<.99&&(l=!0)})),r.geometry.setVertexCount(r.geometry.getPolylineVertexCount(i)),r.geometry.setTriangleCount(r.geometry.getPolylineTriangleCount(i)),r.geometry.addPolyline(i,a,vJ(e.get("lineStyle.width"),1)),r.geometry.dirty(),r.geometry.updateBoundingBox();var u=r.material;u.transparent=l,u.depthMask=!l;var c=e.getModel("debug.wireframe");c.get("show")?(r.geometry.createAttribute("barycentric","float",3),r.geometry.generateBarycentric(),r.material.set("both","WIREFRAME_TRIANGLE"),r.material.set("wireframeLineColor",zJ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)")),r.material.set("wireframeLineWidth",vJ(c.get("lineStyle.width"),1))):r.material.set("both","WIREFRAME_TRIANGLE"),this._points=i,this._initHandler(e,t)},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,e)},_initHandler:function(e,t){var n=e.getData(),r=e.coordinateSystem,i=this._line3DMesh,o=-1;i.seriesIndex=e.seriesIndex,i.off("mousemove"),i.off("mouseout"),i.on("mousemove",(function(e){var a=r.pointToData(e.point.array),s=n.indicesOfNearest("x",a[0])[0];s!==o&&(t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",s),n.get("y",s),n.get("z",s)]}),i.dataIndex=s),o=s}),this),i.on("mouseout",(function(e){o=-1,i.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateNDCPosition:function(){var e=new iK,t=this._camera;iK.multiply(e,t.projectionMatrix,t.viewMatrix);var n=this._positionNDC,r=this._points,i=r.length/3;n&&n.length/2===i||(n=this._positionNDC=new Float32Array(2*i));for(var o=[],a=0;a<i;a++){var s=3*a,l=2*a;o[0]=r[s],o[1]=r[s+1],o[2]=r[s+2],o[3]=1,o3.transformMat4(o,o,e.array),n[l]=o[0]/o[3],n[l+1]=o[1]/o[3]}},_pick:function(e,t,n,r,i,o){var a=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,u=.5*n.viewport.width,c=.5*n.viewport.height;e=(e+1)*u,t=(t+1)*c;for(var h=1;h<a.length/2;h++){var d=(a[2*(h-1)]+1)*u,p=(a[2*(h-1)+1]+1)*c,f=(a[2*h]+1)*u,g=(a[2*h+1]+1)*c;if(Ts(d,p,f,g,s,e,t))l=(d-e)*(d-e)+(p-t)*(p-t)<(f-e)*(f-e)+(g-t)*(g-t)?h-1:h}if(l>=0){var m=3*l,v=new Bq(this._points[m],this._points[m+1],this._points[m+2]);o.push({dataIndex:l,point:v,pointWorld:v.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(v)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(a3),e.registerSeriesModel(i3),e.registerLayout((function(e,t){e.eachSeriesByType("line3D",(function(e){var t=e.getData(),n=e.coordinateSystem;if(n){if("cartesian3D"!==n.type)return void("production"!==process.env.NODE_ENV&&console.error("line3D needs cartesian3D coordinateSystem"));var r=new Float32Array(3*t.count()),i=[],o=[],a=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n&&t.each(a,(function(e,t,a,s){i[0]=e,i[1]=t,i[2]=a,n.dataToPoint(i,o),r[3*s]=o[0],r[3*s+1]=o[1],r[3*s+2]=o[2]})),t.setLayout("points",r)}}))}))}));var s3=Vg.extend({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(e,t){return U2(this)},getFormattedLabel:function(e,t,n,r){var i=G2.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},formatTooltip:function(e){return H2(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,progressive:1e5,progressiveThreshold:1e5,grid3DIndex:0,globeIndex:0,symbol:"circle",symbolSize:10,blendMode:"source-over",label:{show:!1,position:"right",distance:5,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},itemStyle:{opacity:.8},emphasis:{label:{show:!0}},animationDurationUpdate:500}});function l3(e,t,n){(t=t||document.createElement("canvas")).width=e,t.height=e;var r=t.getContext("2d");return n&&n(r),t}var u3={getMarginByStyle:function(e){var t=e.minMargin||0,n=0;e.stroke&&"none"!==e.stroke&&(n=null==e.lineWidth?1:e.lineWidth);var r=e.shadowBlur||0,i=e.shadowOffsetX||0,o=e.shadowOffsetY||0,a={};return a.left=Math.max(n/2,-i+r,t),a.right=Math.max(n/2,i+r,t),a.top=Math.max(n/2,-o+r,t),a.bottom=Math.max(n/2,o+r,t),a},createSymbolSprite:function(e,t,n,r){var i=function(e,t,n,r){J(t)||(t=[t,t]);var i=u3.getMarginByStyle(n,r),o=t[0]+i.left+i.right,a=t[1]+i.top+i.bottom,s=lv(e,0,0,t[0],t[1]),l=Math.max(o,a);s.x=i.left,s.y=i.top,o>a?s.y+=(l-a)/2:s.x+=(l-o)/2;var u=s.getBoundingRect();return s.x-=u.x,s.y-=u.y,s.setStyle(n),s.update(),s.__size=l,s}(e,t,n),o=u3.getMarginByStyle(n);return{image:l3(i.__size,r,(function(e){Ev(e,i)})),margin:o}},createSDFFromCanvas:function(e,t,n,r){return l3(t,r,(function(t){var r=e.getContext("2d").getImageData(0,0,e.width,e.height);t.putImageData(function(e,t,n){var r=t.width,i=t.height,o=e.canvas.width,a=e.canvas.height,s=r/o,l=i/a;function u(e){return e<128?1:-1}function c(e,o){var a=1/0;e=Math.floor(e*s);for(var c=(o=Math.floor(o*l))*r+e,h=u(t.data[4*c]),d=Math.max(o-n,0);d<Math.min(o+n,i);d++)for(var p=Math.max(e-n,0);p<Math.min(e+n,r);p++){c=d*r+p;var f=p-e,g=d-o;if(h!==u(t.data[4*c])){var m=f*f+g*g;m<a&&(a=m)}}return h*Math.sqrt(a)}for(var h=e.createImageData(o,a),d=0;d<a;d++)for(var p=0;p<o;p++){var f=c(p,d)/n*.5+.5,g=4*(d*o+p);h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255}return h}(t,r,n),0,0)}))},createSimpleSprite:function(e,t){return l3(e,t,(function(t){var n=e/2;t.beginPath(),t.arc(n,n,60,0,2*Math.PI,!1),t.closePath();var r=t.createRadialGradient(n,n,0,n,n,n);r.addColorStop(0,"rgba(255, 255, 255, 1)"),r.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),r.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=r,t.fill()}))}},c3=sQ.vec3,h3={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(e,t){var n=this.indices,r=c3.create();if(!n){n=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i<n.length;i++)n[i]=i}if(0===t){var o,a=this.attributes.position,s=(e=e.array,0);this._zList&&this._zList.length===this.vertexCount||(this._zList=new Float32Array(this.vertexCount));for(i=0;i<this.vertexCount;i++){a.get(i,r);var l=c3.sqrDist(r,e);isNaN(l)&&(l=1e7,s++),0===i?(o=l,l=0):l-=o,this._zList[i]=l}this._noneCount=s}if(this.vertexCount<2e4)0===t&&this._simpleSort(this._noneCount/this.vertexCount>.05);else for(i=0;i<3;i++)this._progressiveQuickSort(3*t+i);this.dirtyIndices()},_simpleSort:function(e){var t=this._zList,n=this.indices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):b1.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._zList,n=this.indices;this._quickSort=this._quickSort||new b1,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}},d3=sQ.vec4;zJ.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");var p3=zJ.Mesh.extend((function(){var e=new zJ.Geometry({dynamic:!0,attributes:{color:new zJ.Geometry.Attribute("color","float",4,"COLOR"),position:new zJ.Geometry.Attribute("position","float",3,"POSITION"),size:new zJ.Geometry.Attribute("size","float",1),prevPosition:new zJ.Geometry.Attribute("prevPosition","float",3),prevSize:new zJ.Geometry.Attribute("prevSize","float",1)}});Object.assign(e,h3);var t=new zJ.Material({shader:zJ.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});t.enableTexture("sprite"),t.define("both","VERTEX_COLOR"),t.define("both","VERTEX_SIZE");var n=new zJ.Texture2D({image:document.createElement("canvas"),flipY:!1});return t.set("sprite",n),e.pick=this._pick.bind(this),{geometry:e,material:t,mode:zJ.Mesh.POINTS,sizeScale:1}}),{_pick:function(e,t,n,r,i,o){var a=this._positionNDC;if(a)for(var s=n.viewport,l=2/s.width,u=2/s.height,c=this.geometry.vertexCount-1;c>=0;c--){var h,d=a[2*(h=this.geometry.indices?this.geometry.indices[c]:c)],p=a[2*h+1],f=this.geometry.attributes.size.get(h)/this.sizeScale/2;if(e>d-f*l&&e<d+f*l&&t>p-f*u&&t<p+f*u){var g=new zJ.Vector3,m=new zJ.Vector3;this.geometry.attributes.position.get(h,g.array),zJ.Vector3.transformMat4(m,g,this.worldTransform),o.push({vertexIndex:h,point:g,pointWorld:m,target:this,distance:m.distance(r.getWorldPosition())})}}},updateNDCPosition:function(e,t,n){var r=this._positionNDC,i=this.geometry;r&&r.length/2===i.vertexCount||(r=this._positionNDC=new Float32Array(2*i.vertexCount));for(var o=d3.create(),a=0;a<i.vertexCount;a++)i.attributes.position.get(a,o),o[3]=1,d3.transformMat4(o,o,e.array),d3.scale(o,o,1/o[3]),r[2*a]=o[0],r[2*a+1]=o[1]}});function f3(e,t){this.rootNode=new zJ.Node,this.is2D=e,this._labelsBuilder=new I1(256,256,t),this._labelsBuilder.getMesh().renderOrder=100,this.rootNode.add(this._labelsBuilder.getMesh()),this._api=t,this._spriteImageCanvas=document.createElement("canvas"),this._startDataIndex=0,this._endDataIndex=0,this._sizeScale=1}f3.prototype={constructor:f3,highlightOnMouseover:!0,update:function(e,t,n,r,i){var o=this._prevMesh;this._prevMesh=this._mesh,this._mesh=o;var a=e.getData();if(null==r&&(r=0),null==i&&(i=a.count()),this._startDataIndex=r,this._endDataIndex=i-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new p3({renderOrder:10,frustumCulling:!1}),s&&(this._mesh.material=s)}s=this._mesh.material;var l=this._mesh.geometry,u=l.attributes;this.rootNode.remove(this._prevMesh),this.rootNode.add(this._mesh),this._setPositionTextureToMesh(this._mesh,this._positionTexture);var c=this._getSymbolInfo(e,r,i),h=n.getDevicePixelRatio(),d=e.getModel("itemStyle").getItemStyle(),p=e.get("large"),f=1;c.maxSize>2?(f=this._updateSymbolSprite(e,d,c,h),s.enableTexture("sprite")):s.disableTexture("sprite"),u.position.init(i-r);var g=[];if(p){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var m=function(e){const t=e.getVisual("style");if(t)return t[e.getVisual("drawType")]}(a),v=function(e){return e.getVisual("style").opacity}(a);zJ.parseColor(m,g),g[3]*=v,s.set({color:g,u_Size:c.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),u.size.init(i-r),u.color.init(i-r),this._originalOpacity=new Float32Array(i-r);for(var y=a.getLayout("points"),_=u.position.value,x=0;x<i-r;x++){var b=3*x,w=2*x;if(this.is2D?(_[b]=y[w],_[b+1]=y[w+1],_[b+2]=-10):(_[b]=y[b],_[b+1]=y[b+1],_[b+2]=y[b+2]),!p){m=D1(a,x),v=A1(a,x);zJ.parseColor(m,g),g[3]*=v,u.color.set(x,g),g[3];var S=a.getItemVisual(x,"symbolSize");S=S instanceof Array?Math.max(S[0],S[1]):S,isNaN(S)&&(S=0),u.size.value[x]=S*f*this._sizeScale,this._originalOpacity[x]=g[3]}}this._mesh.sizeScale=f,l.updateBoundingBox(),l.dirty(),this._updateMaterial(e,d);var T=e.coordinateSystem;T&&T.viewGL&&s[T.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE");p||this._updateLabelBuilder(e,r,i),this._updateHandler(e,t,n),this._updateAnimation(e),this._api=n},getPointsMesh:function(){return this._mesh},updateLabels:function(e){this._labelsBuilder.updateLabels(e)},hideLabels:function(){this.rootNode.remove(this._labelsBuilder.getMesh())},showLabels:function(){this.rootNode.add(this._labelsBuilder.getMesh())},dispose:function(){this._labelsBuilder.dispose()},_updateSymbolSprite:function(e,t,n,r){n.maxSize=Math.min(2*n.maxSize,200);var i,o,a=[];return n.aspect>1?(a[0]=n.maxSize,a[1]=n.maxSize/n.aspect):(a[1]=n.maxSize,a[0]=n.maxSize*n.aspect),a[0]=a[0]||1,a[1]=a[1]||1,this._symbolType===n.type&&(i=this._symbolSize,o=a,i&&o&&i[0]===o[0]&&i[1]===o[1])&&this._lineWidth===t.lineWidth||(u3.createSymbolSprite(n.type,a,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(a[0]/2,10)},this._spriteImageCanvas),u3.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=n.type,this._symbolSize=a,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/n.maxSize*r},_updateMaterial:function(e,t){var n="lighter"===e.get("blendMode")?zJ.additiveBlend:null,r=this._mesh.material;r.blend=n,r.set("lineWidth",t.lineWidth/20);var i=zJ.parseColor(t.stroke);r.set("strokeColor",i),r.transparent=!0,r.depthMask=!1,r.depthTest=!this.is2D,r.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,n){var r=e.getData(),i=this._mesh.geometry,o=i.attributes.position.value,a=(t=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(r,t,n),this._labelsBuilder.getLabelPosition=function(e,n,r){var i=3*(e-t);return[o[i],o[i+1],o[i+2]]},this._labelsBuilder.getLabelDistance=function(e,n,r){return i.attributes.size.get(e-t)/a/2+r},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,n){var r,i=e.getData(),o=this._mesh,a=this,s=-1,l=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;l&&(r=e.coordinateSystem.model),o.seriesIndex=e.seriesIndex,o.off("mousemove"),o.off("mouseout"),o.on("mousemove",(function(t){var u=t.vertexIndex+a._startDataIndex;u!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,u),this._labelsBuilder.updateLabels([u])),l&&n.dispatchAction({type:"grid3DShowAxisPointer",value:[i.get(e.coordDimToDataDim("x")[0],u),i.get(e.coordDimToDataDim("y")[0],u),i.get(e.coordDimToDataDim("z")[0],u)],grid3DIndex:r.componentIndex})),o.dataIndex=u,s=u}),this),o.on("mouseout",(function(e){var t=e.vertexIndex+a._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,o.dataIndex=-1,l&&n.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:r.componentIndex})}),this)},updateLayout:function(e,t,n){var r=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,o=r.getLayout("points");if(this.is2D)for(var a=0;a<o.length/2;a++){var s=3*a,l=2*a;i[s]=o[l],i[s+1]=o[l+1],i[s+2]=-10}else for(a=0;a<o.length;a++)i[a]=o[a];this._mesh.geometry.dirty(),n.getZr().refresh()}},updateView:function(e){if(this._mesh){var t=new iK;iK.mul(t,e.viewMatrix,this._mesh.worldTransform),iK.mul(t,e.projectionMatrix,t),this._mesh.updateNDCPosition(t,this.is2D,this._api)}},highlight:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=e.getItemModel(t).getModel("emphasis.itemStyle"),r=n.get("color"),i=n.get("opacity");if(null==r)r=ir(D1(e,t),-.4);null==i&&(i=A1(e,t));var o=zJ.parseColor(r);o[3]*=i,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,o),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},downplay:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=D1(e,t),r=A1(e,t),i=zJ.parseColor(n);i[3]*=r,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,i),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeOutAll:function(e){if(this._originalOpacity){for(var t=this._mesh.geometry,n=0;n<t.vertexCount;n++){var r=this._originalOpacity[n]*e;t.attributes.color.value[4*n+3]=r}t.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeInAll:function(){this.fadeOutAll(1)},setPositionTexture:function(e){this._mesh&&this._setPositionTextureToMesh(this._mesh,e),this._positionTexture=e},removePositionTexture:function(){this._positionTexture=null,this._mesh&&this._setPositionTextureToMesh(this._mesh,null)},setSizeScale:function(e){if(e!==this._sizeScale){if(this._mesh){var t=this._mesh.material.get("u_Size");this._mesh.material.set("u_Size",t/this._sizeScale*e);var n=this._mesh.geometry.attributes;if(n.size.value)for(var r=0;r<n.size.value.length;r++)n.size.value[r]=n.size.value[r]/this._sizeScale*e}this._sizeScale=e}},_setPositionTextureToMesh:function(e,t){t&&e.material.set("positionTexture",t),e.material[t?"enableTexture":"disableTexture"]("positionTexture")},_getSymbolInfo:function(e,t,n){if(e.get("large"))return(h=vJ(e.get("symbolSize"),1))instanceof Array?(l=Math.max(h[0],h[1]),r=h[0]/h[1]):(l=h,r=1),{maxSize:h,type:e.get("symbol"),aspect:r};for(var r,i=e.getData(),o=!1,a=i.getItemVisual(0,"symbol")||"circle",s=!1,l=0,u=t;u<n;u++){var c,h=i.getItemVisual(u,"symbolSize"),d=i.getItemVisual(u,"symbol");if(h instanceof Array)c=h[0]/h[1],l=Math.max(Math.max(h[0],h[1]),l);else{if(isNaN(h))continue;c=1,l=Math.max(h,l)}"production"!==process.env.NODE_ENV&&(null!=r&&Math.abs(c-r)>.05&&(o=!0),d!==a&&(s=!0)),a=d,r=c}return"production"!==process.env.NODE_ENV&&(o&&console.warn("Different symbol width / height ratio will be ignored."),s&&console.warn("Different symbol type will be ignored.")),{maxSize:l,type:a,aspect:r}}};var g3=Kg.extend({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(e,t,n){if(this.groupGL.removeAll(),e.getData().count()){var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new f3(!1,n)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),i.update(e,t,n),i.updateView(r.viewGL.camera)}else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system")}},incrementalPrepareRender:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL)r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system");this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new f3(!1,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),i.update(t,n,r,e.start,e.end),i.updateView(t.coordinateSystem.viewGL.camera),this._currentStep++}},updateCamera:function(){this._pointsBuilderList.forEach((function(e){e.updateView(this._camera)}),this)},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=yJ(o,i),s="highlight"===e;null!=a?W(G2.normalizeToArray(a),(function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}),this):o.each((function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}))},dispose:function(){this._pointsBuilderList.forEach((function(e){e.dispose()})),this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(g3),e.registerSeriesModel(s3),e.registerLayout({seriesType:"scatter3D",reset:function(e){var t=e.coordinateSystem;if(t){var n=t.dimensions;if(n.length<3)return void("production"!==process.env.NODE_ENV&&console.error("scatter3D needs 3D coordinateSystem"));var r=n.map((function(t){return e.coordDimToDataDim(t)[0]})),i=[],o=[];return{progress:function(e,n){for(var a=new Float32Array(3*(e.end-e.start)),s=e.start;s<e.end;s++){var l=3*(s-e.start);i[0]=n.get(r[0],s),i[1]=n.get(r[1],s),i[2]=n.get(r[2],s),t.dataToPoint(i,o),a[l]=o[0],a[l+1]=o[1],a[l+2]=o[2]}n.setLayout("points",a)}}}}})}));var m3=sQ.vec3,v3=sQ.vec2,y3=m3.normalize,_3=m3.cross,x3=m3.sub,b3=m3.add,w3=m3.create,S3=w3(),T3=w3(),M3=w3(),C3=w3(),D3=[],A3=[];function I3(e,t){v3.copy(D3,e[0]),v3.copy(A3,e[1]);var n=[],r=n[0]=w3(),i=n[1]=w3(),o=n[2]=w3(),a=n[3]=w3();t.dataToPoint(D3,r),t.dataToPoint(A3,a),y3(S3,r),x3(T3,a,r),y3(T3,T3),_3(M3,T3,S3),y3(M3,M3),_3(T3,S3,M3),b3(i,S3,T3),y3(i,i),y3(S3,a),x3(T3,r,a),y3(T3,T3),_3(M3,T3,S3),y3(M3,M3),_3(T3,S3,M3),b3(o,S3,T3),y3(o,o),b3(C3,r,a),y3(C3,C3);var s=m3.dot(r,C3),l=m3.dot(C3,i),u=(Math.max(m3.len(r),m3.len(a))-s)/l*2;return m3.scaleAndAdd(i,r,i,u),m3.scaleAndAdd(o,a,o,u),n}function E3(e,t){for(var n=new Float32Array(3*e.length),r=0,i=[],o=0;o<e.length;o++)t.dataToPoint(e[o],i),n[r++]=i[0],n[r++]=i[1],n[r++]=i[2];return n}function L3(e){var t=[];return e.each((function(n){var r=e.getItemModel(n),i=r.option instanceof Array?r.option:r.getShallow("coords",!0);if("production"!==process.env.NODE_ENV&&!(i instanceof Array&&i.length>0&&i[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(i)+". Lines must have 2d coords array in data item.");t.push(i)})),{coordsList:t}}function N3(e,t,n){var r=e.getData(),i=e.get("polyline"),o=L3(r);r.setLayout("lineType",i?"polyline":"cubicBezier"),r.each((function(e){var a=o.coordsList[e],s=i?E3(a,t):function(e,t,n){var r=[],i=r[0]=m3.create(),o=r[1]=m3.create(),a=r[2]=m3.create(),s=r[3]=m3.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var l=m3.dist(i,s);return m3.lerp(o,i,s,.3),m3.lerp(a,i,s,.3),m3.scaleAndAdd(o,o,n,Math.min(.1*l,10)),m3.scaleAndAdd(a,a,n,Math.min(.1*l,10)),r}(a,t,n);r.setItemLayout(e,s)}))}function P3(e,t){e.eachSeriesByType("lines3D",(function(e){var t=e.coordinateSystem;"globe"===t.type?function(e,t){var n=e.getData(),r=e.get("polyline");n.setLayout("lineType",r?"polyline":"cubicBezier");var i=L3(n);n.each((function(e){var o=i.coordsList[e],a=r?E3:I3;n.setItemLayout(e,a(o,t))}))}(e,t):"geo3D"===t.type?N3(e,t,[0,1,0]):"mapbox3D"!==t.type&&"maptalks3D"!==t.type||N3(e,t,[0,0,1])}))}var O3=Vg.extend({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){var n=new L_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"globe",globeIndex:0,geo3DIndex:0,zlevel:-10,polyline:!1,effect:{show:!1,period:4,trailWidth:4,trailLength:.2,spotIntensity:6},silent:!0,blendMode:"source-over",lineStyle:{width:1,opacity:.5}}}),R3=sQ.vec3;zJ.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");var k3=zJ.Mesh.extend((function(){var e=new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.trail2.vertex"),zJ.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new cQ({dynamic:!0});return t.createAttribute("dist","float",1),t.createAttribute("distAll","float",1),t.createAttribute("start","float",1),{geometry:t,material:e,culling:!1,$ignorePicking:!0}}),{updateData:function(e,t,n){var r=e.hostModel,i=this.geometry,o=r.getModel("effect"),a=o.get("trailWidth")*t.getDevicePixelRatio(),s=o.get("trailLength"),l=r.get("effect.constantSpeed"),u=1e3*r.get("effect.period"),c=null!=l;"production"!==process.env.NODE_ENV&&(this.getScene()||console.error("TrailMesh must been add to scene before updateData")),c?this.material.set("speed",l/1e3):this.material.set("period",u),this.material[c?"define":"undefine"]("vertex","CONSTANT_SPEED");var h=r.get("polyline");i.trailLength=s,this.material.set("trailLength",s),i.resetOffset(),["position","positionPrev","positionNext"].forEach((function(e){i.attributes[e].value=n.attributes[e].value}));["dist","distAll","start","offset","color"].forEach((function(e){i.attributes[e].init(i.vertexCount)})),i.indices=n.indices;var d=[],p=o.get("trailColor"),f=o.get("trailOpacity"),g=null!=p,m=null!=f;this.updateWorldTransform();var v=this.worldTransform.x.len(),y=this.worldTransform.y.len(),_=this.worldTransform.z.len(),x=0,b=0;e.each((function(t){var r=e.getItemLayout(t),o=m?f:A1(e,t),s=D1(e,t);null==o&&(o=1),(d=zJ.parseColor(g?p:s,d))[3]*=o;for(var l=h?n.getPolylineVertexCount(r):n.getCubicCurveVertexCount(r[0],r[1],r[2],r[3]),w=0,S=[],T=[],M=x;M<x+l;M++)i.attributes.position.get(M,S),S[0]*=v,S[1]*=y,S[2]*=_,M>x&&(w+=R3.dist(S,T)),i.attributes.dist.set(M,w),R3.copy(T,S);b=Math.max(b,w);var C=Math.random()*(c?w:u);for(M=x;M<x+l;M++)i.attributes.distAll.set(M,w),i.attributes.start.set(M,C),i.attributes.offset.set(M,(n.attributes.offset.get(M)>0?1:-1)*a/2),i.attributes.color.set(M,d);x+=l})),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",o.get("spotIntensity")),i.dirty()},setAnimationTime:function(e){this.material.set("time",e)}});zJ.Shader.import(CQ);var z3=Kg.extend({type:"lines3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._meshLinesMaterial=new zJ.Material({shader:zJ.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new zJ.Mesh({geometry:new cQ,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new k3},render:function(e,t,n){this.groupGL.add(this._linesMesh);var r=e.coordinateSystem,i=e.getData();if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._updateLines(e,t,n);var o=r.viewGL.isLinearSpace()?"define":"undefine";this._linesMesh.material[o]("fragment","SRGB_DECODE"),this._trailMesh.material[o]("fragment","SRGB_DECODE")}var a=this._trailMesh;if(a.stopAnimation(),e.get("effect.show")){this.groupGL.add(a),a.updateData(i,n,this._linesMesh.geometry),a.__time=a.__time||0;var s=36e5;this._curveEffectsAnimator=a.animate("",{loop:!0}).when(s,{__time:s}).during((function(){a.setAnimationTime(a.__time)})).start()}else this.groupGL.remove(a),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===e.get("blendMode")?zJ.additiveBlend:null},pauseEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.pause()},resumeEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.resume()},toggleEffect:function(){var e=this._curveEffectsAnimator;e&&(e.isPaused()?e.resume():e.pause())},_updateLines:function(e,t,n){var r=e.getData(),i=e.coordinateSystem,o=this._linesMesh.geometry,a=e.get("polyline");o.expandLine=!0;var s=function(e){return null!=e.radius?e.radius:null!=e.size?Math.max(e.size[0],e.size[1],e.size[2]):100}(i);o.segmentScale=s/20;var l="lineStyle.width".split("."),u=n.getDevicePixelRatio();r.each((function(e){var t=r.getItemModel(e).get(l);null==t&&(t=1),r.setItemVisual(e,"lineWidth",t)})),o.useNativeLine=!1;var c=0,h=0;r.each((function(e){var t=r.getItemLayout(e);a?(c+=o.getPolylineVertexCount(t),h+=o.getPolylineTriangleCount(t)):(c+=o.getCubicCurveVertexCount(t[0],t[1],t[2],t[3]),h+=o.getCubicCurveTriangleCount(t[0],t[1],t[2],t[3]))})),o.setVertexCount(c),o.setTriangleCount(h),o.resetOffset();var d=[];r.each((function(e){var t=r.getItemLayout(e),n=D1(r,e),i=A1(r,e),s=r.getItemVisual(e,"lineWidth")*u;null==i&&(i=1),(d=zJ.parseColor(n,d))[3]*=i,a?o.addPolyline(t,d,s):o.addCubicCurve(t[0],t[1],t[2],t[3],d,s)})),o.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function V3(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}i_((function(e){e.registerChartView(z3),e.registerSeriesModel(O3),e.registerLayout(P3),e.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},(function(){})),e.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},(function(){})),e.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},(function(){}))}));var B3=Vg.extend({type:"series.polygons3D",getRegionModel:function(e){return this.getData().getItemModel(e)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getItemModel(e),r=n.option instanceof Array?n.option:n.getShallow("coords");n.get("multiPolygon")||(r=[r]);for(var i=[],o=0;o<r.length;o++){for(var a=[],s=1;s<r[o].length;s++)a.push(V3(t,r[o][s]));i.push({exterior:V3(t,r[o][0]),interiors:a})}return i},getInitialData:function(e){var t=new L_(["value"],this);return t.hasItemOption=!1,t.initData(e.data,[],(function(e,n,r,i){if(e instanceof Array)return NaN;t.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),t},defaultOption:{show:!0,data:null,multiPolygon:!1,progressiveThreshold:1e3,progressive:1e3,zlevel:-10,label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}});R(B3.prototype,X0);var F3=Kg.extend({type:"polygons3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL);var i=this._geo3DBuilderList[0];i||((i=new L1(n)).extrudeY="mapbox3D"!==r.type&&"maptalks3D"!==r.type,this._geo3DBuilderList[0]=i),this._updateShaderDefines(r,i),i.update(e,t,n),this._geo3DBuilderList.length=1,this.groupGL.add(i.rootNode)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(e,t,n,r){var i=this._geo3DBuilderList[this._currentStep],o=t.coordinateSystem;i||((i=new L1(r)).extrudeY="mapbox3D"!==o.type&&"maptalks3D"!==o.type,this._geo3DBuilderList[this._currentStep]=i),i.update(t,n,r,e.start,e.end),this.groupGL.add(i.rootNode),this._updateShaderDefines(o,i),this._currentStep++},_updateShaderDefines:function(e,t){var n=e.viewGL.isLinearSpace()?"define":"undefine";t.rootNode.traverse((function(t){t.material&&(t.material[n]("fragment","SRGB_DECODE"),"mapbox3D"!==e.type&&"maptalks3D"!==e.type||(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1)))}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll(),this._geo3DBuilderList.forEach((function(e){e.dispose()}))}});i_((function(e){e.registerChartView(F3),e.registerSeriesModel(B3)}));var G3=Vg.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return H2(this,e)},getInitialData:function(e,t){var n=e.data;function r(e){return!(isNaN(e.min)||isNaN(e.max)||isNaN(e.step))}function i(e){var t=oo;return Math.max(t(e.min),t(e.max),t(e.step))+1}if(!n)if(e.parametric){var o=e.parametricEquation||{},a=o.u||{},s=o.v||{};["u","v"].forEach((function(e){r(o[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid parametricEquation.%s",e)})),["x","y","z"].forEach((function(e){"function"==typeof o[e]||"production"!==process.env.NODE_ENV&&console.error("parametricEquation.%s needs to be function",e)}));var l=Math.floor((a.max+a.step-a.min)/a.step),u=Math.floor((s.max+s.step-s.min)/s.step);n=new Float32Array(l*u*5);var c=i(a),h=i(s);for(S=0,T=0;T<u;T++)for(M=0;M<l;M++){var d=M*a.step+a.min,p=T*s.step+s.min,f=no(Math.min(d,a.max),c),g=no(Math.min(p,s.max),h);C=o.x(f,g),D=o.y(f,g),E=o.z(f,g);n[S++]=C,n[S++]=D,n[S++]=E,n[S++]=f,n[S++]=g}}else{var m=e.equation||{},v=m.x||{},y=m.y||{};if(["x","y"].forEach((function(e){r(m[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid equation.%s",e)})),"function"!=typeof m.z)return void("production"!==process.env.NODE_ENV&&console.error("equation.z needs to be function"));var _=Math.floor((v.max+v.step-v.min)/v.step),x=Math.floor((y.max+y.step-y.min)/y.step);n=new Float32Array(_*x*3);for(var b=i(v),w=i(y),S=0,T=0;T<x;T++)for(var M=0;M<_;M++){var C=M*v.step+v.min,D=T*y.step+y.min,A=no(Math.min(C,v.max),b),I=no(Math.min(D,y.max),w),E=m.z(A,I);n[S++]=A,n[S++]=I,n[S++]=E}}var L=["x","y","z"];return e.parametric&&L.push("u","v"),U2(this,L,n)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,shading:"lambert",parametric:!1,wireframe:{show:!0,lineStyle:{color:"rgba(0,0,0,0.5)",width:1}},equation:{x:{min:-1,max:1,step:.1},y:{min:-1,max:1,step:.1},z:null},parametricEquation:{u:{min:-1,max:1,step:.1},v:{min:-1,max:1,step:.1},x:null,y:null,z:null},dataShape:null,itemStyle:{},animationDurationUpdate:500}});R(G3.prototype,X0);var H3=sQ.vec3;function U3(e){return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])}var W3=Kg.extend({type:"surface",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node},render:function(e,t,n){var r=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=r,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var i=e.coordinateSystem,o=e.get("shading"),a=e.getData(),s="ecgl."+o;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=zJ.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),zJ.setMaterialFromModel(o,this._surfaceMesh.material,e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var l=i.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var u=e.get("parametric"),c=e.get("dataShape");c||(c=this._getDataShape(a,u),"production"!==process.env.NODE_ENV&&e.get("data")&&console.warn("dataShape is not provided. Guess it is ",c));var h=e.getModel("wireframe"),d=h.get("lineStyle.width"),p=h.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,e,c,p);var f=this._surfaceMesh.material;p?(f.define("WIREFRAME_QUAD"),f.set("wireframeLineWidth",d),f.set("wireframeLineColor",zJ.parseColor(h.get("lineStyle.color")))):f.undefine("WIREFRAME_QUAD"),this._initHandler(e,n),this._updateAnimation(e)},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new zJ.Mesh({geometry:new zJ.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.sm.depth.vertex"),zJ.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),Object.assign(e.geometry,C1),e},_initHandler:function(e,t){var n=e.getData(),r=this._surfaceMesh,i=e.coordinateSystem;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=function(e,t){for(var n=1/0,i=-1,o=[],a=0;a<e.length;a++){r.geometry.attributes.position.get(e[a],o);var s=H3.dist(t.array,o);s<n&&(n=s,i=e[a])}return i}(e.triangle,e.point);if(a>=0){var s=[];r.geometry.attributes.position.get(a,s);for(var l=i.pointToData(s),u=1/0,c=-1,h=[],d=0;d<n.count();d++){h[0]=n.get("x",d),h[1]=n.get("y",d),h[2]=n.get("z",d);var p=H3.squaredDistance(h,l);p<u&&(c=d,u=p)}c!==o&&t.dispatchAction({type:"grid3DShowAxisPointer",value:l}),o=c,r.dataIndex=c}else r.dataIndex=-1}),this),r.on("mouseout",(function(e){o=-1,r.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateSurfaceMesh:function(e,t,n,r){var i=e.geometry,o=t.getData(),a=o.getLayout("points"),s=0;o.each((function(e){o.hasValue(e)||s++}));var l=s||r,u=i.attributes.position,c=i.attributes.normal,h=i.attributes.texcoord0,d=i.attributes.barycentric,p=i.attributes.color,f=n[0],g=n[1],m="color"!==t.get("shading");if(l){var v=(f-1)*(g-1)*4;u.init(v),r&&d.init(v)}else u.value=new Float32Array(a);p.init(i.vertexCount),h.init(i.vertexCount);var y=[0,3,1,1,3,2],_=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],x=i.indices=new(i.vertexCount>65535?Uint32Array:Uint16Array)((f-1)*(g-1)*6),b=function(e,t,n){n[1]=e*g+t,n[0]=e*g+t+1,n[3]=(e+1)*g+t+1,n[2]=(e+1)*g+t},w=!1;if(l){var S=[],T=[],M=0;m?c.init(i.vertexCount):c.value=null;for(var C=[[],[],[]],D=[],A=[],I=H3.create(),E=function(e,t,n){var r=3*t;return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n},L=new Float32Array(a.length),N=new Float32Array(a.length/3*4),P=0;P<o.count();P++)if(o.hasValue(P)){var O=zJ.parseColor(D1(o,P));null!=(j=A1(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0);for(var R=0;R<4;R++)N[4*P+R]=O[R]}var k=[1e7,1e7,1e7];for(P=0;P<f-1;P++)for(var z=0;z<g-1;z++){var V=4*(P*(g-1)+z);b(P,z,S);var B=!1;for(R=0;R<4;R++)E(a,S[R],T),U3(T)&&(B=!0);for(R=0;R<4;R++)B?u.set(V+R,k):(E(a,S[R],T),u.set(V+R,T)),r&&d.set(V+R,_[R]);for(R=0;R<6;R++)x[M++]=y[R]+V;if(m&&!B)for(R=0;R<2;R++){for(var F=3*R,G=0;G<3;G++){E(a,W=S[y[F]+G],C[G])}H3.sub(D,C[0],C[1]),H3.sub(A,C[1],C[2]),H3.cross(I,D,A);for(G=0;G<3;G++){var H=3*S[y[F]+G];L[H]=L[H]+I[0],L[H+1]=L[H+1]+I[1],L[H+2]=L[H+2]+I[2]}}}if(m)for(P=0;P<L.length/3;P++)E(L,P,I),H3.normalize(I,I),L[3*P]=I[0],L[3*P+1]=I[1],L[3*P+2]=I[2];O=[];var U=[];for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){V=4*(P*(g-1)+z);b(P,z,S);for(R=0;R<4;R++){for(G=0;G<4;G++)O[G]=N[4*S[R]+G];p.set(V+R,O),m&&(E(L,S[R],I),c.set(V+R,I));var W=S[R];U[0]=W%g/(g-1),U[1]=Math.floor(W/g)/(f-1),h.set(V+R,U)}0}}else{for(U=[],P=0;P<o.count();P++){U[0]=P%g/(g-1),U[1]=Math.floor(P/g)/(f-1);var j;O=zJ.parseColor(D1(o,P));null!=(j=A1(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0),p.set(P,O),h.set(P,U)}S=[];var X=0;for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){b(P,z,S);for(R=0;R<6;R++)x[X++]=S[y[R]]}m?i.generateVertexNormals():c.value=null}e.material.get("normalMap")&&i.generateTangents(),i.updateBoundingBox(),i.dirty(),e.material.transparent=w,e.material.depthMask=!w},_getDataShape:function(e,t){for(var n=-1/0,r=0,i=0,o=0,a=!1,s=t?"u":"x",l=e.count(),u=0;u<l;u++){var c=e.get(s,u);c<n&&(o&&o!==i&&"production"!==process.env.NODE_ENV&&(a=!0),o=i,i=0,r++),n=c,i++}if(r&&1!==i||(a=!0),!a)return[r+1,i];for(var h=Math.floor(Math.sqrt(l));h>0;){if(Math.floor(l/h)===l/h)return[h,l/h];h--}return[h=Math.floor(Math.sqrt(l)),h]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function j3(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}i_((function(e){e.registerChartView(W3),e.registerSeriesModel(G3),e.registerLayout((function(e,t){e.eachSeriesByType("surface",(function(e){var t=e.coordinateSystem;t&&"cartesian3D"===t.type||"production"!==process.env.NODE_ENV&&console.error("Surface chart only support cartesian3D coordinateSystem");var n=e.getData(),r=new Float32Array(3*n.count()),i=[NaN,NaN,NaN];if(t&&"cartesian3D"===t.type){var o=t.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n.each(o,(function(e,o,a,s){var l;l=n.hasValue(s)?t.dataToPoint([e,o,a]):i,r[3*s]=l[0],r[3*s+1]=l[1],r[3*s+2]=l[2]}))}n.setLayout("points",r)}))}))}));var X3=Vg.extend({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(e){e=e||{};var t=this.get("coordinateSystem");if(null!=t&&"geo3D"!==t){if("production"!==process.env.NODE_ENV){var n=[];["left","top","width","height","boxWidth","boxDepth","boxHeight","light","viewControl","postEffect","temporalSuperSampling","environment","groundPlane"].forEach((function(t){null!=e[t]&&n.push(t)})),n.length&&console.warn("Property %s in map3D series will be ignored if coordinate system is %s",n.join(", "),t)}this.get("groundPlane.show")&&(this.option.groundPlane.show=!1),this._geo=null}},getInitialData:function(e){e.data=this.getFilledRegions(e.data,e.map);var t=N_(e.data,{coordDimensions:["value"]}),n=new L_(t,this);n.initData(e.data);var r={};return n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,n},formatTooltip:function(e){return H2(this,e)},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Fh(null,this)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getName(e);if(t.transform)return(r=t.getRegion(n))?r.geometries:[];this._geo||(this._geo=H1.createGeo3D(this));for(var r=this._geo.getRegion(n),i=[],o=0;o<r.geometries.length;o++){var a=r.geometries[o],s=[],l=j3(t,a.exterior);if(s&&s.length)for(var u=0;u<a.interiors.length;u++)s.push(j3(t,s[u]));i.push({interiors:s,exterior:l})}return i},getFormattedLabel:function(e,t){var n=G2.getFormattedLabel(this,e,t);return null==n&&(n=this.getData().getName(e)),n},defaultOption:{coordinateSystem:"geo3D",data:null}});R(X3.prototype,Y0),R(X3.prototype,JJ),R(X3.prototype,QJ),R(X3.prototype,eQ),R(X3.prototype,X0);var Y3=Kg.extend({type:"map3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new L1(t),this.groupGL=new zJ.Node},render:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),r.viewGL.add(this.groupGL),"geo3D"===r.type){this._sceneHelper||(this._sceneHelper=new pQ,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var i=this._control;i||(i=this._control=new oQ({zr:n.getZr()}),this._control.init());var o=e.getModel("viewControl");i.setViewGL(r.viewGL),i.setFromViewControlModel(o,0),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"map3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),from:this.uid,map3DId:e.id})})),this._geo3DBuilder.extrudeY=!0}else this._control&&(this._control.dispose(),this._control=null),this._sceneHelper&&(this._sceneHelper.dispose(),this._sceneHelper=null),e.getData().getLayout("geo3D"),this._geo3DBuilder.extrudeY=!1;this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")}))}},afterRender:function(e,t,n,r){var i=r.renderer,o=e.coordinateSystem;o&&"geo3D"===o.type&&(this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n))},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._geo3DBuilder.dispose()}});i_((function(e){U1(e),e.registerChartView(Y3),e.registerSeriesModel(X3),e.registerAction({type:"map3DChangeCamera",event:"map3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"series",subType:"map3D",query:e},(function(t){t.setView(e)}))}))}));var Z3=Vg.extend({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(){return Kx(this)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,progressive:1e5,progressiveThreshold:1e5,large:!1,symbol:"circle",symbolSize:10,zoomScale:0,blendMode:"source-over",itemStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}});function q3(e){this.viewGL=e}q3.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=[1,0,0,1,0,0],this.updateTransform(e,t)},q3.prototype.updateTransform=function(e,t){var n=e.coordinateSystem;n.getRoamTransform&&(Pt(this._viewTransform,n.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},q3.prototype.dataToPoint=function(e,t,n){n=e.dataToPoint(t,null,n);var r=this._viewTransform;r&&Ke(n,n,r)},q3.prototype.removeTransformInPoint=function(e){return this._viewTransform&&Ke(e,e,this._viewTransform),e},q3.prototype.getZoom=function(){if(this._viewTransform){var e=this._viewTransform;return 1/Math.max(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]))}return 1},q3.prototype._setCameraTransform=function(e){var t=this.viewGL.camera;t.position.set(e[4],e[5],0),t.scale.set(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]),1)},q3.prototype._updateCamera=function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.top=0,r.bottom=t,r.right=e,r.near=0,r.far=100};var K3=Kg.extend({type:"scatterGL",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this.viewGL=new N0("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new q3(this.viewGL)},render:function(e,t,n){if(this.groupGL.removeAll(),this._glViewHelper.reset(e,n),e.getData().count()){var r=this._pointsBuilderList[0];r||(r=this._pointsBuilderList[0]=new f3(!0,n)),this._pointsBuilderList.length=1,this.groupGL.add(r.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),r.update(e,t,n),this.viewGL.setPostEffect(e.getModel("postEffect"),n)}},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new f3(!0,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.setSizeScale(this._sizeScale),i.update(t,n,r,e.start,e.end),r.getZr().refresh(),this._currentStep++}},updateTransform:function(e,t,n){if(e.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(e,n);var r=this._glViewHelper.getZoom(),i=Math.max((e.get("zoomScale")||0)*(r-1)+1,0);this._sizeScale=i,this._pointsBuilderList.forEach((function(e){e.setSizeScale(i)}))}},_removeTransformInPoints:function(e){if(e)for(var t=[],n=0;n<e.length;n+=2)t[0]=e[n],t[1]=e[n+1],this._glViewHelper.removeTransformInPoint(t),e[n]=t[0],e[n+1]=t[1]},dispose:function(){this.groupGL.removeAll(),this._pointsBuilderList.forEach((function(e){e.dispose()}))},remove:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(K3),e.registerSeriesModel(Z3),e.registerLayout({seriesType:"scatterGL",reset:function(e){var t,n=e.coordinateSystem,r=e.getData();if(n){var i=n.dimensions.map((function(e){return r.mapDimension(e)})).slice(0,2),o=[];1===i.length?t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),o=e.start;o<e.end;o++){var a=2*(o-e.start),s=r.get(i[0],o),l=n.dataToPoint(s);t[a]=l[0],t[a+1]=l[1]}r.setLayout("points",t)}:2===i.length&&(t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),a=e.start;a<e.end;a++){var s=2*(a-e.start),l=r.get(i[0],a),u=r.get(i[1],a);o[0]=l,o[1]=u,o=n.dataToPoint(o),t[s]=o[0],t[s+1]=o[1]}r.setLayout("points",t)})}return{progress:t}}})}));var $3=Vg.extend({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(e){$3.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(e){$3.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(e,t,n,r){var i=G2.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},getInitialData:function(e,t){var n=e.edges||e.links||[],r=e.data||e.nodes||[],i=this;return function(e,t,n,r,i){for(var o=new NE(r),a=0;a<e.length;a++)o.addNode(vJ(e[a].id,e[a].name,a),a);var s,l=[],u=[],c=0;for(a=0;a<t.length;a++){var h=t[a],d=h.source,p=h.target;o.addEdge(d,p,c)&&(u.push(h),l.push(vJ(h.id,d+" > "+p)),c++)}var f=N_(e,{coordDimensions:["value"]});(s=new L_(f,n)).initData(e);var g=new L_(["value"],n);return g.initData(u,l),i(s,g),xA({mainData:s,struct:o,structAttr:"graph",datas:{node:s,edge:g},datasAttr:{node:"data",edge:"edgeData"}}),o.update(),o}(r,n,this,!0,(function(e,n){e.wrapMethod("getItemModel",(function(e){const t=i._categoriesModels[e.getShallow("category")];return t&&(t.parentModel=e.parentModel,e.parentModel=t),e}));const r=t.getModel([]).getModel;function o(e,t){const n=r.call(this,e,t);return n.resolveParentPath=a,n}function a(e){if(e&&("label"===e[0]||"label"===e[1])){const t=e.slice();return"label"===e[0]?t[0]="edgeLabel":"label"===e[1]&&(t[1]="edgeLabel"),t}return e}n.wrapMethod("getItemModel",(function(e){return e.resolveParentPath=a,e.getModel=o,e}))})).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(e,t,n){if("edge"===n){var r=this.getData(),i=this.getDataParams(e,n),o=r.graph.getEdgeByIndex(e),a=r.getName(o.node1.dataIndex),s=r.getName(o.node2.dataIndex),l=[];return null!=a&&l.push(a),null!=s&&l.push(s),l=dt(l.join(" > ")),i.value&&(l+=" : "+dt(i.value)),l}return $3.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var e=(this.option.categories||[]).map((function(e){return null!=e.value?e:Object.assign({value:0},e)})),t=new L_(["value"],this);t.initData(e),this._categoriesData=t,this._categoriesModels=t.mapArray((function(e){return t.getItemModel(e,!0)}))},setView:function(e){null!=e.zoom&&(this.option.zoom=e.zoom),null!=e.offset&&(this.option.offset=e.offset)},setNodePosition:function(e){for(var t=0;t<e.length/2;t++){var n=e[2*t],r=e[2*t+1],i=this.getData().getRawDataItem(t);i.x=n,i.y=r}},isAnimationEnabled:function(){return $3.superCall(this,"isAnimationEnabled")&&!("force"===this.get("layout")&&this.get("force.layoutAnimation"))},defaultOption:{zlevel:10,z:2,legendHoverLink:!0,layout:"forceAtlas2",forceAtlas2:{initLayout:null,GPU:!0,steps:1,maxSteps:1e3,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,edgeWeightInfluence:1,edgeWeight:[1,4],nodeWeight:[1,4],preventOverlap:!1,gravityCenter:null},focusNodeAdjacency:!0,focusNodeAdjacencyOn:"mouseover",left:"center",top:"center",symbol:"circle",symbolSize:5,roam:!1,center:null,zoom:1,label:{show:!1,formatter:"{b}",position:"right",distance:5,textStyle:{fontSize:14}},itemStyle:{},lineStyle:{color:"#aaa",width:1,opacity:.5},emphasis:{label:{show:!0}},animation:!1}}),J3=sQ.vec2,Q3=[[0,0],[1,1]],e5=WK.extend((function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new WK.Attribute("position","float",2,"POSITION"),normal:new WK.Attribute("normal","float",2),offset:new WK.Attribute("offset","float",1),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.offset.init(e),t.normal.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(J3.dist(e,t)+J3.dist(n,t)+J3.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(Q3)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Q3)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?0:2*(t-1)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=t[0],u=t[1],c=n[0],h=n[1],d=r[0],p=r[1],f=this._getCubicCurveApproxStep(e,t,n,r),g=f*f,m=g*f,v=3*f,y=3*g,_=6*g,x=6*m,b=a-2*l+c,w=s-2*u+h,S=3*(l-c)-a+d,T=3*(u-h)-s+p,M=a,C=s,D=(l-a)*v+b*y+S*m,A=(u-s)*v+w*y+T*m,I=b*_+S*x,E=w*_+T*x,L=S*x,N=T*x,P=0,O=0,R=Math.ceil(1/f),k=new Float32Array(3*(R+1)),z=(k=[],0);for(O=0;O<R+1;O++)k[z++]=M,k[z++]=C,M+=D,C+=A,D+=I,A+=E,I+=L,E+=N,(P+=f)>1&&(M=D>0?Math.min(M,d):Math.max(M,d),C=A>0?Math.min(C,p):Math.max(C,p));this.addPolyline(k,i,o)},addLine:function(e,t,n,r){this.addPolyline([e,t],n,r)},addPolyline:function(){var e=J3.create(),t=J3.create(),n=J3.create(),r=J3.create(),i=[],o=[],a=[];return function(s,l,u,c,h){if(s.length){var d="number"!=typeof s[0];if(null==h&&(h=d?s.length:s.length/2),!(h<2)){null==c&&(c=0),null==u&&(u=1),this._itemVertexOffsets.push(this._vertexOffset);for(var p,f=d?"number"!=typeof l[0]:l.length/4===h,g=this.attributes.position,m=this.attributes.color,v=this.attributes.offset,y=this.attributes.normal,_=this.indices,x=this._vertexOffset,b=0;b<h;b++){if(d)i=s[b+c],p=f?l[b+c]:l;else{var w=2*b+c;if((i=i||[])[0]=s[w],i[1]=s[w+1],f){var S=4*b+c;(p=p||[])[0]=l[S],p[1]=l[S+1],p[2]=l[S+2],p[3]=l[S+3]}else p=l}if(this.useNativeLine)b>1&&(g.copy(x,x-1),m.copy(x,x-1),x++);else{var T;if(b<h-1){if(d)J3.copy(o,s[b+1]);else{w=2*(b+1)+c;(o=o||[])[0]=s[w],o[1]=s[w+1]}if(b>0){J3.sub(e,i,a),J3.sub(t,o,i),J3.normalize(e,e),J3.normalize(t,t),J3.add(r,e,t),J3.normalize(r,r);var M=u/2*Math.min(1/J3.dot(e,r),2);n[0]=-r[1],n[1]=r[0],T=M}else J3.sub(e,o,i),J3.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2}else J3.sub(e,i,a),J3.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2;y.set(x,n),y.set(x+1,n),v.set(x,T),v.set(x+1,-T),J3.copy(a,i),g.set(x,i),g.set(x+1,i),m.set(x,p),m.set(x+1,p),x+=2}if(this.useNativeLine)m.set(x,p),g.set(x,i),x++;else if(b>0){var C=3*this._faceOffset;(_=this.indices)[C]=x-4,_[C+1]=x-3,_[C+2]=x-2,_[C+3]=x-3,_[C+4]=x-1,_[C+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")}});V(e5.prototype,aQ);zJ.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");var t5={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function n5(e){var t={type:zJ.Texture.FLOAT,minFilter:zJ.Texture.NEAREST,magFilter:zJ.Texture.NEAREST};this._positionSourceTex=new zJ.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new zJ.Texture2D(t),this._positionPrevTex=new zJ.Texture2D(t),this._forceTex=new zJ.Texture2D(t),this._forcePrevTex=new zJ.Texture2D(t),this._weightedSumTex=new zJ.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new zJ.Texture2D(t),this._globalSpeedPrevTex=new zJ.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new lJ({fragment:zJ.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new lJ({fragment:zJ.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new lJ({fragment:zJ.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new lJ({fragment:zJ.Shader.source("clay.compositor.output")});var n=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new zJ.Mesh({geometry:new zJ.Geometry({attributes:{node1:new zJ.Geometry.Attribute("node1","float",2),node2:new zJ.Geometry.Attribute("node2","float",2),weight:new zJ.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new zJ.Material({transparent:!0,shader:zJ.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:n,depthMask:!1,depthText:!1}),mode:zJ.Mesh.POINTS}),this._weightedSumMesh=new zJ.Mesh({geometry:new zJ.Geometry({attributes:{node:new zJ.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new zJ.Material({transparent:!0,shader:zJ.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:n,depthMask:!1,depthText:!1}),mode:zJ.Mesh.POINTS}),this._framebuffer=new k$({depthBuffer:!1}),this._dummyCamera=new zJ.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}n5.prototype.updateOption=function(e){for(var t in t5)this[t]=t5[t];var n=this._nodes.length;if(this.jitterTolerence=n>5e4?10:n>5e3?1:.1,this.scaling=n>100?2:10,e)for(var t in t5)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var r=this._positionSourceTex.pixels,i=0;i<this._nodes.length;i++)r[4*i+2]=(this._nodes[i].degree||0)+1},n5.prototype._updateGravityCenter=function(e){var t=this._nodes,n=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var r=[1/0,1/0],i=[-1/0,-1/0],o=0;o<t.length;o++)r[0]=Math.min(t[o].x,r[0]),r[1]=Math.min(t[o].y,r[1]),i[0]=Math.max(t[o].x,i[0]),i[1]=Math.max(t[o].y,i[1]);this._gravityCenter=[.5*(r[0]+i[0]),.5*(r[1]+i[1])]}for(o=0;o<n.length;o++){var a=n[o].node1,s=n[o].node2;t[a].degree=(t[a].degree||0)+1,t[s].degree=(t[s].degree||0)+1}},n5.prototype.initData=function(e,t){this._nodes=e,this._edges=t,this._updateGravityCenter();var n=Math.ceil(Math.sqrt(e.length)),r=n,i=new Float32Array(n*r*4);this._resize(n,r);for(var o=0,a=0;a<e.length;a++){var s=e[a];i[o++]=s.x||0,i[o++]=s.y||0,i[o++]=s.mass||1,i[o++]=s.size||1}this._positionSourceTex.pixels=i;var l=this._edgeForceMesh.geometry,u=t.length;l.attributes.node1.init(2*u),l.attributes.node2.init(2*u),l.attributes.weight.init(2*u);var c=[];for(a=0;a<t.length;a++){var h=l.attributes,d=t[a].weight;null==d&&(d=1),h.node1.set(a,this.getNodeUV(t[a].node1,c)),h.node2.set(a,this.getNodeUV(t[a].node2,c)),h.weight.set(a,d),h.node1.set(a+u,this.getNodeUV(t[a].node2,c)),h.node2.set(a+u,this.getNodeUV(t[a].node1,c)),h.weight.set(a+u,d)}var p=this._weightedSumMesh.geometry;p.attributes.node.init(e.length);for(a=0;a<e.length;a++)p.attributes.node.set(a,this.getNodeUV(a,c));l.dirty(),p.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",e.length),this._nodeRepulsionPass.material.setUniform("textureSize",[n,r]),this._inited=!1,this._frame=0},n5.prototype.getNodes=function(){return this._nodes},n5.prototype.getEdges=function(){return this._edges},n5.prototype.step=function(e){this._inited||(this._initFromSource(e),this._inited=!0),this._frame++,this._framebuffer.attach(this._forceTex),this._framebuffer.bind(e);var t=this._nodeRepulsionPass;t.setUniform("strongGravityMode",this.strongGravityMode),t.setUniform("gravity",this.gravity),t.setUniform("gravityCenter",this._gravityCenter),t.setUniform("scaling",this.scaling),t.setUniform("preventOverlap",this.preventOverlap),t.setUniform("positionTex",this._positionPrevTex),t.render(e);var n=this._edgeForceMesh;n.material.set("linLogMode",this.linLogMode),n.material.set("edgeWeightInfluence",this.edgeWeightInfluence),n.material.set("preventOverlap",this.preventOverlap),n.material.set("positionTex",this._positionPrevTex),e.gl.enable(e.gl.BLEND),e.renderPass([n],this._dummyCamera),this._framebuffer.attach(this._weightedSumTex),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT),e.gl.enable(e.gl.BLEND);var r=this._weightedSumMesh;r.material.set("positionTex",this._positionPrevTex),r.material.set("forceTex",this._forceTex),r.material.set("forcePrevTex",this._forcePrevTex),e.renderPass([r],this._dummyCamera),this._framebuffer.attach(this._globalSpeedTex);var i=this._globalSpeedPass;i.setUniform("globalSpeedPrevTex",this._globalSpeedPrevTex),i.setUniform("weightedSumTex",this._weightedSumTex),i.setUniform("jitterTolerence",this.jitterTolerence),e.gl.disable(e.gl.BLEND),i.render(e);var o=this._positionPass;this._framebuffer.attach(this._positionTex),o.setUniform("globalSpeedTex",this._globalSpeedTex),o.setUniform("positionTex",this._positionPrevTex),o.setUniform("forceTex",this._forceTex),o.setUniform("forcePrevTex",this._forcePrevTex),o.render(e),this._framebuffer.unbind(e),this._swapTexture()},n5.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1);for(var r=0;r<t;r++)this.step(e);n&&n()},n5.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},n5.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1)||0,t},n5.prototype.getNodePosition=function(e,t){var n=this._positionArr,r=this._positionTex.width,i=this._positionTex.height,o=r*i;n&&n.length===4*o||(n=this._positionArr=new Float32Array(4*o)),this._framebuffer.bind(e),this._framebuffer.attach(this._positionPrevTex),e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,n),this._framebuffer.unbind(e),t||(t=new Float32Array(2*this._nodes.length));for(var a=0;a<this._nodes.length;a++)t[2*a]=n[4*a],t[2*a+1]=n[4*a+1];return t},n5.prototype.getTextureData=function(e,t){var n=this["_"+t+"Tex"],r=n.width,i=n.height;this._framebuffer.bind(e),this._framebuffer.attach(n);var o=new Float32Array(r*i*4);return e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,o),this._framebuffer.unbind(e),o},n5.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},n5.prototype.isFinished=function(e){return this._frame>e},n5.prototype._swapTexture=function(){var e=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=e;e=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=e;e=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=e},n5.prototype._initFromSource=function(e){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(e),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(e),e.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(e)},n5.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach((function(n){this[n].width=e,this[n].height=t,this[n].dirty()}),this)},n5.prototype.dispose=function(e){this._framebuffer.dispose(e),this._copyPass.dispose(e),this._nodeRepulsionPass.dispose(e),this._positionPass.dispose(e),this._globalSpeedPass.dispose(e),this._edgeForceMesh.geometry.dispose(e),this._weightedSumMesh.geometry.dispose(e),this._positionSourceTex.dispose(e),this._positionTex.dispose(e),this._positionPrevTex.dispose(e),this._forceTex.dispose(e),this._forcePrevTex.dispose(e),this._weightedSumTex.dispose(e),this._globalSpeedTex.dispose(e),this._globalSpeedPrevTex.dispose(e)};var r5=function(){var e=function(){return new Float32Array(2)},t=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},n=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},r=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},i=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},o=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},a=function(e,t){return e[0]=t[0],e[1]=t[1],e},s=function(e,t,n){return e[0]=t,e[1]=n,e};function l(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var u=l.prototype;function c(){this.position=new Float32Array(2),this.force=e(),this.forcePrev=e(),this.mass=1,this.inDegree=0,this.outDegree=0}function h(e,t){this.source=e,this.target=t,this.weight=1}function d(){this.autoSettings=!0,this.barnesHutOptimize=!0,this.barnesHutTheta=1.5,this.repulsionByDegree=!0,this.linLogMode=!1,this.strongGravityMode=!1,this.gravity=1,this.scaling=1,this.edgeWeightInfluence=1,this.jitterTolerence=.1,this.preventOverlap=!1,this.dissuadeHubs=!1,this.rootRegion=new l,this.rootRegion.centerOfMass=e(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}u.beforeUpdate=function(){for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].beforeUpdate();this.mass=0,this.centerOfMass&&(this.centerOfMass[0]=0,this.centerOfMass[1]=0),this.nSubRegions=0,this.node=null},u.afterUpdate=function(){this.subRegions.length=this.nSubRegions;for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].afterUpdate()},u.addNode=function(e){if(0===this.nSubRegions){if(null==this.node)return void(this.node=e);this._addNodeToSubRegion(this.node),this.node=null}this._addNodeToSubRegion(e),this._updateCenterOfMass(e)},u.findSubRegion=function(e,t){for(var n=0;n<this.nSubRegions;n++){var r=this.subRegions[n];if(r.contain(e,t))return r}},u.contain=function(e,t){return this.bbox[0]<=e&&this.bbox[2]>=e&&this.bbox[1]<=t&&this.bbox[3]>=t},u.setBBox=function(e,t,n,r){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r,this.size=(n-e+r-t)/2},u._newSubRegion=function(){var e=this.subRegions[this.nSubRegions];return e||(e=new l,this.subRegions[this.nSubRegions]=e),this.nSubRegions++,e},u._addNodeToSubRegion=function(e){var t=this.findSubRegion(e.position[0],e.position[1]),n=this.bbox;if(!t){var r=(n[0]+n[2])/2,i=(n[1]+n[3])/2,o=(n[2]-n[0])/2,a=(n[3]-n[1])/2,s=e.position[0]>=r?1:0,l=e.position[1]>=i?1:0;(t=this._newSubRegion()).setBBox(s*o+n[0],l*a+n[1],(s+1)*o+n[0],(l+1)*a+n[1])}t.addNode(e)},u._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,n=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,n+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=n/this.mass};var p=d.prototype;p.initNodes=function(e,t,n){var r=t.length;this.nodes.length=0;for(var i=void 0!==n,o=0;o<r;o++){var a=new c;a.position[0]=e[2*o],a.position[1]=e[2*o+1],a.mass=t[o],i&&(a.size=n[o]),this.nodes.push(a)}this._massArr=t,this._swingingArr=new Float32Array(r),i&&(this._sizeArr=n)},p.initEdges=function(e,t){var n=e.length/2;this.edges.length=0;for(var r=0;r<n;r++){var i=e[2*r],o=e[2*r+1],a=this.nodes[i],s=this.nodes[o];if(!a||!s)return void console.error("Node not exists, try initNodes before initEdges");a.outDegree++,s.inDegree++;var l=new h(a,s);t&&(l.weight=t[r]),this.edges.push(l)}},p.updateSettings=function(){if(this.repulsionByDegree)for(var e=0;e<this.nodes.length;e++){(t=this.nodes[e]).mass=t.inDegree+t.outDegree+1}else for(e=0;e<this.nodes.length;e++){var t;(t=this.nodes[e]).mass=this._massArr[e]}},p.update=function(){var o=this.nodes.length;if(this.updateSettings(),this.updateBBox(),this.barnesHutOptimize){this.rootRegion.setBBox(this.bbox[0],this.bbox[1],this.bbox[2],this.bbox[3]),this.rootRegion.beforeUpdate();for(var l=0;l<o;l++)this.rootRegion.addNode(this.nodes[l]);this.rootRegion.afterUpdate()}for(l=0;l<o;l++){var u=this.nodes[l];a(u.forcePrev,u.force),s(u.force,0,0)}for(l=0;l<o;l++){var c=this.nodes[l];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,c);else for(var h=l+1;h<o;h++){var d=this.nodes[h];this.applyNodeToNodeRepulsion(c,d,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(c):this.applyNodeGravity(c))}for(l=0;l<this.edges.length;l++)this.applyEdgeAttraction(this.edges[l]);var p=0,f=0,g=e();for(l=0;l<o;l++){u=this.nodes[l];p+=(v=t(u.force,u.forcePrev))*u.mass,i(g,u.force,u.forcePrev),f+=.5*n(g)*u.mass,this._swingingArr[l]=v}var m=this.jitterTolerence*this.jitterTolerence*f/p;this._globalSpeed>0&&(m=Math.min(m/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=m;for(l=0;l<o;l++){u=this.nodes[l];var v=this._swingingArr[l],y=.1*m/(1+m*Math.sqrt(v)),_=n(u.force);_>0&&(y=Math.min(_*y,10)/_,r(u.position,u.position,u.force,y))}},p.applyRegionToNodeRepulsion=function(){var t=e();return function(e,n){if(e.node)this.applyNodeToNodeRepulsion(e.node,n,!0);else{o(t,n.position,e.centerOfMass);var i=t[0]*t[0]+t[1]*t[1];if(i>this.barnesHutTheta*e.size*e.size){var a=this.scaling*n.mass*e.mass/i;r(n.force,n.force,t,a)}else for(var s=0;s<e.nSubRegions;s++)this.applyRegionToNodeRepulsion(e.subRegions[s],n)}}}(),p.applyNodeToNodeRepulsion=function(){var t=e();return function(e,n,i){if(e!=n){o(t,e.position,n.position);var a=t[0]*t[0]+t[1]*t[1];if(0!==a){var s;if(this.preventOverlap){var l=Math.sqrt(a);if((l=l-e.size-n.size)>0)s=this.scaling*e.mass*n.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*e.mass*n.mass}}else s=this.scaling*e.mass*n.mass/a;r(e.force,e.force,t,s),r(n.force,n.force,t,-s)}}}}(),p.applyEdgeAttraction=function(){var t=e();return function(e){var i=e.source,a=e.target;o(t,i.position,a.position);var s,l,u=n(t);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?e.weight:Math.pow(e.weight,this.edgeWeightInfluence),this.preventOverlap&&(u=u-i.size-a.size)<=0||(l=this.linLogMode?-s*Math.log(u+1)/(u+1):-s,r(i.force,i.force,t,l),r(a.force,a.force,t,-l))}}(),p.applyNodeGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position);var i=n(t);r(e.force,e.force,t,this.gravity*e.mass/(i+1))}}(),p.applyNodeStrongGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position),r(e.force,e.force,t,this.gravity*e.mass)}}(),p.updateBBox=function(){for(var e=1/0,t=1/0,n=-1/0,r=-1/0,i=0;i<this.nodes.length;i++){var o=this.nodes[i].position;e=Math.min(e,o[0]),t=Math.min(t,o[1]),n=Math.max(n,o[0]),r=Math.max(r,o[1])}this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r},p.getGlobalSpeed=function(){return this._globalSpeed};var f=null;self.onmessage=function(e){switch(e.data.cmd){case"init":(f=new d).initNodes(e.data.nodesPosition,e.data.nodesMass,e.data.nodesSize),f.initEdges(e.data.edges,e.data.edgesWeight);break;case"updateConfig":if(f)for(var t in e.data.config)f[t]=e.data.config[t];break;case"update":var n=e.data.steps;if(f){for(var r=0;r<n;r++)f.update();var i=f.nodes.length,o=new Float32Array(2*i);for(r=0;r<i;r++){var a=f.nodes[r];o[2*r]=a.position[0],o[2*r+1]=a.position[1]}self.postMessage({buffer:o.buffer,globalSpeed:f.getGlobalSpeed()},[o.buffer])}else{var s=new Float32Array;self.postMessage({buffer:s.buffer,globalSpeed:f.getGlobalSpeed()},[s.buffer])}}}}.toString();r5=r5.slice(r5.indexOf("{")+1,r5.lastIndexOf("}"));var i5={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},o5=function(e){for(var t in i5)this[t]=i5[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new PK({type:AK.FLOAT,flipY:!1,minFilter:AK.NEAREST,magFilter:AK.NEAREST})};o5.prototype.initData=function(e,t){var n=new Blob([r5]),r=window.URL.createObjectURL(n);this._worker=new Worker(r),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,o=t.length,a=new Float32Array(2*i),s=new Float32Array(i),l=new Float32Array(i),u=new Float32Array(2*o),c=new Float32Array(o),h=0;h<e.length;h++){var d=e[h];a[2*h]=d.x,a[2*h+1]=d.y,s[h]=null==d.mass?1:d.mass,l[h]=null==d.size?1:d.size}for(h=0;h<t.length;h++){var p=t[h],f=p.node1,g=p.node2;u[2*h]=f,u[2*h+1]=g,c[h]=null==p.weight?1:p.weight}var m=Math.ceil(Math.sqrt(e.length)),v=m,y=new Float32Array(m*v*4),_=this._positionTex;_.width=m,_.height=v,_.pixels=y,this._worker.postMessage({cmd:"init",nodesPosition:a,nodesMass:s,nodesSize:l,edges:u,edgesWeight:c}),this._globalSpeed=1/0},o5.prototype.updateOption=function(e){var t={};for(var n in i5)t[n]=i5[n];var r=this._nodes,i=this._edges,o=r.length;if(t.jitterTolerence=o>5e4?10:o>5e3?1:.1,t.scaling=o>100?2:10,t.barnesHutOptimize=o>1e3,e)for(var n in i5)null!=e[n]&&(t[n]=e[n]);if(!t.gravityCenter){for(var a=[1/0,1/0],s=[-1/0,-1/0],l=0;l<r.length;l++)a[0]=Math.min(r[l].x,a[0]),a[1]=Math.min(r[l].y,a[1]),s[0]=Math.max(r[l].x,s[0]),s[1]=Math.max(r[l].y,s[1]);t.gravityCenter=[.5*(a[0]+s[0]),.5*(a[1]+s[1])]}for(l=0;l<i.length;l++){var u=i[l].node1,c=i[l].node2;r[u].degree=(r[u].degree||0)+1,r[c].degree=(r[c].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:t})},o5.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1),this._frame+=t,this._onupdate=n,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(t)})},o5.prototype._$onupdate=function(e){if(!this._disposed){var t=new Float32Array(e.data.buffer);this._globalSpeed=e.data.globalSpeed,this._positionArr=t,this._updateTexture(t),this._onupdate&&this._onupdate()}},o5.prototype.getNodePositionTexture=function(){return this._positionTex},o5.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1),t},o5.prototype.getNodes=function(){return this._nodes},o5.prototype.getEdges=function(){return this._edges},o5.prototype.isFinished=function(e){return this._frame>e},o5.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var n=0;n<this._positionArr.length;n++)t[n]=this._positionArr[n];return t},o5.prototype._updateTexture=function(e){for(var t=this._positionTex.pixels,n=0,r=0;r<e.length;)t[n++]=e[r++],t[n++]=e[r++],t[n++]=1,t[n++]=1;this._positionTex.dirty()},o5.prototype.dispose=function(e){this._disposed=!0,this._worker=null};var a5=bY.extend((function(){return{zr:null,viewGL:null,minZoom:.2,maxZoom:5,_needsUpdate:!1,_dx:0,_dy:0,_zoom:1}}),(function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._update=this._update.bind(this)}),{init:function(){var e=this.zr;e.on("mousedown",this._mouseDownHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("globalout",this._mouseUpHandler),e.animation.on("frame",this._update)},setTarget:function(e){this._target=e},setZoom:function(e){this._zoom=Math.max(Math.min(e,this.maxZoom),this.minZoom),this._needsUpdate=!0},setOffset:function(e){this._dx=e[0],this._dy=e[1],this._needsUpdate=!0},getZoom:function(){return this._zoom},getOffset:function(){return[this._dx,this._dy]},_update:function(){if(this._target&&this._needsUpdate){var e=this._target,t=this._zoom;e.position.x=this._dx,e.position.y=this._dy,e.scale.set(t,t,t),this.zr.refresh(),this._needsUpdate=!1,this.trigger("update")}},_mouseDownHandler:function(e){if(!e.target){var t=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(t,n)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var r=this._convertPos(t,n);this._x=r.x,this._y=r.y}}},_convertPos:function(e,t){var n=this.viewGL.camera,r=this.viewGL.viewport;return{x:(e-r.x)/r.width*(n.right-n.left)+n.left,y:(t-r.y)/r.height*(n.bottom-n.top)+n.top}},_mouseMoveHandler:function(e){var t=this._convertPos(e.offsetX,e.offsetY);this._dx+=t.x-this._x,this._dy+=t.y-this._y,this._x=t.x,this._y=t.y,this._needsUpdate=!0},_mouseUpHandler:function(e){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_mouseWheelHandler:function(e){var t=(e=e.event).wheelDelta||-e.detail;if(0!==t){var n=e.offsetX,r=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(n,r)){var i=t>0?1.1:.9,o=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=o/this._zoom;var a=this._convertPos(n,r),s=(a.x-this._dx)*(i-1),l=(a.y-this._dy)*(i-1);this._dx-=s,this._dy-=l,this._zoom=o,this._needsUpdate=!0}}},dispose:function(){var e=this.zr;e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("globalout",this._mouseUpHandler),e.animation.off("frame",this._update)}}),s5=sQ.vec2;zJ.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");var l5=1,u5=Kg.extend({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this.viewGL=new N0("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new f3(!0,t),this._forceEdgesMesh=new zJ.Mesh({material:new zJ.Material({shader:zJ.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new zJ.Geometry({attributes:{node:new zJ.Geometry.Attribute("node","float",2),color:new zJ.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:zJ.Mesh.LINES}),this._edgesMesh=new zJ.Mesh({material:new zJ.Material({shader:zJ.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new e5({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new a5({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,n){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=n,this._initLayout(e,t,n),this._pointsBuilder.update(e,t,n),this._forceLayoutInstance instanceof n5||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,n),this._control.off("update"),this._control.on("update",(function(){n.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)}),this),this._control.setZoom(vJ(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var r=this._pointsBuilder.getPointsMesh();if(r.off("mousemove",this._mousemoveHandler),r.off("mouseout",this._mouseOutHandler,this),n.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?n.getZr().on("click",this._clickHandler):"mouseover"===i?(r.on("mousemove",this._mousemoveHandler,this),r.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1):"production"!==process.env.NODE_ENV&&console.warn("Unkown focusNodeAdjacencyOn value s"+i)}this._lastMouseOverDataIndex=-1},_clickHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?t!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._mouseOutHandler(e),this._lastMouseOverDataIndex=t}},_mouseOutHandler:function(e){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(e,t){var n=this._forceEdgesMesh.geometry,r=t.getEdgeData(),i=0,o=this._forceLayoutInstance,a=2*r.count();n.attributes.node.init(a),n.attributes.color.init(a),r.each((function(t){var a=e[t];n.attributes.node.set(i,o.getNodeUV(a.node1)),n.attributes.node.set(i+1,o.getNodeUV(a.node2));var s=D1(r,a.dataIndex),l=zJ.parseColor(s);l[3]*=vJ(A1(r,a.dataIndex),1),n.attributes.color.set(i,l),n.attributes.color.set(i+1,l),i+=2})),n.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,n=(e=this._model.getEdgeData(),this._model.getData().getLayout("points"));t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var r=[],i=[],o=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each((function(a){var s=e.graph.getEdgeByIndex(a),l=2*s.node1.dataIndex,u=2*s.node2.dataIndex;r[0]=n[l],r[1]=n[l+1],i[0]=n[u],i[1]=n[u+1];var c=D1(e,s.dataIndex),h=zJ.parseColor(c);h[3]*=vJ(A1(e,s.dataIndex),1);var d=e.getItemModel(s.dataIndex),p=vJ(d.get(o),1)*this._api.getDevicePixelRatio();t.addLine(r,i,h,p);for(var f=0;f<4;f++)this._originalEdgeColors[4*s.dataIndex+f]=h[f];this._edgeIndicesMap[s.dataIndex]=a}),this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),n=[],r=0;r<e.count();r++)this._forceLayoutInstance.getNodeUV(r,n),t.geometry.attributes.position.set(r,n);t.geometry.dirty("position")},_initLayout:function(e,t,n){var r=e.get("layout"),i=e.getGraph(),o=Wd(e.getBoxLayoutParams(),{width:n.getWidth(),height:n.getHeight()});"force"===r&&("production"!==process.env.NODE_ENV&&console.warn("Currently only forceAtlas2 layout supported."),r="forceAtlas2"),this.stopLayout(e,t,n,{beforeLayout:!0});var a=e.getData(),s=e.getData();if("forceAtlas2"===r){var l=e.getModel("forceAtlas2"),u=this._forceLayoutInstance,c=[],h=[],d=a.getDataExtent("value"),p=s.getDataExtent("value"),f=vJ(l.get("edgeWeight"),1),g=vJ(l.get("nodeWeight"),1);"number"==typeof f&&(f=[f,f]),"number"==typeof g&&(g=[g,g]);var m=0,v={},y=new Float32Array(2*a.count());if(i.eachNode((function(e){var t,n,r=e.dataIndex,i=a.get("value",r);if(a.hasItemOption){var s=a.getItemModel(r);t=s.get("x"),n=s.get("y")}null==t&&(t=o.x+Math.random()*o.width,n=o.y+Math.random()*o.height),y[2*m]=t,y[2*m+1]=n,v[e.id]=m++;var l=eo(i,d,g);isNaN(l)&&(l=isNaN(g[0])?1:g[0]),c.push({x:t,y:n,mass:l,size:a.getItemVisual(r,"symbolSize")})})),a.setLayout("points",y),i.eachEdge((function(e){var t=e.dataIndex,n=eo(a.get("value",t),p,f);isNaN(n)&&(n=isNaN(f[0])?1:f[0]),h.push({node1:v[e.node1.id],node2:v[e.node2.id],weight:n,dataIndex:t})})),!u){var _=l.get("GPU");this._forceLayoutInstance&&((!_||this._forceLayoutInstance instanceof n5)&&(_||this._forceLayoutInstance instanceof o5)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),u=this._forceLayoutInstance=_?new n5:new o5}u.initData(c,h),u.updateOption(l.option),this._updateForceEdgesGeometry(u.getEdges(),e),this._updatePositionTexture(),n.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else{y=new Float32Array(2*a.count()),m=0;i.eachNode((function(e){var t,n,r=e.dataIndex;if(a.hasItemOption){var i=a.getItemModel(r);t=i.get("x"),n=i.get("y")}y[m++]=t,y[m++]=n})),a.setLayout("points",y),this._updateAfterLayout(e,t,n)}},_updatePositionTexture:function(){var e=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(e),this._forceEdgesMesh.material.set("positionTex",e)},startLayout:function(e,t,n,r){if(!r||null==r.from||r.from===this.uid){var i=this.viewGL,o=(n=this._api,this._forceLayoutInstance),a=this._model.getData(),s=this._model.getModel("forceAtlas2");if(o){if(this.groupGL.remove(this._edgesMesh),this.groupGL.add(this._forceEdgesMesh),this._forceLayoutInstance){this._updateForceNodesGeometry(e.getData()),this._pointsBuilder.hideLabels();var l=this,u=this._layoutId=l5++,c=s.getShallow("maxSteps"),h=s.getShallow("steps"),d=0,p=Math.max(2*h,20),f=function(t){if(t===l._layoutId)return o.isFinished(c)?(n.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void n.dispatchAction({type:"graphGLFinishLayout",points:a.getLayout("points"),from:l.uid})):void o.update(i.layer.renderer,h,(function(){l._updatePositionTexture(),(d+=h)>=p&&(l._syncNodePosition(e),d=0),n.getZr().refresh(),dn((function(){f(t)}))}))};dn((function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(i.layer.renderer),l._forceLayoutInstanceToDispose=null),f(u)})),this._layouting=!0}}else"production"!==process.env.NODE_ENV&&console.error("None layout don't have startLayout action")}},stopLayout:function(e,t,n,r){r&&null!=r.from&&r.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(r&&r.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,n)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(e){var t=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);e.getData().setLayout("points",t),e.setNodePosition(t)},_updateAfterLayout:function(e,t,n){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,n),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,n,r){var i=this._model.getData();this._downplayAll();var o=r.dataIndex,a=i.graph,s=[],l=a.getNodeByIndex(o);s.push(l),l.edges.forEach((function(e){e.dataIndex<0||(e.node1!==l&&s.push(e.node1),e.node2!==l&&s.push(e.node2))}),this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach((function(e){this._pointsBuilder.highlight(i,e.dataIndex)}),this),this._pointsBuilder.updateLabels(s.map((function(e){return e.dataIndex})));var u=[];l.edges.forEach((function(e){e.dataIndex>=0&&(this._highlightEdge(e.dataIndex),u.push(e))}),this),this._focusNodes=s,this._focusEdges=u},unfocusNodeAdjacency:function(e,t,n,r){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),n=zJ.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),r=vJ(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);n[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],n)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach((function(e){this._pointsBuilder.downplay(this._model.getData(),e.dataIndex)}),this),this._focusEdges&&this._focusEdges.forEach((function(e){this._downplayEdge(e.dataIndex)}),this)},_downplayEdge:function(e){var t=this._getColor(e,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],t)},_setEdgeFade:function(){var e=[];return function(t,n){this._getColor(t,e),e[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var n=0;n<4;n++)t[n]=this._originalEdgeColors[4*e+n];return t},_fadeOutEdgesAll:function(e){this._model.getData().graph.eachEdge((function(t){this._setEdgeFade(t.dataIndex,e)}),this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(e,t){this.viewGL.setViewport(0,0,t.getWidth(),t.getHeight(),t.getDevicePixelRatio());for(var n=this.viewGL.camera,r=e.getData().getLayout("points"),i=s5.create(1/0,1/0),o=s5.create(-1/0,-1/0),a=[],s=0;s<r.length;)a[0]=r[s++],a[1]=r[s++],s5.min(i,i,a),s5.max(o,o,a);var l=(o[1]+i[1])/2,u=(o[0]+i[0])/2;if(!(u>n.left&&u<n.right&&l<n.bottom&&l>n.top)){var c=Math.max(o[0]-i[0],10),h=c/t.getWidth()*t.getHeight();c*=1.4,h*=1.4,i[0]-=.2*c,n.left=i[0],n.top=l-h/2,n.bottom=l+h/2,n.right=c+i[0],n.near=0,n.far=100}},dispose:function(){var e=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(e),this.groupGL.removeAll(),this._layoutId=-1,this._pointsBuilder.dispose()},remove:function(){this.groupGL.removeAll(),this._control.dispose()}});function c5(e){return e instanceof Array||(e=[e,e]),e}i_((function(e){function t(){}e.registerChartView(u5),e.registerSeriesModel($3),e.registerVisual((function(e){const t={};e.eachSeriesByType("graphGL",(function(e){var n=e.getCategoriesData(),r=e.getData(),i={};n.each((function(r){var o=n.getName(r);i["ec-"+o]=r;var a=n.getItemModel(r),s=a.getModel("itemStyle").getItemStyle();s.fill||(s.fill=e.getColorFromPalette(o,t)),n.setItemVisual(r,"style",s);var l=["symbol","symbolSize","symbolKeepAspect"];for(let e=0;e<l.length;e++){var u=a.getShallow(l[e],!0);null!=u&&n.setItemVisual(r,l[e],u)}})),n.count()&&r.each((function(e){let t=r.getItemModel(e).getShallow("category");if(null!=t){"string"==typeof t&&(t=i["ec-"+t]);var o=n.getItemVisual(t,"style");z(r.ensureUniqueItemVisual(e,"style"),o);var a=["symbol","symbolSize","symbolKeepAspect"];for(let i=0;i<a.length;i++)r.setItemVisual(e,a[i],n.getItemVisual(t,a[i]))}}))}))})),e.registerVisual((function(e){e.eachSeriesByType("graphGL",(function(e){var t=e.getGraph(),n=e.getEdgeData(),r=c5(e.get("edgeSymbol")),i=c5(e.get("edgeSymbolSize"));n.setVisual("drawType","stroke"),n.setVisual("fromSymbol",r&&r[0]),n.setVisual("toSymbol",r&&r[1]),n.setVisual("fromSymbolSize",i&&i[0]),n.setVisual("toSymbolSize",i&&i[1]),n.setVisual("style",e.getModel("lineStyle").getLineStyle()),n.each((function(e){var r=n.getItemModel(e),i=t.getEdgeByIndex(e),o=c5(r.getShallow("symbol",!0)),a=c5(r.getShallow("symbolSize",!0)),s=r.getModel("lineStyle").getLineStyle(),l=n.ensureUniqueItemVisual(e,"style");switch(z(l,s),l.stroke){case"source":var u=i.node1.getVisual("style");l.stroke=u&&u.fill;break;case"target":u=i.node2.getVisual("style");l.stroke=u&&u.fill}o[0]&&i.setVisual("fromSymbol",o[0]),o[1]&&i.setVisual("toSymbol",o[1]),a[0]&&i.setVisual("fromSymbolSize",a[0]),a[1]&&i.setVisual("toSymbolSize",a[1])}))}))})),e.registerAction({type:"graphGLRoam",event:"graphglroam",update:"series.graphGL:roam"},(function(e,t){t.eachComponent({mainType:"series",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"graphGLStartLayout",event:"graphgllayoutstarted",update:"series.graphGL:startLayout"},t),e.registerAction({type:"graphGLStopLayout",event:"graphgllayoutstopped",update:"series.graphGL:stopLayout"},t),e.registerAction({type:"graphGLFocusNodeAdjacency",event:"graphGLFocusNodeAdjacency",update:"series.graphGL:focusNodeAdjacency"},t),e.registerAction({type:"graphGLUnfocusNodeAdjacency",event:"graphGLUnfocusNodeAdjacency",update:"series.graphGL:unfocusNodeAdjacency"},t)}));var h5=Vg.extend({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(e,t){var n=this.get("coordinateSystem"),r="geo"===n?["lng","lat"]:Yy(n)||["x","y"];if("production"!==process.env.NODE_ENV&&r.length>2)throw new Error("flowGL can only be used on 2d coordinate systems.");r.push("vx","vy");var i=N_(this.getSource(),{coordDimensions:r,encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),o=new L_(i,this);return o.initData(this.getSource()),o},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}}),d5=WK.extend((function(){return{dynamic:!0,attributes:{position:new WK.Attribute("position","float",3,"POSITION")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(e){var t=this.attributes,n=4*e,r=2*e;this.vertexCount!==n&&t.position.init(n),this.triangleCount!==r&&(this.indices=0===r?null:this.vertexCount>65535?new Uint32Array(3*r):new Uint16Array(3*r))},addLine:function(e){var t=this._vertexOffset;this.attributes.position.set(t,[e[0],e[1],1]),this.attributes.position.set(t+1,[e[0],e[1],-1]),this.attributes.position.set(t+2,[e[0],e[1],2]),this.attributes.position.set(t+3,[e[0],e[1],-2]),this.setTriangleIndices(this._faceOffset++,[t,t+1,t+2]),this.setTriangleIndices(this._faceOffset++,[t+1,t+2,t+3]),this._vertexOffset+=4}});bq.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");var p5=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new PK({type:AK.FLOAT,flipY:!1}),this.particleLife=[5,20],this._particleType="point",this._particleSize=1,this.particleColor=[1,1,1,1],this.particleSpeedScaling=1,this._thisFrameTexture=null,this._particlePass=null,this._spawnTexture=null,this._particleTexture0=null,this._particleTexture1=null,this._particlePointsMesh=null,this._surfaceFrameBuffer=null,this._elapsedTime=0,this._scene=null,this._camera=null,this._lastFrameTexture=null,this._supersampling=1,this._downsampleTextures=[],this._width=512,this._height=512,this.init()};p5.prototype={constructor:p5,init:function(){var e={type:AK.FLOAT,minFilter:AK.NEAREST,magFilter:AK.NEAREST,useMipmap:!1};this._spawnTexture=new PK(e),this._particleTexture0=new PK(e),this._particleTexture1=new PK(e),this._frameBuffer=new k$({depthBuffer:!1}),this._particlePass=new lJ({fragment:bq.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new lJ({fragment:bq.source("clay.compositor.downsample")});var t=new IK({renderOrder:10,material:new WZ({shader:new bq(bq.source("ecgl.vfParticle.renderPoints.vertex"),bq.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:IK.POINTS,geometry:new WK({dynamic:!0,mainAttribute:"texcoord0"})}),n=new IK({renderOrder:10,material:new WZ({shader:new bq(bq.source("ecgl.vfParticle.renderLines.vertex"),bq.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new d5,culling:!1}),r=new IK({material:new WZ({shader:new bq(bq.source("ecgl.color.vertex"),bq.source("ecgl.color.fragment"))}),geometry:new B$});r.material.enableTexture("diffuseMap"),this._particlePointsMesh=t,this._particleLinesMesh=n,this._lastFrameFullQuadMesh=r,this._camera=new iJ,this._thisFrameTexture=new PK,this._lastFrameTexture=new PK},setParticleDensity:function(e,t){for(var n=new Float32Array(4*(e*t)),r=0,i=this.particleLife,o=0;o<e;o++)for(var a=0;a<t;a++,r++){n[4*r]=Math.random(),n[4*r+1]=Math.random(),n[4*r+2]=Math.random();var s=(i[1]-i[0])*Math.random()+i[0];n[4*r+3]=s}"line"===this._particleType?this._setLineGeometry(e,t):this._setPointsGeometry(e,t),this._spawnTexture.width=e,this._spawnTexture.height=t,this._spawnTexture.pixels=n,this._particleTexture0.width=this._particleTexture1.width=e,this._particleTexture0.height=this._particleTexture1.height=t,this._particlePass.setUniform("textureSize",[e,t])},_setPointsGeometry:function(e,t){var n=e*t,r=this._particlePointsMesh.geometry,i=r.attributes;i.texcoord0.init(n);for(var o=0,a=0;a<e;a++)for(var s=0;s<t;s++,o++)i.texcoord0.value[2*o]=a/e,i.texcoord0.value[2*o+1]=s/t;r.dirty()},_setLineGeometry:function(e,t){var n=e*t,r=this._getParticleMesh().geometry;r.setLineCount(n),r.resetOffset();for(var i=0;i<e;i++)for(var o=0;o<t;o++)r.addLine([i/e,o/t]);r.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(e,t,n,r){var i=this._getParticleMesh(),o=this._frameBuffer,a=this._particlePass;r&&this._updateDownsampleTextures(e,t),i.material.set("size",this._particleSize*this._supersampling),i.material.set("color",this.particleColor),a.setUniform("speedScaling",this.particleSpeedScaling),o.attach(this._particleTexture1),a.setUniform("firstFrameTime",r?(this.particleLife[1]+this.particleLife[0])/2:0),a.setUniform("particleTexture",this._particleTexture0),a.setUniform("deltaTime",n),a.setUniform("elapsedTime",this._elapsedTime),a.render(e,o),i.material.set("particleTexture",this._particleTexture1),i.material.set("prevParticleTexture",this._particleTexture0),o.attach(this._thisFrameTexture),o.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT);var s=this._lastFrameFullQuadMesh;s.material.set("diffuseMap",this._lastFrameTexture),s.material.set("color",[1,1,1,this.motionBlurFactor]),this._camera.update(!0),e.renderPass([s,i],this._camera),o.unbind(e),this._downsample(e),this._swapTexture(),this._elapsedTime+=n},_downsample:function(e){var t=this._downsampleTextures;if(0!==t.length)for(var n=0,r=this._thisFrameTexture,i=t[n];i;)this._frameBuffer.attach(i),this._downsamplePass.setUniform("texture",r),this._downsamplePass.setUniform("textureSize",[r.width,r.height]),this._downsamplePass.render(e,this._frameBuffer),r=i,i=t[++n]},getSurfaceTexture:function(){var e=this._downsampleTextures;return e.length>0?e[e.length-1]:this._lastFrameTexture},setRegion:function(e){this._particlePass.setUniform("region",e)},resize:function(e,t){this._lastFrameTexture.width=e*this._supersampling,this._lastFrameTexture.height=t*this._supersampling,this._thisFrameTexture.width=e*this._supersampling,this._thisFrameTexture.height=t*this._supersampling,this._width=e,this._height=t},setParticleSize:function(e){var t=this._getParticleMesh();if(e<=2)return t.material.disableTexture("spriteTexture"),void(t.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new PK),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=function(e){var t=document.createElement("canvas");t.width=t.height=e;var n=t.getContext("2d");return n.fillStyle="#fff",n.arc(e/2,e/2,e/2,0,2*Math.PI),n.fill(),t}(e),this._spriteTexture.dirty()),t.material.transparent=!0,t.material.enableTexture("spriteTexture"),t.material.set("spriteTexture",this._spriteTexture),this._particleSize=e},setGradientTexture:function(e){var t=this._getParticleMesh().material;t[e?"enableTexture":"disableTexture"]("gradientTexture"),t.setUniform("gradientTexture",e)},setColorTextureImage:function(e,t){this._getParticleMesh().material.setTextureImage("colorTexture",e,t,{flipY:!0})},setParticleType:function(e){this._particleType=e},clearFrame:function(e){var t=this._frameBuffer;t.attach(this._lastFrameTexture),t.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),t.unbind(e)},setSupersampling:function(e){this._supersampling=e,this.resize(this._width,this._height)},_updateDownsampleTextures:function(e,t){for(var n=this._downsampleTextures,r=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,o=this._width*this._supersampling,a=this._height*this._supersampling,s=0;s<r;s++)n[s]=n[s]||new PK,n[s].width=o/i,n[s].height=a/i,i*=2;for(;s<n.length;s++)n[s].dispose(e);n.length=r},_swapTexture:function(){var e=this._particleTexture0;this._particleTexture0=this._particleTexture1,this._particleTexture1=e;e=this._thisFrameTexture;this._thisFrameTexture=this._lastFrameTexture,this._lastFrameTexture=e},dispose:function(e){e.disposeFrameBuffer(this._frameBuffer),e.disposeTexture(this.vectorFieldTexture),e.disposeTexture(this._spawnTexture),e.disposeTexture(this._particleTexture0),e.disposeTexture(this._particleTexture1),e.disposeTexture(this._thisFrameTexture),e.disposeTexture(this._lastFrameTexture),e.disposeGeometry(this._particleLinesMesh.geometry),e.disposeGeometry(this._particlePointsMesh.geometry),e.disposeGeometry(this._lastFrameFullQuadMesh.geometry),this._spriteTexture&&e.disposeTexture(this._spriteTexture),this._particlePass.dispose(e),this._downsamplePass.dispose(e),this._downsampleTextures.forEach((function(t){t.dispose(e)}))}};var f5=Kg.extend({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new N0("orthographic"),this.groupGL=new zJ.Node,this.viewGL.add(this.groupGL),this._particleSurface=new p5;var n=new zJ.Mesh({geometry:new zJ.PlaneGeometry,material:new zJ.Material({shader:new zJ.Shader({vertex:zJ.Shader.source("ecgl.color.vertex"),fragment:zJ.Shader.source("ecgl.color.fragment")}),transparent:!0})});n.material.enableTexture("diffuseMap"),this.groupGL.add(n),this._planeMesh=n},render:function(e,t,n){var r=this._particleSurface;r.setParticleType(e.get("particleType")),r.setSupersampling(e.get("supersampling")),this._updateData(e,n),this._updateCamera(n.getWidth(),n.getHeight(),n.getDevicePixelRatio());var i=vJ(e.get("particleDensity"),128);r.setParticleDensity(i,i);var o=this._planeMesh,a=+new Date,s=this,l=!0;o.__percent=0,o.stopAnimation(),o.animate("",{loop:!0}).when(1e5,{__percent:1}).during((function(){var e=+new Date,t=Math.min(e-a,20);a+=t,s._renderer&&(r.update(s._renderer,n,t/1e3,l),o.material.set("diffuseMap",r.getSurfaceTexture())),l=!1})).start();var u=e.getModel("itemStyle"),c=zJ.parseColor(u.get("color"));c[3]*=vJ(u.get("opacity"),1),o.material.set("color",c),r.setColorTextureImage(e.get("colorTexture"),n),r.setParticleSize(e.get("particleSize")),r.particleSpeedScaling=e.get("particleSpeed"),r.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,n){this._updateData(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._renderer=i},_updateData:function(e,t){var n=e.coordinateSystem,r=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]})),i=e.getData(),o=i.getDataExtent(r[0]),a=i.getDataExtent(r[1]),s=e.get("gridWidth"),l=e.get("gridHeight");if(null==s||"auto"===s){var u=(o[1]-o[0])/(a[1]-a[0]);s=Math.round(Math.sqrt(u*i.count()))}null!=l&&"auto"!==l||(l=Math.ceil(i.count()/s));var c=this._particleSurface.vectorFieldTexture,h=c.pixels;if(h&&h.length===l*s*4)for(var d=0;d<h.length;d++)h[d]=0;else h=c.pixels=new Float32Array(s*l*4);var p=0,f=1/0,g=new Float32Array(2*i.count()),m=0,v=[[1/0,1/0],[-1/0,-1/0]];i.each([r[0],r[1],"vx","vy"],(function(e,t,r,i){var o=n.dataToPoint([e,t]);g[m++]=o[0],g[m++]=o[1],v[0][0]=Math.min(o[0],v[0][0]),v[0][1]=Math.min(o[1],v[0][1]),v[1][0]=Math.max(o[0],v[1][0]),v[1][1]=Math.max(o[1],v[1][1]);var a=Math.sqrt(r*r+i*i);p=Math.max(p,a),f=Math.min(f,a)})),i.each(["vx","vy"],(function(e,t,n){var r=Math.round((g[2*n]-v[0][0])/(v[1][0]-v[0][0])*(s-1)),i=4*((l-1-Math.round((g[2*n+1]-v[0][1])/(v[1][1]-v[0][1])*(l-1)))*s+r);h[i]=e/p*.5+.5,h[i+1]=t/p*.5+.5,h[i+3]=1})),c.width=s,c.height=l,"bmap"===e.get("coordinateSystem")&&this._fillEmptyPixels(c),c.dirty(),this._updatePlanePosition(v[0],v[1],e,t),this._updateGradientTexture(i.getVisual("visualMeta"),[f,p])},_fillEmptyPixels:function(e){var t=e.pixels,n=e.width,r=e.height;function i(e,i,o){e=Math.max(Math.min(e,n-1),0);var a=4*((i=Math.max(Math.min(i,r-1),0))*(n-1)+e);return 0!==t[a+3]&&(o[0]=t[a],o[1]=t[a+1],!0)}function o(e,t,n){n[0]=e[0]+t[0],n[1]=e[1]+t[1]}for(var a=[],s=[],l=[],u=[],c=[],h=0,d=0;d<r;d++)for(var p=0;p<n;p++){var f=4*(d*(n-1)+p);0===t[f+3]&&(h=a[0]=a[1]=0,i(p-1,d,s)&&(h++,o(s,a,a)),i(p+1,d,l)&&(h++,o(l,a,a)),i(p,d-1,u)&&(h++,o(u,a,a)),i(p,d+1,c)&&(h++,o(c,a,a)),a[0]/=h,a[1]/=h,t[f]=a[0],t[f+1]=a[1]),t[f+3]=1}},_updateGradientTexture:function(e,t){if(e&&e.length){this._gradientTexture=this._gradientTexture||new zJ.Texture2D({image:document.createElement("canvas")});var n=this._gradientTexture,r=n.image;r.width=200,r.height=1;var i=r.getContext("2d"),o=i.createLinearGradient(0,.5,r.width,.5);e[0].stops.forEach((function(e){var n;t[1]===t[0]?n=0:(n=e.value/t[1],n=Math.min(Math.max(n,0),1)),o.addColorStop(n,e.color)})),i.fillStyle=o,i.fillRect(0,0,r.width,r.height),n.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(e,t,n,r){var i=this._limitInViewportAndFullFill(e,t,n,r);e=i.leftTop,t=i.rightBottom,this._particleSurface.setRegion(i.region),this._planeMesh.position.set((e[0]+t[0])/2,r.getHeight()-(e[1]+t[1])/2,0);var o=t[0]-e[0],a=t[1]-e[1];this._planeMesh.scale.set(o/2,a/2,1),this._particleSurface.resize(Math.max(Math.min(o,2048),1),Math.max(Math.min(a,2048),1)),this._renderer&&this._particleSurface.clearFrame(this._renderer)},_limitInViewportAndFullFill:function(e,t,n,r){var i=[Math.max(e[0],0),Math.max(e[1],0)],o=[Math.min(t[0],r.getWidth()),Math.min(t[1],r.getHeight())];if("bmap"===n.get("coordinateSystem")){var a=n.getData().getDataExtent(n.coordDimToDataDim("lng")[0]);Math.floor(a[1]-a[0])>=359&&(i[0]>0&&(i[0]=0),o[0]<r.getWidth()&&(o[0]=r.getWidth()))}var s=t[0]-e[0],l=t[1]-e[1],u=o[0]-i[0],c=o[1]-i[1];return{leftTop:i,rightBottom:o,region:[(i[0]-e[0])/s,1-c/l-(i[1]-e[1])/l,u/s,c/l]}},_updateCamera:function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.bottom=0,r.top=t,r.right=e,r.near=0,r.far=100,r.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}});i_((function(e){e.registerChartView(f5),e.registerSeriesModel(h5)}));var g5=Vg.extend({type:"series.linesGL",dependencies:["grid","geo"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",streamEnabled:!0,init:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),g5.superApply(this,"init",arguments)},mergeOption:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),g5.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=Me(this._flatCoords,t.flatCoords),this._flatCoordsOffset=Me(this._flatCoordsOffset,t.flatCoordsOffset)):(this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset),e.data=new Float32Array(t.count)),this.getRawData().appendData(e.data)},_getCoordsFromItemModel:function(e){var t=this.getData().getItemModel(e),n=t.option instanceof Array?t.option:t.getShallow("coords");if("production"!==process.env.NODE_ENV&&!(n instanceof Array&&n.length>0&&n[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(n)+". Lines must have 2d coords array in data item.");return n},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var n=this._flatCoordsOffset[2*e],r=this._flatCoordsOffset[2*e+1],i=0;i<r;i++)t[i]=t[i]||[],t[i][0]=this._flatCoords[n+2*i],t[i][1]=this._flatCoords[n+2*i+1];return r}var o=this._getCoordsFromItemModel(e);for(i=0;i<o.length;i++)t[i]=t[i]||[],t[i][0]=o[i][0],t[i][1]=o[i][1];return o.length},_processFlatCoordsArray:function(e){var t=0;if(this._flatCoords&&(t=this._flatCoords.length),"number"==typeof e[0]){for(var n=e.length,r=new Uint32Array(n),i=new Float64Array(n),o=0,a=0,s=0,l=0;l<n;){s++;var u=e[l++];r[a++]=o+t,r[a++]=u;for(var c=0;c<u;c++){var h=e[l++],d=e[l++];if(i[o++]=h,i[o++]=d,l>n&&"production"!==process.env.NODE_ENV)throw new Error("Invalid data format.")}}return{flatCoordsOffset:new Uint32Array(r.buffer,0,a),flatCoords:i,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:e.length}},getInitialData:function(e,t){var n=new L_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"geo",zlevel:10,progressive:1e4,progressiveThreshold:5e4,blendMode:"source-over",lineStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}}),m5=Kg.extend({type:"linesGL",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this.viewGL=new N0("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new q3(this.viewGL),this._nativeLinesShader=zJ.createShader("ecgl.lines3D"),this._meshLinesShader=zJ.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n);var r=this._linesMeshes[0];r||(r=this._linesMeshes[0]=this._createLinesMesh(e)),this._linesMeshes.length=1,this.groupGL.add(r),this._updateLinesMesh(e,r,0,e.getData().count()),this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){var i=this._linesMeshes[this._currentStep];i||(i=this._createLinesMesh(t),this._linesMeshes[this._currentStep]=i),this._updateLinesMesh(t,i,e.start,e.end),this.groupGL.add(i),r.getZr().refresh(),this._currentStep++},updateTransform:function(e,t,n){e.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(e,n)},_createLinesMesh:function(e){return new zJ.Mesh({$ignorePicking:!0,material:new zJ.Material({shader:zJ.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new e5({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:zJ.Mesh.LINES,culling:!1})},_updateLinesMesh:function(e,t,n,r){var i=e.getData();t.material.blend="lighter"===e.get("blendMode")?zJ.additiveBlend:null;var o=e.get("lineStyle.curveness")||0,a=e.get("polyline"),s=t.geometry,l=e.coordinateSystem,u=vJ(e.get("lineStyle.width"),1);u>1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=zJ.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=zJ.Mesh.LINES),n=n||0,r=r||i.count(),s.resetOffset();var c=0,h=0,d=[],p=[],f=[],g=[],m=[],v=.3,y=.7;function _(){p[0]=d[0]*y+g[0]*v-(d[1]-g[1])*o,p[1]=d[1]*y+g[1]*v-(g[0]-d[0])*o,f[0]=d[0]*v+g[0]*y-(d[1]-g[1])*o,f[1]=d[1]*v+g[1]*y-(g[0]-d[0])*o}if(a||0!==o)for(var x=n;x<r;x++)if(a){var b=e.getLineCoordsCount(x);c+=s.getPolylineVertexCount(b),h+=s.getPolylineTriangleCount(b)}else e.getLineCoords(x,m),this._glViewHelper.dataToPoint(l,m[0],d),this._glViewHelper.dataToPoint(l,m[1],g),_(),c+=s.getCubicCurveVertexCount(d,p,f,g),h+=s.getCubicCurveTriangleCount(d,p,f,g);else{var w=r-n;c+=w*s.getLineVertexCount(),h+=w*s.getLineVertexCount()}s.setVertexCount(c),s.setTriangleCount(h);var S=n,T=[];for(x=n;x<r;x++){zJ.parseColor(D1(i,S),T);var M=vJ(A1(i,S),1);T[3]*=M;b=e.getLineCoords(x,m);for(var C=0;C<b;C++)this._glViewHelper.dataToPoint(l,m[C],m[C]);a?s.addPolyline(m,T,u,0,b):0!==o?(d=m[0],g=m[1],_(),s.addCubicCurve(d,p,f,g,T,u)):s.addPolyline(m,T,u,0,2),S++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(m5),e.registerSeriesModel(g5)}));const v5=({className:e="",style:n={},extraOption:r={},lineStyles:i={},pointsStyles:s={},pointsData:l=[],linesData:u=[],globeOption:c={}})=>{const h=t(null),[d,p]=o();return a((()=>{const e=Ry(h.current);p(e);const t=KX(e.resize,500),n=()=>{t()};return globalThis.addEventListener("resize",n),()=>{globalThis.removeEventListener("resize",n)}}),[]),a((()=>{if(d){const e=[];e.push(Object.assign({type:"lines3D",name:"lines3D",effect:{show:!0,trailWidth:2,trailLength:.15,trailOpacity:1,trailColor:"rgb(30, 30, 60)"},lineStyle:{width:5,color:"rgb(50, 50, 150)",opacity:.3},blendMode:"lighter",data:u},i)),e.push(Object.assign({type:"scatter3D",coordinateSystem:"globe",zlevel:3,rippleEffect:{brushType:"stroke"},label:{fontSize:8,show:!0,position:"right",formatter:"{b}"},itemStyle:{normal:{color:"#f5f802"}},data:l},s)),d.setOption(Object.assign({backgroundColor:"#000",baseColor:"#000",shading:"realistic",globe:Object.assign({environment:"https://img.alicdn.com/imgextra/i2/O1CN017x8UE61p6wqej1Y0c_!!6000000005312-0-tps-2048-1024.jpg",heightTexture:"https://img.alicdn.com/imgextra/i2/O1CN01BB16kM1ILFttfdYZg_!!6000000000876-0-tps-4096-2048.jpg",baseTexture:"https://img.alicdn.com/imgextra/i4/O1CN01fs70Dq25ElSd8mU6C_!!6000000007495-0-tps-5400-2700.jpg",shading:"lambert",light:{ambient:{intensity:1},main:{intensity:.1}},viewControl:{autoRotate:!0,distance:2e3}},c),series:e},r));const t=setTimeout((()=>{d.resize()}),500);return()=>{clearTimeout(t)}}}),[d,r,c,i,u,l,s]),vU.jsx(iX,{ref:h,className:e,style:n})};export{v5 as EarthChart,dY as WinChart,oX as WinChartType,dY as default,cU as echarts};
22
+ `;var oX;!function(e){e[e.MINI_AREA=0]="MINI_AREA",e[e.AREA=1]="AREA",e[e.DUAL_LINE_BAR=2]="DUAL_LINE_BAR",e[e.STACK_DUAL_LINE_BAR=3]="STACK_DUAL_LINE_BAR",e[e.COLUMN=4]="COLUMN",e[e.STACK_COLUMN=5]="STACK_COLUMN",e[e.LINE=6]="LINE",e[e.BAR=7]="BAR",e[e.STACK_BAR=8]="STACK_BAR",e[e.FUNNEL=9]="FUNNEL",e[e.PIE=10]="PIE",e[e.CYCLE=11]="CYCLE",e[e.RADAR=12]="RADAR"}(oX||(oX={}));const aX=["#3D84FF","#00DCF0","#FCBC26","#00DB75","#BDB8FF","#40B4FF","#FFA101","#90ABE0","#6EE67A","#6B84FF","#FA6B69"],sX={grid:{top:24,left:0,right:12,bottom:32,containLabel:!0},color:aX,legend:{itemWidth:10,itemHeight:10,bottom:0,type:"scroll",icon:"circle"}};function lX(){return lX=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lX.apply(null,arguments)}function uX(e,t){return uX=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},uX(e,t)}function cX(e){return cX=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},cX(e)}function hX(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(hX=function(){return!!e})()}function dX(e){var t="function"==typeof Map?new Map:void 0;return dX=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(hX())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&uX(i,n.prototype),i}(e,arguments,cX(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),uX(n,e)},dX(e)}var pX={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function fX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=t[0],o=[];for(r=1;r<t.length;r+=1)o.push(t[r]);return o.forEach((function(e){i=i.replace(/%[a-z]/,e)})),i}var gX=function(e){function t(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];n=e.call(this,fX.apply(void 0,[pX[t]].concat(i)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,uX(e,t)}(t,e),t}(dX(Error));function mX(e){return Math.round(255*e)}function vX(e,t,n){return mX(e)+","+mX(t)+","+mX(n)}function yX(e,t,n,r){if(void 0===r&&(r=vX),0===t)return r(n,n,n);var i=(e%360+360)%360/60,o=(1-Math.abs(2*n-1))*t,a=o*(1-Math.abs(i%2-1)),s=0,l=0,u=0;i>=0&&i<1?(s=o,l=a):i>=1&&i<2?(s=a,l=o):i>=2&&i<3?(l=o,u=a):i>=3&&i<4?(l=a,u=o):i>=4&&i<5?(s=a,u=o):i>=5&&i<6&&(s=o,u=a);var c=n-o/2;return r(s+c,l+c,u+c)}var _X={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",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",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",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",rebeccapurple:"639",red:"f00",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:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var xX=/^#[a-fA-F0-9]{6}$/,bX=/^#[a-fA-F0-9]{8}$/,wX=/^#[a-fA-F0-9]{3}$/,SX=/^#[a-fA-F0-9]{4}$/,TX=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,MX=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,CX=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,DX=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function AX(e){if("string"!=typeof e)throw new gX(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return _X[t]?"#"+_X[t]:e}(e);if(t.match(xX))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(bX)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(wX))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(SX)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var i=TX.exec(t);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var o=MX.exec(t.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=CX.exec(t);if(a){var s="rgb("+yX(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",l=TX.exec(s);if(!l)throw new gX(4,t,s);return{red:parseInt(""+l[1],10),green:parseInt(""+l[2],10),blue:parseInt(""+l[3],10)}}var u=DX.exec(t.substring(0,50));if(u){var c="rgb("+yX(parseInt(""+u[1],10),parseInt(""+u[2],10)/100,parseInt(""+u[3],10)/100)+")",h=TX.exec(c);if(!h)throw new gX(4,t,c);return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10),alpha:parseFloat(""+u[4])>1?parseFloat(""+u[4])/100:parseFloat(""+u[4])}}throw new gX(5)}function IX(e){return function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,o=Math.max(n,r,i),a=Math.min(n,r,i),s=(o+a)/2;if(o===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var l=o-a,u=s>.5?l/(2-o-a):l/(o+a);switch(o){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;default:t=(n-r)/l+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:u,lightness:s,alpha:e.alpha}:{hue:t,saturation:u,lightness:s}}(AX(e))}var EX=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function LX(e){var t=e.toString(16);return 1===t.length?"0"+t:t}function NX(e){return LX(Math.round(255*e))}function PX(e,t,n){return EX("#"+NX(e)+NX(t)+NX(n))}function OX(e,t,n){return yX(e,t,n,PX)}function RX(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return EX("#"+LX(e)+LX(t)+LX(n));if("object"==typeof e&&void 0===t&&void 0===n)return EX("#"+LX(e.red)+LX(e.green)+LX(e.blue));throw new gX(6)}function kX(e,t,n,r){if("string"==typeof e&&"number"==typeof t){var i=AX(e);return"rgba("+i.red+","+i.green+","+i.blue+","+t+")"}if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?RX(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new gX(7)}function zX(e){if("object"!=typeof e)throw new gX(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return kX(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return RX(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return function(e,t,n,r){if("object"==typeof e&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?OX(e.hue,e.saturation,e.lightness):"rgba("+yX(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new gX(2)}(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return function(e,t,n){if("object"==typeof e&&void 0===t&&void 0===n)return OX(e.hue,e.saturation,e.lightness);throw new gX(1)}(e);throw new gX(8)}function VX(e,t,n){return function(){var r=n.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):VX(e,t,r)}}function BX(e){return VX(e,e.length,[])}function FX(e,t,n){return Math.max(e,Math.min(t,n))}BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{hue:n.hue+parseFloat(e)}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{lightness:FX(0,1,n.lightness-parseFloat(e))}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{saturation:FX(0,1,n.saturation-parseFloat(e))}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{lightness:FX(0,1,n.lightness+parseFloat(e))}))}));var GX=BX((function(e,t,n){if("transparent"===t)return n;if("transparent"===n)return t;if(0===e)return n;var r=AX(t),i=lX({},r,{alpha:"number"==typeof r.alpha?r.alpha:1}),o=AX(n),a=lX({},o,{alpha:"number"==typeof o.alpha?o.alpha:1}),s=i.alpha-a.alpha,l=2*parseFloat(e)-1,u=((l*s==-1?l:l+s)/(1+l*s)+1)/2,c=1-u;return kX({red:Math.floor(i.red*u+a.red*c),green:Math.floor(i.green*u+a.green*c),blue:Math.floor(i.blue*u+a.blue*c),alpha:i.alpha*parseFloat(e)+a.alpha*(1-parseFloat(e))})})),HX=GX;function UX(e){return Array.isArray(e)&&e.length>0}BX((function(e,t){if("transparent"===t)return t;var n=AX(t);return kX(lX({},n,{alpha:FX(0,1,(100*("number"==typeof n.alpha?n.alpha:1)+100*parseFloat(e))/100)}))})),BX((function(e,t){if("transparent"===t)return t;var n=IX(t);return zX(lX({},n,{saturation:FX(0,1,n.saturation+parseFloat(e))}))})),BX((function(e,t){return"transparent"===t?t:zX(lX({},IX(t),{hue:parseFloat(e)}))})),BX((function(e,t){return"transparent"===t?t:zX(lX({},IX(t),{lightness:parseFloat(e)}))})),BX((function(e,t){return"transparent"===t?t:zX(lX({},IX(t),{saturation:parseFloat(e)}))})),BX((function(e,t){return"transparent"===t?t:HX(parseFloat(e),"rgb(0, 0, 0)",t)})),BX((function(e,t){return"transparent"===t?t:HX(parseFloat(e),"rgb(255, 255, 255)",t)})),BX((function(e,t){if("transparent"===t)return t;var n=AX(t);return kX(lX({},n,{alpha:FX(0,1,+(100*("number"==typeof n.alpha?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))}));const WX=(e,t=2)=>"number"==typeof e?`${Number((100*e).toFixed(t))}%`:"-%";function jX(e){return Array.isArray(e)?[...new Set(e)]:[]}const XX=e=>Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>{const n=Number(t);return e+(Object.is(n,NaN)?0:n)}),0):0,YX=(e,t="desc")=>{if(Array.isArray(e)&&"asc"===t){return JSON.parse(JSON.stringify(e)).sort(((e,t)=>e.value-t.value))}if(Array.isArray(e)&&"desc"===t){return JSON.parse(JSON.stringify(e)).sort(((e,t)=>t.value-e.value))}return e},ZX=e=>{let t=e.data;return(e=>Array.isArray(e)&&e.length>0)(t)||(t=e.extraData),{boundaryGap:!0,axisTick:{alignWithLabel:!0},data:jX(null==t?void 0:t.map((e=>e.label))),axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}}},qX=(e,t)=>(e.sort(((e,n)=>t.indexOf(e.label)-t.indexOf(n.label))),e);function KX(e,t){let n=null;return function(...r){clearTimeout(n),n=setTimeout((()=>{e.apply(globalThis,r)}),t)}}const $X=e=>"dark"===e.theme?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.7)";function JX(e){const t=e.reduce(((e,t)=>{const{label:n,value:r}=t;return e[n]||(e[n]=0),r&&(e[n]+=Number(r)),e}),{});return Object.values(t).map((e=>parseFloat(e.toFixed(2))))}const QX=e=>{const t=(e=>{const{data:t,extraData:n,sort:r}=e;if(t&&r){const a=(i=[...t],"asc"===(o=r)?i.sort(((e,t)=>e.value-t.value)):"desc"===o&&i.sort(((e,t)=>t.value-e.value)),i),s=jX(a.map((e=>e.label))),l=qX(a,s),u=qX([...null!=n?n:[]],s);return Object.assign(Object.assign({},e),{data:l,extraData:u})}var i,o;return e})(e);switch(t.chartType){case oX.MINI_AREA:return(e=>{var t,n,r;const i=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),o=e.color;return{color:o,grid:{top:4,left:0,right:0,bottom:0,containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{show:!1},xAxis:{show:!1,boundaryGap:!1,data:jX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label)))},yAxis:{show:!1,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},series:[...i.map(((t,n)=>{var r,i;const a=null!==(r=null==o?void 0:o[n])&&void 0!==r?r:aX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new yc(0,0,0,1,[{offset:0,color:kX(a,.5)},{offset:1,color:"dark"===e.theme?kX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(i=e.data)||void 0===i?void 0:i.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.AREA:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:ZX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:[...r.map(((t,n)=>{var r;const i=aX[n];return Object.assign(Object.assign({name:t,type:"line",smooth:!0,lineStyle:{width:2},showSymbol:!1,areaStyle:{opacity:.8,color:new yc(0,0,0,1,[{offset:0,color:kX(i,.5)},{offset:1,color:"dark"===e.theme?kX("gray",.1):"#fff"}])},emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"},showSymbol:!0}),{data:null===(r=e.data)||void 0===r?void 0:r.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.LINE:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:ZX(e),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!1,lineStyle:{width:2},showSymbol:!0,emphasis:{focus:"series"}},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))}})(t);case oX.COLUMN:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})}))}})(t);case oX.STACK_COLUMN:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:{min:null===(n=e.yStart)||void 0===n?void 0:n[0]},series:r.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})}))}})(t);case oX.BAR:return(e=>{var t,n,r;const i=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:{},yAxis:{data:jX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:[0,500,500,0]}})))})}))}})(t);case oX.STACK_BAR:return(e=>{var t,n,r;const i=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type)));return{grid:Object.assign({},e.showStackTotal&&{right:32}),tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll",data:i},xAxis:{},yAxis:{data:jX(null===(n=e.data)||void 0===n?void 0:n.map((e=>e.label))),axisTick:{alignWithLabel:!0},axisPointer:{type:"shadow"},min:null===(r=e.yStart)||void 0===r?void 0:r[0],axisLabel:{rotate:e.xAxisLabelRotate,formatter:t=>{const n=e.xAxisLabelLength;return"number"==typeof n&&t.length>n?`${t.slice(0,n)}...`:t}}},series:[...i.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&!e.showStackTotal&&{label:{show:!0,formatter:"{c}",position:"right"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),Object.assign(Object.assign({name:"总和",type:"bar",stack:"abc",barGap:"-100%",barMaxWidth:8,itemStyle:{normal:{color:"transparent"}},tooltip:{show:!1}},e.showStackTotal&&{label:{normal:{show:!0,position:"right",color:"#000"},formatter:t=>{var n;return String(Number(XX(null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.label===t.name)).map((e=>e.value))).toFixed(2)))}}}),{data:JX(e.data)})]}})(t);case oX.FUNNEL:return(e=>{var t,n;const r=null!==(n=null===(t=YX(e.data))||void 0===t?void 0:t.map((t=>{var n;return{value:null!==(n=t.value)&&void 0!==n?n:0,name:e.reserveValueWithLabelType?t.label:t.type}})))&&void 0!==n?n:[],i={type:"funnel",minSize:"20%",left:10,top:24,width:"76%",sort:"descending",data:r};return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[Object.assign(Object.assign({},i),{label:{show:!0,position:"outer",formatter:"{c}"}}),Object.assign(Object.assign({},i),{emphasis:{label:{fontSize:20}},label:{show:!0,position:"inner",color:"#fff",formatter:e=>{const t=e.dataIndex;if(0===t)return"100%";const n=r[t-1].value;return WX(e.value/n)}}})]}})(t);case oX.DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=jX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value,itemStyle:{borderRadius:e.value>0?[500,500,0,0]:[0,0,500,500]}})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.STACK_DUAL_LINE_BAR:return(e=>{var t,n,r,i;const o=jX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.type))),a=jX(null===(n=e.extraData)||void 0===n?void 0:n.map((e=>e.type)));return{tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:"#999"},label:{backgroundColor:"#999"}}},legend:{bottom:0,type:"scroll"},xAxis:Object.assign(Object.assign({},ZX(e)),{axisPointer:{type:"shadow"}}),yAxis:[{alignTicks:!0,min:null===(r=e.yStart)||void 0===r?void 0:r[0]},{alignTicks:!0,min:null===(i=e.yStart)||void 0===i?void 0:i[1]}],series:[...o.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"bar",stack:"total",barGap:"30%",barCategoryGap:"30%",barMaxWidth:8},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.data)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>({value:e.value})))})})),...a.map((t=>{var n;return Object.assign(Object.assign({name:t,type:"line",smooth:!0,yAxisIndex:1,showSymbol:!1},e.showLabel&&{label:{show:!0,formatter:"{c}",position:"top"}}),{data:null===(n=e.extraData)||void 0===n?void 0:n.filter((e=>e.type===t)).map((e=>e.value))})}))]}})(t);case oX.PIE:return(e=>{var t,n;const r=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:"50%",data:null===(n=YX(e.data))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:$X(e),position:"outside",formatter:e=>WX(e.value/(r||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}})(t);case oX.CYCLE:return(e=>{var t,n,r,i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x;const b=XX(null===(t=e.data)||void 0===t?void 0:t.map((e=>e.value)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},series:[{top:-30,type:"pie",radius:["60%","48%"],data:null===(n=YX(e.data,e.sort))||void 0===n?void 0:n.map((t=>({value:t.value,name:e.reserveValueWithLabelType?t.label:t.type}))),label:{show:!0,fontSize:12,color:$X(e),position:"outside",formatter:e=>WX(e.value/(b||1))},emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}],graphic:[{type:"text",left:"center",top:null!==(o=null===(i=null===(r=e.cycleCenterConfig)||void 0===r?void 0:r.content)||void 0===i?void 0:i.top)&&void 0!==o?o:76,style:{text:null!==(l=null===(s=null===(a=e.cycleCenterConfig)||void 0===a?void 0:a.content)||void 0===s?void 0:s.value)&&void 0!==l?l:Number(b.toFixed(2)).toString(),fill:"dark"===e.theme?"#fff":"#12161F",fontFamily:"roboto",fontSize:null!==(h=null===(c=null===(u=e.cycleCenterConfig)||void 0===u?void 0:u.content)||void 0===c?void 0:c.fontSize)&&void 0!==h?h:28,fontWeight:"bold"}},{type:"text",left:"center",top:null!==(f=null===(p=null===(d=e.cycleCenterConfig)||void 0===d?void 0:d.title)||void 0===p?void 0:p.top)&&void 0!==f?f:112,style:{text:null!==(v=null===(m=null===(g=e.cycleCenterConfig)||void 0===g?void 0:g.title)||void 0===m?void 0:m.value)&&void 0!==v?v:"总计",fill:"dark"===e.theme?"#fff":"#394252 ",fontSize:null!==(x=null===(_=null===(y=e.cycleCenterConfig)||void 0===y?void 0:y.title)||void 0===_?void 0:_.fontSize)&&void 0!==x?x:14}}]}})(t);case oX.RADAR:return(e=>{var t,n;const r=jX(null===(t=e.data)||void 0===t?void 0:t.map((t=>e.reserveValueWithLabelType?t.label:t.type)));return{tooltip:{trigger:"item"},legend:{bottom:0,type:"scroll"},radar:{shape:"circle",radius:"60%",indicator:jX(null===(n=e.data)||void 0===n?void 0:n.map((t=>e.reserveValueWithLabelType?t.type:t.label))).map((e=>({name:e}))),axisName:{color:"#5d677a"},splitArea:{areaStyle:{color:["transparent"]}},axisLine:{lineStyle:{color:"rgba(226, 229, 235, .3)"}},splitLine:{lineStyle:{color:"#e2e5eb",type:"dashed",dashOffset:1.5}}},series:[{type:"radar",data:r.map(((t,n)=>{var r;return{name:t,value:null===(r=e.data)||void 0===r?void 0:r.filter((n=>e.reserveValueWithLabelType?n.label:n.type===t)).map((e=>e.value)),areaStyle:{color:kX(aX[n],.2)},label:{show:e.reserveValueWithLabelType,formatter:e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.toString()}}}})),emphasis:{lineStyle:{width:4}}}]}})(t);default:return{}}};var eY={color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"rgba(0,0,0,0)",textStyle:{},title:{textStyle:{color:"#272f3d"},subtextStyle:{color:"#394252"}},line:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},radar:{itemStyle:{borderWidth:1},lineStyle:{width:2},symbolSize:4,symbol:"emptyCircle",smooth:!1},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#dfe3eb"},symbolSize:4,symbol:"emptyCircle",smooth:!1,color:["#3379ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!0,lineStyle:{color:["#eef0f5"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"#eef0f5"}},axisTick:{show:!0,lineStyle:{color:"#eef0f5"}},axisLabel:{show:!0,color:"#828b9e"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#828c9e"},emphasis:{iconStyle:{borderColor:"#394252"}}},legend:{textStyle:{color:"#828b9e"}},tooltip:{axisPointer:{lineStyle:{color:"#ccd1db",width:"1"},crossStyle:{color:"#ccd1db",width:"1"}}},timeline:{lineStyle:{color:"#eef0f5",width:2},itemStyle:{color:"#eef0f5",borderWidth:"1"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},checkpointStyle:{color:"#3379ff",borderColor:"#ffffff"},label:{color:"#b1b9c7"},emphasis:{itemStyle:{color:"#3379ff"},controlStyle:{color:"#828c9e",borderColor:"#828c9e",borderWidth:1},label:{color:"#b1b9c7"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},tY={color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],backgroundColor:"transparent",textStyle:{},title:{textStyle:{color:"#ffffff"},subtextStyle:{color:"#ffffff"}},line:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},radar:{itemStyle:{borderWidth:"1"},lineStyle:{width:"2"},symbolSize:"6",symbol:"emptyCircle",smooth:!0},bar:{itemStyle:{barBorderWidth:"0",barBorderColor:"#cccccc"}},pie:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},scatter:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},boxplot:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},parallel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},sankey:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},funnel:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},gauge:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"}},candlestick:{itemStyle:{color:"#f15451",color0:"#00c267",borderColor:"#f15451",borderColor0:"#00c267",borderWidth:1}},graph:{itemStyle:{borderWidth:"0",borderColor:"#cccccc"},lineStyle:{width:"1",color:"#ffffff"},symbolSize:"6",symbol:"emptyCircle",smooth:!0,color:["#5798ff","#00dcf0","#ffc94d","#00db75","#b8b3ff","#40b4ff","#ffa101","#90abe0","#6ee67a","#6b84ff","#fa6b69"],label:{color:"#ffffff"}},map:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},geo:{itemStyle:{areaColor:"#eee",borderColor:"#444",borderWidth:.5},label:{color:"#000"},emphasis:{itemStyle:{areaColor:"rgba(255,215,0,0.8)",borderColor:"#444",borderWidth:1},label:{color:"rgb(100,0,0)"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},valueAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},logAxis:{axisLine:{show:!1,lineStyle:{color:"#6E7079"}},axisTick:{show:!1,lineStyle:{color:"#6E7079"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!0,lineStyle:{color:["rgba(255,255,255,0.12)"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisTick:{show:!0,lineStyle:{color:"rgba(255,255,255,0.12)"}},axisLabel:{show:!0,color:"rgba(255,255,255,0.5)"},splitLine:{show:!1,lineStyle:{color:["#E0E6F1"]}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},toolbox:{iconStyle:{borderColor:"#ffffff"},emphasis:{iconStyle:{borderColor:"#ffffff"}}},legend:{textStyle:{color:"#ffffff"}},tooltip:{axisPointer:{lineStyle:{color:"#ffffff",width:"1"},crossStyle:{color:"#ffffff",width:"1"}}},timeline:{lineStyle:{color:"#ffffff",width:2},itemStyle:{color:"#ffffff",borderWidth:"1"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},checkpointStyle:{color:"#5798ff",borderColor:"#ffffff"},label:{color:"#ffffff"},emphasis:{itemStyle:{color:"#5798ff"},controlStyle:{color:"#ffffff",borderColor:"#ffffff",borderWidth:1},label:{color:"#ffffff"}}},visualMap:{color:["#062379","#2058d2","#3379ff","#a0cbff","#e8f4ff"]},dataZoom:{handleSize:"undefined%",textStyle:{}},markPoint:{label:{color:"#ffffff"},emphasis:{label:{color:"#ffffff"}}}},nY=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===rY}(e)}(e)};var rY="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function iY(e,t){return!1!==t.clone&&t.isMergeableObject(e)?uY((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function oY(e,t,n){return e.concat(t).map((function(e){return iY(e,n)}))}function aY(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function sY(e,t){try{return t in e}catch(e){return!1}}function lY(e,t,n){var r={};return n.isMergeableObject(e)&&aY(e).forEach((function(t){r[t]=iY(e[t],n)})),aY(t).forEach((function(i){(function(e,t){return sY(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(sY(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return uY;var n=t.customMerge(e);return"function"==typeof n?n:uY}(i,n)(e[i],t[i],n):r[i]=iY(t[i],n))})),r}function uY(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||oY,n.isMergeableObject=n.isMergeableObject||nY,n.cloneUnlessOtherwiseSpecified=iY;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):lY(e,t,n):iY(t,n)}uY.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return uY(e,n,t)}),{})};var cY=hU(uY);By("light",cY(eY,sX)),By("dark",cY(tY,sX));const hY={arrayMerge:(e,t)=>t},dY=e=>{const n=t(null),[r,i]=o();return a((()=>{var t;const r=Ry(n.current,null!==(t=e.theme)&&void 0!==t?t:"light");i(r);const o=KX(r.resize,500),a=()=>o();return globalThis.addEventListener("resize",a),()=>{globalThis.removeEventListener("resize",a)}}),[e.theme]),a((()=>{var t;if(r){const n=r.getHeight()-48,i=Object.assign(Object.assign({},e),e.chartType===oX.CYCLE&&!e.cycleCenterConfig&&{cycleCenterConfig:{title:{top:n/2+24},content:{top:n/2-8}}}),{extraOption:o={},extraSeriesOption:a}=i;r.clear();const s=cY(((e,t)=>(UX(e.series)&&UX(t)&&t.forEach((t=>{e.series=e.series.map((e=>Object.assign(Object.assign({},e),e.name===t.name&&t)))})),e))(QX(i),a),o,hY);r.setOption(s),null===(t=i.onLoad)||void 0===t||t.call(i,r);const l=setTimeout((()=>{r.resize()}),500);return()=>{clearTimeout(l)}}}),[r,e]),vU.jsx(iX,{ref:n,className:e.className,style:e.style})};function pY(e,t,n){"object"==typeof t&&(n=t,t=null);var r,i=this;if(!(e instanceof Function))for(var o in r=[],e)e.hasOwnProperty(o)&&r.push(o);var a=function(t){if(i.apply(this,arguments),e instanceof Function?fY(this,e.call(this,t)):function(e,t,n){for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}}(this,e,r),this.constructor===a)for(var n=a.__initializers__,o=0;o<n.length;o++)n[o].apply(this,arguments)};a.__super__=i,i.__initializers__?a.__initializers__=i.__initializers__.slice():a.__initializers__=[],t&&a.__initializers__.push(t);var s=function(){};return s.prototype=i.prototype,a.prototype=new s,a.prototype.constructor=a,fY(a.prototype,n),a.extend=i.extend,a.derive=i.extend,a}function fY(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}i_([kS,vH]),i_(mw);var gY={extend:pY,derive:pY};function mY(e,t){this.action=e,this.context=t}var vY={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,r=-1,i=arguments;switch(i.length){case 1:for(;++r<n;)t[r].action.call(t[r].context);return;case 2:for(;++r<n;)t[r].action.call(t[r].context,i[1]);return;case 3:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2]);return;case 4:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3]);return;case 5:for(;++r<n;)t[r].action.call(t[r].context,i[1],i[2],i[3],i[4]);return;default:for(;++r<n;)t[r].action.apply(t[r].context,Array.prototype.slice.call(i,1));return}}},on:function(e,t,n){if(e&&t){var r=this.__handlers__||(this.__handlers__={});if(r[e]){if(this.has(e,t))return}else r[e]=[];var i=new mY(t,n||this);return r[e].push(i),this}},once:function(e,t,n){if(e&&t){var r=this;return this.on(e,(function n(){r.off(e,n),t.apply(this,arguments)}),n)}},before:function(e,t,n){if(e&&t)return e="before"+e,this.on(e,t,n)},after:function(e,t,n){if(e&&t)return e="after"+e,this.on(e,t,n)},success:function(e,t){return this.once("success",e,t)},error:function(e,t){return this.once("error",e,t)},off:function(e,t){var n=this.__handlers__||(this.__handlers__={});if(t){if(n[e]){for(var r=n[e],i=[],o=0;o<r.length;o++)t&&r[o].action!==t&&i.push(r[o]);n[e]=i}return this}n[e]=[]},has:function(e,t){var n=this.__handlers__;if(!n||!n[e])return!1;for(var r=n[e],i=0;i<r.length;i++)if(r[i].action===t)return!0}},yY=0,_Y=Array.prototype.forEach,xY={genGUID:function(){return++yY},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;for(var n=e.split("/"),r=t.split("/"),i=n[0];"."===i||".."===i;)".."===i&&r.pop(),n.shift(),i=n[0];return r.join("/")+"/"+n.join("/")},extend:function(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},defaults:function(e,t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n]);return e},extendWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];e[i]=t[i]}return e},defaultsWithPropList:function(e,t,n){if(t)for(var r=0;r<n.length;r++){var i=n[r];null==e[i]&&(e[i]=t[i])}return e},each:function(e,t,n){if(e&&t)if(e.forEach&&e.forEach===_Y)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(n,e[o],o,e)},isObject:function(e){return e===Object(e)},isArray:function(e){return Array.isArray(e)},isArrayLike:function(e){return!!e&&e.length===+e.length},clone:function(e){if(xY.isObject(e)){if(xY.isArray(e))return e.slice();if(xY.isArrayLike(e)){for(var t=new e.constructor(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return xY.extend({},e)}return e}},bY=function(){this.__uid__=xY.genGUID()};bY.__initializers__=[function(e){xY.extend(this,e)}],xY.extend(bY,gY),xY.extend(bY.prototype,vY);var wY=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],SY=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];function TY(e){for(var t={},n={},r=0;r<wY.length;r++){o(wY[r])}for(r=0;r<SY.length;r++){var i=SY[r];n[i]=e.getParameter(e[i])}function o(n){if(e.getExtension){var r=e.getExtension(n);r||(r=e.getExtension("MOZ_"+n)),r||(r=e.getExtension("WEBKIT_"+n)),t[n]=r}}this.getExtension=function(e){return e in t||o(e),t[e]},this.getParameter=function(e){return n[e]}}var MY=256,CY=1024,DY=16384,AY=0,IY=1,EY=2,LY=3,NY=4,PY=5,OY=6,RY=35040,kY=35044,zY=35048,VY=1028,BY=1029,FY=1032,GY=2304,HY=2305,UY=5120,WY=5121,jY=5122,XY=5123,YY=5124,ZY=5125,qY=5126,KY=6402,$Y=6406,JY=6407,QY=6408,eZ=6409,tZ=6410,nZ=9728,rZ=9729,iZ=9984,oZ=9985,aZ=9986,sZ=9987,lZ=3553,uZ=34067,cZ=10497,hZ=33071,dZ=33648,pZ=36160,fZ=36161,gZ=34041,mZ=36064,vZ=36096,yZ=36128,_Z=33306;var xZ,bZ={get:function(e){var t=new XMLHttpRequest;t.open("get",e.url),t.responseType=e.responseType||"text",e.onprogress&&(t.onprogress=function(t){if(t.lengthComputable){var n=t.loaded/t.total;e.onprogress(n,t.loaded,t.total)}else e.onprogress(null)}),t.onload=function(n){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}},wZ={supportWebGL:function(){if(null==xZ)try{var e=document.createElement("canvas");if(!(e.getContext("webgl")||e.getContext("experimental-webgl")))throw new Error}catch(e){xZ=!1}return xZ}};wZ.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,wZ.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,wZ.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,wZ.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,wZ.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,wZ.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,wZ.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var SZ={};"undefined"!=typeof window?SZ=window:"undefined"!=typeof global&&(SZ=global),wZ.requestAnimationFrame=SZ.requestAnimationFrame||SZ.msRequestAnimationFrame||SZ.mozRequestAnimationFrame||SZ.webkitRequestAnimationFrame||function(e){setTimeout(e,16)},wZ.createCanvas=function(){return document.createElement("canvas")},wZ.createImage=function(){return new SZ.Image},wZ.request={get:bZ.get},wZ.addEventListener=function(e,t,n,r){e.addEventListener(t,n,r)},wZ.removeEventListener=function(e,t,n){e.removeEventListener(t,n)};var TZ=function(){this.head=null,this.tail=null,this._length=0};TZ.prototype.insert=function(e){var t=new TZ.Entry(e);return this.insertEntry(t),t},TZ.prototype.insertAt=function(e,t){if(!(e<0)){for(var n=this.head,r=0;n&&r!=e;)n=n.next,r++;if(n){var i=new TZ.Entry(t),o=n.prev;o?(o.next=i,i.prev=o):this.head=i,i.next=n,n.prev=i}else this.insert(t)}},TZ.prototype.insertBeforeEntry=function(e,t){var n=new TZ.Entry(e),r=t.prev;r?(r.next=n,n.prev=r):this.head=n,n.next=t,t.prev=n,this._length++},TZ.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},TZ.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._length--},TZ.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t?(this.remove(t),t.value):void 0}},TZ.prototype.getHead=function(){if(this.head)return this.head.value},TZ.prototype.getTail=function(){if(this.tail)return this.tail.value},TZ.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,n=0;t&&n!=e;)t=t.next,n++;return t.value}},TZ.prototype.indexOf=function(e){for(var t=this.head,n=0;t;){if(t.value===e)return n;t=t.next,n++}},TZ.prototype.length=function(){return this._length},TZ.prototype.isEmpty=function(){return 0===this._length},TZ.prototype.forEach=function(e,t){for(var n=this.head,r=0,i=void 0!==t;n;)i?e.call(t,n.value,r):e(n.value,r),n=n.next,r++},TZ.prototype.clear=function(){this.tail=this.head=null,this._length=0},TZ.Entry=function(e){this.value=e,this.next=null,this.prev=null};var MZ=function(e){this._list=new TZ,this._map={},this._maxSize=e||10};MZ.prototype.setMaxSize=function(e){this._maxSize=e},MZ.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){var n=this._list.length();if(n>=this._maxSize&&n>0){var r=this._list.head;this._list.remove(r),delete this._map[r.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},MZ.prototype.get=function(e){var t=this._map[e];if(this._map.hasOwnProperty(e))return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value},MZ.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},MZ.prototype.clear=function(){this._list.clear(),this._map={}};var CZ={},DZ={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function AZ(e){return(e=Math.round(e))<0?0:e>255?255:e}function IZ(e){return e<0?0:e>1?1:e}function EZ(e){return e.length&&"%"===e.charAt(e.length-1)?AZ(parseFloat(e)/100*255):AZ(parseInt(e,10))}function LZ(e){return e.length&&"%"===e.charAt(e.length-1)?IZ(parseFloat(e)/100):IZ(parseFloat(e))}function NZ(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function PZ(e,t,n){return e+(t-e)*n}function OZ(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function RZ(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var kZ=new MZ(20),zZ=null;function VZ(e,t){zZ&&RZ(zZ,t),zZ=kZ.put(e,zZ||t.slice())}function BZ(e,t){var n=(parseFloat(e[0])%360+360)%360/360,r=LZ(e[1]),i=LZ(e[2]),o=i<=.5?i*(r+1):i+r-i*r,a=2*i-o;return OZ(t=t||[],AZ(255*NZ(a,o,n+1/3)),AZ(255*NZ(a,o,n)),AZ(255*NZ(a,o,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}CZ.parse=function(e,t){if(e){t=t||[];var n=kZ.get(e);if(n)return RZ(t,n);var r,i=(e+="").replace(/ /g,"").toLowerCase();if(i in DZ)return RZ(t,DZ[i]),VZ(e,t),t;if("#"===i.charAt(0))return 4===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=4095?(OZ(t,(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1),VZ(e,t),t):void OZ(t,0,0,0,1):7===i.length?(r=parseInt(i.substr(1),16))>=0&&r<=16777215?(OZ(t,(16711680&r)>>16,(65280&r)>>8,255&r,1),VZ(e,t),t):void OZ(t,0,0,0,1):void 0;var o=i.indexOf("("),a=i.indexOf(")");if(-1!==o&&a+1===i.length){var s=i.substr(0,o),l=i.substr(o+1,a-(o+1)).split(","),u=1;switch(s){case"rgba":if(4!==l.length)return void OZ(t,0,0,0,1);u=LZ(l.pop());case"rgb":return 3!==l.length?void OZ(t,0,0,0,1):(OZ(t,EZ(l[0]),EZ(l[1]),EZ(l[2]),u),VZ(e,t),t);case"hsla":return 4!==l.length?void OZ(t,0,0,0,1):(l[3]=LZ(l[3]),BZ(l,t),VZ(e,t),t);case"hsl":return 3!==l.length?void OZ(t,0,0,0,1):(BZ(l,t),VZ(e,t),t);default:return}}OZ(t,0,0,0,1)}},CZ.parseToFloat=function(e,t){if(t=CZ.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},CZ.lift=function(e,t){var n=CZ.parse(e);if(n){for(var r=0;r<3;r++)n[r]=t<0?n[r]*(1-t)|0:(255-n[r])*t+n[r]|0;return CZ.stringify(n,4===n.length?"rgba":"rgb")}},CZ.toHex=function(e){var t=CZ.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},CZ.fastLerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){n=n||[];var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=t[i],s=t[o],l=r-i;return n[0]=AZ(PZ(a[0],s[0],l)),n[1]=AZ(PZ(a[1],s[1],l)),n[2]=AZ(PZ(a[2],s[2],l)),n[3]=IZ(PZ(a[3],s[3],l)),n}},CZ.fastMapToColor=CZ.fastLerp,CZ.lerp=function(e,t,n){if(t&&t.length&&e>=0&&e<=1){var r=e*(t.length-1),i=Math.floor(r),o=Math.ceil(r),a=CZ.parse(t[i]),s=CZ.parse(t[o]),l=r-i,u=CZ.stringify([AZ(PZ(a[0],s[0],l)),AZ(PZ(a[1],s[1],l)),AZ(PZ(a[2],s[2],l)),IZ(PZ(a[3],s[3],l))],"rgba");return n?{color:u,leftIndex:i,rightIndex:o,value:r}:u}},CZ.mapToColor=CZ.lerp,CZ.modifyHSL=function(e,t,n,r){if(e=CZ.parse(e))return e=function(e){if(e){var t,n,r=e[0]/255,i=e[1]/255,o=e[2]/255,a=Math.min(r,i,o),s=Math.max(r,i,o),l=s-a,u=(s+a)/2;if(0===l)t=0,n=0;else{n=u<.5?l/(s+a):l/(2-s-a);var c=((s-r)/6+l/2)/l,h=((s-i)/6+l/2)/l,d=((s-o)/6+l/2)/l;r===s?t=d-h:i===s?t=1/3+c-d:o===s&&(t=2/3+h-c),t<0&&(t+=1),t>1&&(t-=1)}var p=[360*t,n,u];return null!=e[3]&&p.push(e[3]),p}}(e),null!=t&&(e[0]=function(e){return(e=Math.round(e))<0?0:e>360?360:e}(t)),null!=n&&(e[1]=LZ(n)),null!=r&&(e[2]=LZ(r)),CZ.stringify(BZ(e),"rgba")},CZ.modifyAlpha=function(e,t){if((e=CZ.parse(e))&&null!=t)return e[3]=IZ(t),CZ.stringify(e,"rgba")},CZ.stringify=function(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}};var FZ=CZ.parseToFloat,GZ={};function HZ(e){var t=Object.keys(e);t.sort();for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e[i];null===o?n.push(i):n.push(i+" "+o.toString())}return n.join("\n")}var UZ,WZ=bY.extend((function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}}),(function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)}),{precision:"highp",setUniform:function(e,t){void 0===t&&console.warn('Uniform value "'+e+'" is undefined');var n=this.uniforms[e];n&&("string"==typeof t&&(t=FZ(t)||t),n.value=t,this.autoUpdateTextureStatus&&"t"===n.type&&(t?this.enableTexture(e):this.disableTexture(e)))},setUniforms:function(e){for(var t in e){var n=e[t];this.setUniform(t,n)}},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if("object"==typeof e)for(var n in e){var r=e[n];this.setUniform(n,r)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var r=this.uniforms;this._enabledUniforms=Object.keys(r),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter((function(e){var t=this.uniforms[e].type;return"t"===t||"tv"===t}),this);var i=this.vertexDefines,o=this.fragmentDefines;if(this.vertexDefines=xY.clone(e.vertexDefines),this.fragmentDefines=xY.clone(e.fragmentDefines),t){for(var a in n)r[a]&&(r[a].value=n[a].value);xY.defaults(this.vertexDefines,i),xY.defaults(this.fragmentDefines,o)}var s={};for(var l in e.textures)s[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:!(!t||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=xY.clone(this.vertexDefines),e.fragmentDefines=xY.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,n){var r=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(n=t,t=e,e="both"),n=null!=n?n:null,"vertex"!==e&&"both"!==e||r[t]!==n&&(r[t]=n,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==n&&(i[t]=n,"both"!==e&&(this._programKey=""))},undefine:function(e,t){"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<2&&(t=e,e="both"),"vertex"!==e&&"both"!==e||this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),"fragment"!==e&&"both"!==e||this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],"both"!==e&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return void 0!==this.vertexDefines[t];case"fragment":return void 0!==this.fragmentDefines[t]}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.enableTexture(e[t]);else{var n=this._textureStatus[e];if(n)n.enabled||(n.enabled=!0,this._programKey="")}},enableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!0;this._programKey=""},disableTexture:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.disableTexture(e[t]);else{var n=this._textureStatus[e];if(n)!n.enabled||(n.enabled=!1,this._programKey="")}},disableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!1;this._programKey=""},isTextureEnabled:function(e){var t=this._textureStatus;return!!t[e]&&t[e].enabled},getEnabledTextures:function(){var e=[],t=this._textureStatus;for(var n in t)t[n].enabled&&e.push(n);return e},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(e,t,n){n.sort();for(var r=[],i=0;i<n.length;i++){var o=n[i];r.push(o)}var a=HZ(e)+"\n"+HZ(t)+"\n"+r.join("\n");if(GZ[a])return GZ[a];var s=xY.genGUID();return GZ[a]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),jZ=1e-6,XZ=Array,YZ=Math.random,ZZ={};ZZ.create=function(){var e=new XZ(2);return e[0]=0,e[1]=0,e},ZZ.clone=function(e){var t=new XZ(2);return t[0]=e[0],t[1]=e[1],t},ZZ.fromValues=function(e,t){var n=new XZ(2);return n[0]=e,n[1]=t,n},ZZ.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},ZZ.set=function(e,t,n){return e[0]=t,e[1]=n,e},ZZ.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},ZZ.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},ZZ.sub=ZZ.subtract,ZZ.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},ZZ.mul=ZZ.multiply,ZZ.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},ZZ.div=ZZ.divide,ZZ.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},ZZ.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},ZZ.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},ZZ.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},ZZ.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},ZZ.dist=ZZ.distance,ZZ.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},ZZ.sqrDist=ZZ.squaredDistance,ZZ.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},ZZ.len=ZZ.length,ZZ.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},ZZ.sqrLen=ZZ.squaredLength,ZZ.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},ZZ.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},ZZ.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},ZZ.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},ZZ.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},ZZ.lerp=function(e,t,n,r){var i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e},ZZ.random=function(e,t){t=t||1;var n=2*GLMAT_RANDOM()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},ZZ.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},ZZ.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},ZZ.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},ZZ.transformMat4=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},ZZ.forEach=(UZ=ZZ.create(),function(e,t,n,r,i,o){var a,s;for(t||(t=2),n||(n=0),s=r?Math.min(r*t+n,e.length):e.length,a=n;a<s;a+=t)UZ[0]=e[a],UZ[1]=e[a+1],i(UZ,UZ,o),e[a]=UZ[0],e[a+1]=UZ[1];return e});var qZ=function(e,t){e=e||0,t=t||0,this.array=ZZ.fromValues(e,t),this._dirty=!0};if(qZ.prototype={constructor:qZ,add:function(e){return ZZ.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t){return this.array[0]=e,this.array[1]=t,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this._dirty=!0,this},clone:function(){return new qZ(this.x,this.y)},copy:function(e){return ZZ.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return ZZ.cross(e.array,this.array,t.array),e._dirty=!0,this},dist:function(e){return ZZ.dist(this.array,e.array)},distance:function(e){return ZZ.distance(this.array,e.array)},div:function(e){return ZZ.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return ZZ.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return ZZ.dot(this.array,e.array)},len:function(){return ZZ.len(this.array)},length:function(){return ZZ.length(this.array)},lerp:function(e,t,n){return ZZ.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return ZZ.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return ZZ.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return ZZ.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return ZZ.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return ZZ.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return ZZ.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return ZZ.random(this.array,e),this._dirty=!0,this},scale:function(e){return ZZ.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return ZZ.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return ZZ.sqrDist(this.array,e.array)},squaredDistance:function(e){return ZZ.squaredDistance(this.array,e.array)},sqrLen:function(){return ZZ.sqrLen(this.array)},squaredLength:function(){return ZZ.squaredLength(this.array)},sub:function(e){return ZZ.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return ZZ.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat2:function(e){return ZZ.transformMat2(this.array,this.array,e.array),this._dirty=!0,this},transformMat2d:function(e){return ZZ.transformMat2d(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return ZZ.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return ZZ.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var KZ=qZ.prototype;Object.defineProperty(KZ,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Object.defineProperty(KZ,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}})}qZ.add=function(e,t,n){return ZZ.add(e.array,t.array,n.array),e._dirty=!0,e},qZ.set=function(e,t,n){return ZZ.set(e.array,t,n),e._dirty=!0,e},qZ.copy=function(e,t){return ZZ.copy(e.array,t.array),e._dirty=!0,e},qZ.cross=function(e,t,n){return ZZ.cross(e.array,t.array,n.array),e._dirty=!0,e},qZ.distance=qZ.dist=function(e,t){return ZZ.distance(e.array,t.array)},qZ.div=function(e,t,n){return ZZ.divide(e.array,t.array,n.array),e._dirty=!0,e},qZ.divide=qZ.div,qZ.dot=function(e,t){return ZZ.dot(e.array,t.array)},qZ.len=function(e){return ZZ.length(e.array)},qZ.lerp=function(e,t,n,r){return ZZ.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},qZ.min=function(e,t,n){return ZZ.min(e.array,t.array,n.array),e._dirty=!0,e},qZ.max=function(e,t,n){return ZZ.max(e.array,t.array,n.array),e._dirty=!0,e},qZ.mul=function(e,t,n){return ZZ.multiply(e.array,t.array,n.array),e._dirty=!0,e},qZ.multiply=qZ.mul,qZ.negate=function(e,t){return ZZ.negate(e.array,t.array),e._dirty=!0,e},qZ.normalize=function(e,t){return ZZ.normalize(e.array,t.array),e._dirty=!0,e},qZ.random=function(e,t){return ZZ.random(e.array,t),e._dirty=!0,e},qZ.scale=function(e,t,n){return ZZ.scale(e.array,t.array,n),e._dirty=!0,e},qZ.scaleAndAdd=function(e,t,n,r){return ZZ.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},qZ.squaredDistance=qZ.sqrDist=function(e,t){return ZZ.sqrDist(e.array,t.array)},qZ.squaredLength=qZ.sqrLen=function(e){return ZZ.sqrLen(e.array)},qZ.sub=function(e,t,n){return ZZ.subtract(e.array,t.array,n.array),e._dirty=!0,e},qZ.subtract=qZ.sub,qZ.transformMat2=function(e,t,n){return ZZ.transformMat2(e.array,t.array,n.array),e._dirty=!0,e},qZ.transformMat2d=function(e,t,n){return ZZ.transformMat2d(e.array,t.array,n.array),e._dirty=!0,e},qZ.transformMat3=function(e,t,n){return ZZ.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},qZ.transformMat4=function(e,t,n){return ZZ.transformMat4(e.array,t.array,n.array),e._dirty=!0,e};var $Z={};function JZ(e){for(var t=e.split("\n"),n=0,r=t.length;n<r;n++)t[n]=n+1+": "+t[n];return t.join("\n")}function QZ(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),JZ(n)].join("\n")}var eq=new wZ.Float32Array(16),tq=bY.extend({uniformSemantics:{},attributes:{}},(function(){this._locations={},this._textureSlot=0,this._program=null}),{bind:function(e){this._textureSlot=0,e.gl.useProgram(this._program)},hasUniform:function(e){var t=this._locations[e];return null!=t},useTextureSlot:function(e,t,n){t&&(e.gl.activeTexture(e.gl.TEXTURE0+n),t.isRenderable()?t.bind(e):t.unbind(e))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(e){this._textureSlot=e||0},takeCurrentTextureSlot:function(e,t){var n=this._textureSlot;return this.useTextureSlot(e,t,n),this._textureSlot++,n},setUniform:function(e,t,n,r){var i=this._locations[n];if(null==i)return!1;switch(t){case"m4":if(!(r instanceof Float32Array)){for(var o=0;o<r.length;o++)eq[o]=r[o];r=eq}e.uniformMatrix4fv(i,!1,r);break;case"2i":e.uniform2i(i,r[0],r[1]);break;case"2f":e.uniform2f(i,r[0],r[1]);break;case"3i":e.uniform3i(i,r[0],r[1],r[2]);break;case"3f":e.uniform3f(i,r[0],r[1],r[2]);break;case"4i":e.uniform4i(i,r[0],r[1],r[2],r[3]);break;case"4f":e.uniform4f(i,r[0],r[1],r[2],r[3]);break;case"1i":e.uniform1i(i,r);break;case"1f":e.uniform1f(i,r);break;case"1fv":e.uniform1fv(i,r);break;case"1iv":e.uniform1iv(i,r);break;case"2iv":e.uniform2iv(i,r);break;case"2fv":e.uniform2fv(i,r);break;case"3iv":e.uniform3iv(i,r);break;case"3fv":e.uniform3fv(i,r);break;case"4iv":e.uniform4iv(i,r);break;case"4fv":e.uniform4fv(i,r);break;case"m2":case"m2v":e.uniformMatrix2fv(i,!1,r);break;case"m3":case"m3v":e.uniformMatrix3fv(i,!1,r);break;case"m4v":if(Array.isArray(r)&&Array.isArray(r[0])){var a=new wZ.Float32Array(16*r.length),s=0;for(o=0;o<r.length;o++)for(var l=r[o],u=0;u<16;u++)a[s++]=l[u];e.uniformMatrix4fv(i,!1,a)}else e.uniformMatrix4fv(i,!1,r)}return!0},setUniformOfSemantic:function(e,t,n){var r=this.uniformSemantics[t];return!!r&&this.setUniform(e,r.type,r.symbol,n)},enableAttributes:function(e,t,n){var r,i=e.gl,o=this._program,a=this._locations;(r=n?n.__enabledAttributeList:$Z[e.__uid__])||(r=n?n.__enabledAttributeList=[]:$Z[e.__uid__]=[]);for(var s=[],l=0;l<t.length;l++){var u=t[l];if(this.attributes[u]){var c=a[u];if(null==c){if(-1===(c=i.getAttribLocation(o,u))){s[l]=-1;continue}a[u]=c}s[l]=c,r[c]?r[c]=2:r[c]=1}else s[l]=-1}for(l=0;l<r.length;l++)switch(r[l]){case 1:i.enableVertexAttribArray(l),r[l]=3;break;case 2:r[l]=3;break;case 3:i.disableVertexAttribArray(l),r[l]=0}return s},getAttribLocation:function(e,t){var n=this._locations,r=n[t];return null==r&&(r=e.getAttribLocation(this._program,t),n[t]=r),r},buildProgram:function(e,t,n,r){var i=e.createShader(e.VERTEX_SHADER),o=e.createProgram();e.shaderSource(i,n),e.compileShader(i);var a=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(a,r),e.compileShader(a);var s=QZ(e,i,n);if(s)return s;if(s=QZ(e,a,r))return s;if(e.attachShader(o,i),e.attachShader(o,a),t.attributeSemantics.POSITION)e.bindAttribLocation(o,0,t.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);e.bindAttribLocation(o,0,l[0])}if(e.linkProgram(o),e.deleteShader(i),e.deleteShader(a),this._program=o,this.vertexCode=n,this.fragmentCode=r,!e.getProgramParameter(o,e.LINK_STATUS))return"Could not link program\n"+e.getProgramInfoLog(o);for(var u=0;u<t.uniforms.length;u++){var c=t.uniforms[u];this._locations[c]=e.getUniformLocation(o,c)}}}),nq=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function rq(e,t,n){var r={};for(var i in n)r[i+"_COUNT"]=n[i];return e.replace(nq,(function(e,n,i,o){var a="";isNaN(n)&&(n=n in t?t[n]:r[n]),isNaN(i)&&(i=i in t?t[i]:r[i]);for(var s=parseInt(n);s<parseInt(i);s++)a+="{"+o.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return a}))}function iq(e,t,n){var r=[];if(t)for(var i in t){var o=t[i];o>0&&r.push("#define "+i.toUpperCase()+"_COUNT "+o)}if(n)for(var a=0;a<n.length;a++){var s=n[a];r.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in e){var l=e[s];null===l?r.push("#define "+s):r.push("#define "+s+" "+l.toString())}return r.join("\n")}function oq(e){this._renderer=e,this._cache={}}oq.prototype.getProgram=function(e,t,n){var r=this._cache,i=e.isSkinnedMesh&&e.isSkinnedMesh(),o=e.isInstancedMesh&&e.isInstancedMesh(),a="s"+t.shader.shaderID+"m"+t.getProgramKey();if(n&&(a+="se"+n.getProgramKey(e.lightGroup)),i&&(a+=",sk"+e.joints.length),o&&(a+=",is"),y=r[a])return y;var s=n?n.getLightsNumbers(e.lightGroup):{},l=this._renderer,u=l.gl,c=t.getEnabledTextures(),h="";if(i){var d={SKINNING:null,JOINT_COUNT:e.joints.length};e.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),h+="\n"+iq(d)+"\n"}o&&(h+="\n#define INSTANCING\n");var p=h+iq(t.vertexDefines,s,c),f=h+iq(t.fragmentDefines,s,c),g=p+"\n"+t.shader.vertex,m=["OES_standard_derivatives","EXT_shader_texture_lod"].filter((function(e){return null!=l.getGLExtension(e)}));m.indexOf("EXT_shader_texture_lod")>=0&&(f+="\n#define SUPPORT_TEXTURE_LOD"),m.indexOf("OES_standard_derivatives")>=0&&(f+="\n#define SUPPORT_STANDARD_DERIVATIVES");var v,y,_=function(e){for(var t=[],n=0;n<e.length;n++)t.push("#extension GL_"+e[n]+" : enable");return t.join("\n")}(m)+"\n"+(["precision",v=t.precision,"float"].join(" ")+";\n"+["precision",v,"int"].join(" ")+";\n"+["precision",v,"sampler2D"].join(" ")+";\n\n")+f+"\n"+t.shader.fragment,x=rq(g,t.vertexDefines,s),b=rq(_,t.fragmentDefines,s);(y=new tq).uniformSemantics=t.shader.uniformSemantics,y.attributes=t.shader.attributes;var w=y.buildProgram(u,t.shader,x,b);return y.__error=w,r[a]=y,y};var aq=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,sq=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,lq=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,uq={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"};function cq(e){for(var t=[],n=0;n<e;n++)t[n]=0;return t}var hq={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return cq(2)},vec3:function(){return cq(3)},vec4:function(){return cq(4)},ivec2:function(){return cq(2)},ivec3:function(){return cq(3)},ivec4:function(){return cq(4)},mat2:function(){return cq(4)},mat3:function(){return cq(9)},mat4:function(){return cq(16)},array:function(){return[]}},dq=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],pq=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],fq=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],gq={vec4:4,vec3:3,vec2:2,float:1},mq={},vq={};function yq(e){return e.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function _q(){console.error("Wrong uniform/attributes syntax")}function xq(e,t){for(var n=/[,=\(\):]/,r=t.replace(/:\s*\[\s*(.*)\s*\]/g,"="+e+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),i=[],o=0;o<r.length;o++)r[o].match(n)?i.push(r[o].charAt(0),r[o].slice(1)):i.push(r[o]);var a,s=0,l={},u=null;function c(e){e||_q();var t=e.match(/\[(.*?)\]/);a=e.replace(/\[(.*?)\]/,""),l[a]={},t&&(l[a].isArray=!0,l[a].arraySize=t[1])}c((r=i)[0]);for(o=1;o<r.length;o++){var h=r[o];if(h)if("="!==h)if(":"!==h)if(","!==h)if(")"!==h)if("("!==h)if(h.indexOf("vec")>=0){if(1!==s&&4!==s){_q();break}s=2,u=[]}else if(1!==s)if(4!==s)c(h),s=0;else{var d=h;dq.indexOf(d)>=0||pq.indexOf(d)>=0||fq.indexOf(d)>=0?l[a].semantic=d:"ignore"===d||"unconfigurable"===d?l[a].ignore=!0:l[a].value="bool"===e?"true"===d:parseFloat(d)}else l[a].value="bool"===e?"true"===h:parseFloat(h),u=null;else{if(2!==s){_q();break}if(!(u instanceof Array)){_q();break}u.push(+r[++o])}else l[a].value=new wZ.Float32Array(u),u=null,s=5;else if(2===s){if(!(u instanceof Array)){_q();break}u.push(+r[++o])}else s=5;else s=4;else{if(0!==s&&3!==s){_q();break}s=1}}return l}function bq(e,t){"object"==typeof e&&(t=e.fragment,e=e.vertex),e=yq(e),t=yq(t),this._shaderID=function(e,t){var n="vertex:"+e+"fragment:"+t;if(mq[n])return mq[n];var r=xY.genGUID();return mq[n]=r,vq[r]={vertex:e,fragment:t},r}(e,t),this._vertexCode=bq.parseImport(e),this._fragmentCode=bq.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}bq.prototype={constructor:bq,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},_parseImport:function(){this._vertexCode=bq.parseImport(this.vertex),this._fragmentCode=bq.parseImport(this.fragment)},_addSemanticUniform:function(e,t,n){if(dq.indexOf(n)>=0)this.attributeSemantics[n]={symbol:e,type:t};else if(fq.indexOf(n)>=0){var r=!1,i=n;n.match(/TRANSPOSE$/)&&(r=!0,i=n.slice(0,-9)),this.matrixSemantics[n]={symbol:e,type:t,isTranspose:r,semanticNoTranspose:i}}else pq.indexOf(n)>=0&&(this.uniformSemantics[n]={symbol:e,type:t})},_addMaterialUniform:function(e,t,n,r,i,o){o[e]={type:n,value:i?hq.array:r||hq[t],semantic:null}},_parseUniforms:function(){var e={},t=this,n="vertex";function r(e){return null!=e?function(){return e}:null}function i(i,o,a){var s=xq(o,a),l=[];for(var u in s){var c=s[u],h=c.semantic,d=u,p=uq[o],f=r(s[u].value);s[u].isArray&&(d+="["+s[u].arraySize+"]",p+="v"),l.push(d),t._uniformList.push(u),c.ignore||("sampler2D"!==o&&"samplerCube"!==o||(t.textures[u]={shaderType:n,type:o}),h?t._addSemanticUniform(u,p,h):t._addMaterialUniform(u,o,p,f,s[u].isArray,e))}return l.length>0?"uniform "+o+" "+l.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(aq,i),n="fragment",this._fragmentCode=this._fragmentCode.replace(aq,i),t.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(sq,(function(n,r,i){var o=xq(r,i),a=gq[r]||1,s=[];for(var l in o){var u=o[l].semantic;if(e[l]={type:"float",size:a,semantic:u||null},u){if(dq.indexOf(u)<0)throw new Error('Unkown semantic "'+u+'"');t.attributeSemantics[u]={symbol:l,type:r}}s.push(l)}return"attribute "+r+" "+s.join(",")+";\n"})),this.attributes=e},_parseDefines:function(){var e=this,t="vertex";function n(n,r,i){var o="vertex"===t?e.vertexDefines:e.fragmentDefines;return o[r]||(o[r]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(lq,n),t="fragment",this._fragmentCode=this._fragmentCode.replace(lq,n)},clone:function(){var e=vq[this._shaderID];return new bq(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(bq.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(bq.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(bq.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(bq.prototype,"uniforms",{get:function(){return this._uniformList}}));var wq=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;bq.parseImport=function(e){return e=e.replace(wq,(function(e,t,n){return(e=bq.source(n))?bq.parseImport(e):(console.error('Shader chunk "'+n+'" not existed in library'),"")}))};var Sq=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;bq.import=function(e){e.replace(Sq,(function(e,t,n,r){if(r=r.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var i,o=n.split("."),a=bq.codes,s=0;s<o.length-1;)a[i=o[s++]]||(a[i]={}),a=a[i];a[i=o[s]]=r}return r}))},bq.codes={},bq.source=function(e){for(var t=e.split("."),n=bq.codes,r=0;n&&r<t.length;){n=n[t[r++]]}return"string"!=typeof n?(console.error('Shader "'+e+'" not existed in library'),""):n};var Tq="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end",Mq={create:function(){var e=new XZ(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},clone:function(e){var t=new XZ(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(i*A-r*I-o*D)*E,e[2]=(g*S-m*w+v*b)*E,e[3]=(d*w-h*S-p*b)*E,e[4]=(l*C-a*I-u*M)*E,e[5]=(n*I-i*C+o*M)*E,e[6]=(m*x-f*S-v*_)*E,e[7]=(c*S-d*x+p*_)*E,e[8]=(a*A-s*C+u*T)*E,e[9]=(r*C-n*A-o*T)*E,e[10]=(f*w-g*x+v*y)*E,e[11]=(h*x-c*w-p*y)*E,e[12]=(s*M-a*D-l*T)*E,e[13]=(n*D-r*M+i*T)*E,e[14]=(g*_-f*b-m*y)*E,e[15]=(c*b-h*_+d*y)*E,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15];return e[0]=s*(d*v-p*m)-h*(l*v-u*m)+g*(l*p-u*d),e[1]=-(r*(d*v-p*m)-h*(i*v-o*m)+g*(i*p-o*d)),e[2]=r*(l*v-u*m)-s*(i*v-o*m)+g*(i*u-o*l),e[3]=-(r*(l*p-u*d)-s*(i*p-o*d)+h*(i*u-o*l)),e[4]=-(a*(d*v-p*m)-c*(l*v-u*m)+f*(l*p-u*d)),e[5]=n*(d*v-p*m)-c*(i*v-o*m)+f*(i*p-o*d),e[6]=-(n*(l*v-u*m)-a*(i*v-o*m)+f*(i*u-o*l)),e[7]=n*(l*p-u*d)-a*(i*p-o*d)+c*(i*u-o*l),e[8]=a*(h*v-p*g)-c*(s*v-u*g)+f*(s*p-u*h),e[9]=-(n*(h*v-p*g)-c*(r*v-o*g)+f*(r*p-o*h)),e[10]=n*(s*v-u*g)-a*(r*v-o*g)+f*(r*u-o*s),e[11]=-(n*(s*p-u*h)-a*(r*p-o*h)+c*(r*u-o*s)),e[12]=-(a*(h*m-d*g)-c*(s*m-l*g)+f*(s*d-l*h)),e[13]=n*(h*m-d*g)-c*(r*m-i*g)+f*(r*d-i*h),e[14]=-(n*(s*m-l*g)-a*(r*m-i*g)+f*(r*l-i*s)),e[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],g=e[14],m=e[15];return(t*a-n*o)*(h*m-d*g)-(t*s-r*o)*(c*m-d*f)+(t*l-i*o)*(c*g-h*f)+(n*s-r*a)*(u*m-d*p)-(n*l-i*a)*(u*g-h*p)+(r*l-i*s)*(u*f-c*p)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],g=t[12],m=t[13],v=t[14],y=t[15],_=n[0],x=n[1],b=n[2],w=n[3];return e[0]=_*r+x*s+b*h+w*g,e[1]=_*i+x*l+b*d+w*m,e[2]=_*o+x*u+b*p+w*v,e[3]=_*a+x*c+b*f+w*y,_=n[4],x=n[5],b=n[6],w=n[7],e[4]=_*r+x*s+b*h+w*g,e[5]=_*i+x*l+b*d+w*m,e[6]=_*o+x*u+b*p+w*v,e[7]=_*a+x*c+b*f+w*y,_=n[8],x=n[9],b=n[10],w=n[11],e[8]=_*r+x*s+b*h+w*g,e[9]=_*i+x*l+b*d+w*m,e[10]=_*o+x*u+b*p+w*v,e[11]=_*a+x*c+b*f+w*y,_=n[12],x=n[13],b=n[14],w=n[15],e[12]=_*r+x*s+b*h+w*g,e[13]=_*i+x*l+b*d+w*m,e[14]=_*o+x*u+b*p+w*v,e[15]=_*a+x*c+b*f+w*y,e},multiplyAffine:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[4],s=t[5],l=t[6],u=t[8],c=t[9],h=t[10],d=t[12],p=t[13],f=t[14],g=n[0],m=n[1],v=n[2];return e[0]=g*r+m*a+v*u,e[1]=g*i+m*s+v*c,e[2]=g*o+m*l+v*h,g=n[4],m=n[5],v=n[6],e[4]=g*r+m*a+v*u,e[5]=g*i+m*s+v*c,e[6]=g*o+m*l+v*h,g=n[8],m=n[9],v=n[10],e[8]=g*r+m*a+v*u,e[9]=g*i+m*s+v*c,e[10]=g*o+m*l+v*h,g=n[12],m=n[13],v=n[14],e[12]=g*r+m*a+v*u+d,e[13]=g*i+m*s+v*c+p,e[14]=g*o+m*l+v*h+f,e}};Mq.mul=Mq.multiply,Mq.mulAffine=Mq.multiplyAffine,Mq.translate=function(e,t,n){var r,i,o,a,s,l,u,c,h,d,p,f,g=n[0],m=n[1],v=n[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*v+t[12],e[13]=t[1]*g+t[5]*m+t[9]*v+t[13],e[14]=t[2]*g+t[6]*m+t[10]*v+t[14],e[15]=t[3]*g+t[7]*m+t[11]*v+t[15]):(r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*g+s*m+h*v+t[12],e[13]=i*g+l*m+d*v+t[13],e[14]=o*g+u*m+p*v+t[14],e[15]=a*g+c*m+f*v+t[15]),e},Mq.scale=function(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Mq.rotate=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f,g,m,v,y,_,x,b,w,S,T,M,C,D,A=r[0],I=r[1],E=r[2],L=Math.sqrt(A*A+I*I+E*E);return Math.abs(L)<jZ?null:(A*=L=1/L,I*=L,E*=L,i=Math.sin(n),a=1-(o=Math.cos(n)),s=t[0],l=t[1],u=t[2],c=t[3],h=t[4],d=t[5],p=t[6],f=t[7],g=t[8],m=t[9],v=t[10],y=t[11],_=A*A*a+o,x=I*A*a+E*i,b=E*A*a-I*i,w=A*I*a-E*i,S=I*I*a+o,T=E*I*a+A*i,M=A*E*a+I*i,C=I*E*a-A*i,D=E*E*a+o,e[0]=s*_+h*x+g*b,e[1]=l*_+d*x+m*b,e[2]=u*_+p*x+v*b,e[3]=c*_+f*x+y*b,e[4]=s*w+h*S+g*T,e[5]=l*w+d*S+m*T,e[6]=u*w+p*S+v*T,e[7]=c*w+f*S+y*T,e[8]=s*M+h*C+g*D,e[9]=l*M+d*C+m*D,e[10]=u*M+p*C+v*D,e[11]=c*M+f*C+y*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},Mq.rotateX=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+u*r,e[5]=a*i+c*r,e[6]=s*i+h*r,e[7]=l*i+d*r,e[8]=u*i-o*r,e[9]=c*i-a*r,e[10]=h*i-s*r,e[11]=d*i-l*r,e},Mq.rotateY=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-u*r,e[1]=a*i-c*r,e[2]=s*i-h*r,e[3]=l*i-d*r,e[8]=o*r+u*i,e[9]=a*r+c*i,e[10]=s*r+h*i,e[11]=l*r+d*i,e},Mq.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},Mq.fromRotationTranslation=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,p=i*l,f=i*u,g=o*u,m=a*s,v=a*l,y=a*u;return e[0]=1-(p+g),e[1]=h+y,e[2]=d-v,e[3]=0,e[4]=h-y,e[5]=1-(c+g),e[6]=f+m,e[7]=0,e[8]=d+v,e[9]=f-m,e[10]=1-(c+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},Mq.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[1]=c+v,e[2]=d-m,e[3]=0,e[4]=c-v,e[5]=1-u-f,e[6]=p+g,e[7]=0,e[8]=d+m,e[9]=p-g,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Mq.frustum=function(e,t,n,r,i,o,a){var s=1/(n-t),l=1/(i-r),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},Mq.perspective=function(e,t,n,r,i){var o=1/Math.tan(t/2),a=1/(r-i);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*a,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*a,e[15]=0,e},Mq.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},Mq.lookAt=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,p,f=t[0],g=t[1],m=t[2],v=r[0],y=r[1],_=r[2],x=n[0],b=n[1],w=n[2];return Math.abs(f-x)<jZ&&Math.abs(g-b)<jZ&&Math.abs(m-w)<jZ?Mq.identity(e):(c=f-x,h=g-b,d=m-w,i=y*(d*=p=1/Math.sqrt(c*c+h*h+d*d))-_*(h*=p),o=_*(c*=p)-v*d,a=v*h-y*c,(p=Math.sqrt(i*i+o*o+a*a))?(i*=p=1/p,o*=p,a*=p):(i=0,o=0,a=0),s=h*a-d*o,l=d*i-c*a,u=c*o-h*i,(p=Math.sqrt(s*s+l*l+u*u))?(s*=p=1/p,l*=p,u*=p):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*f+o*g+a*m),e[13]=-(s*f+l*g+u*m),e[14]=-(c*f+h*g+d*m),e[15]=1,e)},Mq.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))};var Cq={create:function(){var e=new XZ(3);return e[0]=0,e[1]=0,e[2]=0,e},clone:function(e){var t=new XZ(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},fromValues:function(e,t,n){var r=new XZ(3);return r[0]=e,r[1]=t,r[2]=n,r},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set:function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}};Cq.sub=Cq.subtract,Cq.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e},Cq.mul=Cq.multiply,Cq.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},Cq.div=Cq.divide,Cq.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e},Cq.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e},Cq.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},Cq.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},Cq.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},Cq.dist=Cq.distance,Cq.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},Cq.sqrDist=Cq.squaredDistance,Cq.length=function(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)},Cq.len=Cq.length,Cq.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},Cq.sqrLen=Cq.squaredLength,Cq.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Cq.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Cq.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o),e},Cq.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},Cq.cross=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e},Cq.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e},Cq.random=function(e,t){t=t||1;var n=2*YZ()*Math.PI,r=2*YZ()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e},Cq.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e},Cq.transformMat3=function(e,t,n){var r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e},Cq.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},Cq.rotateX=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Cq.rotateY=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Cq.rotateZ=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Cq.forEach=function(){var e=Cq.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=3),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}(),Cq.angle=function(e,t){var n=Cq.fromValues(e[0],e[1],e[2]),r=Cq.fromValues(t[0],t[1],t[2]);Cq.normalize(n,n),Cq.normalize(r,r);var i=Cq.dot(n,r);return i>1?0:Math.acos(i)},bq.import(Tq);var Dq=Mq.create,Aq={};function Iq(e){return e.material}function Eq(e,t,n){return t.uniforms[n].value}function Lq(e,t,n,r){return n!==r}function Nq(e){return!0}function Pq(){}var Oq={float:qY,byte:UY,ubyte:WY,short:jY,ushort:XY};function Rq(e,t,n){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=n,this.vao=null}function kq(e){var t,n;this.bind=function(e){t||((t=wZ.createCanvas()).width=t.height=1,t.getContext("2d"));var r=e.gl,i=!n;i&&(n=r.createTexture()),r.bindTexture(r.TEXTURE_2D,n),i&&r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},this.unbind=function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var zq=bY.extend((function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}}),(function(){this.canvas||(this.canvas=wZ.createCanvas());var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new TY(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}this._programMgr=new oq(this),this._placeholderTexture=new kq}),{resize:function(e,t){var n=this.canvas,r=this.devicePixelRatio;null!=e?(n.style&&(n.style.width=e+"px",n.style.height=t+"px"),n.width=e*r,n.height=t*r,this._width=e,this._height=t):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,n,r,i){if("object"==typeof e){var o=e;e=o.x,t=o.y,n=o.width,r=o.height,i=o.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,r*i),this.viewport={x:e,y:t,width:n,height:r,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,n,r){var i=this.gl,o=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var a=this.viewport,s=!1,l=a.devicePixelRatio;(a.width!==this._width||a.height!==this._height||l&&l!==this.devicePixelRatio||a.x||a.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(a.x*l,a.y*l,a.width*l,a.height*l)),i.clearColor(o[0],o[1],o[2],o[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(n||e.update(!1),e.updateLights(),t=t||e.getMainCamera()){t.update();var u=e.updateRenderList(t,!0);this._sceneRendering=e;var c=u.opaque,h=u.transparent,d=e.material;e.trigger("beforerender",this,e,t,u),r?(this.renderPreZ(c,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var p=Dq(),f=Cq.create(),g=0;g<h.length;g++){var m=h[g];Mq.multiplyAffine(p,t.viewMatrix.array,m.worldTransform.array),Cq.transformMat4(f,m.position.array,p),m.__depth=f[2]}this.renderPass(c,t,{getMaterial:function(e){return d||e.material},sortCompare:this.opaqueSortCompare}),this.renderPass(h,t,{getMaterial:function(e){return d||e.material},sortCompare:this.transparentSortCompare}),e.trigger("afterrender",this,e,t,u),this._sceneRendering=null}else console.error("Can't find camera in the scene.")},getProgram:function(e,t,n){return t=t||e.material,this._programMgr.getProgram(e,t,n)},validateProgram:function(e){if(e.__error){var t=e.__error;if(Aq[e.__uid__])return;if(Aq[e.__uid__]=!0,this.throwError)throw new Error(t);this.trigger("error",t)}},updatePrograms:function(e,t,n){var r=n&&n.getMaterial||Iq;t=t||null;for(var i=0;i<e.length;i++){var o=e[i],a=r.call(this,o);if(i>0){var s=e[i-1],l=s.joints?s.joints.length:0;if((o.joints?o.joints.length:0)===l&&o.material===s.material&&o.lightGroup===s.lightGroup){o.__program=s.__program;continue}}var u=this._programMgr.getProgram(o,a,t);this.validateProgram(u),o.__program=u}},renderPass:function(e,t,n){this.trigger("beforerenderpass",this,e,t,n),(n=n||{}).getMaterial=n.getMaterial||Iq,n.getUniform=n.getUniform||Eq,n.isMaterialChanged=n.isMaterialChanged||Lq,n.beforeRender=n.beforeRender||Pq,n.afterRender=n.afterRender||Pq;var r=n.ifRender||Nq;this.updatePrograms(e,this._sceneRendering,n),n.sortCompare&&e.sort(n.sortCompare);var i=this.viewport,o=i.devicePixelRatio,a=[i.x*o,i.y*o,i.width*o,i.height*o],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],u=[a[2],a[3]],c=Date.now();t?(Mq.copy(Vq.VIEW,t.viewMatrix.array),Mq.copy(Vq.PROJECTION,t.projectionMatrix.array),Mq.copy(Vq.VIEWINVERSE,t.worldTransform.array)):(Mq.identity(Vq.VIEW),Mq.identity(Vq.PROJECTION),Mq.identity(Vq.VIEWINVERSE)),Mq.multiply(Vq.VIEWPROJECTION,Vq.PROJECTION,Vq.VIEW),Mq.invert(Vq.PROJECTIONINVERSE,Vq.PROJECTION),Mq.invert(Vq.VIEWPROJECTIONINVERSE,Vq.VIEWPROJECTION);for(var h,d,p,f,g,m,v,y,_,x,b,w,S=this.gl,T=this._sceneRendering,M=0;M<e.length;M++){var C,D=e[M],A=null!=D.worldTransform;if(r(D)){A&&(C=D.isSkinnedMesh&&D.isSkinnedMesh()?D.offsetMatrix?D.offsetMatrix.array:Vq.IDENTITY:D.worldTransform.array);var I=D.geometry,E=n.getMaterial.call(this,D),L=D.__program,N=E.shader,P=I.__uid__+"-"+L.__uid__,O=P!==x;x=P,A&&(Mq.copy(Vq.WORLD,C),Mq.multiply(Vq.WORLDVIEWPROJECTION,Vq.VIEWPROJECTION,C),Mq.multiplyAffine(Vq.WORLDVIEW,Vq.VIEW,C),(N.matrixSemantics.WORLDINVERSE||N.matrixSemantics.WORLDINVERSETRANSPOSE)&&Mq.invert(Vq.WORLDINVERSE,C),(N.matrixSemantics.WORLDVIEWINVERSE||N.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Mq.invert(Vq.WORLDVIEWINVERSE,Vq.WORLDVIEW),(N.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||N.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Mq.invert(Vq.WORLDVIEWPROJECTIONINVERSE,Vq.WORLDVIEWPROJECTION)),D.beforeRender&&D.beforeRender(this),n.beforeRender.call(this,D,E,h);var R=L!==d;R?(L.bind(this),L.setUniformOfSemantic(S,"VIEWPORT",a),L.setUniformOfSemantic(S,"WINDOW_SIZE",l),t&&(L.setUniformOfSemantic(S,"NEAR",t.near),L.setUniformOfSemantic(S,"FAR",t.far)),L.setUniformOfSemantic(S,"DEVICEPIXELRATIO",o),L.setUniformOfSemantic(S,"TIME",c),L.setUniformOfSemantic(S,"VIEWPORT_SIZE",u),T&&T.setLightUniforms(L,D.lightGroup,this)):L=d,(R||n.isMaterialChanged(D,p,E,h))&&(E.depthTest!==f&&(E.depthTest?S.enable(S.DEPTH_TEST):S.disable(S.DEPTH_TEST),f=E.depthTest),E.depthMask!==g&&(S.depthMask(E.depthMask),g=E.depthMask),E.transparent!==_&&(E.transparent?S.enable(S.BLEND):S.disable(S.BLEND),_=E.transparent),E.transparent&&(E.blend?E.blend(S):(S.blendEquationSeparate(S.FUNC_ADD,S.FUNC_ADD),S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA))),w=this._bindMaterial(D,E,L,p||null,h||null,d||null,n.getUniform),h=E);var k=N.matrixSemanticKeys;if(A)for(var z=0;z<k.length;z++){var V=k[z],B=N.matrixSemantics[V],F=Vq[V];if(B.isTranspose){var G=Vq[B.semanticNoTranspose];Mq.transpose(F,G)}L.setUniform(S,B.type,B.symbol,F)}D.cullFace!==v&&(v=D.cullFace,S.cullFace(v)),D.frontFace!==y&&(y=D.frontFace,S.frontFace(y)),D.culling!==m&&((m=D.culling)?S.enable(S.CULL_FACE):S.disable(S.CULL_FACE)),this._updateSkeleton(D,L,w),O&&(b=this._bindVAO(null,N,I,L)),this._renderObject(D,b,L),n.afterRender(this,D),D.afterRender&&D.afterRender(this),d=L,p=D}}this.trigger("afterrenderpass",this,e,t,n)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(e,t,n){var r=this.gl,i=e.skeleton;if(i)if(i.update(),e.joints.length>this.getMaxJointNumber()){var o=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,o,n),t.setUniform(r,"1i","skinMatricesTexture",n),t.setUniform(r,"1f","skinMatricesTextureSize",o.width)}else{var a=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(r,"SKIN_MATRIX",a)}},_renderObject:function(e,t,n){var r=this.gl,i=e.geometry,o=e.mode;null==o&&(o=4);var a=null,s=e.isInstancedMesh&&e.isInstancedMesh();if(!s||(a=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(e,n,a)),t.indicesBuffer){var u=this.getGLExtension("OES_element_index_uint")&&i.indices instanceof Uint32Array?r.UNSIGNED_INT:r.UNSIGNED_SHORT;s?a.drawElementsInstancedANGLE(o,t.indicesBuffer.count,u,0,e.getInstanceCount()):r.drawElements(o,t.indicesBuffer.count,u,0)}else s?a.drawArraysInstancedANGLE(o,0,i.vertexCount,e.getInstanceCount()):r.drawArrays(o,0,i.vertexCount);if(s)for(var c=0;c<l.length;c++)r.disableVertexAttribArray(l[c])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(e,t,n){for(var r=this.gl,i=e.getInstancedAttributesBuffers(this),o=[],a=0;a<i.length;a++){var s=i[a],l=t.getAttribLocation(r,s.symbol);if(!(l<0)){var u=Oq[s.type]||r.FLOAT;r.enableVertexAttribArray(l),r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.vertexAttribPointer(l,s.size,u,!1,0,0),n.vertexAttribDivisorANGLE(l,s.divisor),o.push(l)}}return o},_bindMaterial:function(e,t,n,r,i,o,a){for(var s=this.gl,l=o===n,u=n.currentTextureSlot(),c=t.getEnabledUniforms(),h=t.getTextureUniforms(),d=this._placeholderTexture,p=0;p<h.length;p++){var f=a(e,t,v=h[p]);if("t"===(m=t.uniforms[v].type)&&f)f.__slot=-1;else if("tv"===m)for(var g=0;g<f.length;g++)f[g]&&(f[g].__slot=-1)}d.__slot=-1;for(p=0;p<c.length;p++){var m,v=c[p],y=t.uniforms[v],_=(f=a(e,t,v),"t"===(m=y.type));if(_&&(f&&f.isRenderable()||(f=d)),i&&l){var x=a(r,i,v);if(_&&(x&&x.isRenderable()||(x=d)),x===f){if(_)n.takeCurrentTextureSlot(this,null);else if("tv"===m&&f)for(g=0;g<f.length;g++)n.takeCurrentTextureSlot(this,null);continue}}if(null!=f)if(_)if(f.__slot<0){var b=n.currentTextureSlot();n.setUniform(s,"1i",v,b)&&(n.takeCurrentTextureSlot(this,f),f.__slot=b)}else n.setUniform(s,"1i",v,f.__slot);else if(Array.isArray(f)){if(0===f.length)continue;if("tv"===m){if(!n.hasUniform(v))continue;var w=[];for(g=0;g<f.length;g++){var S=f[g];if(S.__slot<0){b=n.currentTextureSlot();w.push(b),n.takeCurrentTextureSlot(this,S),S.__slot=b}else w.push(S.__slot)}n.setUniform(s,"1iv",v,w)}else n.setUniform(s,y.type,v,f)}else n.setUniform(s,y.type,v,f)}var T=n.currentTextureSlot();return n.resetTextureSlot(u),T},_bindVAO:function(e,t,n,r){var i=!n.dynamic,o=this.gl,a=this.__uid__+"-"+r.__uid__,s=n.__vaoCache[a];if(!s){var l=n.getBufferChunks(this);if(!l||!l.length)return;for(var u=l[0],c=u.attributeBuffers,h=u.indicesBuffer,d=[],p=[],f=0;f<c.length;f++){var g,m=(w=c[f]).name,v=w.semantic;if(v){var y=t.attributeSemantics[v];g=y&&y.symbol}else g=m;g&&r.attributes[g]&&(d.push(w),p.push(g))}s=new Rq(d,p,h),i&&(n.__vaoCache[a]=s)}var _=!0;e&&i&&(null==s.vao?s.vao=e.createVertexArrayOES():_=!1,e.bindVertexArrayOES(s.vao));d=s.availableAttributes,h=s.indicesBuffer;if(_){var x=r.enableAttributes(this,s.availableAttributeSymbols,e&&i&&s);for(f=0;f<d.length;f++){var b=x[f];if(-1!==b){var w,S=(w=d[f]).buffer,T=w.size,M=Oq[w.type]||o.FLOAT;o.bindBuffer(o.ARRAY_BUFFER,S),o.vertexAttribPointer(b,T,M,!1,0,0)}}n.isUseIndices()&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.buffer)}return s},renderPreZ:function(e,t,n){var r=this.gl,i=this._prezMaterial||new WZ({shader:new bq(bq.source("clay.prez.vertex"),bq.source("clay.prez.fragment"))});this._prezMaterial=i,r.colorMask(!1,!1,!1,!1),r.depthMask(!0),this.renderPass(e,n,{ifRender:function(e){return!e.ignorePreZ},isMaterialChanged:function(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)},getUniform:function(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)},getMaterial:function(){return i},sort:this.opaqueSortCompare}),r.colorMask(!0,!0,!0,!0),r.depthMask(!0)},disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){e.getParent()&&e.getParent().remove(e);var r={};e.traverse((function(e){var i=e.material;if(e.geometry&&t&&e.geometry.dispose(this),n&&i&&!r[i.__uid__]){for(var o=i.getTextureUniforms(),a=0;a<o.length;a++){var s=o[a],l=i.uniforms[s].value,u=i.uniforms[s].type;if(l)if("t"===u)l.dispose&&l.dispose(this);else if("tv"===u)for(var c=0;c<l.length;c++)l[c]&&l[c].dispose&&l[c].dispose(this)}r[i.__uid__]=!0}e.dispose&&e.dispose(this)}),this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new qZ),t=this._height-t;var r=this.viewport,i=n.array;return i[0]=(e-r.x)/r.width,i[0]=2*i[0]-1,i[1]=(t-r.y)/r.height,i[1]=2*i[1]-1,n}});zq.opaqueSortCompare=zq.prototype.opaqueSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.renderOrder-t.renderOrder},zq.transparentSortCompare=zq.prototype.transparentSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var Vq={IDENTITY:Dq(),WORLD:Dq(),VIEW:Dq(),PROJECTION:Dq(),WORLDVIEW:Dq(),VIEWPROJECTION:Dq(),WORLDVIEWPROJECTION:Dq(),WORLDINVERSE:Dq(),VIEWINVERSE:Dq(),PROJECTIONINVERSE:Dq(),WORLDVIEWINVERSE:Dq(),VIEWPROJECTIONINVERSE:Dq(),WORLDVIEWPROJECTIONINVERSE:Dq(),WORLDTRANSPOSE:Dq(),VIEWTRANSPOSE:Dq(),PROJECTIONTRANSPOSE:Dq(),WORLDVIEWTRANSPOSE:Dq(),VIEWPROJECTIONTRANSPOSE:Dq(),WORLDVIEWPROJECTIONTRANSPOSE:Dq(),WORLDINVERSETRANSPOSE:Dq(),VIEWINVERSETRANSPOSE:Dq(),PROJECTIONINVERSETRANSPOSE:Dq(),WORLDVIEWINVERSETRANSPOSE:Dq(),VIEWPROJECTIONINVERSETRANSPOSE:Dq(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Dq()};zq.COLOR_BUFFER_BIT=DY,zq.DEPTH_BUFFER_BIT=MY,zq.STENCIL_BUFFER_BIT=CY;var Bq=function(e,t,n){e=e||0,t=t||0,n=n||0,this.array=Cq.fromValues(e,t,n),this._dirty=!0};Bq.prototype={constructor:Bq,add:function(e){return Cq.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new Bq(this.x,this.y,this.z)},copy:function(e){return Cq.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return Cq.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return Cq.dist(this.array,e.array)},distance:function(e){return Cq.distance(this.array,e.array)},div:function(e){return Cq.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return Cq.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return Cq.dot(this.array,e.array)},len:function(){return Cq.len(this.array)},length:function(){return Cq.length(this.array)},lerp:function(e,t,n){return Cq.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return Cq.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return Cq.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return Cq.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return Cq.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return Cq.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Cq.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return Cq.random(this.array,e),this._dirty=!0,this},scale:function(e){return Cq.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return Cq.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return Cq.sqrDist(this.array,e.array)},squaredDistance:function(e){return Cq.squaredDistance(this.array,e.array)},sqrLen:function(){return Cq.sqrLen(this.array)},squaredLength:function(){return Cq.squaredLength(this.array)},sub:function(e){return Cq.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return Cq.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return Cq.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return Cq.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return Cq.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(0===(e=e.array)[15]){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){Bq.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){Bq.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Fq=Object.defineProperty;if(Fq){var Gq=Bq.prototype;Fq(Gq,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Fq(Gq,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Fq(Gq,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}function Hq(e,t,n){return e<t?t:e>n?n:e}Bq.add=function(e,t,n){return Cq.add(e.array,t.array,n.array),e._dirty=!0,e},Bq.set=function(e,t,n,r){Cq.set(e.array,t,n,r),e._dirty=!0},Bq.copy=function(e,t){return Cq.copy(e.array,t.array),e._dirty=!0,e},Bq.cross=function(e,t,n){return Cq.cross(e.array,t.array,n.array),e._dirty=!0,e},Bq.distance=Bq.dist=function(e,t){return Cq.distance(e.array,t.array)},Bq.div=function(e,t,n){return Cq.divide(e.array,t.array,n.array),e._dirty=!0,e},Bq.divide=Bq.div,Bq.dot=function(e,t){return Cq.dot(e.array,t.array)},Bq.len=function(e){return Cq.length(e.array)},Bq.lerp=function(e,t,n,r){return Cq.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},Bq.min=function(e,t,n){return Cq.min(e.array,t.array,n.array),e._dirty=!0,e},Bq.max=function(e,t,n){return Cq.max(e.array,t.array,n.array),e._dirty=!0,e},Bq.mul=function(e,t,n){return Cq.multiply(e.array,t.array,n.array),e._dirty=!0,e},Bq.multiply=Bq.mul,Bq.negate=function(e,t){return Cq.negate(e.array,t.array),e._dirty=!0,e},Bq.normalize=function(e,t){return Cq.normalize(e.array,t.array),e._dirty=!0,e},Bq.random=function(e,t){return Cq.random(e.array,t),e._dirty=!0,e},Bq.scale=function(e,t,n){return Cq.scale(e.array,t.array,n),e._dirty=!0,e},Bq.scaleAndAdd=function(e,t,n,r){return Cq.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},Bq.squaredDistance=Bq.sqrDist=function(e,t){return Cq.sqrDist(e.array,t.array)},Bq.squaredLength=Bq.sqrLen=function(e){return Cq.sqrLen(e.array)},Bq.sub=function(e,t,n){return Cq.subtract(e.array,t.array,n.array),e._dirty=!0,e},Bq.subtract=Bq.sub,Bq.transformMat3=function(e,t,n){return Cq.transformMat3(e.array,t.array,n.array),e._dirty=!0,e},Bq.transformMat4=function(e,t,n){return Cq.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},Bq.transformQuat=function(e,t,n){return Cq.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var Uq=Math.atan2,Wq=Math.asin,jq=Math.abs;Bq.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=t[0],o=t[1],a=t[2],s=t[3],l=i*i,u=o*o,c=a*a,h=s*s;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=Uq(2*(i*s-o*a),h-l-u+c),r[1]=Wq(Hq(2*(i*a+o*s),-1,1)),r[2]=Uq(2*(a*s-i*o),h+l-u-c);break;case"YXZ":r[0]=Wq(Hq(2*(i*s-o*a),-1,1)),r[1]=Uq(2*(i*a+o*s),h-l-u+c),r[2]=Uq(2*(i*o+a*s),h-l+u-c);break;case"ZXY":r[0]=Wq(Hq(2*(i*s+o*a),-1,1)),r[1]=Uq(2*(o*s-a*i),h-l-u+c),r[2]=Uq(2*(a*s-i*o),h-l+u-c);break;case"ZYX":r[0]=Uq(2*(i*s+a*o),h-l-u+c),r[1]=Wq(Hq(2*(o*s-i*a),-1,1)),r[2]=Uq(2*(i*o+a*s),h+l-u-c);break;case"YZX":r[0]=Uq(2*(i*s-a*o),h-l+u-c),r[1]=Uq(2*(o*s-i*a),h+l-u-c),r[2]=Wq(Hq(2*(i*o+a*s),-1,1));break;case"XZY":r[0]=Uq(2*(i*s+o*a),h-l+u-c),r[1]=Uq(2*(i*a+o*s),h+l-u-c),r[2]=Wq(Hq(2*(a*s-i*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},Bq.eulerFromMat3=function(e,t,n){var r=t.array,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],u=r[7],c=r[2],h=r[5],d=r[8],p=e.array;switch(n=(n||"XYZ").toUpperCase()){case"XYZ":p[1]=Wq(Hq(a,-1,1)),jq(a)<.99999?(p[0]=Uq(-u,d),p[2]=Uq(-o,i)):(p[0]=Uq(h,l),p[2]=0);break;case"YXZ":p[0]=Wq(-Hq(u,-1,1)),jq(u)<.99999?(p[1]=Uq(a,d),p[2]=Uq(s,l)):(p[1]=Uq(-c,i),p[2]=0);break;case"ZXY":p[0]=Wq(Hq(h,-1,1)),jq(h)<.99999?(p[1]=Uq(-c,d),p[2]=Uq(-o,l)):(p[1]=0,p[2]=Uq(s,i));break;case"ZYX":p[1]=Wq(-Hq(c,-1,1)),jq(c)<.99999?(p[0]=Uq(h,d),p[2]=Uq(s,i)):(p[0]=0,p[2]=Uq(-o,l));break;case"YZX":p[2]=Wq(Hq(s,-1,1)),jq(s)<.99999?(p[0]=Uq(-u,l),p[1]=Uq(-c,i)):(p[0]=0,p[1]=Uq(a,d));break;case"XZY":p[2]=Wq(-Hq(o,-1,1)),jq(o)<.99999?(p[0]=Uq(h,l),p[1]=Uq(a,i)):(p[0]=Uq(-u,d),p[1]=0);break;default:console.warn("Unkown order: "+n)}return e._dirty=!0,e},Object.defineProperties(Bq,{POSITIVE_X:{get:function(){return new Bq(1,0,0)}},NEGATIVE_X:{get:function(){return new Bq(-1,0,0)}},POSITIVE_Y:{get:function(){return new Bq(0,1,0)}},NEGATIVE_Y:{get:function(){return new Bq(0,-1,0)}},POSITIVE_Z:{get:function(){return new Bq(0,0,1)}},NEGATIVE_Z:{get:function(){return new Bq(0,0,-1)}},UP:{get:function(){return new Bq(0,1,0)}},ZERO:{get:function(){return new Bq}}});var Xq,Yq,Zq,qq,Kq=function(e,t){this.origin=e||new Bq,this.direction=t||new Bq};Kq.prototype={constructor:Kq,intersectPlane:function(e,t){var n=e.normal.array,r=e.distance,i=this.origin.array,o=this.direction.array,a=Cq.dot(n,o);if(0===a)return null;t||(t=new Bq);var s=(Cq.dot(n,i)-r)/a;return Cq.scaleAndAdd(t.array,i,o,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=Cq.dot(e.normal.array,this.direction.array);Cq.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=Cq.create();return function(t){Cq.sub(e,t,this.origin.array);var n=Cq.dot(e,this.direction.array);if(n<0)return Cq.distance(this.origin.array,t);var r=Cq.lenSquared(e);return Math.sqrt(r-n*n)}}(),intersectSphere:function(){var e=Cq.create();return function(t,n,r){var i=this.origin.array,o=this.direction.array;t=t.array,Cq.sub(e,t,i);var a=Cq.dot(e,o),s=Cq.squaredLength(e)-a*a,l=n*n;if(!(s>l)){var u=Math.sqrt(l-s),c=a-u,h=a+u;return r||(r=new Bq),c<0?h<0?null:(Cq.scaleAndAdd(r.array,i,o,h),r):(Cq.scaleAndAdd(r.array,i,o,c),r)}}}(),intersectBoundingBox:function(e,t){var n,r,i,o,a,s,l=this.direction.array,u=this.origin.array,c=e.min.array,h=e.max.array,d=1/l[0],p=1/l[1],f=1/l[2];if(d>=0?(n=(c[0]-u[0])*d,r=(h[0]-u[0])*d):(r=(c[0]-u[0])*d,n=(h[0]-u[0])*d),p>=0?(i=(c[1]-u[1])*p,o=(h[1]-u[1])*p):(o=(c[1]-u[1])*p,i=(h[1]-u[1])*p),n>o||i>r)return null;if((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),f>=0?(a=(c[2]-u[2])*f,s=(h[2]-u[2])*f):(s=(c[2]-u[2])*f,a=(h[2]-u[2])*f),n>s||a>r)return null;if((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0)return null;var g=n>=0?n:r;return t||(t=new Bq),Cq.scaleAndAdd(t.array,u,l,g),t},intersectTriangle:(Xq=Cq.create(),Yq=Cq.create(),Zq=Cq.create(),qq=Cq.create(),function(e,t,n,r,i,o){var a=this.direction.array,s=this.origin.array;e=e.array,t=t.array,n=n.array,Cq.sub(Xq,t,e),Cq.sub(Yq,n,e),Cq.cross(qq,Yq,a);var l=Cq.dot(Xq,qq);if(r){if(l>-1e-5)return null}else if(l>-1e-5&&l<1e-5)return null;Cq.sub(Zq,s,e);var u=Cq.dot(qq,Zq)/l;if(u<0||u>1)return null;Cq.cross(qq,Xq,Zq);var c=Cq.dot(a,qq)/l;if(c<0||c>1||u+c>1)return null;Cq.cross(qq,Xq,Yq);var h=-Cq.dot(Zq,qq)/l;return h<0?null:(i||(i=new Bq),o&&Bq.set(o,1-u-c,u,c),Cq.scaleAndAdd(i.array,s,a,h),i)}),applyTransform:function(e){Bq.add(this.direction,this.direction,this.origin),Bq.transformMat4(this.origin,this.origin,e),Bq.transformMat4(this.direction,this.direction,e),Bq.sub(this.direction,this.direction,this.origin),Bq.normalize(this.direction,this.direction)},copy:function(e){Bq.copy(this.origin,e.origin),Bq.copy(this.direction,e.direction)},clone:function(){var e=new Kq;return e.copy(this),e}};var $q={create:function(){var e=new XZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},clone:function(e){var t=new XZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues:function(e,t,n,r){var i=new XZ(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},set:function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},add:function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},subtract:function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}};$q.sub=$q.subtract,$q.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},$q.mul=$q.multiply,$q.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},$q.div=$q.divide,$q.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},$q.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},$q.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},$q.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},$q.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return Math.sqrt(n*n+r*r+i*i+o*o)},$q.dist=$q.distance,$q.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+i*i+o*o},$q.sqrDist=$q.squaredDistance,$q.length=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)},$q.len=$q.length,$q.squaredLength=function(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i},$q.sqrLen=$q.squaredLength,$q.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},$q.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},$q.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e[3]=t[3]*a),e},$q.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},$q.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e[3]=s+r*(n[3]-s),e},$q.random=function(e,t){return t=t||1,e[0]=YZ(),e[1]=YZ(),e[2]=YZ(),e[3]=YZ(),$q.normalize(e,e),$q.scale(e,e,t),e},$q.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e},$q.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,p=-a*r-s*i-l*o;return e[0]=c*u+p*-a+h*-l-d*-s,e[1]=h*u+p*-s+d*-a-c*-l,e[2]=d*u+p*-l+c*-s-h*-a,e},$q.forEach=function(){var e=$q.create();return function(t,n,r,i,o,a){var s,l;for(n||(n=4),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s<l;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],o(e,e,a),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var Jq={create:function(){var e=new XZ(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromMat4:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},clone:function(e){var t=new XZ(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},transpose:function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*a-s*u,d=-c*o+s*l,p=u*o-a*l,f=n*h+r*d+i*p;return f?(f=1/f,e[0]=h*f,e[1]=(-c*r+i*u)*f,e[2]=(s*r-i*a)*f,e[3]=d*f,e[4]=(c*n-i*l)*f,e[5]=(-s*n+i*o)*f,e[6]=p*f,e[7]=(-u*n+r*l)*f,e[8]=(a*n-r*o)*f,e):null},adjoint:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},determinant:function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8];return t*(u*o-a*l)+n*(-u*i+a*s)+r*(l*i-o*s)},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1],f=n[2],g=n[3],m=n[4],v=n[5],y=n[6],_=n[7],x=n[8];return e[0]=d*r+p*a+f*u,e[1]=d*i+p*s+f*c,e[2]=d*o+p*l+f*h,e[3]=g*r+m*a+v*u,e[4]=g*i+m*s+v*c,e[5]=g*o+m*l+v*h,e[6]=y*r+_*a+x*u,e[7]=y*i+_*s+x*c,e[8]=y*o+_*l+x*h,e}};Jq.mul=Jq.multiply,Jq.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],p=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+p*a+u,e[7]=d*i+p*s+c,e[8]=d*o+p*l+h,e},Jq.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=Math.sin(n),p=Math.cos(n);return e[0]=p*r+d*a,e[1]=p*i+d*s,e[2]=p*o+d*l,e[3]=p*a-d*r,e[4]=p*s-d*i,e[5]=p*l-d*o,e[6]=u,e[7]=c,e[8]=h,e},Jq.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},Jq.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},Jq.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,p=i*s,f=i*l,g=o*a,m=o*s,v=o*l;return e[0]=1-h-f,e[3]=c-v,e[6]=d+m,e[1]=c+v,e[4]=1-u-f,e[7]=p-g,e[2]=d-m,e[5]=p+g,e[8]=1-u-h,e},Jq.normalFromMat4=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],y=n*s-r*a,_=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,S=i*u-o*l,T=c*g-h*f,M=c*m-d*f,C=c*v-p*f,D=h*m-d*g,A=h*v-p*g,I=d*v-p*m,E=y*I-_*A+x*D+b*C-w*M+S*T;return E?(E=1/E,e[0]=(s*I-l*A+u*D)*E,e[1]=(l*C-a*I-u*M)*E,e[2]=(a*A-s*C+u*T)*E,e[3]=(i*A-r*I-o*D)*E,e[4]=(n*I-i*C+o*M)*E,e[5]=(r*C-n*A-o*T)*E,e[6]=(g*S-m*w+v*b)*E,e[7]=(m*x-f*S-v*_)*E,e[8]=(f*w-g*x+v*y)*E,e):null},Jq.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))};var Qq,eK,tK,nK,rK={};rK.create=function(){var e=new XZ(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},rK.rotationTo=(Qq=Cq.create(),eK=Cq.fromValues(1,0,0),tK=Cq.fromValues(0,1,0),function(e,t,n){var r=Cq.dot(t,n);return r<-.999999?(Cq.cross(Qq,eK,t),Cq.length(Qq)<1e-6&&Cq.cross(Qq,tK,t),Cq.normalize(Qq,Qq),rK.setAxisAngle(e,Qq,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Cq.cross(Qq,t,n),e[0]=Qq[0],e[1]=Qq[1],e[2]=Qq[2],e[3]=1+r,rK.normalize(e,e))}),rK.setAxes=(nK=Jq.create(),function(e,t,n,r){return nK[0]=n[0],nK[3]=n[1],nK[6]=n[2],nK[1]=r[0],nK[4]=r[1],nK[7]=r[2],nK[2]=-t[0],nK[5]=-t[1],nK[8]=-t[2],rK.normalize(e,rK.fromMat3(e,nK))}),rK.clone=$q.clone,rK.fromValues=$q.fromValues,rK.copy=$q.copy,rK.set=$q.set,rK.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},rK.setAxisAngle=function(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e},rK.add=$q.add,rK.multiply=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*c+a*s+i*u-o*l,e[1]=i*c+a*l+o*s-r*u,e[2]=o*c+a*u+r*l-i*s,e[3]=a*c-r*s-i*l-o*u,e},rK.mul=rK.multiply,rK.scale=$q.scale,rK.rotateX=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e},rK.rotateY=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e},rK.rotateZ=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},rK.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},rK.dot=$q.dot,rK.lerp=$q.lerp,rK.slerp=function(e,t,n,r){var i,o,a,s,l,u=t[0],c=t[1],h=t[2],d=t[3],p=n[0],f=n[1],g=n[2],m=n[3];return(o=u*p+c*f+h*g+d*m)<0&&(o=-o,p=-p,f=-f,g=-g,m=-m),1-o>1e-6?(i=Math.acos(o),a=Math.sin(i),s=Math.sin((1-r)*i)/a,l=Math.sin(r*i)/a):(s=1-r,l=r),e[0]=s*u+l*p,e[1]=s*c+l*f,e[2]=s*h+l*g,e[3]=s*d+l*m,e},rK.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=o*s,e},rK.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},rK.length=$q.length,rK.len=rK.length,rK.squaredLength=$q.squaredLength,rK.sqrLen=rK.squaredLength,rK.normalize=$q.normalize,rK.fromMat3=function(e,t){var n,r=t[0]+t[4]+t[8];if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*o+o]-t[3*a+a]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*o+a]-t[3*a+o])*n,e[o]=(t[3*o+i]+t[3*i+o])*n,e[a]=(t[3*a+i]+t[3*i+a])*n}return e};var iK=function(){this._axisX=new Bq,this._axisY=new Bq,this._axisZ=new Bq,this.array=Mq.create(),this._dirty=!0};iK.prototype={constructor:iK,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return Mq.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new iK).copy(this)},copy:function(e){return Mq.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Mq.determinant(this.array)},fromQuat:function(e){return Mq.fromQuat(this.array,e.array),this._dirty=!0,this},fromRotationTranslation:function(e,t){return Mq.fromRotationTranslation(this.array,e.array,t.array),this._dirty=!0,this},fromMat2d:function(e){return iK.fromMat2d(this,e),this},frustum:function(e,t,n,r,i,o){return Mq.frustum(this.array,e,t,n,r,i,o),this._dirty=!0,this},identity:function(){return Mq.identity(this.array),this._dirty=!0,this},invert:function(){return Mq.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(e,t,n){return Mq.lookAt(this.array,e.array,t.array,n.array),this._dirty=!0,this},mul:function(e){return Mq.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Mq.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Mq.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Mq.multiply(this.array,e.array,this.array),this._dirty=!0,this},ortho:function(e,t,n,r,i,o){return Mq.ortho(this.array,e,t,n,r,i,o),this._dirty=!0,this},perspective:function(e,t,n,r){return Mq.perspective(this.array,e,t,n,r),this._dirty=!0,this},rotate:function(e,t){return Mq.rotate(this.array,this.array,e,t.array),this._dirty=!0,this},rotateX:function(e){return Mq.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return Mq.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return Mq.rotateZ(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Mq.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Mq.translate(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return Mq.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:function(){var e=Cq.create(),t=Cq.create(),n=Cq.create(),r=Jq.create();return function(i,o,a){var s=this.array;Cq.set(e,s[0],s[1],s[2]),Cq.set(t,s[4],s[5],s[6]),Cq.set(n,s[8],s[9],s[10]);var l=Cq.length(e),u=Cq.length(t),c=Cq.length(n);this.determinant()<0&&(l=-l),i&&i.set(l,u,c),a.set(s[12],s[13],s[14]),Jq.fromMat4(r,s),r[0]/=l,r[1]/=l,r[2]/=l,r[3]/=u,r[4]/=u,r[5]/=u,r[6]/=c,r[7]/=c,r[8]/=c,rK.fromMat3(o.array,r),rK.normalize(o.array,o.array),o._dirty=!0,a._dirty=!0}}(),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var oK=Object.defineProperty;if(oK){var aK=iK.prototype;oK(aK,"z",{get:function(){var e=this.array;return this._axisZ.set(e[8],e[9],e[10]),this._axisZ},set:function(e){var t=this.array;e=e.array,t[8]=e[0],t[9]=e[1],t[10]=e[2],this._dirty=!0}}),oK(aK,"y",{get:function(){var e=this.array;return this._axisY.set(e[4],e[5],e[6]),this._axisY},set:function(e){var t=this.array;e=e.array,t[4]=e[0],t[5]=e[1],t[6]=e[2],this._dirty=!0}}),oK(aK,"x",{get:function(){var e=this.array;return this._axisX.set(e[0],e[1],e[2]),this._axisX},set:function(e){var t=this.array;e=e.array,t[0]=e[0],t[1]=e[1],t[2]=e[2],this._dirty=!0}})}iK.adjoint=function(e,t){return Mq.adjoint(e.array,t.array),e._dirty=!0,e},iK.copy=function(e,t){return Mq.copy(e.array,t.array),e._dirty=!0,e},iK.determinant=function(e){return Mq.determinant(e.array)},iK.identity=function(e){return Mq.identity(e.array),e._dirty=!0,e},iK.ortho=function(e,t,n,r,i,o,a){return Mq.ortho(e.array,t,n,r,i,o,a),e._dirty=!0,e},iK.perspective=function(e,t,n,r,i){return Mq.perspective(e.array,t,n,r,i),e._dirty=!0,e},iK.lookAt=function(e,t,n,r){return Mq.lookAt(e.array,t.array,n.array,r.array),e._dirty=!0,e},iK.invert=function(e,t){return Mq.invert(e.array,t.array),e._dirty=!0,e},iK.mul=function(e,t,n){return Mq.mul(e.array,t.array,n.array),e._dirty=!0,e},iK.multiply=iK.mul,iK.fromQuat=function(e,t){return Mq.fromQuat(e.array,t.array),e._dirty=!0,e},iK.fromRotationTranslation=function(e,t,n){return Mq.fromRotationTranslation(e.array,t.array,n.array),e._dirty=!0,e},iK.fromMat2d=function(e,t){e._dirty=!0;t=t.array;return(e=e.array)[0]=t[0],e[4]=t[2],e[12]=t[4],e[1]=t[1],e[5]=t[3],e[13]=t[5],e},iK.rotate=function(e,t,n,r){return Mq.rotate(e.array,t.array,n,r.array),e._dirty=!0,e},iK.rotateX=function(e,t,n){return Mq.rotateX(e.array,t.array,n),e._dirty=!0,e},iK.rotateY=function(e,t,n){return Mq.rotateY(e.array,t.array,n),e._dirty=!0,e},iK.rotateZ=function(e,t,n){return Mq.rotateZ(e.array,t.array,n),e._dirty=!0,e},iK.scale=function(e,t,n){return Mq.scale(e.array,t.array,n.array),e._dirty=!0,e},iK.transpose=function(e,t){return Mq.transpose(e.array,t.array),e._dirty=!0,e},iK.translate=function(e,t,n){return Mq.translate(e.array,t.array,n.array),e._dirty=!0,e};var sK,lK=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=void 0===r?1:r,this.array=rK.fromValues(e,t,n,r),this._dirty=!0};lK.prototype={constructor:lK,add:function(e){return rK.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return rK.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new lK(this.x,this.y,this.z,this.w)},conjugate:function(){return rK.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return rK.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return rK.dot(this.array,e.array)},fromMat3:function(e){return rK.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:(sK=Jq.create(),function(e){return Jq.fromMat4(sK,e.array),Jq.transpose(sK,sK),rK.fromMat3(this.array,sK),this._dirty=!0,this}),identity:function(){return rK.identity(this.array),this._dirty=!0,this},invert:function(){return rK.invert(this.array,this.array),this._dirty=!0,this},len:function(){return rK.len(this.array)},length:function(){return rK.length(this.array)},lerp:function(e,t,n){return rK.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},mul:function(e){return rK.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return rK.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return rK.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return rK.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return rK.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return rK.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return rK.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return rK.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return rK.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,n){return rK.setAxes(this.array,e.array,t.array,n.array),this._dirty=!0,this},setAxisAngle:function(e,t){return rK.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,n){return rK.slerp(this.array,e.array,t.array,n),this._dirty=!0,this},sqrLen:function(){return rK.sqrLen(this.array)},squaredLength:function(){return rK.squaredLength(this.array)},fromEuler:function(e,t){return lK.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var uK=Object.defineProperty;if(uK){var cK=lK.prototype;uK(cK,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),uK(cK,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),uK(cK,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),uK(cK,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}lK.add=function(e,t,n){return rK.add(e.array,t.array,n.array),e._dirty=!0,e},lK.set=function(e,t,n,r,i){rK.set(e.array,t,n,r,i),e._dirty=!0},lK.copy=function(e,t){return rK.copy(e.array,t.array),e._dirty=!0,e},lK.calculateW=function(e,t){return rK.calculateW(e.array,t.array),e._dirty=!0,e},lK.conjugate=function(e,t){return rK.conjugate(e.array,t.array),e._dirty=!0,e},lK.identity=function(e){return rK.identity(e.array),e._dirty=!0,e},lK.invert=function(e,t){return rK.invert(e.array,t.array),e._dirty=!0,e},lK.dot=function(e,t){return rK.dot(e.array,t.array)},lK.len=function(e){return rK.length(e.array)},lK.lerp=function(e,t,n,r){return rK.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},lK.slerp=function(e,t,n,r){return rK.slerp(e.array,t.array,n.array,r),e._dirty=!0,e},lK.mul=function(e,t,n){return rK.multiply(e.array,t.array,n.array),e._dirty=!0,e},lK.multiply=lK.mul,lK.rotateX=function(e,t,n){return rK.rotateX(e.array,t.array,n),e._dirty=!0,e},lK.rotateY=function(e,t,n){return rK.rotateY(e.array,t.array,n),e._dirty=!0,e},lK.rotateZ=function(e,t,n){return rK.rotateZ(e.array,t.array,n),e._dirty=!0,e},lK.setAxisAngle=function(e,t,n){return rK.setAxisAngle(e.array,t.array,n),e._dirty=!0,e},lK.normalize=function(e,t){return rK.normalize(e.array,t.array),e._dirty=!0,e},lK.squaredLength=lK.sqrLen=function(e){return rK.sqrLen(e.array)},lK.fromMat3=function(e,t){return rK.fromMat3(e.array,t.array),e._dirty=!0,e},lK.setAxes=function(e,t,n,r){return rK.setAxes(e.array,t.array,n.array,r.array),e._dirty=!0,e},lK.rotationTo=function(e,t,n){return rK.rotationTo(e.array,t.array,n.array),e._dirty=!0,e},lK.fromEuler=function(e,t,n){e._dirty=!0,t=t.array;var r=e.array,i=Math.cos(t[0]/2),o=Math.cos(t[1]/2),a=Math.cos(t[2]/2),s=Math.sin(t[0]/2),l=Math.sin(t[1]/2),u=Math.sin(t[2]/2);switch(n=(n||"XYZ").toUpperCase()){case"XYZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"YXZ":r[0]=s*o*a+i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"ZXY":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a-s*l*u;break;case"ZYX":r[0]=s*o*a-i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a+s*l*u;break;case"YZX":r[0]=s*o*a+i*l*u,r[1]=i*l*a+s*o*u,r[2]=i*o*u-s*l*a,r[3]=i*o*a-s*l*u;break;case"XZY":r[0]=s*o*a-i*l*u,r[1]=i*l*a-s*o*u,r[2]=i*o*u+s*l*a,r[3]=i*o*a+s*l*u}};var hK,dK,pK,fK,gK,mK,vK=Cq.set,yK=Cq.copy,_K=function(e,t){this.min=e||new Bq(1/0,1/0,1/0),this.max=t||new Bq(-1/0,-1/0,-1/0),this.vertices=null};_K.prototype={constructor:_K,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,r=t.array,i=n.array;yK(r,e[0]),yK(i,e[0]);for(var o=1;o<e.length;o++){var a=e[o];a[0]<r[0]&&(r[0]=a[0]),a[1]<r[1]&&(r[1]=a[1]),a[2]<r[2]&&(r[2]=a[2]),a[0]>i[0]&&(i[0]=a[0]),a[1]>i[1]&&(i[1]=a[1]),a[2]>i[2]&&(i[2]=a[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return Cq.min(t.array,t.array,e.min.array),Cq.max(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return Cq.max(t.array,t.array,e.min.array),Cq.min(n.array,n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]<r[0]||n[1]<r[1]||n[2]<r[2])},containBoundingBox:function(e){var t=this.min.array,n=this.max.array,r=e.min.array,i=e.max.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min.array,n=this.max.array,r=e.array;return t[0]<=r[0]&&t[1]<=r[1]&&t[2]<=r[2]&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]>=r[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:(hK=Cq.create(),dK=Cq.create(),pK=Cq.create(),fK=Cq.create(),gK=Cq.create(),mK=Cq.create(),function(e,t){var n=e.min.array,r=e.max.array,i=t.array;return hK[0]=i[0]*n[0],hK[1]=i[1]*n[0],hK[2]=i[2]*n[0],dK[0]=i[0]*r[0],dK[1]=i[1]*r[0],dK[2]=i[2]*r[0],pK[0]=i[4]*n[1],pK[1]=i[5]*n[1],pK[2]=i[6]*n[1],fK[0]=i[4]*r[1],fK[1]=i[5]*r[1],fK[2]=i[6]*r[1],gK[0]=i[8]*n[2],gK[1]=i[9]*n[2],gK[2]=i[10]*n[2],mK[0]=i[8]*r[2],mK[1]=i[9]*r[2],mK[2]=i[10]*r[2],n=this.min.array,r=this.max.array,n[0]=Math.min(hK[0],dK[0])+Math.min(pK[0],fK[0])+Math.min(gK[0],mK[0])+i[12],n[1]=Math.min(hK[1],dK[1])+Math.min(pK[1],fK[1])+Math.min(gK[1],mK[1])+i[13],n[2]=Math.min(hK[2],dK[2])+Math.min(pK[2],fK[2])+Math.min(gK[2],mK[2])+i[14],r[0]=Math.max(hK[0],dK[0])+Math.max(pK[0],fK[0])+Math.max(gK[0],mK[0])+i[12],r[1]=Math.max(hK[1],dK[1])+Math.max(pK[1],fK[1])+Math.max(gK[1],mK[1])+i[13],r[2]=Math.max(hK[2],dK[2])+Math.max(pK[2],fK[2])+Math.max(gK[2],mK[2])+i[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(e){var t=this.min.array,n=this.max.array,r=e.array,i=t[0],o=t[1],a=t[2],s=n[0],l=n[1],u=t[2],c=n[0],h=n[1],d=n[2];if(1===r[15])t[0]=r[0]*i+r[12],t[1]=r[5]*o+r[13],n[2]=r[10]*a+r[14],n[0]=r[0]*c+r[12],n[1]=r[5]*h+r[13],t[2]=r[10]*d+r[14];else{var p=-1/a;t[0]=r[0]*i*p,t[1]=r[5]*o*p,n[2]=(r[10]*a+r[14])*p,p=-1/u,n[0]=r[0]*s*p,n[1]=r[5]*l*p,p=-1/d,t[2]=(r[10]*d+r[14])*p}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=Cq.fromValues(0,0,0);this.vertices=e}var n=this.min.array,r=this.max.array;return vK(e[0],n[0],n[1],n[2]),vK(e[1],n[0],r[1],n[2]),vK(e[2],r[0],n[1],n[2]),vK(e[3],r[0],r[1],n[2]),vK(e[4],n[0],n[1],r[2]),vK(e[5],n[0],r[1],r[2]),vK(e[6],r[0],n[1],r[2]),vK(e[7],r[0],r[1],r[2]),this},copy:function(e){var t=this.min,n=this.max;return yK(t.array,e.min.array),yK(n.array,e.max.array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new _K;return e.copy(this),e}};var xK,bK,wK=0,SK=bY.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},(function(){this.name||(this.name=(this.type||"NODE")+"_"+wK++),this.position||(this.position=new Bq),this.rotation||(this.rotation=new lK),this.scale||(this.scale=new Bq(1,1,1)),this.worldTransform=new iK,this.localTransform=new iK,this._children=[]}),{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t<e.length;t++)e[t]._parent=null,this._scene&&e[t].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(e){e._scene.removeFromScene(e),e._scene=null},_addSelfToScene:function(e){this._scene.addToScene(e),e._scene=this._scene},isAncestor:function(e){for(var t=e._parent;t;){if(t===this)return!0;t=t._parent}return!1},children:function(){return this._children.slice()},childAt:function(e){return this._children[e]},getChildByName:function(e){for(var t=this._children,n=0;n<t.length;n++)if(t[n].name===e)return t[n]},getDescendantByName:function(e){for(var t=this._children,n=0;n<t.length;n++){var r=t[n];if(r.name===e)return r;var i=r.getDescendantByName(e);if(i)return i}},queryNode:function(e){if(e){for(var t=e.split("/"),n=this,r=0;r<t.length;r++){var i=t[r];if(i){for(var o=!1,a=n._children,s=0;s<a.length;s++){var l=a[s];if(l.name===i){n=l,o=!0;break}}if(!o)return}}return n}},getPath:function(e){if(!this._parent)return"/";for(var t=this._parent,n=this.name;t._parent&&(n=t.name+"/"+n,t._parent!=e);)t=t._parent;return!t._parent&&e?null:n},traverse:function(e,t){e.call(t,this);for(var n=this._children,r=0,i=n.length;r<i;r++)n[r].traverse(e,t)},eachChild:function(e,t){for(var n=this._children,r=0,i=n.length;r<i;r++){var o=n[r];e.call(t,o,r)}},setLocalTransform:function(e){Mq.copy(this.localTransform.array,e.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(e){var t=e?null:this.scale;this.localTransform.decomposeMatrix(t,this.rotation,this.position)},setWorldTransform:function(e){Mq.copy(this.worldTransform.array,e.array),this.decomposeWorldTransform()},decomposeWorldTransform:(xK=Mq.create(),function(e){var t=this.localTransform,n=this.worldTransform;this._parent?(Mq.invert(xK,this._parent.worldTransform.array),Mq.multiply(t.array,xK,n.array)):Mq.copy(t.array,n.array);var r=e?null:this.scale;t.decomposeMatrix(r,this.rotation,this.position)}),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var e=this.position,t=this.rotation,n=this.scale;if(this.transformNeedsUpdate()){var r=this.localTransform.array;Mq.fromRotationTranslation(r,t.array,e.array),Mq.scale(r,r,n.array),t._dirty=!1,n._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var e=this.localTransform.array,t=this.worldTransform.array;this._parent?Mq.multiplyAffine(t,this._parent.worldTransform.array,e):Mq.copy(t,e)},updateWorldTransform:function(){for(var e=this;e&&e.getParent()&&e.getParent().transformNeedsUpdate();)e=e.getParent();e.update()},update:function(e){this.autoUpdateLocalTransform?this.updateLocalTransform():e=!0,(e||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),e=!0,this._needsUpdateWorldTransform=!1);for(var t=this._children,n=0,r=t.length;n<r;n++)t[n].update(e)},getBoundingBox:function(){function e(e){return!e.invisible&&e.geometry}var t=new _K,n=new iK,r=new iK;return function(i,o){return o=o||new _K,this._parent?iK.invert(r,this._parent.worldTransform):iK.identity(r),this.traverse((function(e){e.geometry&&e.geometry.boundingBox&&(t.copy(e.geometry.boundingBox),iK.multiply(n,r,e.worldTransform),t.applyTransform(n),o.union(t))}),this,e),o}}(),getWorldPosition:function(e){this.transformNeedsUpdate()&&this.updateWorldTransform();var t=this.worldTransform.array;if(e){var n=e.array;return n[0]=t[12],n[1]=t[13],n[2]=t[14],e}return new Bq(t[12],t[13],t[14])},clone:function(){var e=new this.constructor,t=this._children;e.setName(this.name),e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale);for(var n=0;n<t.length;n++)e.add(t[n].clone());return e},rotateAround:function(){var e=new Bq,t=new iK;return function(n,r,i){e.copy(this.position).subtract(n);var o=this.localTransform;o.identity(),o.translate(n),o.rotate(i,r),t.fromRotationTranslation(this.rotation,e),o.multiply(t),o.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var e=new iK;return function(t,n){e.lookAt(this.position,t,n||this.localTransform.y).invert(),this.setLocalTransform(e),this.target=t}}()}),TK=SK.extend({material:null,geometry:null,mode:NY,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:BY,frontFace:HY,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=SK.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:(bK=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var e=SK.prototype.clone.call(this);e.geometry=this.geometry,e.material=this.material;for(var t=0;t<bK.length;t++){var n=bK[t];e[n]!==this[n]&&(e[n]=this[n])}return e})});TK.POINTS=AY,TK.LINES=IY,TK.LINE_LOOP=EY,TK.LINE_STRIP=LY,TK.TRIANGLES=NY,TK.TRIANGLE_STRIP=PY,TK.TRIANGLE_FAN=OY,TK.BACK=BY,TK.FRONT=VY,TK.FRONT_AND_BACK=FY,TK.CW=GY,TK.CCW=HY;var MK=bY.extend({scene:null,camera:null,renderer:null},(function(){this._ray=new Kq,this._ndc=new qZ}),{pick:function(e,t,n){return this.pickAll(e,t,[],n)[0]||null},pickAll:function(e,t,n,r){return this.renderer.screenToNDC(e,t,this._ndc),this.camera.castRay(this._ndc,this._ray),n=n||[],this._intersectNode(this.scene,n,r||!1),n.sort(this._intersectionCompareFunc),n},_intersectNode:function(e,t,n){e instanceof TK&&e.isRenderable()&&(e.ignorePicking&&!n||!(e.mode===NY&&e.geometry.isUseIndices()||e.geometry.pickByRay||e.geometry.pick)||this._intersectRenderable(e,t));for(var r=0;r<e._children.length;r++)this._intersectNode(e._children[r],t,n)},_intersectRenderable:function(){var e=new Bq,t=new Bq,n=new Bq,r=new Kq,i=new iK;return function(o,a){var s=o.isSkinnedMesh();r.copy(this._ray),iK.invert(i,o.worldTransform),s||r.applyTransform(i);var l=o.geometry,u=s?o.skeleton.boundingBox:l.boundingBox;if(!u||r.intersectBoundingBox(u))if(l.pick)l.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,o,a);else if(l.pickByRay)l.pickByRay(r,o,a);else{var c,h,d=o.cullFace===BY&&o.frontFace===HY||o.cullFace===VY&&o.frontFace===GY,p=l.indices,f=l.attributes.position,g=l.attributes.weight,m=l.attributes.joint,v=[];if(f&&f.value&&p){if(s){h=o.skeleton.getSubSkinMatrices(o.__uid__,o.joints);for(var y=0;y<o.joints.length;y++){v[y]=v[y]||[];for(var _=0;_<16;_++)v[y][_]=h[16*y+_]}var x=[],b=[],w=[],S=[],T=[],M=l.attributes.skinnedPosition;M&&M.value||(l.createAttribute("skinnedPosition","f",3),(M=l.attributes.skinnedPosition).init(l.vertexCount));for(y=0;y<l.vertexCount;y++){f.get(y,x),g.get(y,b),m.get(y,w),b[3]=1-b[0]-b[1]-b[2],Cq.set(S,0,0,0);for(_=0;_<4;_++)w[_]>=0&&b[_]>1e-4&&(Cq.transformMat4(T,x,v[w[_]]),Cq.scaleAndAdd(S,S,T,b[_]));M.set(y,S)}}for(y=0;y<p.length;y+=3){var C=p[y],D=p[y+1],A=p[y+2],I=s?l.attributes.skinnedPosition:f;if(I.get(C,e.array),I.get(D,t.array),I.get(A,n.array),c=d?r.intersectTriangle(e,t,n,o.culling):r.intersectTriangle(e,n,t,o.culling)){var E=new Bq;s?Bq.copy(E,c):Bq.transformMat4(E,c,o.worldTransform),a.push(new MK.Intersection(c,E,o,[C,D,A],y/3,Bq.dist(E,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});MK.Intersection=function(e,t,n,r,i,o){this.point=e,this.pointWorld=t,this.target=n,this.triangle=r,this.triangleIndex=i,this.distance=o};var CK="__dt__",DK=function(){this._contextId=0,this._caches=[],this._context={}};DK.prototype={use:function(e,t){var n=this._caches;n[e]||(n[e]={},t&&(n[e]=t())),this._contextId=e,this._context=n[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){var t=CK+(e=e||"");this.put(t,!0)},dirtyAll:function(e){for(var t=CK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!0)},fresh:function(e){var t=CK+(e=e||"");this.put(t,!1)},freshAll:function(e){for(var t=CK+(e=e||""),n=this._caches,r=0;r<n.length;r++)n[r]&&(n[r][t]=!1)},isDirty:function(e){var t=CK+(e=e||""),n=this._context;return!n.hasOwnProperty(t)||!0===n[t]},deleteContext:function(e){delete this._caches[e],this._context={}},delete:function(e){delete this._context[e]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(e,t){Object.keys(this._caches).forEach((function(n){e&&e.call(t,n)}))},miss:function(e){return!this._context.hasOwnProperty(e)}},DK.prototype.constructor=DK;var AK=bY.extend({width:512,height:512,type:WY,format:QY,wrapS:cZ,wrapT:cZ,minFilter:sZ,magFilter:rZ,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},(function(){this._cache=new DK}),{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__uid__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===KY&&(this.useMipmap=!1);var n=e.getGLExtension("EXT_sRGB");this.format!==AK.SRGB||n||(this.format=AK.RGB),this.format!==AK.SRGB_ALPHA||n||(this.format=AK.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?hZ:this.wrapS},getAvailableWrapT:function(){return this.NPOT?hZ:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===iZ||e===aZ?nZ:e===sZ||e===oZ?rZ:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(AK.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(AK.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),AK.BYTE=UY,AK.UNSIGNED_BYTE=WY,AK.SHORT=jY,AK.UNSIGNED_SHORT=XY,AK.INT=YY,AK.UNSIGNED_INT=ZY,AK.FLOAT=qY,AK.HALF_FLOAT=36193,AK.UNSIGNED_INT_24_8_WEBGL=34042,AK.DEPTH_COMPONENT=KY,AK.DEPTH_STENCIL=gZ,AK.ALPHA=$Y,AK.RGB=JY,AK.RGBA=QY,AK.LUMINANCE=eZ,AK.LUMINANCE_ALPHA=tZ,AK.SRGB=35904,AK.SRGB_ALPHA=35906,AK.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,AK.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,AK.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,AK.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,AK.NEAREST=nZ,AK.LINEAR=rZ,AK.NEAREST_MIPMAP_NEAREST=iZ,AK.LINEAR_MIPMAP_NEAREST=oZ,AK.NEAREST_MIPMAP_LINEAR=aZ,AK.LINEAR_MIPMAP_LINEAR=sZ,AK.REPEAT=cZ,AK.CLAMP_TO_EDGE=hZ,AK.MIRRORED_REPEAT=dZ;var IK=TK.extend({skeleton:null,joints:null},(function(){this.joints||(this.joints=[])}),{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var e=TK.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});IK.POINTS=AY,IK.LINES=IY,IK.LINE_LOOP=EY,IK.LINE_STRIP=LY,IK.TRIANGLES=NY,IK.TRIANGLE_STRIP=PY,IK.TRIANGLE_FAN=OY,IK.BACK=BY,IK.FRONT=VY,IK.FRONT_AND_BACK=FY,IK.CW=GY,IK.CCW=HY;var EK={isPowerOfTwo:function(e){return!(e&e-1)},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}},LK=EK.isPowerOfTwo;function NK(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}var PK=AK.extend((function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}}),{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==AK.REPEAT&&this.wrapT!==AK.REPEAT||!this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var o=e.getGLExtension("EXT_texture_filter_anisotropic");(o&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,o.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=qY));if(this.mipmaps.length)for(var a=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var u=this.mipmaps[l];this._updateTextureData(t,u,l,a,s,n,r,!1),a/=2,s/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r,i),!this.useMipmap||this.NPOT&&!i||t.generateMipmap(t.TEXTURE_2D);t.bindTexture(t.TEXTURE_2D,null)},_updateTextureData:function(e,t,n,r,i,o,a,s){if(t.image){var l=t.image;s&&(this._potCanvas=function(e,t){var n=NK(e.width),r=NK(e.height);return(t=t||document.createElement("canvas")).width=n,t.height=r,t.getContext("2d").drawImage(e.image,0,0,n,r),t}(this,this._potCanvas),l=this._potCanvas),e.texImage2D(e.TEXTURE_2D,n,o,o,a,l)}else o<=AK.COMPRESSED_RGBA_S3TC_DXT5_EXT&&o>=AK.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,r,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,r,i,0,o,a,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return LK(this.width)&&LK(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var n=wZ.createImage();t&&(n.crossOrigin=t);var r=this;return n.onload=function(){r.dirty(),r.trigger("success",r)},n.onerror=function(){r.trigger("error",r)},n.src=e,this.image=n,this}});function OK(e){return{byte:wZ.Int8Array,ubyte:wZ.Uint8Array,short:wZ.Int16Array,ushort:wZ.Uint16Array}[e]||wZ.Float32Array}function RK(e){return"attr_"+e}function kK(e,t,n,r){switch(this.name=e,this.type=t,this.size=n,this.semantic=r||"",this.value=null,n){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t},this.copy=function(e,t){this.value[e]=this.value[e]};break;case 2:this.get=function(e,t){var n=this.value;return t[0]=n[2*e],t[1]=n[2*e+1],t},this.set=function(e,t){var n=this.value;n[2*e]=t[0],n[2*e+1]=t[1]},this.copy=function(e,t){var n=this.value;t*=2,n[e*=2]=n[t],n[e+1]=n[t+1]};break;case 3:this.get=function(e,t){var n=3*e,r=this.value;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t},this.set=function(e,t){var n=3*e,r=this.value;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2]},this.copy=function(e,t){var n=this.value;t*=3,n[e*=3]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2]};break;case 4:this.get=function(e,t){var n=this.value,r=4*e;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t[3]=n[r+3],t},this.set=function(e,t){var n=this.value,r=4*e;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2],n[r+3]=t[3]},this.copy=function(e,t){var n=this.value;t*=4,n[e*=4]=n[t],n[e+1]=n[t+1],n[e+2]=n[t+2],n[e+3]=n[t+3]}}}function zK(e,t,n,r,i){this.name=e,this.type=t,this.buffer=n,this.size=r,this.semantic=i,this.symbol="",this.needsRemove=!1}function VK(e){this.buffer=e,this.count=0}Object.defineProperty(PK.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(PK.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),kK.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=OK(this.type);this.value=new t(e*this.size)}},kK.prototype.fromArray=function(e){var t,n=OK(this.type);if(e[0]&&e[0].length){var r=0,i=this.size;t=new n(e.length*i);for(var o=0;o<e.length;o++)for(var a=0;a<i;a++)t[r++]=e[o][a]}else t=new n(e);this.value=t},kK.prototype.clone=function(e){var t=new kK(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t};var BK=bY.extend((function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}}),(function(){this._cache=new DK,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}}),{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t<e.length;t++)this.dirtyAttribute(e[t]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(e){this._cache.dirtyAll(RK(e)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(e,t){if(e<this.triangleCount&&e>=0){t||(t=[]);var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?wZ.Uint32Array:wZ.Uint16Array;if(e[0]&&e[0].length){var r=0;t=new n(3*e.length);for(var i=0;i<e.length;i++)for(var o=0;o<3;o++)t[r++]=e[i][o]}else t=new n(e);this.indices=t},createAttribute:function(e,t,n,r){var i=new kK(e,t,n,r);return this.attributes[e]&&this.removeAttribute(e),this.attributes[e]=i,this._attributeList.push(e),i},removeAttribute:function(e){var t=this._attributeList,n=t.indexOf(e);return n>=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],r=this.vertexCount,i=0;i<t.length;i++){var o=t[i],a=this.attributes[o];a.value&&a.value.length===r*a.size&&n.push(o)}return this._enabledAttributes=n,n},getBufferChunks:function(e){var t=this._cache;t.use(e.__uid__);var n=t.isDirty("attributes"),r=t.isDirty("indices");if(n||r){this._updateBuffer(e.gl,n,r);for(var i=this.getEnabledAttributes(),o=0;o<i.length;o++)t.fresh(RK(i[o]));t.fresh("attributes"),t.fresh("indices")}return t.fresh("any"),t.get("chunks")},_updateBuffer:function(e,t,n){var r=this._cache,i=r.get("chunks"),o=!1;i||((i=[])[0]={attributeBuffers:[],indicesBuffer:null},r.put("chunks",i),o=!0);var a=i[0],s=a.attributeBuffers,l=a.indicesBuffer;if(t||o){var u=this.getEnabledAttributes(),c={};if(!o)for(var h=0;h<s.length;h++)c[s[h].name]=s[h];for(var d=0;d<u.length;d++){var p,f,g=u[d],m=this.attributes[g];o||(p=c[g]),f=p?p.buffer:e.createBuffer(),r.isDirty(RK(g))&&(e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,m.value,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW)),s[d]=new zK(g,m.type,f,m.size,m.semantic)}for(h=d;h<s.length;h++)e.deleteBuffer(s[h].buffer);s.length=d}this.isUseIndices()&&(n||o)&&(l||(l=new VK(e.createBuffer()),a.indicesBuffer=l),l.count=this.indices.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.buffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW))},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});Object.defineProperty&&(Object.defineProperty(BK.prototype,"vertexCount",{enumerable:!1,get:function(){var e=this.attributes[this.mainAttribute];return e||(e=this.attributes[this._attributeList[0]]),e&&e.value?e.value.length/e.size:0}}),Object.defineProperty(BK.prototype,"triangleCount",{enumerable:!1,get:function(){var e=this.indices;return e?e.length/3:0}})),BK.STATIC_DRAW=kY,BK.DYNAMIC_DRAW=zY,BK.STREAM_DRAW=RY,BK.AttributeBuffer=zK,BK.IndicesBuffer=VK,BK.Attribute=kK;var FK=Cq.create,GK=Cq.add,HK=Cq.set,UK=BK.Attribute,WK=BK.extend((function(){return{attributes:{position:new UK("position","float",3,"POSITION"),texcoord0:new UK("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new UK("texcoord1","float",2,"TEXCOORD_1"),normal:new UK("normal","float",3,"NORMAL"),tangent:new UK("tangent","float",4,"TANGENT"),color:new UK("color","float",4,"COLOR"),weight:new UK("weight","float",3,"WEIGHT"),joint:new UK("joint","float",4,"JOINT"),barycentric:new UK("barycentric","float",3,null)},boundingBox:null}}),{mainAttribute:"position",updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new _K);var t=this.attributes.position.value;if(t&&t.length){var n=e.min,r=e.max,i=n.array,o=r.array;Cq.set(i,t[0],t[1],t[2]),Cq.set(o,t[0],t[1],t[2]);for(var a=3;a<t.length;){var s=t[a++],l=t[a++],u=t[a++];s<i[0]&&(i[0]=s),l<i[1]&&(i[1]=l),u<i[2]&&(i[2]=u),s>o[0]&&(o[0]=s),l>o[1]&&(o[1]=l),u>o[2]&&(o[2]=u)}n._dirty=!0,r._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value;if(r&&r.length===n.length)for(var i=0;i<r.length;i++)r[i]=0;else r=t.normal.value=new wZ.Float32Array(n.length);for(var o,a,s,l=FK(),u=FK(),c=FK(),h=FK(),d=FK(),p=FK(),f=e?e.length:this.vertexCount,g=0;g<f;){e?(o=e[g++],a=e[g++],s=e[g++]):(o=g++,a=g++,s=g++),HK(l,n[3*o],n[3*o+1],n[3*o+2]),HK(u,n[3*a],n[3*a+1],n[3*a+2]),HK(c,n[3*s],n[3*s+1],n[3*s+2]),Cq.sub(h,l,u),Cq.sub(d,u,c),Cq.cross(p,h,d);for(i=0;i<3;i++)r[3*o+i]=r[3*o+i]+p[i],r[3*a+i]=r[3*a+i]+p[i],r[3*s+i]=r[3*s+i]+p[i]}for(i=0;i<r.length;)HK(p,r[i],r[i+1],r[i+2]),Cq.normalize(p,p),r[i++]=p[0],r[i++]=p[1],r[i++]=p[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.indices,t=this.attributes,n=t.position.value,r=t.normal.value,i=FK(),o=FK(),a=FK(),s=FK(),l=FK(),u=FK();r||(r=t.normal.value=new Float32Array(n.length));for(var c,h,d,p=e?e.length:this.vertexCount,f=0;f<p;){e?(c=e[f++],h=e[f++],d=e[f++]):(c=f++,h=f++,d=f++),HK(i,n[3*c],n[3*c+1],n[3*c+2]),HK(o,n[3*h],n[3*h+1],n[3*h+2]),HK(a,n[3*d],n[3*d+1],n[3*d+2]),Cq.sub(s,i,o),Cq.sub(l,o,a),Cq.cross(u,s,l),Cq.normalize(u,u);for(var g=0;g<3;g++)r[3*c+g]=u[g],r[3*h+g]=u[g],r[3*d+g]=u[g]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var e=this.vertexCount,t=this.attributes;t.tangent.value||(t.tangent.value=new Float32Array(4*e));var n=t.texcoord0.value,r=t.position.value,i=t.tangent.value,o=t.normal.value;if(n){for(var a=[],s=[],l=0;l<e;l++)a[l]=[0,0,0],s[l]=[0,0,0];var u,c,h,d=[0,0,0],p=[0,0,0],f=this.indices,g=f?f.length:this.vertexCount;for(l=0;l<g;){f?(u=f[l++],c=f[l++],h=f[l++]):(u=l++,c=l++,h=l++);var m=n[2*u],v=n[2*c],y=n[2*h],_=n[2*u+1],x=n[2*c+1],b=n[2*h+1],w=r[3*u],S=r[3*c],T=r[3*h],M=r[3*u+1],C=r[3*c+1],D=r[3*h+1],A=r[3*u+2],I=S-w,E=T-w,L=C-M,N=D-M,P=r[3*c+2]-A,O=r[3*h+2]-A,R=v-m,k=y-m,z=x-_,V=b-_,B=1/(R*V-z*k);d[0]=(V*I-z*E)*B,d[1]=(V*L-z*N)*B,d[2]=(V*P-z*O)*B,p[0]=(R*E-k*I)*B,p[1]=(R*N-k*L)*B,p[2]=(R*O-k*P)*B,GK(a[u],a[u],d),GK(a[c],a[c],d),GK(a[h],a[h],d),GK(s[u],s[u],p),GK(s[c],s[c],p),GK(s[h],s[h],p)}var F=FK(),G=FK(),H=FK();for(l=0;l<e;l++){H[0]=o[3*l],H[1]=o[3*l+1],H[2]=o[3*l+2];var U=a[l];Cq.scale(F,H,Cq.dot(H,U)),Cq.sub(F,U,F),Cq.normalize(F,F),Cq.cross(G,H,U),i[4*l]=F[0],i[4*l+1]=F[1],i[4*l+2]=F[2],i[4*l+3]=Cq.dot(G,s[l])<0?-1:1}this.dirty()}else console.warn("Geometry without texcoords can't generate tangents.")}},isUniqueVertex:function(){return!this.isUseIndices()||this.vertexCount===this.indices.length},generateUniqueVertex:function(){if(this.vertexCount&&this.indices){this.indices.length>65535&&(this.indices=new wZ.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),r={},i=0;i<n.length;i++){r[l=n[i]]=e[l].value,e[l].init(this.indices.length)}for(var o=0,a=0;a<t.length;a++){var s=t[a];for(i=0;i<n.length;i++)for(var l,u=e[l=n[i]].value,c=e[l].size,h=0;h<c;h++)u[o*c+h]=r[l][s*c+h];t[a]=o,o++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.attributes,t=e.barycentric.value,n=this.indices;if(!t||t.length!==3*n.length){t=e.barycentric.value=new Float32Array(3*n.length);for(var r=0;r<(n?n.length:this.vertexCount/3);)for(var i=0;i<3;i++){t[3*(n?n[r++]:3*r+i)+i]=1}this.dirty()}}},applyTransform:function(e){var t=this.attributes,n=t.position.value,r=t.normal.value,i=t.tangent.value;e=e.array;var o=Mq.create();Mq.invert(o,e),Mq.transpose(o,o);var a=Cq.transformMat4,s=Cq.forEach;s(n,3,0,null,a,e),r&&s(r,3,0,null,a,o),i&&s(i,4,0,null,a,o),this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__uid__);var n=t.get("chunks");if(n)for(var r=0;r<n.length;r++){for(var i=n[r],o=0;o<i.attributeBuffers.length;o++){var a=i.attributeBuffers[o];e.gl.deleteBuffer(a.buffer)}i.indicesBuffer&&e.gl.deleteBuffer(i.indicesBuffer.buffer)}if(this.__vaoCache){var s=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&s.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});WK.STATIC_DRAW=BK.STATIC_DRAW,WK.DYNAMIC_DRAW=BK.DYNAMIC_DRAW,WK.STREAM_DRAW=BK.STREAM_DRAW,WK.AttributeBuffer=BK.AttributeBuffer,WK.IndicesBuffer=BK.IndicesBuffer,WK.Attribute=UK;var jK="uniform vec3 ",XK="uniform float ",YK="@export clay.header.",ZK="@end",qK=":unconfigurable;",KK=[YK+"directional_light",jK+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+qK,jK+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+qK,ZK,YK+"ambient_light",jK+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+qK,ZK,YK+"ambient_sh_light",jK+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+qK,jK+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+qK,"vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}",ZK,YK+"ambient_cubemap_light",jK+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+qK,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+qK,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+qK,ZK,YK+"point_light",jK+"pointLightPosition[POINT_LIGHT_COUNT]"+qK,XK+"pointLightRange[POINT_LIGHT_COUNT]"+qK,jK+"pointLightColor[POINT_LIGHT_COUNT]"+qK,ZK,YK+"spot_light",jK+"spotLightPosition[SPOT_LIGHT_COUNT]"+qK,jK+"spotLightDirection[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightRange[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+qK,XK+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+qK,jK+"spotLightColor[SPOT_LIGHT_COUNT]"+qK,ZK].join("\n");bq.import(KK);var $K,JK,QK,e$,t$=SK.extend((function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}}),{type:"",clone:function(){var e=SK.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}}),n$=function(e,t){this.normal=e||new Bq(0,1,0),this.distance=t||0};n$.prototype={constructor:n$,distanceToPoint:function(e){return Cq.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new Bq);var n=this.distanceToPoint(e);return Cq.scaleAndAdd(t.array,e.array,this.normal.array,-n),t._dirty=!0,t},normalize:function(){var e=1/Cq.len(this.normal.array);Cq.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,n=this.normal.array,r=Cq.dot(t[0].array,n)>this.distance,i=1;i<8;i++)if(Cq.dot(t[i].array,n)>this.distance!=r)return!0},intersectLine:(e$=Cq.create(),function(e,t,n){var r=this.distanceToPoint(e),i=this.distanceToPoint(t);if(r>0&&i>0||r<0&&i<0)return null;var o=this.normal.array,a=this.distance,s=e.array;Cq.sub(e$,t.array,e.array),Cq.normalize(e$,e$);var l=Cq.dot(o,e$);if(0===l)return null;n||(n=new Bq);var u=(Cq.dot(o,s)-a)/l;return Cq.scaleAndAdd(n.array,s,e$,-u),n._dirty=!0,n}),applyTransform:($K=Mq.create(),JK=$q.create(),QK=$q.create(),QK[3]=1,function(e){e=e.array,Cq.scale(QK,this.normal.array,this.distance),$q.transformMat4(QK,QK,e),this.distance=Cq.dot(QK,this.normal.array),Mq.invert($K,e),Mq.transpose($K,$K),JK[3]=0,Cq.copy(JK,this.normal.array),$q.transformMat4(JK,JK,$K),Cq.copy(this.normal.array,JK)}),copy:function(e){Cq.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new n$;return e.copy(this),e}};var r$,i$=Cq.set,o$=Cq.copy,a$=Cq.transformMat4,s$=Math.min,l$=Math.max,u$=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new n$);this.boundingBox=new _K,this.vertices=[];for(e=0;e<8;e++)this.vertices[e]=Cq.fromValues(0,0,0)};u$.prototype={setFromProjection:function(e){var t=this.planes,n=e.array,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],d=n[9],p=n[10],f=n[11],g=n[12],m=n[13],v=n[14],y=n[15];i$(t[0].normal.array,a-r,c-s,f-h),t[0].distance=-(y-g),t[0].normalize(),i$(t[1].normal.array,a+r,c+s,f+h),t[1].distance=-(y+g),t[1].normalize(),i$(t[2].normal.array,a+i,c+l,f+d),t[2].distance=-(y+m),t[2].normalize(),i$(t[3].normal.array,a-i,c-l,f-d),t[3].distance=-(y-m),t[3].normalize(),i$(t[4].normal.array,a-o,c-u,f-p),t[4].distance=-(y-v),t[4].normalize(),i$(t[5].normal.array,a+o,c+u,f+p),t[5].distance=-(y+v),t[5].normalize();var _=this.boundingBox,x=this.vertices;if(0===y){var b=l/r,w=-v/(p-1),S=-v/(p+1),T=-S/l,M=-w/l;_.min.set(-T*b,-T,S),_.max.set(T*b,T,w),i$(x[0],-T*b,-T,S),i$(x[1],-T*b,T,S),i$(x[2],T*b,-T,S),i$(x[3],T*b,T,S),i$(x[4],-M*b,-M,w),i$(x[5],-M*b,M,w),i$(x[6],M*b,-M,w),i$(x[7],M*b,M,w)}else{var C=(-1-g)/r,D=(1-g)/r,A=(1-m)/l,I=(-1-m)/l,E=(-1-v)/p,L=(1-v)/p;_.min.set(Math.min(C,D),Math.min(I,A),Math.min(L,E)),_.max.set(Math.max(D,C),Math.max(A,I),Math.max(E,L));var N=_.min.array,P=_.max.array;i$(x[0],N[0],N[1],N[2]),i$(x[1],N[0],P[1],N[2]),i$(x[2],P[0],N[1],N[2]),i$(x[3],P[0],P[1],N[2]),i$(x[4],N[0],N[1],P[2]),i$(x[5],N[0],P[1],P[2]),i$(x[6],P[0],N[1],P[2]),i$(x[7],P[0],P[1],P[2])}},getTransformedBoundingBox:(r$=Cq.create(),function(e,t){var n=this.vertices,r=t.array,i=e.min,o=e.max,a=i.array,s=o.array,l=n[0];a$(r$,l,r),o$(a,r$),o$(s,r$);for(var u=1;u<8;u++)l=n[u],a$(r$,l,r),a[0]=s$(r$[0],a[0]),a[1]=s$(r$[1],a[1]),a[2]=s$(r$[2],a[2]),s[0]=l$(r$[0],s[0]),s[1]=l$(r$[1],s[1]),s[2]=l$(r$[2],s[2]);return i._dirty=!0,o._dirty=!0,e})};var c$,h$=SK.extend((function(){return{projectionMatrix:new iK,invProjectionMatrix:new iK,viewMatrix:new iK,frustum:new u$}}),(function(){this.update(!0)}),{update:function(e){SK.prototype.update.call(this,e),iK.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),iK.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){iK.copy(this.viewMatrix,e),iK.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){iK.copy(this.projectionMatrix,e),iK.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(c$=$q.create(),function(e,t){var n=void 0!==t?t:new Kq,r=e.array[0],i=e.array[1];return $q.set(c$,r,i,-1,1),$q.transformMat4(c$,c$,this.invProjectionMatrix.array),$q.transformMat4(c$,c$,this.worldTransform.array),Cq.scale(n.origin.array,c$,1/c$[3]),$q.set(c$,r,i,1,1),$q.transformMat4(c$,c$,this.invProjectionMatrix.array),$q.transformMat4(c$,c$,this.worldTransform.array),Cq.scale(c$,c$,1/c$[3]),Cq.sub(n.direction.array,c$,n.origin.array),Cq.normalize(n.direction.array,n.direction.array),n.direction._dirty=!0,n.origin._dirty=!0,n})}),d$=Mq.create(),p$=Mq.create(),f$={};function g$(e){var t=[],n=Object.keys(e);n.sort();for(var r=0;r<n.length;r++){var i=n[r];t.push(i+" "+e[i])}var o=t.join("\n");if(f$[o])return f$[o];var a=xY.genGUID();return f$[o]=a,a}function m$(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}m$.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},m$.prototype.add=function(e,t){t?this.transparent[this._transparentCount++]=e:this.opaque[this._opaqueCount++]=e},m$.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var v$,y$,_$=SK.extend((function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new _K,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new MZ(20)}}),(function(){this._scene=this}),{addToScene:function(e){e instanceof h$?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof t$&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof h$?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof t$&&(t=this.lights.indexOf(e))>=0&&this.lights.splice(t,1),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},n=0;n<e.length;n++){var r=e[n];if(!r.invisible){var i=r.group;t[i]||(t[i]={}),t[i][r.type]=t[i][r.type]||0,t[i][r.type]++}}for(var o in this._lightNumber=t,t)this._lightProgramKeys[o]=g$(t[o]);this._updateLightUniforms()},cloneNode:function(e){var t=e.clone(),n={};return function e(t,r){n[t.__uid__]=r;for(var i=0;i<t._children.length;i++){e(t._children[i],r._children[i])}}(e,t),t.traverse((function(e){e.skeleton&&(e.skeleton=e.skeleton.clone(n)),e.material&&(e.material=e.material.clone())})),t},updateRenderList:function(e,t){var n=e.__uid__,r=this._renderLists.get(n);r||(r=new m$,this._renderLists.put(n,r)),r.startCount(),t&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var i=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,e,i,r,t),r.endCount(),r},getRenderList:function(e){return this._renderLists.get(e.__uid__)},_doUpdateRenderList:function(e,t,n,r,i){if(!e.invisible)for(var o=0;o<e._children.length;o++){var a=e._children[o];if(a.isRenderable()){var s=a.isSkinnedMesh()?d$:a.worldTransform.array,l=a.geometry;Mq.multiplyAffine(p$,t.viewMatrix.array,s),(i&&!l.boundingBox||!this.isFrustumCulled(a,t,p$))&&r.add(a,a.material.transparent||n)}a._children.length>0&&this._doUpdateRenderList(a,t,n,r,i)}},isFrustumCulled:(v$=new _K,y$=new iK,function(e,t,n){var r=e.boundingBox;if(r||(r=e.skeleton&&e.skeleton.boundingBox?e.skeleton.boundingBox:e.geometry.boundingBox),!r)return!1;if(y$.array=n,v$.transformFrom(r,y$),e.castShadow&&this.viewBoundingBoxLastFrame.union(v$),e.frustumCulling){if(!v$.intersectBoundingBox(t.frustum.boundingBox))return!0;y$.array=t.projectionMatrix.array,v$.max.array[2]>0&&v$.min.array[2]<0&&(v$.max.array[2]=-1e-20),v$.applyProjection(y$);var i=v$.min.array,o=v$.max.array;if(o[0]<-1||i[0]>1||o[1]<-1||i[1]>1||o[2]<-1||i[2]>1)return!0}return!1}),_updateLightUniforms:function(){var e=this.lights;e.sort(x$);var t=this._lightUniforms;for(var n in t)for(var r in t[n])t[n][r].value.length=0;for(var i=0;i<e.length;i++){var o=e[i];if(!o.invisible){n=o.group;for(var r in o.uniformTemplates){var a=o.uniformTemplates[r],s=a.value(o);if(null!=s){t[n]||(t[n]={}),t[n][r]||(t[n][r]={type:"",value:[]});var l=t[n][r];switch(l.type=a.type+"v",a.type){case"1i":case"1f":case"t":l.value.push(s);break;case"2f":case"3f":case"4f":for(var u=0;u<s.length;u++)l.value.push(s[u]);break;default:console.error("Unkown light uniform type "+a.type)}}}}}},getLightGroups:function(){var e=[];for(var t in this._lightNumber)e.push(t);return e},getNumberChangedLightGroups:function(){var e=[];for(var t in this._lightNumber)this.isLightNumberChanged(t)&&e.push(t);return e},isLightNumberChanged:function(e){var t=this._previousLightNumber,n=this._lightNumber;for(var r in n[e]){if(!t[e])return!0;if(n[e][r]!==t[e][r])return!0}for(var r in t[e]){if(!n[e])return!0;if(n[e][r]!==t[e][r])return!0}return!1},getLightsNumbers:function(e){return this._lightNumber[e]},getProgramKey:function(e){return this._lightProgramKeys[e]},setLightUniforms:function(){function e(e,t,n){for(var r in e){var i=e[r];if("tv"===i.type){if(!t.hasUniform(r))continue;for(var o=[],a=0;a<i.value.length;a++){var s=i.value[a],l=t.takeCurrentTextureSlot(n,s);o.push(l)}t.setUniform(n.gl,"1iv",r,o)}else t.setUniform(n.gl,i.type,r,i.value)}}return function(t,n,r){e(this._lightUniforms[n],t,r),e(this.shadowUniforms,t,r)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});function x$(e,t){if(t.castShadow&&!e.castShadow)return!0}var b$=EK.isPowerOfTwo,w$=["px","nx","py","ny","pz","nz"],S$=AK.extend((function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}}),{textureType:"textureCube",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,r=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===r)&&(e.getGLExtension("OES_texture_half_float")||(r=qY));if(this.mipmaps.length)for(var o=this.width,a=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(t,l,s,o,a,n,r),o/=2,a/=2}else this._updateTextureData(t,this,0,this.width,this.height,n,r),!this.NPOT&&this.useMipmap&&t.generateMipmap(t.TEXTURE_CUBE_MAP);t.bindTexture(t.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(e,t,n,r,i,o,a){for(var s=0;s<6;s++){var l=w$[s],u=t.image&&t.image[l];u?e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,o,a,u):e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,n,o,r,i,0,o,a,t.pixels&&t.pixels[l])}},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_CUBE_MAP))},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?b$(this.image.px.width)&&b$(this.image.px.height):b$(this.width)&&b$(this.height)},isRenderable:function(){return this.image.px?T$(this.image.px)&&T$(this.image.nx)&&T$(this.image.py)&&T$(this.image.ny)&&T$(this.image.pz)&&T$(this.image.nz):!(!this.width||!this.height)},load:function(e,t){var n=0,r=this;return xY.each(e,(function(e,i){var o=wZ.createImage();t&&(o.crossOrigin=t),o.onload=function(){0===--n&&(r.dirty(),r.trigger("success",r))},o.onerror=function(){n--},n++,o.src=e,r.image[i]=o})),this}});function T$(e){return e.width>0&&e.height>0}Object.defineProperty(S$.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(S$.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}});var M$=h$.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=h$.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),C$="framebuffer",D$="renderbuffer",A$=D$+"_width",I$=D$+"_height",E$=D$+"_attached",L$="depthtexture_attached",N$=pZ,P$=fZ,O$=vZ,R$=mZ,k$=bY.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},(function(){this._cache=new DK,this._textures={}}),{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(e){if(e.__currentFrameBuffer){if(e.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}e.__currentFrameBuffer=this;var t=e.gl;t.bindFramebuffer(N$,this._getFrameBufferGL(e)),this._boundRenderer=e;var n=this._cache;n.put("viewport",e.viewport);var r,i,o=!1;for(var a in this._textures){o=!0;var s=this._textures[a];s&&(r=s.texture.width,i=s.texture.height,this._doAttach(e,s.texture,a,s.target))}this._width=r,this._height=i,!o&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?e.setViewport(this.viewport):e.setViewport(0,0,r,i,1);var l=n.get("attached_textures");if(l)for(var a in l)if(!this._textures[a]){var u=l[a];this._doDetach(t,a,u)}if(!n.get(L$)&&this.depthBuffer){n.miss(D$)&&n.put(D$,t.createRenderbuffer());var c=n.get(D$);r===n.get(A$)&&i===n.get(I$)||(t.bindRenderbuffer(P$,c),t.renderbufferStorage(P$,t.DEPTH_COMPONENT16,r,i),n.put(A$,r),n.put(I$,i),t.bindRenderbuffer(P$,null)),n.get(E$)||(t.framebufferRenderbuffer(N$,O$,P$,c),n.put(E$,!0))}},unbind:function(e){e.__currentFrameBuffer=null,e.gl.bindFramebuffer(N$,null),this._boundRenderer=null,this._cache.use(e.__uid__);var t=this._cache.get("viewport");t&&e.setViewport(t),this.updateMipmap(e)},updateMipmap:function(e){var t=e.gl;for(var n in this._textures){var r=this._textures[n];if(r){var i=r.texture;if(!i.NPOT&&i.useMipmap&&i.minFilter===AK.LINEAR_MIPMAP_LINEAR){var o="textureCube"===i.textureType?uZ:lZ;t.bindTexture(o,i.getWebGLTexture(e)),t.generateMipmap(o),t.bindTexture(o,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(N$)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(C$)&&t.put(C$,e.gl.createFramebuffer()),t.get(C$)},attach:function(e,t,n){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||R$,n=n||lZ;var r,i=this._boundRenderer;if(i&&i.gl){var o=this._cache;o.use(i.__uid__),r=o.get("attached_textures")}var a=this._textures[t];if(!a||a.target!==n||a.texture!==e||!r||null==r[t]){var s=!0;i&&(s=this._doAttach(i,e,t,n),this.viewport||i.setViewport(0,0,e.width,e.height,1)),s&&(this._textures[t]=this._textures[t]||{},this._textures[t].texture=e,this._textures[t].target=n)}},_doAttach:function(e,t,n,r){var i=e.gl,o=t.getWebGLTexture(e),a=this._cache.get("attached_textures");if(a&&a[n]){var s=a[n];if(s.texture===t&&s.target===r)return}var l=!0;if(((n=+n)===O$||n===_Z)&&(e.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==KY&&t.format!==gZ&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var u=this._cache.get(D$);u&&(i.framebufferRenderbuffer(N$,O$,P$,null),i.deleteRenderbuffer(u),this._cache.put(D$,!1)),this._cache.put(E$,!1),this._cache.put(L$,!0)}return i.framebufferTexture2D(N$,n,r,o,0),a||(a={},this._cache.put("attached_textures",a)),a[n]=a[n]||{},a[n].texture=t,a[n].target=r,l},_doDetach:function(e,t,n){e.framebufferTexture2D(N$,t,n,null,0);var r=this._cache.get("attached_textures");r&&r[t]&&(r[t]=null),t!==O$&&t!==_Z||this._cache.put(L$,!1)},detach:function(e,t){(this._textures[e]=null,this._boundRenderer)&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,e,t))},dispose:function(e){var t=e.gl,n=this._cache;n.use(e.__uid__);var r=n.get(D$);r&&t.deleteRenderbuffer(r);var i=n.get(C$);i&&t.deleteFramebuffer(i),n.deleteContext(e.__uid__),this._textures={}}});k$.DEPTH_ATTACHMENT=O$,k$.COLOR_ATTACHMENT0=R$,k$.STENCIL_ATTACHMENT=yZ,k$.DEPTH_STENCIL_ATTACHMENT=_Z;var z$=["px","nx","py","ny","pz","nz"],V$=bY.extend((function(){var e={position:new Bq,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new M$({fov:90}),nx:new M$({fov:90}),py:new M$({fov:90}),ny:new M$({fov:90}),pz:new M$({fov:90}),nz:new M$({fov:90})};return t.px.lookAt(Bq.POSITIVE_X,Bq.NEGATIVE_Y),t.nx.lookAt(Bq.NEGATIVE_X,Bq.NEGATIVE_Y),t.py.lookAt(Bq.POSITIVE_Y,Bq.POSITIVE_Z),t.ny.lookAt(Bq.NEGATIVE_Y,Bq.NEGATIVE_Z),t.pz.lookAt(Bq.POSITIVE_Z,Bq.NEGATIVE_Y),t.nz.lookAt(Bq.NEGATIVE_Z,Bq.NEGATIVE_Y),e._frameBuffer=new k$,e}),{getCamera:function(e){return this._cameras[e]},render:function(e,t,n){var r=e.gl;n||t.update();for(var i=this.texture.width,o=2*Math.atan(i/(i-.5))/Math.PI*180,a=0;a<6;a++){var s=z$[a],l=this._cameras[s];if(Bq.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=o,this.shadowMapPass){l.update();var u=t.getBoundingBox();u.applyTransform(l.viewMatrix),t.viewBoundingBoxLastFrame.copy(u),this.shadowMapPass.render(e,t,l,!0)}this._frameBuffer.attach(this.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a),this._frameBuffer.bind(e),e.render(t,l,!0),this._frameBuffer.unbind(e)}},dispose:function(e){this._frameBuffer.dispose(e)}}),B$=WK.extend({dynamic:!1,widthSegments:1,heightSegments:1},(function(){this.build()}),{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,r=[],i=[],o=[],a=[],s=0;s<=e;s++)for(var l=s/e,u=0;u<=t;u++){var c=u/t;if(r.push([2*c-1,2*l-1,0]),i.push([c,l]),o.push([0,0,1]),u<t&&s<e){var h=u+s*(t+1);a.push([h,h+1,h+t+1]),a.push([h+t+1,h+1,h+t+2])}}n.position.fromArray(r),n.texcoord0.fromArray(i),n.normal.fromArray(o),this.initIndicesFromArray(a),this.boundingBox=new _K,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),F$=new iK,G$=WK.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},(function(){this.build()}),{build:function(){var e={px:H$("px",this.depthSegments,this.heightSegments),nx:H$("nx",this.depthSegments,this.heightSegments),py:H$("py",this.widthSegments,this.depthSegments),ny:H$("ny",this.widthSegments,this.depthSegments),pz:H$("pz",this.widthSegments,this.heightSegments),nz:H$("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],n=0,r=0;for(var i in e)n+=e[i].vertexCount,r+=e[i].indices.length;for(var o=0;o<t.length;o++)this.attributes[t[o]].init(n);this.indices=new wZ.Uint16Array(r);var a=0,s=0;for(var i in e){var l=e[i];for(o=0;o<t.length;o++)for(var u=t[o],c=l.attributes[u].value,h=l.attributes[u].size,d="normal"===u,p=0;p<c.length;p++){var f=c[p];this.inside&&d&&(f=-f),this.attributes[u].value[p+h*s]=f}var g=l.indices.length;for(p=0;p<l.indices.length;p++)this.indices[p+a]=s+l.indices[this.inside?g-p-1:p];a+=l.indices.length,s+=l.vertexCount}this.boundingBox=new _K,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});function H$(e,t,n){F$.identity();var r=new B$({widthSegments:t,heightSegments:n});switch(e){case"px":iK.translate(F$,F$,Bq.POSITIVE_X),iK.rotateY(F$,F$,Math.PI/2);break;case"nx":iK.translate(F$,F$,Bq.NEGATIVE_X),iK.rotateY(F$,F$,-Math.PI/2);break;case"py":iK.translate(F$,F$,Bq.POSITIVE_Y),iK.rotateX(F$,F$,-Math.PI/2);break;case"ny":iK.translate(F$,F$,Bq.NEGATIVE_Y),iK.rotateX(F$,F$,Math.PI/2);break;case"pz":iK.translate(F$,F$,Bq.POSITIVE_Z);break;case"nz":iK.translate(F$,F$,Bq.NEGATIVE_Z),iK.rotateY(F$,F$,Math.PI)}return r.applyTransform(F$),r}bq.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");var U$=IK.extend((function(){var e=new bq({vertex:bq.source("clay.skybox.vertex"),fragment:bq.source("clay.skybox.fragment")}),t=new WZ({shader:e,depthMask:!1});return{scene:null,geometry:new G$,material:t,environmentMap:null,culling:!1,_dummyCamera:new M$}}),(function(){var e=this.scene;e&&this.attachScene(e),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)}),{attachScene:function(e){this.scene&&this.detachScene(),e.skybox=this,this.scene=e,e.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(e){this.detachScene(),this.geometry.dispose(e)},setEnvironmentMap:function(e){"texture2D"===e.textureType?(this.material.define("EQUIRECTANGULAR"),e.minFilter=AK.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,n){this.renderSkybox(e,n)},renderSkybox:function(e,t){var n=this._dummyCamera;n.aspect=e.getViewportAspect(),n.fov=t.fov||50,n.updateProjectionMatrix(),iK.invert(n.invProjectionMatrix,n.projectionMatrix),n.worldTransform.copy(t.worldTransform),n.viewMatrix.copy(t.viewMatrix),this.position.copy(t.getWorldPosition()),this.update(),e.gl.disable(e.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],n)}});function W$(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var j$=W$("DXT1"),X$=W$("DXT3"),Y$=W$("DXT5"),Z$=function(e,t){var n=new Int32Array(e,0,31);if(542327876!==n[0])return null;if(4&!n(20))return null;var r,i,o=n(21),a=n[4],s=n[3],l=512&n[28],u=131072&n[2];switch(o){case j$:r=8,i=AK.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case X$:r=16,i=AK.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case Y$:r=16,i=AK.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var c=n[1]+4,h=l?6:1,d=1;u&&(d=Math.max(1,n[7]));for(var p=[],f=0;f<h;f++){var g=a,m=s;p[f]=new PK({width:g,height:m,format:i});for(var v=[],y=0;y<d;y++){var _=Math.max(4,g)/4*Math.max(4,m)/4*r,x=new Uint8Array(e,c,_);c+=_,g*=.5,m*=.5,v[y]=x}p[f].pixels=v[0],u&&(p[f].mipmaps=v)}if(!t)return p[0];t.width=p[0].width,t.height=p[0].height,t.format=p[0].format,t.pixels=p[0].pixels,t.mipmaps=p[0].mipmaps},q$=String.fromCharCode;function K$(e,t,n,r){if(e[3]>0){var i=Math.pow(2,e[3]-128-8+r);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function $$(e,t,n,r){for(var i,o,a=0,s=0,l=r;l>0;)if(e[s][0]=t[n++],e[s][1]=t[n++],e[s][2]=t[n++],e[s][3]=t[n++],1===e[s][0]&&1===e[s][1]&&1===e[s][2]){for(var u=e[s][3]<<a>>>0;u>0;u--)i=e[s-1],(o=e[s])[0]=i[0],o[1]=i[1],o[2]=i[2],o[3]=i[3],s++,l--;a+=8}else s++,l--,a=0;return n}function J$(e,t,n,r){if(r<8|r>32767)return $$(e,t,n,r);if(2!=(i=t[n++]))return $$(e,t,n-1,r);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==r)return null;for(var i=0;i<4;i++)for(var o=0;o<r;){var a=t[n++];if(a>128){a=(127&a)>>>0;for(var s=t[n++];a--;)e[o++][i]=s}else for(;a--;)e[o++][i]=t[n++]}return n}var Q$=function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),i=r.length;if("#?"===function(e,t,n){for(var r="",i=t;i<n;i++)r+=q$(e[i]);return r}(r,0,2)){for(var o=2;o<i&&("\n"!==q$(r[o])||"\n"!==q$(r[o+1]));o++);if(!(o>=i)){o+=2;for(var a="";o<i;o++){var s=q$(r[o]);if("\n"===s)break;a+=s}var l=a.split(" "),u=parseInt(l[1]),c=parseInt(l[3]);if(c&&u){for(var h=o+1,d=[],p=0;p<c;p++){d[p]=[];for(var f=0;f<4;f++)d[p][f]=0}for(var g=new Float32Array(c*u*4),m=0,v=0;v<u;v++){if(!(h=J$(d,r,h,c)))return null;for(p=0;p<c;p++)K$(d[p],g,m,n),m+=4}return t||(t=new PK),t.width=c,t.height=u,t.pixels=g,t.type=AK.FLOAT,t}}}},eJ={loadTexture:function(e,t,n,r){var i;if("function"==typeof t?(r=n=t,t={}):t=t||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===t.fileType)return i=new PK({width:0,height:0,sRGB:!1}),eJ._fetchTexture(e,(function(e){Q$(e,i,t.exposure),i.dirty(),n&&n(i)}),r),i;e.match(/.dds$/)||"dds"===t.fileType?(i=new PK({width:0,height:0}),eJ._fetchTexture(e,(function(e){Z$(e,i),i.dirty(),n&&n(i)}),r)):((i=new PK).load(e),i.success(n),i.error(r))}else"object"==typeof e&&void 0!==e.px&&((i=new S$).load(e),i.success(n),i.error(r));return i},loadPanorama:function(e,t,n,r,i,o){var a=this;"function"==typeof r?(o=i=r,r={}):r=r||{},eJ.loadTexture(t,r,(function(t){t.flipY=r.flipY||!1,a.panoramaToCubeMap(e,t,n,r),t.dispose(e),i&&i(n)}),o)},panoramaToCubeMap:function(e,t,n,r){var i=new V$,o=new U$({scene:new _$});return o.setEnvironmentMap(t),(r=r||{}).encodeRGBM&&o.material.define("fragment","RGBM_ENCODE"),n.sRGB=t.sRGB,i.texture=n,i.render(e,o.scene),i.texture=null,i.dispose(e),n},heightToNormal:function(e,t){var n=document.createElement("canvas"),r=n.width=e.width,i=n.height=e.height,o=n.getContext("2d");o.drawImage(e,0,0,r,i),t=t||!1;for(var a=o.getImageData(0,0,r,i),s=o.createImageData(r,i),l=0;l<a.data.length;l+=4){if(t){var u=a.data[l],c=a.data[l+1],h=a.data[l+2];if(Math.abs(u-c)+Math.abs(c-h)>20)return console.warn("Given image is not a height map"),e}var d,p,f,g;l%(4*r)==0?(d=a.data[l],f=a.data[l+4]):l%(4*r)==4*(r-1)?(d=a.data[l-4],f=a.data[l]):(d=a.data[l-4],f=a.data[l+4]),l<4*r?(p=a.data[l],g=a.data[l+4*r]):l>r*(i-1)*4?(p=a.data[l-4*r],g=a.data[l]):(p=a.data[l-4*r],g=a.data[l+4*r]),s.data[l]=d-f+127,s.data[l+1]=p-g+127,s.data[l+2]=255,s.data[l+3]=255}return o.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var r=document.createElement("canvas"),i=r.getContext("2d"),o=t||32;n=n||20,r.width=r.height=o,i.drawImage(e,0,0,o,o);for(var a=i.getImageData(0,0,o,o),s=0;s<a.data.length;s+=4){var l=a.data[s],u=a.data[s+1],c=a.data[s+2];if(Math.abs(l-u)+Math.abs(u-c)>n)return!1}return!0},_fetchTexture:function(e,t,n){wZ.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,r){e=e||512,t=t||64,n=n||"black",r=r||"white";var i=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var a=o.getContext("2d");a.fillStyle=r,a.fillRect(0,0,e,e),a.fillStyle=n;for(var s=0;s<i;s++)for(var l=0;l<i;l++){(l%2?s%2:s%2-1)&&a.fillRect(s*t,l*t,t,t)}return new PK({image:o,anisotropic:8})},createBlank:function(e){var t=document.createElement("canvas");t.width=1,t.height=1;var n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,1,1),new PK({image:t})}},tJ=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function nJ(e){return"_on"+e}var rJ=function(e){var t=this;this._texture=new PK({anisotropic:32,flipY:!1,surface:this,dispose:function(e){t.dispose(),PK.prototype.dispose.call(this,e)}}),tJ.forEach((function(e){this[nJ(e)]=function(t){t.triangle&&this._meshes.forEach((function(n){this.dispatchEvent(e,n,t.triangle,t.point)}),this)}}),this),this._meshes=[],e&&this.setECharts(e),this.onupdate=null};rJ.prototype={constructor:rJ,getTexture:function(){return this._texture},setECharts:function(e){this._chart=e;var t=e.getDom();if(t instanceof HTMLCanvasElement){var n=this,r=e.getZr(),i=r.__oldRefreshImmediately||r.refreshImmediately;r.refreshImmediately=function(){i.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},r.__oldRefreshImmediately=i}else console.error("ECharts must init on canvas if it is used as texture."),t=document.createElement("canvas");this._texture.image=t,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var e=new Bq,t=new Bq,n=new Bq,r=new qZ,i=new qZ,o=new qZ,a=new qZ,s=new Bq;return function(l,u,c,h){var d=u.geometry,p=d.attributes.position,f=d.attributes.texcoord0,g=Bq.dot,m=Bq.cross;p.get(c[0],e.array),p.get(c[1],t.array),p.get(c[2],n.array),f.get(c[0],r.array),f.get(c[1],i.array),f.get(c[2],o.array),m(s,t,n);var v=g(e,s),y=g(h,s)/v;m(s,n,e);var _=g(h,s)/v;m(s,e,t);var x=g(h,s)/v;qZ.scale(a,r,y),qZ.scaleAndAdd(a,a,i,_),qZ.scaleAndAdd(a,a,o,x);var b=a.x*this._chart.getWidth(),w=a.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:b,zrY:w})}}(),attachToMesh:function(e){this._meshes.indexOf(e)>=0||(tJ.forEach((function(t){e.on(t,this[nJ(t)],this)}),this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),tJ.forEach((function(t){e.off(t,this[nJ(t)])}),this)},dispose:function(){this._meshes.forEach((function(e){this.detachFromMesh(e)}),this)}};var iJ=h$.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=h$.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});bq.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var oJ=new B$,aJ=new IK({geometry:oJ,frustumCulling:!1}),sJ=new iJ,lJ=bY.extend((function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}}),(function(){var e=new bq(bq.source("clay.compositor.vertex"),this.fragment),t=new WZ({shader:e});t.enableTexturesAll(),this.material=t}),{setUniform:function(e,t){this.material.setUniform(e,t)},getUniform:function(e){var t=this.material.uniforms[e];if(t)return t.value},attachOutput:function(e,t){this.outputs||(this.outputs={}),t=t||mZ,this.outputs[t]=e},detachOutput:function(e){for(var t in this.outputs)this.outputs[t]===e&&(this.outputs[t]=null)},bind:function(e,t){if(this.outputs)for(var n in this.outputs){var r=this.outputs[n];r&&t.attach(r,n)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var n=e.gl;if(t){this.bind(e,t);var r=e.getGLExtension("EXT_draw_buffers");if(r&&this.outputs){var i=[];for(var o in this.outputs)(o=+o)>=n.COLOR_ATTACHMENT0&&o<=n.COLOR_ATTACHMENT0+8&&i.push(o);r.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var a=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){a|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(a),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){aJ.material=this.material,e.renderPass([aJ],sJ)},dispose:function(e){}}),uJ={},cJ=["px","nx","py","ny","pz","nz"];uJ.prefilterEnvironmentMap=function(e,t,n,r,i){i&&r||(r=uJ.generateNormalDistribution(),i=uJ.integrateBRDF(e,r));var o=(n=n||{}).width||64,a=n.height||64,s=n.type||t.type,l=new S$({width:o,height:a,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var u=Math.min(o,a),c=Math.log(u)/Math.log(2)+1,h=new WZ({shader:new bq({vertex:bq.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});h.set("normalDistribution",r),n.encodeRGBM&&h.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&h.define("fragment","RGBM_DECODE");var d,p=new _$;if("texture2D"===t.textureType){var f=new S$({width:o,height:a,type:s===AK.FLOAT?AK.HALF_FLOAT:s});eJ.panoramaToCubeMap(e,t,f,{encodeRGBM:n.decodeRGBM}),t=f}(d=new U$({scene:p,material:h})).material.set("environmentMap",t);var g=new V$({texture:l});n.encodeRGBM&&(s=l.type=AK.UNSIGNED_BYTE);for(var m=new PK({width:o,height:a,type:s}),v=new k$({depthBuffer:!1}),y=wZ[s===AK.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],_=0;_<c;_++){l.mipmaps[_]={pixels:{}},d.material.set("roughness",_/(c-1));for(var x=m.width,b=2*Math.atan(x/(x-.5))/Math.PI*180,w=0;w<cJ.length;w++){var S=new y(m.width*m.height*4);v.attach(m),v.bind(e);var T=g.getCamera(cJ[w]);T.fov=b,e.render(p,T),e.gl.readPixels(0,0,m.width,m.height,AK.RGBA,s,S),v.unbind(e),l.mipmaps[_].pixels[cJ[w]]=S}m.width/=2,m.height/=2,m.dirty()}return v.dispose(e),m.dispose(e),d.dispose(e),r.dispose(e),{environmentMap:l,brdfLookup:i,normalDistribution:r,maxMipmapLevel:c}},uJ.integrateBRDF=function(e,t){t=t||uJ.generateNormalDistribution();var n=new k$({depthBuffer:!1}),r=new lJ({fragment:"#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),i=new PK({width:512,height:256,type:AK.HALF_FLOAT,wrapS:AK.CLAMP_TO_EDGE,wrapT:AK.CLAMP_TO_EDGE,minFilter:AK.NEAREST,magFilter:AK.NEAREST,useMipmap:!1});return r.setUniform("normalDistribution",t),r.setUniform("viewportSize",[512,256]),r.attachOutput(i),r.render(e,n),n.dispose(e),i},uJ.generateNormalDistribution=function(e,t){for(var n=new PK({width:e=e||256,height:t=t||1024,type:AK.FLOAT,minFilter:AK.NEAREST,magFilter:AK.NEAREST,wrapS:AK.CLAMP_TO_EDGE,wrapT:AK.CLAMP_TO_EDGE,useMipmap:!1}),r=new Float32Array(t*e*4),i=[],o=0;o<e;o++){for(var a=o/e,s=a*a,l=0;l<t;l++){var u=(l<<16|l>>>16)>>>0;u=(((16711935&(u=((252645135&(u=((858993459&(u=((1431655765&u)<<1|(2863311530&u)>>>1)>>>0))<<2|(3435973836&u)>>>2)>>>0))<<4|(4042322160&u)>>>4)>>>0))<<8|(4278255360&u)>>>8)>>>0)/4294967296;var c=Math.sqrt((1-u)/(1+(s*s-1)*u));i[l]=c}for(l=0;l<t;l++){var h=4*(l*e+o),d=(c=i[l],Math.sqrt(1-c*c)),p=l/t,f=2*Math.PI*p;r[h]=d*Math.cos(f),r[h+1]=c,r[h+2]=d*Math.sin(f),r[h+3]=1}}return n.pixels=r,n};var hJ=t$.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){if(e.getGLExtension("EXT_shader_texture_lod")){this._brdfLookup||(this._normalDistribution=uJ.generateNormalDistribution(),this._brdfLookup=uJ.integrateBRDF(e,this._normalDistribution));var n=this.cubemap;if(!n.__prefiltered){var r=uJ.prefilterEnvironmentMap(e,n,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=r.environmentMap,this.cubemap.__prefiltered=!0,n.dispose(e)}}else console.warn("Device not support textureCubeLodEXT")},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}}),dJ=t$.extend({castShadow:!1,coefficients:[]},(function(){this._coefficientsTmpArr=new wZ.Float32Array(27)}),{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,n=0;n<e.coefficients.length;n++)t[n]=e.coefficients[n];return t}}}}),pJ={},fJ=["px","nx","py","ny","pz","nz"];function gJ(e,t){var n=e[0],r=e[1],i=e[2];return 0===t?1:1===t?n:2===t?r:3===t?i:4===t?n*i:5===t?r*i:6===t?n*r:7===t?3*i*i-1:n*n-r*r}var mJ={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};pJ.projectEnvironmentMap=function(e,t,n){var r;(n=n||{}).lod=n.lod||0;var i=new _$,o=64;"texture2D"===t.textureType||(o=t.image&&t.image.px?t.image.px.width:t.width),r=new U$({scene:i,environmentMap:t});var a=Math.ceil(o/Math.pow(2,n.lod)),s=Math.ceil(o/Math.pow(2,n.lod)),l=new PK({width:a,height:s}),u=new k$;r.material.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&r.material.define("fragment","RGBM_DECODE"),r.material.set("lod",n.lod);for(var c=new V$({texture:l}),h={},d=0;d<fJ.length;d++){h[fJ[d]]=new Uint8Array(a*s*4);var p=c.getCamera(fJ[d]);p.fov=90,u.attach(l),u.bind(e),e.render(i,p),e.gl.readPixels(0,0,a,s,AK.RGBA,AK.UNSIGNED_BYTE,h[fJ[d]]),u.unbind(e)}return r.dispose(e),u.dispose(e),l.dispose(e),function(e,t,n,r){for(var i=new wZ.Float32Array(27),o=Cq.create(),a=Cq.create(),s=Cq.create(),l=0;l<9;l++){for(var u=Cq.create(),c=0;c<fJ.length;c++){for(var h=t[fJ[c]],d=Cq.create(),p=0,f=0,g=mJ[fJ[c]],m=0;m<r;m++)for(var v=0;v<n;v++){o[0]=v/(n-1)*2-1,o[1]=m/(r-1)*2-1,o[2]=-1,Cq.normalize(o,o),s[0]=o[g[0]]*g[3],s[1]=o[g[1]]*g[4],s[2]=o[g[2]]*g[5],a[0]=h[f++]/255,a[1]=h[f++]/255,a[2]=h[f++]/255;var y=h[f++]/255*8.12;a[0]*=y,a[1]*=y,a[2]*=y,Cq.scaleAndAdd(d,d,a,gJ(s,l)*-o[2]),p+=-o[2]}Cq.scaleAndAdd(u,u,d,1/p)}i[3*l]=u[0]/6,i[3*l+1]=u[1]/6,i[3*l+2]=u[2]/6}return i}(0,h,a,s)};var vJ=function(){for(var e=0,t=arguments.length;e<t;e++)if(null!=arguments[e])return arguments[e]},yJ=function(e,t){return null!=t.dataIndexInside?t.dataIndexInside:null!=t.dataIndex?J(t.dataIndex)?j(t.dataIndex,(function(t){return e.indexOfRawIndex(t)})):e.indexOfRawIndex(t.dataIndex):null!=t.name?J(t.name)?j(t.name,(function(t){return e.indexOfName(t)})):e.indexOfName(t.name):void 0},_J=WK.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},(function(){this.build()}),{build:function(){var e=this.heightSegments,t=this.widthSegments,n=this.attributes.position,r=this.attributes.texcoord0,i=this.attributes.normal,o=(t+1)*(e+1);n.init(o),r.init(o),i.init(o);var a,s,l,u,c,h,d,p,f,g,m,v=o>65535?Uint32Array:Uint16Array,y=this.indices=new v(t*e*6),_=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,S=this.thetaLength,T=[],M=[],C=0,D=1/(_=this.radius);for(d=0;d<=e;d++)for(h=0;h<=t;h++)u=h/t,c=d/e,a=-_*Math.cos(x+u*b)*Math.sin(w+c*S),s=_*Math.cos(w+c*S),l=_*Math.sin(x+u*b)*Math.sin(w+c*S),T[0]=a,T[1]=s,T[2]=l,M[0]=u,M[1]=c,n.set(C,T),r.set(C,M),T[0]*=D,T[1]*=D,T[2]*=D,i.set(C,T),C++;var A=t+1,I=0;for(d=0;d<e;d++)for(h=0;h<t;h++)f=d*A+h,p=d*A+h+1,m=(d+1)*A+h+1,g=(d+1)*A+h,y[I++]=p,y[I++]=f,y[I++]=m,y[I++]=f,y[I++]=g,y[I++]=m;this.boundingBox=new _K,this.boundingBox.max.set(_,_,_),this.boundingBox.min.set(-_,-_,-_)}}),xJ=t$.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}}),bJ=t$.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Bq,e.__dir.copy(e.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=t$.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),wJ=t$.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(e){return e.range}},pointLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=t$.prototype.clone.call(this);return e.range=this.range,e}}),SJ=t$.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(e){return e.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(e){return e.falloffFactor}},spotLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new Bq,e.__dir.copy(e.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=t$.prototype.clone.call(this);return e.range=this.range,e.umbraAngle=this.umbraAngle,e.penumbraAngle=this.penumbraAngle,e.falloffFactor=this.falloffFactor,e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),TJ=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=r||0,this.array=$q.fromValues(e,t,n,r),this._dirty=!0};TJ.prototype={constructor:TJ,add:function(e){return $q.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,n,r){return this.array[0]=e,this.array[1]=t,this.array[2]=n,this.array[3]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new TJ(this.x,this.y,this.z,this.w)},copy:function(e){return $q.copy(this.array,e.array),this._dirty=!0,this},dist:function(e){return $q.dist(this.array,e.array)},distance:function(e){return $q.distance(this.array,e.array)},div:function(e){return $q.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return $q.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return $q.dot(this.array,e.array)},len:function(){return $q.len(this.array)},length:function(){return $q.length(this.array)},lerp:function(e,t,n){return $q.lerp(this.array,e.array,t.array,n),this._dirty=!0,this},min:function(e){return $q.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return $q.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return $q.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return $q.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return $q.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return $q.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return $q.random(this.array,e),this._dirty=!0,this},scale:function(e){return $q.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return $q.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return $q.sqrDist(this.array,e.array)},squaredDistance:function(e){return $q.squaredDistance(this.array,e.array)},sqrLen:function(){return $q.sqrLen(this.array)},squaredLength:function(){return $q.squaredLength(this.array)},sub:function(e){return $q.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return $q.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return $q.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return $q.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var MJ=Object.defineProperty;if(MJ){var CJ=TJ.prototype;MJ(CJ,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),MJ(CJ,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),MJ(CJ,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),MJ(CJ,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}TJ.add=function(e,t,n){return $q.add(e.array,t.array,n.array),e._dirty=!0,e},TJ.set=function(e,t,n,r,i){$q.set(e.array,t,n,r,i),e._dirty=!0},TJ.copy=function(e,t){return $q.copy(e.array,t.array),e._dirty=!0,e},TJ.distance=TJ.dist=function(e,t){return $q.distance(e.array,t.array)},TJ.div=function(e,t,n){return $q.divide(e.array,t.array,n.array),e._dirty=!0,e},TJ.divide=TJ.div,TJ.dot=function(e,t){return $q.dot(e.array,t.array)},TJ.len=function(e){return $q.length(e.array)},TJ.lerp=function(e,t,n,r){return $q.lerp(e.array,t.array,n.array,r),e._dirty=!0,e},TJ.min=function(e,t,n){return $q.min(e.array,t.array,n.array),e._dirty=!0,e},TJ.max=function(e,t,n){return $q.max(e.array,t.array,n.array),e._dirty=!0,e},TJ.mul=function(e,t,n){return $q.multiply(e.array,t.array,n.array),e._dirty=!0,e},TJ.multiply=TJ.mul,TJ.negate=function(e,t){return $q.negate(e.array,t.array),e._dirty=!0,e},TJ.normalize=function(e,t){return $q.normalize(e.array,t.array),e._dirty=!0,e},TJ.random=function(e,t){return $q.random(e.array,t),e._dirty=!0,e},TJ.scale=function(e,t,n){return $q.scale(e.array,t.array,n),e._dirty=!0,e},TJ.scaleAndAdd=function(e,t,n,r){return $q.scaleAndAdd(e.array,t.array,n.array,r),e._dirty=!0,e},TJ.squaredDistance=TJ.sqrDist=function(e,t){return $q.sqrDist(e.array,t.array)},TJ.squaredLength=TJ.sqrLen=function(e){return $q.sqrLen(e.array)},TJ.sub=function(e,t,n){return $q.subtract(e.array,t.array,n.array),e._dirty=!0,e},TJ.subtract=TJ.sub,TJ.transformMat4=function(e,t,n){return $q.transformMat4(e.array,t.array,n.array),e._dirty=!0,e},TJ.transformQuat=function(e,t,n){return $q.transformQuat(e.array,t.array,n.array),e._dirty=!0,e};var DJ={create:function(){var e=new XZ(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},clone:function(e){var t=new XZ(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},transpose:function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(a=1/a,e[0]=o*a,e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null},adjoint:function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},determinant:function(e){return e[0]*e[3]-e[2]*e[1]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*s+o*l,e[1]=i*s+a*l,e[2]=r*u+o*c,e[3]=i*u+a*c,e}};DJ.mul=DJ.multiply,DJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l,e},DJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1];return e[0]=r*s,e[1]=i*s,e[2]=o*l,e[3]=a*l,e},DJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2))},DJ.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]};var AJ=function(){this.array=DJ.create(),this._dirty=!0};AJ.prototype={constructor:AJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new AJ).copy(this)},copy:function(e){return DJ.copy(this.array,e.array),this._dirty=!0,this},adjoint:function(){return DJ.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return DJ.determinant(this.array)},identity:function(){return DJ.identity(this.array),this._dirty=!0,this},invert:function(){return DJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return DJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return DJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return DJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return DJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return DJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return DJ.scale(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return DJ.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},AJ.adjoint=function(e,t){return DJ.adjoint(e.array,t.array),e._dirty=!0,e},AJ.copy=function(e,t){return DJ.copy(e.array,t.array),e._dirty=!0,e},AJ.determinant=function(e){return DJ.determinant(e.array)},AJ.identity=function(e){return DJ.identity(e.array),e._dirty=!0,e},AJ.invert=function(e,t){return DJ.invert(e.array,t.array),e._dirty=!0,e},AJ.mul=function(e,t,n){return DJ.mul(e.array,t.array,n.array),e._dirty=!0,e},AJ.multiply=AJ.mul,AJ.rotate=function(e,t,n){return DJ.rotate(e.array,t.array,n),e._dirty=!0,e},AJ.scale=function(e,t,n){return DJ.scale(e.array,t.array,n.array),e._dirty=!0,e},AJ.transpose=function(e,t){return DJ.transpose(e.array,t.array),e._dirty=!0,e};var IJ={create:function(){var e=new XZ(6);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},clone:function(e){var t=new XZ(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},identity:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},invert:function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n*o-r*i;return l?(l=1/l,e[0]=o*l,e[1]=-r*l,e[2]=-i*l,e[3]=n*l,e[4]=(i*s-o*a)*l,e[5]=(r*a-n*s)*l,e):null},determinant:function(e){return e[0]*e[3]-e[1]*e[2]},multiply:function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1],h=n[2],d=n[3],p=n[4],f=n[5];return e[0]=r*u+o*c,e[1]=i*u+a*c,e[2]=r*h+o*d,e[3]=i*h+a*d,e[4]=r*p+o*f+s,e[5]=i*p+a*f+l,e}};IJ.mul=IJ.multiply,IJ.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=Math.sin(n),c=Math.cos(n);return e[0]=r*c+o*u,e[1]=i*c+a*u,e[2]=r*-u+o*c,e[3]=i*-u+a*c,e[4]=s,e[5]=l,e},IJ.scale=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r*u,e[1]=i*u,e[2]=o*c,e[3]=a*c,e[4]=s,e[5]=l,e},IJ.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=r*u+o*c+s,e[5]=i*u+a*c+l,e},IJ.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+1)};var EJ=function(){this.array=IJ.create(),this._dirty=!0};EJ.prototype={constructor:EJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return(new EJ).copy(this)},copy:function(e){return IJ.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return IJ.determinant(this.array)},identity:function(){return IJ.identity(this.array),this._dirty=!0,this},invert:function(){return IJ.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return IJ.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return IJ.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return IJ.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return IJ.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return IJ.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return IJ.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return IJ.translate(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},EJ.copy=function(e,t){return IJ.copy(e.array,t.array),e._dirty=!0,e},EJ.determinant=function(e){return IJ.determinant(e.array)},EJ.identity=function(e){return IJ.identity(e.array),e._dirty=!0,e},EJ.invert=function(e,t){return IJ.invert(e.array,t.array),e._dirty=!0,e},EJ.mul=function(e,t,n){return IJ.mul(e.array,t.array,n.array),e._dirty=!0,e},EJ.multiply=EJ.mul,EJ.rotate=function(e,t,n){return IJ.rotate(e.array,t.array,n),e._dirty=!0,e},EJ.scale=function(e,t,n){return IJ.scale(e.array,t.array,n.array),e._dirty=!0,e},EJ.translate=function(e,t,n){return IJ.translate(e.array,t.array,n.array),e._dirty=!0,e};var LJ=function(){this.array=Jq.create(),this._dirty=!0};LJ.prototype={constructor:LJ,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return Jq.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new LJ).copy(this)},copy:function(e){return Jq.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Jq.determinant(this.array)},fromMat2d:function(e){return Jq.fromMat2d(this.array,e.array),this._dirty=!0,this},fromMat4:function(e){return Jq.fromMat4(this.array,e.array),this._dirty=!0,this},fromQuat:function(e){return Jq.fromQuat(this.array,e.array),this._dirty=!0,this},identity:function(){return Jq.identity(this.array),this._dirty=!0,this},invert:function(){return Jq.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return Jq.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Jq.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Jq.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Jq.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return Jq.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Jq.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Jq.translate(this.array,this.array,e.array),this._dirty=!0,this},normalFromMat4:function(e){return Jq.normalFromMat4(this.array,e.array),this._dirty=!0,this},transpose:function(){return Jq.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},LJ.adjoint=function(e,t){return Jq.adjoint(e.array,t.array),e._dirty=!0,e},LJ.copy=function(e,t){return Jq.copy(e.array,t.array),e._dirty=!0,e},LJ.determinant=function(e){return Jq.determinant(e.array)},LJ.identity=function(e){return Jq.identity(e.array),e._dirty=!0,e},LJ.invert=function(e,t){return Jq.invert(e.array,t.array),e},LJ.mul=function(e,t,n){return Jq.mul(e.array,t.array,n.array),e._dirty=!0,e},LJ.multiply=LJ.mul,LJ.fromMat2d=function(e,t){return Jq.fromMat2d(e.array,t.array),e._dirty=!0,e},LJ.fromMat4=function(e,t){return Jq.fromMat4(e.array,t.array),e._dirty=!0,e},LJ.fromQuat=function(e,t){return Jq.fromQuat(e.array,t.array),e._dirty=!0,e},LJ.normalFromMat4=function(e,t){return Jq.normalFromMat4(e.array,t.array),e._dirty=!0,e},LJ.rotate=function(e,t,n){return Jq.rotate(e.array,t.array,n),e._dirty=!0,e},LJ.scale=function(e,t,n){return Jq.scale(e.array,t.array,n.array),e._dirty=!0,e},LJ.transpose=function(e,t){return Jq.transpose(e.array,t.array),e._dirty=!0,e},LJ.translate=function(e,t,n){return Jq.translate(e.array,t.array,n.array),e._dirty=!0,e};var NJ={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(e,t){this._animators=this._animators||[];var n;if(e){for(var r=e.split("."),i=this,o=0,a=r.length;o<a;o++)i&&(i=i[r[o]]);i&&(n=i)}else n=this;if(null==n)throw new Error("Target "+e+" not exists");var s=this._animators,l=new Wr(n,t),u=this;return l.during((function(){u.__zr&&u.__zr.refresh()})).done((function(){var e=s.indexOf(l);e>=0&&s.splice(e,1)})),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,n=t.length,r=0;r<n;r++)t[r].stop(e);return t.length=0,this},addAnimatorsToZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.addAnimator(this._animators[t])},removeAnimatorsFromZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.removeAnimator(this._animators[t])}},PJ="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return 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 return 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}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end";function OJ(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}Object.assign(SK.prototype,NJ),bq.import(PJ),bq.import(Tq),bq.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),bq.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),bq.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),bq.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),bq.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),bq.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var RJ=_$.prototype.addToScene,kJ=_$.prototype.removeFromScene;_$.prototype.addToScene=function(e){if(RJ.call(this,e),this.__zr){var t=this.__zr;e.traverse((function(e){e.__zr=t,e.addAnimatorsToZr&&e.addAnimatorsToZr(t)}))}},_$.prototype.removeFromScene=function(e){kJ.call(this,e),e.traverse((function(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}))},WZ.prototype.setTextureImage=function(e,t,n,r){if(this.shader){var i,o,a=n.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(e),(o=t)&&"none"!==o&&(i=zJ.loadTexture(t,n,r,(function(t){s.enableTexture(e),a&&a.refresh()})),s.set(e,i)),i}};var zJ={};zJ.Renderer=zq,zJ.Node=SK,zJ.Mesh=IK,zJ.Shader=bq,zJ.Material=WZ,zJ.Texture=AK,zJ.Texture2D=PK,zJ.Geometry=WK,zJ.SphereGeometry=_J,zJ.PlaneGeometry=B$,zJ.CubeGeometry=G$,zJ.AmbientLight=xJ,zJ.DirectionalLight=bJ,zJ.PointLight=wJ,zJ.SpotLight=SJ,zJ.PerspectiveCamera=M$,zJ.OrthographicCamera=iJ,zJ.Vector2=qZ,zJ.Vector3=Bq,zJ.Vector4=TJ,zJ.Quaternion=lK,zJ.Matrix2=AJ,zJ.Matrix2d=EJ,zJ.Matrix3=LJ,zJ.Matrix4=iK,zJ.Plane=n$,zJ.Ray=Kq,zJ.BoundingBox=_K,zJ.Frustum=u$;var VJ=null;function BJ(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function FJ(e){if((e.wrapS===AK.REPEAT||e.wrapT===AK.REPEAT)&&e.image){var t=BJ(e.width),n=BJ(e.height);if(t!==e.width||n!==e.height){var r=document.createElement("canvas");r.width=t,r.height=n,r.getContext("2d").drawImage(e.image,0,0,t,n),e.image=r}}}zJ.loadTexture=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n=n||{};for(var i=Object.keys(n).sort(),o="",a=0;a<i.length;a++)o+=i[a]+"_"+n[i[a]]+"_";var s,l=t.__textureCache=t.__textureCache||new Un(20);if((s=e).getZr&&s.setOption){var u=e.__textureid__;if(h=l.get(o+u))h.texture.surface.setECharts(e),r&&r(h.texture);else{var c=new rJ(e);c.onupdate=function(){t.getZr().refresh()},h={texture:c.getTexture()};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_ec__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),r&&r(h.texture)}return h.texture}if(OJ(e)){var h;u=e.__textureid__;if(!(h=l.get(o+u))){h={texture:new zJ.Texture2D({image:e})};for(a=0;a<i.length;a++)h.texture[i[a]]=n[i[a]];u=e.__textureid__||"__ecgl_image__"+h.texture.__uid__,e.__textureid__=u,l.put(o+u,h),FJ(h.texture),r&&r(h.texture)}return h.texture}if(h=l.get(o+e))h.callbacks?h.callbacks.push(r):r&&r(h.texture);else if(e.match(/.hdr$|^data:application\/octet-stream/)){h={callbacks:[r]};var d=eJ.loadTexture(e,{exposure:n.exposure,fileType:"hdr"},(function(){d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null}));h.texture=d,l.put(o+e,h)}else{for(d=new zJ.Texture2D({image:new Image}),a=0;a<i.length;a++)d[i[a]]=n[i[a]];h={texture:d,callbacks:[r]};var p=d.image;p.onload=function(){d.image=p,FJ(d),d.dirty(),h.callbacks.forEach((function(e){e&&e(d)})),h.callbacks=null},p.crossOrigin="Anonymous",p.src=e,d.image=null!==VJ?VJ:VJ=eJ.createBlank("rgba(255,255,255,0)").image,l.put(o+e,h)}return h.texture},zJ.createAmbientCubemap=function(e,t,n,r){var i=(e=e||{}).texture,o=vJ(e.exposure,1),a=new hJ({intensity:vJ(e.specularIntensity,1)}),s=new dJ({intensity:vJ(e.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return a.cubemap=zJ.loadTexture(i,n,{exposure:o},(function(){if(a.cubemap.flipY=!1,"production"!==process.env.NODE_ENV)var e=Date.now();if(a.prefilter(t,32),"production"!==process.env.NODE_ENV){var n=Date.now()-e;console.log("Prefilter environment map: "+n+"ms")}s.coefficients=pJ.projectEnvironmentMap(t,a.cubemap,{lod:1}),r&&r()})),{specular:a,diffuse:s}},zJ.createBlankTexture=eJ.createBlank,zJ.isImage=OJ,zJ.additiveBlend=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)},zJ.parseColor=function(e,t){return e instanceof Array?(t||(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],e.length>3?t[3]=e[3]:t[3]=1,t):((t=nr(e||"#000",t)||[0,0,0,0])[0]/=255,t[1]/=255,t[2]/=255,t)},zJ.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,r=-t/180*Math.PI+Math.PI/2,i=[],o=Math.sin(n);return i[0]=o*Math.cos(r),i[1]=-Math.cos(n),i[2]=o*Math.sin(r),i},zJ.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096}return t},zJ.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],zJ.createShader=function(e){"ecgl.shadow"===e&&(e="ecgl.displayShadow");var t=bq.source(e+".vertex"),n=bq.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),n||console.error("Fragment shader of '%s' not exits",e);var r=new bq(t,n);return r.name=e,r},zJ.createMaterial=function(e,t){t instanceof Array||(t=[t]);var n=zJ.createShader(e),r=new WZ({shader:n});return t.forEach((function(e){"string"==typeof e&&r.define(e)})),r},zJ.setMaterialFromModel=function(e,t,n,r){t.autoUpdateTextureStatus=!1;var i=n.getModel(e+"Material"),o=i.get("detailTexture"),a=vJ(i.get("textureTiling"),1),s=vJ(i.get("textureOffset"),0);"number"==typeof a&&(a=[a,a]),"number"==typeof s&&(s=[s,s]);var l=a[0]>1||a[1]>1?zJ.Texture.REPEAT:zJ.Texture.CLAMP_TO_EDGE,u={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===e){var c=i.get("roughness"),h=i.get("metalness");null!=h?isNaN(h)&&(t.setTextureImage("metalnessMap",h,r,u),h=vJ(i.get("metalnessAdjust"),.5)):h=0,null!=c?isNaN(c)&&(t.setTextureImage("roughnessMap",c,r,u),c=vJ(i.get("roughnessAdjust"),.5)):c=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",o,r,u),t.setTextureImage("normalMap",d,r,u),t.set({roughness:c,metalness:h,detailUvRepeat:a,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",o,r,u),t.set({detailUvRepeat:a,detailUvOffset:s});else if("hatching"===e){var p=i.get("hatchingTextures")||[];p.length<6&&"production"!==process.env.NODE_ENV&&console.error("Invalid hatchingTextures.");for(var f=0;f<6;f++)t.setTextureImage("hatch"+(f+1),p[f],r,{anisotropic:8,wrapS:zJ.Texture.REPEAT,wrapT:zJ.Texture.REPEAT});t.set({detailUvRepeat:a,detailUvOffset:s})}},zJ.updateVertexAnimation=function(e,t,n,r){var i=r.get("animation"),o=r.get("animationDurationUpdate"),a=r.get("animationEasingUpdate"),s=n.shadowDepthMaterial;if(i&&t&&o>0&&t.geometry.vertexCount===n.geometry.vertexCount){n.material.define("vertex","VERTEX_ANIMATION"),n.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<e.length;l++)n.geometry.attributes[e[l][0]].value=t.geometry.attributes[e[l][1]].value;n.geometry.dirty(),n.__percent=0,n.material.set("percent",0),n.stopAnimation(),n.animate().when(o,{__percent:1}).during((function(){n.material.set("percent",n.__percent),s&&s.set("percent",n.__percent)})).done((function(){n.ignorePreZ=!1,n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")})).start(a)}else n.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")};var GJ=function(e,t){this.id=e,this.zr=t;try{this.renderer=new zq({clearBit:0,devicePixelRatio:t.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(t.painter.getWidth(),t.painter.getHeight())}catch(e){return this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",void console.error(e)}this.onglobalout=this.onglobalout.bind(this),t.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var n=this.dom.style;n.position="absolute",n.left="0",n.top="0",this.views=[],this._picking=new MK({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new tl({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null,this._disposed=!1};function HJ(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}GJ.prototype.setUnpainted=function(){},GJ.prototype.addView=function(e){if(e.layer!==this){var t=this._viewsToDispose.indexOf(e);t>=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var n=this.zr;e.scene.traverse((function(e){e.__zr=n,e.addAnimatorsToZr&&e.addAnimatorsToZr(n)}))}},GJ.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(HJ,this),e.layer=null,this._viewsToDispose.push(e))}},GJ.prototype.removeViewsAll=function(){this.views.forEach((function(e){e.scene.traverse(HJ,this),e.layer=null,this._viewsToDispose.push(e)}),this),this.views.length=0},GJ.prototype.resize=function(e,t){this.renderer.resize(e,t)},GJ.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)},GJ.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},GJ.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},GJ.prototype.needsRefresh=function(){this.zr.refresh()},GJ.prototype.refresh=function(e){this._backgroundColor=e?zJ.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t<this.views.length;t++)this.views[t].prepareRender(this.renderer);this._doRender(!1),this._trackAndClean();for(t=0;t<this._viewsToDispose.length;t++)this._viewsToDispose[t].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()},GJ.prototype.renderToCanvas=function(e){this._startAccumulating(!0),e.drawImage(this.dom,0,0,e.canvas.width,e.canvas.height)},GJ.prototype._doRender=function(e){this.clear(),this.renderer.saveViewport();for(var t=0;t<this.views.length;t++)this.views[t].render(this.renderer,e);this.renderer.restoreViewport()},GJ.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var UJ=1;function WJ(e){for(var t=0;t<e.length;t++)e[t].__used__=0}function jJ(e,t){for(var n=0;n<t.length;n++)t[n].__used__||t[n].dispose(e)}function XJ(e,t){e.__used__=e.__used__||0,e.__used__++,1===e.__used__&&t.push(e)}function YJ(e,t,n){var r,i;e.traverse((function(e){if(e.isRenderable()){var o=e.geometry,a=e.material;if(a!==r)for(var s=a.getTextureUniforms(),l=0;l<s.length;l++){var u=s[l],c=a.uniforms[u].value;if(c)if(c instanceof AK)XJ(c,t);else if(c instanceof Array)for(var h=0;h<c.length;h++)c[h]instanceof AK&&XJ(c[h],t)}o!==i&&XJ(o,n),r=a,i=o}}));for(var o=0;o<e.lights.length;o++)e.lights[o].cubemap&&XJ(e.lights[o].cubemap,t)}GJ.prototype._startAccumulating=function(e){var t=this;this._stopAccumulating();for(var n=!1,r=0;r<this.views.length;r++)n=this.views[r].needsAccumulate()||n;function i(r){if(t._accumulatingId&&r===t._accumulatingId){for(var o=!0,a=0;a<t.views.length;a++)o=t.views[a].isAccumulateFinished()&&n;o||(t._doRender(!0),e?i(r):dn((function(){i(r)})))}}n&&(this._accumulatingId=UJ++,e?i(t._accumulatingId):this._accumulatingTimeout=setTimeout((function(){i(t._accumulatingId)}),50))},GJ.prototype._trackAndClean=function(){var e=[],t=[];this._textureList&&(WJ(this._textureList),WJ(this._geometriesList));for(var n=0;n<this.views.length;n++)YJ(this.views[n].scene,e,t);this._textureList&&(jJ(this.renderer,this._textureList),jJ(this.renderer,this._geometriesList)),this._textureList=e,this._geometriesList=t},GJ.prototype.dispose=function(){this._disposed||(this._stopAccumulating(),this._textureList&&(WJ(this._textureList),WJ(this._geometriesList),jJ(this.renderer,this._textureList),jJ(this.renderer,this._geometriesList)),this.zr.off("globalout",this.onglobalout),this._disposed=!0)},GJ.prototype.onmousedown=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mousedown",e,t),this._dispatchDataEvent("mousedown",e,t)),this._downX=e.offsetX,this._downY=e.offsetY}},GJ.prototype.onmousemove=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY),n=t&&t.target,r=this._hovered;this._hovered=t,r&&n!==r.target&&(r.relatedTarget=n,this._dispatchEvent("mouseout",e,r),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",e,t),t&&(this.zr.setCursorStyle("pointer"),r&&n===r.target||this._dispatchEvent("mouseover",e,t)),this._dispatchDataEvent("mousemove",e,t)}},GJ.prototype.onmouseup=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mouseup",e,t),this._dispatchDataEvent("mouseup",e,t)),this._upX=e.offsetX,this._upY=e.offsetY}},GJ.prototype.onclick=GJ.prototype.dblclick=function(e){if(!e.target||!e.target.__isGLToZRProxy){var t=this._upX-this._downX,n=this._upY-this._downY;if(!(Math.sqrt(t*t+n*n)>20)){e=e.event;var r=this.pickObject(e.offsetX,e.offsetY);r&&(this._dispatchEvent(e.type,e,r),this._dispatchDataEvent(e.type,e,r));var i=this._clickToSetFocusPoint(e);if(i)i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}},GJ.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,n=t.viewport,r=this.views.length-1;r>=0;r--){var i=this.views[r];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var o=this._picking.pick(e.offsetX,e.offsetY,!0);if(o)return o.view=i,o}}t.viewport=n},GJ.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},GJ.prototype.pickObject=function(e,t){for(var n=[],r=this.renderer,i=r.viewport,o=0;o<this.views.length;o++){var a=this.views[o];a.containPoint(e,t)&&(this._picking.scene=a.scene,this._picking.camera=a.camera,r.viewport=a.viewport,this._picking.pickAll(e,t,n))}return r.viewport=i,n.sort((function(e,t){return e.distance-t.distance})),n[0]},GJ.prototype._dispatchEvent=function(e,t,n){n||(n={});var r=n.target;for(n.cancelBubble=!1,n.event=t,n.type=e,n.offsetX=t.offsetX,n.offsetY=t.offsetY;r&&(r.trigger(e,n),r=r.getParent(),!n.cancelBubble););this._dispatchToView(e,n)},GJ.prototype._dispatchDataEvent=function(e,t,n){var r=n&&n.target,i=r&&r.dataIndex,o=r&&r.seriesIndex,a=r&&r.eventData,s=!1,l=this._zrEventProxy;l.x=t.offsetX,l.y=t.offsetY,l.update();var u={target:l};const c=vl(l);"mousemove"===e&&(null!=i?i!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0):null!=a&&a!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0),this._lastEventData=a,this._lastDataIndex=i,this._lastSeriesIndex=o),c.eventData=a,c.dataIndex=i,c.seriesIndex=o,(null!=a||parseInt(i,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,e,t),s&&this.zr.handler.dispatchToElement(u,"mouseover",t))},GJ.prototype._dispatchToView=function(e,t){for(var n=0;n<this.views.length;n++)this.views[n].containPoint(t.offsetX,t.offsetY)&&this.views[n].trigger(e,t)},Object.assign(GJ.prototype,vY);var ZJ=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function qJ(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var n=e[t].normal,r=e[t].emphasis;n&&(e[t]=n),r&&(e.emphasis=e.emphasis||{},e.emphasis[t]=r)}}function KJ(e){e&&(e instanceof Array||(e=[e]),W(e,(function(e){if(e.axisLabel){var t=e.axisLabel;Object.assign(t,t.textStyle),t.textStyle=null}})))}function $J(e){this._layers={},this._zr=e}$J.prototype.update=function(e,t){var n=this,r=t.getZr();if(r.getWidth()&&r.getHeight()){for(var i in this._layers)this._layers[i].removeViewsAll();e.eachComponent((function(n,r){if("series"!==n){var i=t.getViewOfComponentModel(r),s=r.coordinateSystem;if(i.__ecgl__){if(s){if(!s.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+r.id);l=s.viewGL}else{if(!r.viewGL)return void console.error("Can't find viewGL of component "+r.id);l=s.viewGL}var l=s.viewGL,u=o(r);u.addView(l),i.afterRender&&i.afterRender(r,e,t,u),a(i.groupGL,r.get("silent"))}}})),e.eachSeries((function(n){var r=t.getViewOfSeriesModel(n),i=n.coordinateSystem;if(r.__ecgl__){if(i&&!i.viewGL&&!r.viewGL)return void console.error("Can't find viewGL of series "+r.id);var s=i&&i.viewGL||r.viewGL,l=o(n);l.addView(s),r.afterRender&&r.afterRender(n,e,t,l),a(r.groupGL,n.get("silent"))}}))}else console.warn("Dom has no width or height");function o(e){var t;r.setSleepAfterStill(0),t=(e.coordinateSystem&&e.coordinateSystem.model,e.get("zlevel"));var i=n._layers,o=i[t];if(!o){if(o=i[t]=new GJ("gl-"+t,r),r.painter.isSingleCanvas()){o.virtual=!0;var a=new Zs({z:1e4,style:{image:o.renderer.canvas},silent:!0});o.__hostImage=a,r.add(a)}r.painter.insertLayer(t,o)}return o.__hostImage&&o.__hostImage.setStyle({width:o.renderer.getWidth(),height:o.renderer.getHeight()}),o}function a(e,t){e&&e.traverse((function(e){e.isRenderable&&e.isRenderable()&&(e.ignorePicking=null!=e.$ignorePicking?e.$ignorePicking:t)}))}},Hy((function(e){var t=e.getZr(),n=t.painter.dispose;t.painter.dispose=function(){"function"==typeof this.eachOtherLayer&&this.eachOtherLayer((function(e){e instanceof GJ&&e.dispose()})),n.call(this)},t.painter.getRenderedCanvas=function(e){if(e=e||{},this._singleCanvas)return this._layers[0].dom;var t=document.createElement("canvas"),n=e.pixelRatio||this.dpr;t.width=this.getWidth()*n,t.height=this.getHeight()*n;var r=t.getContext("2d");r.dpr=n,r.clearRect(0,0,t.width,t.height),e.backgroundColor&&(r.fillStyle=e.backgroundColor,r.fillRect(0,0,t.width,t.height));var i,o=this.storage.getDisplayList(!0),a={},s=this;function l(e,t){var n,i=s._zlevelList;null==e&&(e=-1/0);for(var o=0;o<i.length;o++){var a=i[o],l=s._layers[a];if(!l.__builtin__&&a>e&&a<t){n=l;break}}n&&n.renderToCanvas&&(r.save(),n.renderToCanvas(r),r.restore())}for(var u={ctx:r},c=0;c<o.length;c++){var h=o[c];h.zlevel!==i&&(l(i,h.zlevel),i=h.zlevel),this._doPaintEl(h,u,!0,null,a)}return l(i,1/0),t}})),Uy((function(e,t){var n=t.getZr();(n.__egl=n.__egl||new $J(n)).update(e,t)})),Fy((function(e){W(e.series,(function(t){F(ZJ,t.type)>=0&&(!function(e){qJ(e,"itemStyle"),qJ(e,"lineStyle"),qJ(e,"areaStyle"),qJ(e,"label")}(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))})),KJ(e.xAxis3D),KJ(e.yAxis3D),KJ(e.zAxis3D),KJ(e.grid3D),qJ(e.geo3D)}));var JJ={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(e){e=e||{},this.option.viewControl=this.option.viewControl||{},null!=e.alpha&&(this.option.viewControl.alpha=e.alpha),null!=e.beta&&(this.option.viewControl.beta=e.beta),null!=e.distance&&(this.option.viewControl.distance=e.distance),null!=e.center&&(this.option.viewControl.center=e.center)}},QJ={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},eQ={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}},tQ=$d.extend({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});R(tQ.prototype,JJ),R(tQ.prototype,QJ),R(tQ.prototype,eQ);var nQ=vJ,rQ={left:0,middle:1,right:2};function iQ(e){return e instanceof Array||(e=[e,e]),e}var oQ=bY.extend((function(){return{zr:null,viewGL:null,_center:new Bq,minDistance:.5,maxDistance:1.5,maxOrthographicSize:300,minOrthographicSize:30,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",_mode:"rotate",_camera:null,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new qZ,_panVelocity:new qZ,_distance:500,_zoomSpeed:0,_stillTimeout:0,_animators:[]}}),(function(){["_mouseDownHandler","_mouseWheelHandler","_mouseMoveHandler","_mouseUpHandler","_pinchHandler","_contextMenuHandler","_update"].forEach((function(e){this[e]=this[e].bind(this)}),this)}),{init:function(){var e=this.zr;e&&(e.on("mousedown",this._mouseDownHandler),e.on("globalout",this._mouseUpHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("pinch",this._pinchHandler),e.animation.on("frame",this._update),e.dom.addEventListener("contextmenu",this._contextMenuHandler))},dispose:function(){var e=this.zr;e&&(e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("pinch",this._pinchHandler),e.off("globalout",this._mouseUpHandler),e.dom.removeEventListener("contextmenu",this._contextMenuHandler),e.animation.off("frame",this._update)),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getOrthographicSize:function(){return this._orthoSize},setOrthographicSize:function(e){this._orthoSize=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setViewGL:function(e){this.viewGL=e},getCamera:function(){return this.viewGL.camera},setFromViewControlModel:function(e,t){var n=(t=t||{}).baseDistance||0,r=t.baseOrthoSize||1,i=e.get("projection");"perspective"!==i&&"orthographic"!==i&&"isometric"!==i&&("production"!==process.env.NODE_ENV&&console.error("Unkown projection type %s, use perspective projection instead.",i),i="perspective"),this._projection=i,this.viewGL.setProjection(i);var o=e.get("distance")+n,a=e.get("orthographicSize")+r;[["damping",.8],["autoRotate",!1],["autoRotateAfterStill",3],["autoRotateDirection","cw"],["autoRotateSpeed",10],["minDistance",30],["maxDistance",400],["minOrthographicSize",30],["maxOrthographicSize",300],["minAlpha",-90],["maxAlpha",90],["minBeta",-1/0],["maxBeta",1/0],["rotateSensitivity",1],["zoomSensitivity",1],["panSensitivity",1],["panMouseButton","left"],["rotateMouseButton","middle"]].forEach((function(t){this[t[0]]=nQ(e.get(t[0]),t[1])}),this),this.minDistance+=n,this.maxDistance+=n,this.minOrthographicSize+=r,this.maxOrthographicSize+=r;var s=e.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach((function(t){l[t]=nQ(e.get(t),s&&s.get(t))}));var u=nQ(t.alpha,e.get("alpha"))||0,c=nQ(t.beta,e.get("beta"))||0,h=nQ(t.center,e.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:u,beta:c,center:h,distance:o,orthographicSize:a,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(o),this.setAlpha(u),this.setBeta(c),this.setCenter(h),this.setOrthographicSize(a)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){"production"!==process.env.NODE_ENV&&(null==rQ[this.panMouseButton]&&console.error("Unkown panMouseButton %s. It should be left|middle|right",this.panMouseButton),null==rQ[this.rotateMouseButton]&&console.error("Unkown rotateMouseButton %s. It should be left|middle|right",this.rotateMouseButton),"cw"!==this.autoRotateDirection&&"ccw"!==this.autoRotateDirection&&console.error("Unkown autoRotateDirection %s. It should be cw|ccw",this.autoRotateDirection))},animateTo:function(e){var t=this.zr,n=this,r={},i={};return null!=e.distance&&(r.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(r.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(r.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(r.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(r.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(r).when(e.duration||1e3,i).during((function(){null!=r.alpha&&n.setAlpha(r.alpha),null!=r.beta&&n.setBeta(r.beta),null!=r.distance&&n.setDistance(r.distance),null!=r.center&&n.setCenter(r.center),null!=r.orthographicSize&&n.setOrthographicSize(r.orthographicSize),n._needsUpdate=!0}))).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e<this._animators.length;e++)this._animators[e].stop();this._animators.length=0},update:function(){this._needsUpdate=!0,this._update(20)},_isAnimating:function(){return this._animators.length>0},_update:function(e){if(this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),n=this._orthoSize,r=n/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-r/2,t.right=r/2,t.top=n/2,t.bottom=-n/2},_updatePan:function(e){var t=this._panVelocity,n=this._distance,r=this.getCamera(),i=r.worldTransform.y,o=r.worldTransform.x;this._center.scaleAndAdd(o,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new Bq,n=this._theta+Math.PI/2,r=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(r),t.y=-Math.cos(n),t.z=i*Math.sin(r),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout((function(){t._rotating=!0}),1e3*e))},_vectorDamping:function(e,t){var n=e.len();(n*=t)<1e-4&&(n=0),e.normalize().scale(n)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),n=Math.atan2(e.x,e.z);this._theta=t,this._phi=-n,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,n=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,n)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?1===e.event.targetTouches.length&&(this._mode="rotate"):e.event.button===rQ[this.rotateMouseButton]?this._mode="rotate":e.event.button===rQ[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy||this._isAnimating())){var t=iQ(this.panSensitivity),n=iQ(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*n[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*n[1]):"pan"===this._mode&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(0!==t){var n,r=e.offsetX,i=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,i))n="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*n*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.event.preventDefault()}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done((function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)})),e}});Object.defineProperty(oQ.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});var aQ={convertToDynamicArray:function(e){e&&this.resetOffset();var t=this.attributes;for(var n in t)e||!t[n].value?t[n].value=[]:t[n].value=Array.prototype.slice.call(t[n].value);e||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var e=this.attributes;for(var t in e)e[t].value&&e[t].value.length>0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},sQ={vec2:ZZ,vec3:Cq,vec4:$q,mat2:DJ,mat2d:IJ,mat3:Jq,mat4:Mq,quat:rK},lQ=sQ.vec3,uQ=[[0,0],[1,1]],cQ=WK.extend((function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new WK.Attribute("position","float",3,"POSITION"),positionPrev:new WK.Attribute("positionPrev","float",3),positionNext:new WK.Attribute("positionNext","float",3),prevPositionPrev:new WK.Attribute("prevPositionPrev","float",3),prevPosition:new WK.Attribute("prevPosition","float",3),prevPositionNext:new WK.Attribute("prevPositionNext","float",3),offset:new WK.Attribute("offset","float",1),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.positionPrev.init(e),t.positionNext.init(e),t.offset.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(lQ.dist(e,t)+lQ.dist(n,t)+lQ.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(uQ)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(uQ)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/3;return this.useNativeLine?0:2*Math.max(t-1,0)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=e[2],u=t[0],c=t[1],h=t[2],d=n[0],p=n[1],f=n[2],g=r[0],m=r[1],v=r[2],y=this._getCubicCurveApproxStep(e,t,n,r),_=y*y,x=_*y,b=3*y,w=3*_,S=6*_,T=6*x,M=a-2*u+d,C=s-2*c+p,D=l-2*h+f,A=3*(u-d)-a+g,I=3*(c-p)-s+m,E=3*(h-f)-l+v,L=a,N=s,P=l,O=(u-a)*b+M*w+A*x,R=(c-s)*b+C*w+I*x,k=(h-l)*b+D*w+E*x,z=M*S+A*T,V=C*S+I*T,B=D*S+E*T,F=A*T,G=I*T,H=E*T,U=0,W=0,j=Math.ceil(1/y),X=new Float32Array(3*(j+1)),Y=(X=[],0);for(W=0;W<j+1;W++)X[Y++]=L,X[Y++]=N,X[Y++]=P,L+=O,N+=R,P+=k,O+=z,R+=V,k+=B,z+=F,V+=G,B+=H,(U+=y)>1&&(L=O>0?Math.min(L,g):Math.max(L,g),N=R>0?Math.min(N,m):Math.max(N,m),P=k>0?Math.min(P,v):Math.max(P,v));return this.addPolyline(X,i,o)},addLine:function(e,t,n,r){return this.addPolyline([e,t],n,r)},addPolyline:function(e,t,n,r,i){if(e.length){var o="number"!=typeof e[0];if(null==i&&(i=o?e.length:e.length/3),!(i<2)){null==r&&(r=0),null==n&&(n=1),this._itemVertexOffsets.push(this._vertexOffset);var a,s,l=(o="number"!=typeof e[0])?"number"!=typeof t[0]:t.length/4===i,u=this.attributes.position,c=this.attributes.positionPrev,h=this.attributes.positionNext,d=this.attributes.color,p=this.attributes.offset,f=this.indices,g=this._vertexOffset;n=Math.max(n,.01);for(var m=r;m<i;m++){if(o)a=e[m],s=l?t[m]:t;else{var v=3*m;if((a=a||[])[0]=e[v],a[1]=e[v+1],a[2]=e[v+2],l){var y=4*m;(s=s||[])[0]=t[y],s[1]=t[y+1],s[2]=t[y+2],s[3]=t[y+3]}else s=t}if(this.useNativeLine?m>1&&(u.copy(g,g-1),d.copy(g,g-1),g++):(m<i-1&&(c.set(g+2,a),c.set(g+3,a)),m>0&&(h.set(g-2,a),h.set(g-1,a)),u.set(g,a),u.set(g+1,a),d.set(g,s),d.set(g+1,s),p.set(g,n/2),p.set(g+1,-n/2),g+=2),this.useNativeLine)d.set(g,s),u.set(g,a),g++;else if(m>0){var _=3*this._triangleOffset;(f=this.indices)[_]=g-4,f[_+1]=g-3,f[_+2]=g-2,f[_+3]=g-3,f[_+4]=g-1,f[_+5]=g-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*i;c.copy(x,x+2),c.copy(x+1,x+3),h.copy(b-1,b-3),h.copy(b-2,b-4)}return this._vertexOffset=g,this._vertexOffset}}},setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});function hQ(e,t,n,r,i,o,a){this._zr=e,this._x=0,this._y=0,this._rowHeight=0,this.width=r,this.height=i,this.offsetX=t,this.offsetY=n,this.dpr=a,this.gap=o}function dQ(e){(e=e||{}).width=e.width||512,e.height=e.height||512,e.devicePixelRatio=e.devicePixelRatio||1,e.gap=null==e.gap?2:e.gap;var t=document.createElement("canvas");t.width=e.width*e.devicePixelRatio,t.height=e.height*e.devicePixelRatio,this._canvas=t,this._texture=new PK({image:t,flipY:!1});var n=this;this._zr=qi(t);var r=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){r.call(this),n._texture.dirty(),n.onupdate&&n.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new hQ(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}function pQ(){}V(cQ.prototype,aQ),hQ.prototype={constructor:hQ,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(e,t,n){var r=e.getBoundingRect();null==t&&(t=r.width),null==n&&(n=r.height),t*=this.dpr,n*=this.dpr,this._fitElement(e,t,n);var i=this._x,o=this._y,a=this.width*this.dpr,s=this.height*this.dpr,l=this.gap;if(i+t+l>a&&(i=this._x=0,o+=this._rowHeight+l,this._y=o,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,n),o+n+l>s)return null;e.x+=this.offsetX*this.dpr+i,e.y+=this.offsetY*this.dpr+o,this._zr.add(e);var u=[this.offsetX/this.width,this.offsetY/this.height];return[[i/a+u[0],o/s+u[1]],[(i+t)/a+u[0],(o+n)/s+u[1]]]},_fitElement:function(e,t,n){var r=e.getBoundingRect(),i=t/r.width,o=n/r.height;e.x=-r.x*i,e.y=-r.y*o,e.scaleX=i,e.scaleY=o,e.update()}},dQ.prototype={clear:function(){for(var e=0;e<this._textureAtlasNodes.length;e++)this._textureAtlasNodes[e].clear();this._currentNodeIdx=0,this._zr.clear(),this._coords={}},getWidth:function(){return this._width},getHeight:function(){return this._height},getTexture:function(){return this._texture},getDevicePixelRatio:function(){return this._dpr},getZr:function(){return this._zr},_getCurrentNode:function(){return this._textureAtlasNodes[this._currentNodeIdx]},_expand:function(){if(this._currentNodeIdx++,this._textureAtlasNodes[this._currentNodeIdx])return this._textureAtlasNodes[this._currentNodeIdx];var e=4096/this._dpr,t=this._textureAtlasNodes.length,n=t*this._nodeWidth%e,r=Math.floor(t*this._nodeWidth/e)*this._nodeHeight;if(!(r>=e)){var i=(n+this._nodeWidth)*this._dpr,o=(r+this._nodeHeight)*this._dpr;try{this._zr.resize({width:i,height:o})}catch(e){this._canvas.width=i,this._canvas.height=o}var a=new hQ(this._zr,n,r,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(a),a}"production"!==process.env.NODE_ENV&&console.error("Too much labels. Some will be ignored.")},add:function(e,t,n){if(this._coords[e.id])return"production"!==process.env.NODE_ENV&&console.warn("Element already been add"),this._coords[e.id];var r=this._getCurrentNode().add(e,t,n);if(!r){var i=this._expand();if(!i)return;r=i.add(e,t,n)}return this._coords[e.id]=r,r},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]},dispose:function(){this._zr.dispose()}},pQ.prototype={constructor:pQ,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new zJ.DirectionalLight({shadowBias:.005}),this.ambientLight=new zJ.AmbientLight,e.add(this.mainLight),e.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(e){var t=this.mainLight,n=this.ambientLight,r=e.getModel("light"),i=r.getModel("main"),o=r.getModel("ambient");t.intensity=i.get("intensity"),n.intensity=o.get("intensity"),t.color=zJ.parseColor(i.get("color")).slice(0,3),n.color=zJ.parseColor(o.get("color")).slice(0,3);var a=i.get("alpha")||0,s=i.get("beta")||0;t.position.setArray(zJ.directionFromAlphaBeta(a,s)),t.lookAt(zJ.Vector3.ZERO),t.castShadow=i.get("shadow"),t.shadowResolution=zJ.getShadowResolution(i.get("shadowQuality"))},updateAmbientCubemap:function(e,t,n){var r=t.getModel("light.ambientCubemap"),i=r.get("texture");if(i){this._cubemapLightsCache=this._cubemapLightsCache||{};var o=this._cubemapLightsCache[i];if(!o){var a=this;o=this._cubemapLightsCache[i]=zJ.createAmbientCubemap(r.option,e,n,(function(){a._isSkyboxFromAmbientCubemap&&a._skybox.setEnvironmentMap(o.specular.cubemap),n.getZr().refresh()}))}this._lightRoot.add(o.diffuse),this._lightRoot.add(o.specular),this._currentCubemapLights=o}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(e,t,n){var r=t.get("environment"),i=this;var o=(i._skybox=i._skybox||new U$,i._skybox);if(r&&"none"!==r)if("auto"===r)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var a=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(a),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"==typeof r&&r.colorStops||"string"==typeof r&&nr(r)){this._isSkyboxFromAmbientCubemap=!1;var s=new zJ.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(s);var l=s.image=document.createElement("canvas");l.width=l.height=16,Ev(l.getContext("2d"),new tl({shape:{x:0,y:0,width:16,height:16},style:{fill:r}})),o.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;s=zJ.loadTexture(r,n,{anisotropic:8,flipY:!1});o.setEnvironmentMap(s),o.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var u=t.coordinateSystem;if(this._skybox)if(!u||!u.viewGL||"auto"===r||r.match&&r.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var c=u.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[c]("fragment","SRGB_DECODE")}}};var fQ=sQ.vec3,gQ=WK.extend((function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new WK.Attribute("position","float",3,"POSITION"),normal:new WK.Attribute("normal","float",3,"NORMAL"),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,n=this.getQuadVertexCount()*e,r=this.getQuadTriangleCount()*e;this.vertexCount!==n&&(t.position.init(n),t.normal.init(n),t.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=fQ.create(),t=fQ.create(),n=fQ.create(),r=[0,3,1,3,2,1];return function(i,o){var a=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;fQ.sub(e,i[1],i[0]),fQ.sub(t,i[2],i[1]),fQ.cross(n,e,t),fQ.normalize(n,n);for(var u=0;u<4;u++)a.set(this._vertexOffset+u,i[u]),l.set(this._vertexOffset+u,o),s.set(this._vertexOffset+u,n);var c=3*this._faceOffset;for(u=0;u<6;u++)this.indices[c+u]=r[u]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});V(gQ.prototype,aQ);var mQ=vJ,vQ={x:0,y:2,z:1};function yQ(e,t,n){this.rootNode=new zJ.Node;var r=new zJ.Mesh({geometry:new cQ({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new zJ.Mesh({geometry:new gQ,material:n,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(r),this.faceInfo=e,this.plane=new zJ.Plane,this.linesMesh=r,this.quadsMesh=i}yQ.prototype.update=function(e,t,n){var r=e.coordinateSystem,i=[r.getAxis(this.faceInfo[0]),r.getAxis(this.faceInfo[1])],o=this.linesMesh.geometry,a=this.quadsMesh.geometry;o.convertToDynamicArray(!0),a.convertToDynamicArray(!0),this._updateSplitLines(o,i,e,n),this._udpateSplitAreas(a,i,e,n),o.convertToTypedArray(),a.convertToTypedArray();var s=r.getAxis(this.faceInfo[2]);!function(e,t,n,r){var i=[0,0,0],o=r<0?n.getExtentMin():n.getExtentMax();i[vQ[n.dim]]=o,e.position.setArray(i),e.rotation.identity(),t.distance=-Math.abs(o),t.normal.set(0,0,0),"x"===n.dim?(e.rotation.rotateY(r*Math.PI/2),t.normal.x=-r):"z"===n.dim?(e.rotation.rotateX(-r*Math.PI/2),t.normal.y=-r):(r>0&&e.rotation.rotateY(Math.PI),t.normal.z=-r)}(this.rootNode,this.plane,s,this.faceInfo[3])},yQ.prototype._updateSplitLines=function(e,t,n,r){var i=r.getDevicePixelRatio();t.forEach((function(r,o){var a=r.model,s=t[1-o].getExtent();if(!r.scale.isBlank()){var l=a.getModel("splitLine",n.getModel("splitLine"));if(l.get("show")){var u=l.getModel("lineStyle"),c=u.get("color"),h=mQ(u.get("opacity"),1),d=mQ(u.get("width"),1);c=J(c)?c:[c];for(var p=r.getTicksCoords({tickModel:l}),f=0,g=0;g<p.length;g++){var m=p[g].coord,v=zJ.parseColor(c[f%c.length]);v[3]*=h;var y=[0,0,0],_=[0,0,0];y[o]=_[o]=m,y[1-o]=s[0],_[1-o]=s[1],e.addLine(y,_,v,d*i),f++}}}}))},yQ.prototype._udpateSplitAreas=function(e,t,n,r){t.forEach((function(r,i){var o=r.model,a=t[1-i].getExtent();if(!r.scale.isBlank()){var s=o.getModel("splitArea",n.getModel("splitArea"));if(s.get("show")){var l=s.getModel("areaStyle"),u=l.get("color"),c=mQ(l.get("opacity"),1);u=J(u)?u:[u];for(var h=r.getTicksCoords({tickModel:s,clamp:!0}),d=0,p=[0,0,0],f=[0,0,0],g=0;g<h.length;g++){var m=h[g].coord,v=[0,0,0],y=[0,0,0];if(v[i]=y[i]=m,v[1-i]=a[0],y[1-i]=a[1],0!==g){var _=zJ.parseColor(u[d%u.length]);_[3]*=c,e.addQuad([p,v,y,f],_),p=v,f=y,d++}else p=v,f=y}}}}))};var _Q=[0,1,2,0,2,3],xQ=WK.extend((function(){return{attributes:{position:new WK.Attribute("position","float",3,"POSITION"),texcoord:new WK.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new WK.Attribute("offset","float",2),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(e){this._spriteCount=e;var t=4*e,n=2*e;this.vertexCount!==t&&(this.attributes.position.init(t),this.attributes.offset.init(t),this.attributes.color.init(t)),this.triangleCount!==n&&(this.indices=t>65535?new Uint32Array(3*n):new Uint16Array(3*n))},setSpriteAlign:function(e,t,n,r,i){var o,a,s,l;switch(null==n&&(n="left"),null==r&&(r="top"),i=i||0,n){case"left":o=i,s=t[0]+i;break;case"center":case"middle":o=-t[0]/2,s=t[0]/2;break;case"right":o=-t[0]-i,s=-i}switch(r){case"bottom":a=i,l=t[1]+i;break;case"middle":a=-t[1]/2,l=t[1]/2;break;case"top":a=-t[1]-i,l=-i}var u=4*e,c=this.attributes.offset;c.set(u,[o,l]),c.set(u+1,[s,l]),c.set(u+2,[s,a]),c.set(u+3,[o,a])},addSprite:function(e,t,n,r,i,o){var a=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,n,r,i,o);for(var s=0;s<_Q.length;s++)this.indices[3*this._faceOffset+s]=_Q[s]+a;return this._faceOffset+=2,this._vertexOffset+=4,a/4},setSprite:function(e,t,n,r,i,o,a){for(var s=4*e,l=this.attributes,u=0;u<4;u++)l.position.set(s+u,t);var c=l.texcoord;c.set(s,[r[0][0],r[0][1]]),c.set(s+1,[r[1][0],r[0][1]]),c.set(s+2,[r[1][0],r[1][1]]),c.set(s+3,[r[0][0],r[1][1]]),this.setSpriteAlign(e,n,i,o,a)}});V(xQ.prototype,aQ);zJ.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");var bQ=zJ.Mesh.extend((function(){return{geometry:new xQ({dynamic:!0}),material:new zJ.Material({shader:zJ.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}})),wQ=vJ,SQ={x:0,y:2,z:1};function TQ(e,t){var n=new zJ.Mesh({geometry:new cQ({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),r=new bQ;r.material.depthMask=!1;var i=new zJ.Node;i.add(n),i.add(r),this.rootNode=i,this.dim=e,this.linesMesh=n,this.labelsMesh=r,this.axisLineCoords=null,this.labelElements=[]}var MQ={x:"y",y:"x",z:"y"};TQ.prototype.update=function(e,t,n){var r=e.coordinateSystem.getAxis(this.dim),i=this.linesMesh.geometry,o=this.labelsMesh.geometry;i.convertToDynamicArray(!0),o.convertToDynamicArray(!0);var a=r.model,s=r.getExtent(),l=n.getDevicePixelRatio(),u=a.getModel("axisLine",e.getModel("axisLine")),c=a.getModel("axisTick",e.getModel("axisTick")),h=a.getModel("axisLabel",e.getModel("axisLabel")),d=u.get("lineStyle.color");if(u.get("show")){var p=u.getModel("lineStyle"),f=[0,0,0];(T=[0,0,0])[M=SQ[r.dim]]=s[0],f[M]=s[1],this.axisLineCoords=[T,f];var g=zJ.parseColor(d),m=wQ(p.get("width"),1),v=wQ(p.get("opacity"),1);g[3]*=v,i.addLine(T,f,g,m*l)}if(c.get("show")){var y=c.getModel("lineStyle"),_=zJ.parseColor(wQ(y.get("color"),d));m=wQ(y.get("width"),1);_[3]*=wQ(y.get("opacity"),1);for(var x=r.getTicksCoords(),b=c.get("length"),w=0;w<x.length;w++){var S=x[w].coord,T=[0,0,0],M=(f=[0,0,0],SQ[r.dim]),C=SQ[MQ[r.dim]];T[M]=f[M]=S,f[C]=b,i.addLine(T,f,_,m*l)}}this.labelElements=[];l=n.getDevicePixelRatio();if(h.get("show")){x=r.getTicksCoords();var D=a.get("data"),A=h.get("margin"),I=r.getViewLabels();for(w=0;w<I.length;w++){var E=I[w].tickValue,L=I[w].formattedLabel,N=I[w].rawLabel,P=(S=r.dataToCoord(E),[0,0,0]);M=SQ[r.dim],C=SQ[MQ[r.dim]];P[M]=P[M]=S,P[C]=A;var O=h;D&&D[E]&&D[E].textStyle&&(O=new Fh(D[E].textStyle,h,a.ecModel));var R=wQ(O.get("color"),d),k=new il({style:yh(O,{text:L,fill:"function"==typeof R?R("category"===r.type?N:"value"===r.type?E+"":E,w):R,verticalAlign:"top",align:"left"})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),this.labelElements.push(k)}}if(a.get("name")){var B=a.getModel("nameTextStyle"),F=(P=[0,0,0],M=SQ[r.dim],C=SQ[MQ[r.dim]],wQ(B.get("color"),d)),G=B.get("borderColor");m=B.get("borderWidth");P[M]=P[M]=(s[0]+s[1])/2,P[C]=a.get("nameGap");k=new il({style:yh(B,{text:a.get("name"),fill:F,stroke:G,lineWidth:m})}),z=t.add(k),V=k.getBoundingRect();o.addSprite(P,[V.width*l,V.height*l],z),k.__idx=this.labelElements.length,this.nameLabelElement=k}this.labelsMesh.material.set("textureAtlas",t.getTexture()),this.labelsMesh.material.set("uvScale",t.getCoordsScale()),i.convertToTypedArray(),o.convertToTypedArray()},TQ.prototype.setSpriteAlign=function(e,t,n){for(var r=n.getDevicePixelRatio(),i=this.labelsMesh.geometry,o=0;o<this.labelElements.length;o++){var a=this.labelElements[o].getBoundingRect();i.setSpriteAlign(o,[a.width*r,a.height*r],e,t)}var s=this.nameLabelElement;if(s){a=s.getBoundingRect();i.setSpriteAlign(s.__idx,[a.width*r,a.height*r],e,t),i.dirty()}this.textAlign=e,this.textVerticalAlign=t};var CQ="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end",DQ=vJ;zJ.Shader.import(CQ);var AQ={x:0,y:2,z:1},IQ=Xg.extend({type:"grid3D",__ecgl__:!0,init:function(e,t){var n=new zJ.Material({shader:zJ.createShader("ecgl.color"),depthMask:!1,transparent:!0}),r=new zJ.Material({shader:zJ.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});n.define("fragment","DOUBLE_SIDED"),n.define("both","VERTEX_COLOR"),this.groupGL=new zJ.Node,this._control=new oQ({zr:t.getZr()}),this._control.init(),this._faces=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]].map((function(e){var t=new yQ(e,r,n);return this.groupGL.add(t.rootNode),t}),this),this._axes=["x","y","z"].map((function(e){var t=new TQ(e,r);return this.groupGL.add(t.rootNode),t}),this);var i=t.getDevicePixelRatio();this._axisLabelSurface=new dQ({width:256,height:256,devicePixelRatio:i}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new zJ.Mesh({geometry:new cQ({useNativeLine:!1}),material:r,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new dQ({width:128,height:128,devicePixelRatio:i}),this._axisPointerLabelsMesh=new bQ({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new zJ.Node,this._sceneHelper=new pQ,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,n){this._model=e,this._api=n;var r=e.coordinateSystem;r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._axisLabelSurface.clear(),i.off("update"),e.get("show")&&(this._faces.forEach((function(r){r.update(e,t,n)}),this),this._axes.forEach((function(t){t.update(e,this._axisLabelSurface,n)}),this)),i.on("update",this._onCameraChange.bind(this,e,n),this),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},showAxisPointer:function(e,t,n,r){this._doShowAxisPointer(),this._updateAxisPointer(r.value)},hideAxisPointer:function(e,t,n,r){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem.viewGL;e.get("show")&&e.get("axisPointer.show")?t.on("mousemove",this._updateAxisPointerOnMousePosition,this):t.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t,n=this._model.coordinateSystem,r=n.viewGL,i=r.castRay(e.offsetX,e.offsetY,new zJ.Ray),o=0;o<this._faces.length;o++){var a=this._faces[o];if(!a.rootNode.invisible){a.plane.normal.dot(r.camera.worldTransform.z)<0&&a.plane.normal.negate();var s=i.intersectPlane(a.plane);if(s){var l=n.getAxis(a.faceInfo[0]),u=n.getAxis(a.faceInfo[1]),c=AQ[a.faceInfo[0]],h=AQ[a.faceInfo[1]];l.contain(s.array[c])&&u.contain(s.array[h])&&(t=s)}}}if(t){var d=n.pointToData(t.array,[],!0);this._updateAxisPointer(d),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(e,t){e.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var n=this._control;t.dispatchAction({type:"grid3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),center:n.getCenter(),from:this.uid,grid3DId:e.id})},_updateFaceVisibility:function(){var e=this._control.getCamera(),t=new zJ.Vector3;e.update();for(var n=0;n<this._faces.length/2;n++){for(var r=[],i=0;i<2;i++){this._faces[2*n+i].rootNode.getWorldPosition(t),t.transformMat4(e.viewMatrix),r[i]=t.z}var o=r[0]>r[1]?0:1,a=this._faces[2*n+o],s=this._faces[2*n+1-o];a.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),n=e.getAxis("y"),r=e.getAxis("z"),i=r.getExtentMax(),o=r.getExtentMin(),a=t.getExtentMin(),s=t.getExtentMax(),l=n.getExtentMax(),u=n.getExtentMin(),c=this._axes[0].rootNode,h=this._axes[1].rootNode,d=this._axes[2].rootNode,p=this._faces,f=p[4].rootNode.invisible?u:l,g=p[2].rootNode.invisible?i:o,m=p[0].rootNode.invisible?a:s,v=p[2].rootNode.invisible?i:o,y=p[0].rootNode.invisible?s:a,_=p[4].rootNode.invisible?u:l;c.rotation.identity(),h.rotation.identity(),d.rotation.identity(),p[4].rootNode.invisible&&(this._axes[0].flipped=!0,c.rotation.rotateX(Math.PI)),p[0].rootNode.invisible&&(this._axes[1].flipped=!0,h.rotation.rotateZ(Math.PI)),p[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),c.position.set(0,g,f),h.position.set(m,v,0),d.position.set(y,0,_),c.update(),h.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new zJ.Vector4,new zJ.Vector4],n=new zJ.Vector4;this.groupGL.getWorldPosition(n),n.w=1,n.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),n.x/=n.w,n.y/=n.w,this._axes.forEach((function(r){var i=r.axisLineCoords;r.labelsMesh.geometry;for(var o=0;o<t.length;o++)t[o].setArray(i[o]),t[o].w=1,t[o].transformMat4(r.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),t[o].x/=t[o].w,t[o].y/=t[o].w;var a,s,l=t[1].x-t[0].x,u=t[1].y-t[0].y,c=(t[1].x+t[0].x)/2,h=(t[1].y+t[0].y)/2;Math.abs(u/l)<.5?(a="center",s=h>n.y?"bottom":"top"):(s="middle",a=c>n.x?"left":"right"),r.setSpriteAlign(a,s,this._api)}),this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){var t=this._model.coordinateSystem,n=t.dataToPoint(e),r=this._axisPointerLineMesh.geometry,i=this._model.getModel("axisPointer"),o=this._api.getDevicePixelRatio();function a(e){return vJ(e.model.get("axisPointer.show"),i.get("show"))}function s(e){var t=e.model.getModel("axisPointer",i).getModel("lineStyle"),n=zJ.parseColor(t.get("color")),r=DQ(t.get("width"),1),o=DQ(t.get("opacity"),1);return n[3]*=o,{color:n,lineWidth:r}}r.convertToDynamicArray(!0);for(var l=0;l<this._faces.length;l++){var u=this._faces[l];if(!u.rootNode.invisible){for(var c=u.faceInfo,h=c[3]<0?t.getAxis(c[2]).getExtentMin():t.getAxis(c[2]).getExtentMax(),d=AQ[c[2]],p=0;p<2;p++){var f=c[p],g=c[1-p],m=t.getAxis(f),v=t.getAxis(g);if(a(m)){var y=AQ[f],_=AQ[g];(w=[0,0,0])[y]=(b=[0,0,0])[y]=n[y],w[d]=b[d]=h,w[_]=v.getExtentMin(),b[_]=v.getExtentMax();var x=s(m);r.addLine(w,b,x.color,x.lineWidth*o)}}if(a(t.getAxis(c[2]))){var b,w=n.slice();(b=n.slice())[d]=h;x=s(t.getAxis(c[2]));r.addLine(w,b,x.color,x.lineWidth*o)}}}r.convertToTypedArray(),this._updateAxisPointerLabelsMesh(e),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(e){var t=this._model,n=this._axisPointerLabelsMesh,r=this._axisPointerLabelsSurface,i=t.coordinateSystem,o=t.getModel("axisPointer");n.geometry.convertToDynamicArray(!0),r.clear();var a={x:"y",y:"x",z:"y"};this._axes.forEach((function(t,s){var l=i.getAxis(t.dim),u=l.model.getModel("axisPointer",o),c=u.getModel("label"),h=u.get("lineStyle.color");if(c.get("show")&&u.get("show")){var d=e[s],p=c.get("formatter"),f=l.scale.getLabel({value:d});if(null!=p)f=p(f,e);else if("interval"===l.scale.type||"log"===l.scale.type){var g=oo(l.scale.getTicks()[0]);f=d.toFixed(g+2)}var m=c.get("color"),v=new il({style:yh(c,{text:f,fill:m||h,align:"left",verticalAlign:"top"})}),y=r.add(v),_=v.getBoundingRect(),x=this._api.getDevicePixelRatio(),b=t.rootNode.position.toArray();b[AQ[a[t.dim]]]+=(t.flipped?-1:1)*c.get("margin"),b[AQ[t.dim]]=l.dataToCoord(e[s]),n.geometry.addSprite(b,[_.width*x,_.height*x],y,t.textAlign,t.textVerticalAlign)}}),this),r.getZr().refreshImmediately(),n.material.set("uvScale",r.getCoordsScale()),n.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._axisLabelSurface.dispose(),this._axisPointerLabelsSurface.dispose()}});function EQ(e){MM.call(this,e),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}function LQ(e,t,n){Eb.call(this,e,t,n)}EQ.prototype={constructor:EQ,model:null,containPoint:function(e){return this.getAxis("x").contain(e[0])&&this.getAxis("y").contain(e[2])&&this.getAxis("z").contain(e[1])},containData:function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])&&this.getAxis("z").containData(e[2])},dataToPoint:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").dataToCoord(e[0],n),t[2]=this.getAxis("y").dataToCoord(e[1],n),t[1]=this.getAxis("z").dataToCoord(e[2],n),t},pointToData:function(e,t,n){return(t=t||[])[0]=this.getAxis("x").coordToData(e[0],n),t[1]=this.getAxis("y").coordToData(e[2],n),t[2]=this.getAxis("z").coordToData(e[1],n),t}},G(EQ,MM),LQ.prototype={constructor:LQ,getExtentMin:function(){var e=this._extent;return Math.min(e[0],e[1])},getExtentMax:function(){var e=this._extent;return Math.max(e[0],e[1])},calculateCategoryInterval:function(){return Math.floor(this.scale.count()/8)}},G(LQ,Eb);var NQ=function(){this._pool={},this._allocatedTextures=[]};NQ.prototype={constructor:NQ,get:function(e){var t=RQ(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var n=this._pool[t];if(!n.length){var r=new PK(e);return this._allocatedTextures.push(r),r}return n.pop()},put:function(e){var t=RQ(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]),this._pool[t].push(e)},clear:function(e){for(var t=0;t<this._allocatedTextures.length;t++)this._allocatedTextures[t].dispose(e);this._pool={},this._allocatedTextures=[]}};var PQ={width:512,height:512,type:WY,format:QY,wrapS:hZ,wrapT:hZ,minFilter:sZ,magFilter:rZ,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},OQ=Object.keys(PQ);function RQ(e){xY.defaultsWithPropList(e,PQ,OQ),function(e){var t=(n=e.width,r=e.height,!(n&n-1||r&r-1));var n,r;e.format===KY&&(e.useMipmap=!1);t&&e.useMipmap||(e.minFilter==iZ||e.minFilter==aZ?e.minFilter=nZ:e.minFilter!=sZ&&e.minFilter!=oZ||(e.minFilter=rZ));t||(e.wrapS=hZ,e.wrapT=hZ)}(e);for(var t="",n=0;n<OQ.length;n++){t+=e[OQ[n]].toString()}return t}var kQ=["px","nx","py","ny","pz","nz"];function zQ(e,t,n){return"alphaMap"===n?e.material.get("diffuseMap"):"alphaCutoff"===n?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===n?e.material.get("uvRepeat"):"uvOffset"===n?e.material.get("uvOffset"):t.get(n)}function VQ(e,t){var n=e.material,r=t.material;return n.get("diffuseMap")!==r.get("diffuseMap")||(n.get("alphaCutoff")||0)!==(r.get("alphaCutoff")||0)}bq.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");var BQ,FQ,GQ,HQ,UQ,WQ,jQ,XQ=bY.extend((function(){return{softShadow:XQ.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"highp",_lastRenderNotCastShadow:!1,_frameBuffer:new k$,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new NQ}}),(function(){this._gaussianPassH=new lJ({fragment:bq.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new lJ({fragment:bq.source("clay.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new lJ({fragment:bq.source("clay.sm.debug_depth")})}),{render:function(e,t,n,r){n||(n=t.getMainCamera()),this.trigger("beforerender",this,e,t,n),this._renderShadowPass(e,t,n,r),this.trigger("afterrender",this,e,t,n)},renderDebug:function(e,t){e.saveClear();var n=e.viewport,r=0,i=t||n.width/4,o=i;for(var a in this.softShadow===XQ.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[a];e.setViewport(r,0,i*s.width/s.height,o),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),r+=i*s.width/s.height}e.setViewport(n),e.restoreClear()},_updateReceivers:function(e,t){if(t.receiveShadow?(this._receivers.push(t),t.material.set("shadowEnabled",1),t.material.set("pcfKernel",this.kernelPCF)):t.material.set("shadowEnabled",0),this.softShadow===XQ.VSM)t.material.define("fragment","USE_VSM"),t.material.undefine("fragment","PCF_KERNEL_SIZE");else{t.material.undefine("fragment","USE_VSM");var n=this.kernelPCF;n&&n.length?t.material.define("fragment","PCF_KERNEL_SIZE",n.length/2):t.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(e,t){var n=this;t.traverse((function(t){t.isRenderable()&&n._updateReceivers(e,t)}));for(var r=0;r<t.lights.length;r++){var i=t.lights[r];i.castShadow&&!i.invisible&&this._lightsCastShadow.push(i)}},_renderShadowPass:function(e,t,n,r){for(var i in this._shadowMapNumber)this._shadowMapNumber[i]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var o=e.gl;if(r||t.update(),n&&n.update(),t.updateLights(),this._update(e,t),this._lightsCastShadow.length||!this._lastRenderNotCastShadow){this._lastRenderNotCastShadow=0===this._lightsCastShadow,o.enable(o.DEPTH_TEST),o.depthMask(!0),o.disable(o.BLEND),o.clearColor(1,1,1,1);for(var a,s=[],l=[],u=[],c=[],h=[],d=[],p=0;p<this._lightsCastShadow.length;p++){var f=this._lightsCastShadow[p];if("DIRECTIONAL_LIGHT"===f.type){if(a){console.warn("Only one direectional light supported with shadow cascade");continue}if(f.shadowCascade>4){console.warn("Support at most 4 cascade");continue}f.shadowCascade>1&&(a=f),this.renderDirectionalLightShadow(e,t,n,f,h,c,u)}else"SPOT_LIGHT"===f.type?this.renderSpotLightShadow(e,t,f,l,s):"POINT_LIGHT"===f.type&&this.renderPointLightShadow(e,t,f,d);this._shadowMapNumber[f.type]++}for(var g in this._shadowMapNumber){var m=this._shadowMapNumber[g],v=g+"_SHADOWMAP_COUNT";for(p=0;p<this._receivers.length;p++){(y=this._receivers[p].material).fragmentDefines[v]!==m&&(m>0?y.define("fragment",v,m):y.isDefined("fragment",v)&&y.undefine("fragment",v))}}for(p=0;p<this._receivers.length;p++){var y=this._receivers[p].material;a?y.define("fragment","SHADOW_CASCADE",a.shadowCascade):y.undefine("fragment","SHADOW_CASCADE")}var _=t.shadowUniforms;if(u.length>0){var x=u.map(T);if(_.directionalLightShadowMaps={value:u,type:"tv"},_.directionalLightMatrices={value:c,type:"m4v"},_.directionalLightShadowMapSizes={value:x,type:"1fv"},a){var b=h.slice(),w=h.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),c.reverse(),_.shadowCascadeClipsNear={value:b,type:"1fv"},_.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var S=s.map(T);(_=t.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},_.spotLightMatrices={value:l,type:"m4v"},_.spotLightShadowMapSizes={value:S,type:"1fv"}}d.length>0&&(_.pointLightShadowMaps={value:d,type:"tv"})}function T(e){return e.height}},renderDirectionalLightShadow:(BQ=new u$,FQ=new iK,GQ=new _K,HQ=new iK,UQ=new iK,WQ=new iK,jQ=new iK,function(e,t,n,r,i,o,a){var s=this._getDepthMaterial(r),l={getMaterial:function(e){return e.shadowDepthMaterial||s},isMaterialChanged:VQ,getUniform:zQ,ifRender:function(e){return e.castShadow},sortCompare:zq.opaqueSortCompare};if(!t.viewBoundingBoxLastFrame.isFinite()){var u=t.getBoundingBox();t.viewBoundingBoxLastFrame.copy(u).applyTransform(n.viewMatrix)}var c=Math.min(-t.viewBoundingBoxLastFrame.min.z,n.far),h=Math.max(-t.viewBoundingBoxLastFrame.max.z,n.near),d=this._getDirectionalLightCamera(r,t,n),p=WQ.array;jQ.copy(d.projectionMatrix),Mq.invert(UQ.array,d.worldTransform.array),Mq.multiply(UQ.array,UQ.array,n.worldTransform.array),Mq.multiply(p,jQ.array,UQ.array);for(var f=[],g=n instanceof M$,m=(n.near+n.far)/(n.near-n.far),v=2*n.near*n.far/(n.near-n.far),y=0;y<=r.shadowCascade;y++){var _=h*Math.pow(c/h,y/r.shadowCascade),x=h+(c-h)*y/r.shadowCascade,b=_*r.cascadeSplitLogFactor+x*(1-r.cascadeSplitLogFactor);f.push(b),i.push(-(-b*m+v)/-b)}var w=this._getTexture(r,r.shadowCascade);a.push(w);var S=e.viewport,T=e.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(e),T.clear(T.COLOR_BUFFER_BIT|T.DEPTH_BUFFER_BIT),y=0;y<r.shadowCascade;y++){var M=f[y],C=f[y+1];g?Mq.perspective(FQ.array,n.fov/180*Math.PI,n.aspect,M,C):Mq.ortho(FQ.array,n.left,n.right,n.bottom,n.top,M,C),BQ.setFromProjection(FQ),BQ.getTransformedBoundingBox(GQ,UQ),GQ.applyProjection(jQ);var D=GQ.min.array,A=GQ.max.array;D[0]=Math.max(D[0],-1),D[1]=Math.max(D[1],-1),A[0]=Math.min(A[0],1),A[1]=Math.min(A[1],1),HQ.ortho(D[0],A[0],D[1],A[1],1,-1),d.projectionMatrix.multiplyLeft(HQ);var I=r.shadowResolution||512;e.setViewport((r.shadowCascade-y-1)*I,0,I,I,1);var E=t.updateRenderList(d);e.renderPass(E.opaque,d,l),this.softShadow===XQ.VSM&&this._gaussianFilter(e,w,w.width);var L=new iK;L.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),o.push(L.array),d.projectionMatrix.copy(jQ)}this._frameBuffer.unbind(e),e.setViewport(S)}),renderSpotLightShadow:function(e,t,n,r,i){var o=this._getTexture(n),a=this._getSpotLightCamera(n),s=e.gl;this._frameBuffer.attach(o),this._frameBuffer.bind(e),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(n),u={getMaterial:function(e){return e.shadowDepthMaterial||l},isMaterialChanged:VQ,getUniform:zQ,ifRender:function(e){return e.castShadow},sortCompare:zq.opaqueSortCompare},c=t.updateRenderList(a);e.renderPass(c.opaque,a,u),this._frameBuffer.unbind(e),this.softShadow===XQ.VSM&&this._gaussianFilter(e,o,o.width);var h=new iK;h.copy(a.worldTransform).invert().multiplyLeft(a.projectionMatrix),i.push(o),r.push(h.array)},renderPointLightShadow:function(e,t,n,r){var i=this._getTexture(n),o=e.gl;r.push(i);var a=this._getDepthMaterial(n),s={getMaterial:function(e){return e.shadowDepthMaterial||a},getUniform:zQ,sortCompare:zq.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},u=new _K,c=n.getWorldPosition().array,h=new _K,d=n.range;h.min.setArray(c),h.max.setArray(c);var p=new Bq(d,d,d);h.max.add(p),h.min.sub(p);var f={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};t.traverse((function(e){if(e.isRenderable()&&e.castShadow){var t=e.geometry;if(!t.boundingBox){for(var n=0;n<kQ.length;n++)l[kQ[n]].push(e);return}if(u.transformFrom(t.boundingBox,e.worldTransform),!u.intersectBoundingBox(h))return;u.updateVertices();for(n=0;n<kQ.length;n++)f[kQ[n]]=!1;for(n=0;n<8;n++){var r=u.vertices[n],i=r[0]-c[0],o=r[1]-c[1],a=r[2]-c[2],s=Math.abs(i),d=Math.abs(o),p=Math.abs(a);s>d?s>p?f[i>0?"px":"nx"]=!0:f[a>0?"pz":"nz"]=!0:d>p?f[o>0?"py":"ny"]=!0:f[a>0?"pz":"nz"]=!0}for(n=0;n<kQ.length;n++)f[kQ[n]]&&l[kQ[n]].push(e)}}));for(var g=0;g<6;g++){var m=kQ[g],v=this._getPointLightCamera(n,m);this._frameBuffer.attach(i,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+g),this._frameBuffer.bind(e),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),e.renderPass(l[m],v,s)}this._frameBuffer.unbind(e)},_getDepthMaterial:function(e){var t=this._lightMaterials[e.__uid__],n="POINT_LIGHT"===e.type;if(!t){var r=n?"clay.sm.distance.":"clay.sm.depth.";t=new WZ({precision:this.precision,shader:new bq(bq.source(r+"vertex"),bq.source(r+"fragment"))}),this._lightMaterials[e.__uid__]=t}return null!=e.shadowSlopeScale&&t.setUniform("slopeScale",e.shadowSlopeScale),null!=e.shadowBias&&t.setUniform("bias",e.shadowBias),this.softShadow===XQ.VSM?t.define("fragment","USE_VSM"):t.undefine("fragment","USE_VSM"),n&&(t.set("lightPosition",e.getWorldPosition().array),t.set("range",e.range)),t},_gaussianFilter:function(e,t,n){var r={width:n,height:n,type:AK.FLOAT},i=this._texturePool.get(r);this._frameBuffer.attach(i),this._frameBuffer.bind(e),this._gaussianPassH.setUniform("texture",t),this._gaussianPassH.setUniform("textureWidth",n),this._gaussianPassH.render(e),this._frameBuffer.attach(t),this._gaussianPassV.setUniform("texture",i),this._gaussianPassV.setUniform("textureHeight",n),this._gaussianPassV.render(e),this._frameBuffer.unbind(e),this._texturePool.put(i)},_getTexture:function(e,t){var n=e.__uid__,r=this._textures[n],i=e.shadowResolution||512;return t=t||1,r||((r="POINT_LIGHT"===e.type?new S$:new PK).width=i*t,r.height=i,this.softShadow===XQ.VSM?(r.type=AK.FLOAT,r.anisotropic=4):(r.minFilter=nZ,r.magFilter=nZ,r.useMipmap=!1),this._textures[n]=r),r},_getPointLightCamera:function(e,t){this._lightCameras.point||(this._lightCameras.point={px:new M$,nx:new M$,py:new M$,ny:new M$,pz:new M$,nz:new M$});var n=this._lightCameras.point[t];switch(n.far=e.range,n.fov=90,n.position.set(0,0,0),t){case"px":n.lookAt(Bq.POSITIVE_X,Bq.NEGATIVE_Y);break;case"nx":n.lookAt(Bq.NEGATIVE_X,Bq.NEGATIVE_Y);break;case"py":n.lookAt(Bq.POSITIVE_Y,Bq.POSITIVE_Z);break;case"ny":n.lookAt(Bq.NEGATIVE_Y,Bq.NEGATIVE_Z);break;case"pz":n.lookAt(Bq.POSITIVE_Z,Bq.NEGATIVE_Y);break;case"nz":n.lookAt(Bq.NEGATIVE_Z,Bq.NEGATIVE_Y)}return e.getWorldPosition(n.position),n.update(),n},_getDirectionalLightCamera:function(){var e=new iK,t=new _K,n=new _K;return function(r,i,o){this._lightCameras.directional||(this._lightCameras.directional=new iJ);var a=this._lightCameras.directional;t.copy(i.viewBoundingBoxLastFrame),t.intersection(o.frustum.boundingBox),a.position.copy(t.min).add(t.max).scale(.5).transformMat4(o.worldTransform),a.rotation.copy(r.rotation),a.scale.copy(r.scale),a.updateWorldTransform(),iK.invert(e,a.worldTransform),iK.multiply(e,e,o.worldTransform),n.copy(t).applyTransform(e);var s=n.min.array,l=n.max.array;return a.position.set((s[0]+l[0])/2,(s[1]+l[1])/2,l[2]).transformMat4(a.worldTransform),a.near=0,a.far=-s[2]+l[2],isNaN(this.lightFrustumBias)?a.far*=4:a.far+=this.lightFrustumBias,a.left=s[0],a.right=l[0],a.top=l[1],a.bottom=s[1],a.update(!0),a}}(),_getSpotLightCamera:function(e){this._lightCameras.spot||(this._lightCameras.spot=new M$);var t=this._lightCameras.spot;return t.fov=2*e.penumbraAngle,t.far=e.range,t.worldTransform.copy(e.worldTransform),t.updateProjectionMatrix(),Mq.invert(t.viewMatrix.array,t.worldTransform.array),t},dispose:function(e){var t=e.gl||e;for(var n in this._frameBuffer&&this._frameBuffer.dispose(t),this._textures)this._textures[n].dispose(t);this._texturePool.clear(e.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var r=0;r<this._receivers.length;r++){var i=this._receivers[r];if(i.material){var o=i.material;o.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),o.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),o.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),o.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});XQ.VSM=1,XQ.PCF=2;var YQ=bY.extend((function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),{updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n=o.width instanceof Function?o.width.call(this,t):o.width,r=o.height instanceof Function?o.height.call(this,t):o.height,a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t.gl),a.width=n,a.height=r,a},setParameter:function(e,t){},getParameter:function(e){},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},render:function(){},getOutput:function(e,t){if(null==t)return t=e,this._outputTextures[t];var n=this.outputs[t];return n?this._rendered?n.outputLastFrame?this._prevOutputTextures[t]:this._outputTextures[t]:this._rendering?(this._prevOutputTextures[t]||(this._prevOutputTextures[t]=this._compositor.allocateTexture(n.parameters||{})),this._prevOutputTextures[t]):(this.render(e),this._outputTextures[t]):void 0},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.enableTexture(e)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(e){if(!this._rendering){for(var t in this._rendering=!0,this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){for(var e in this._rendered=!1,this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks){if(this._outputReferences[e]>0)this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}}),ZQ=bY.extend((function(){return{nodes:[]}}),{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t<this.nodes.length;t++)if(this.nodes[t].name===e)return this.nodes[t]},update:function(){for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear();for(e=0;e<this.nodes.length;e++){var t=this.nodes[e];if(t.inputs)for(var n in t.inputs)if(t.inputs[n])if(!t.pass||t.pass.material.isUniformEnabled(n)){var r=t.inputs[n],i=this.findPin(r);i?t.link(n,i.node,i.pin):"string"==typeof r?console.warn("Node "+r+" not exist"):console.warn("Pin of "+r.node+"."+r.pin+" not exist")}else console.warn("Pin "+t.name+"."+n+" not used.")}},findPin:function(e){var t;if(("string"==typeof e||e instanceof YQ)&&(e={node:e}),"string"==typeof e.node)for(var n=0;n<this.nodes.length;n++){var r=this.nodes[n];r.name===e.node&&(t=r)}else t=e.node;if(t){var i=e.pin;if(i||t.outputs&&(i=Object.keys(t.outputs)[0]),t.outputs[i])return{node:t,pin:i}}}}),qQ=ZQ.extend((function(){return{_outputs:[],_texturePool:new NQ,_frameBuffer:new k$({depthBuffer:!1})}}),{addNode:function(e){ZQ.prototype.addNode.call(this,e),e._compositor=this},render:function(e,t){if(this._dirty){this.update(),this._dirty=!1,this._outputs.length=0;for(var n=0;n<this.nodes.length;n++)this.nodes[n].outputs||this._outputs.push(this.nodes[n])}for(n=0;n<this.nodes.length;n++)this.nodes[n].beforeFrame();for(n=0;n<this._outputs.length;n++)this._outputs[n].updateReference();for(n=0;n<this._outputs.length;n++)this._outputs[n].render(e,t);for(n=0;n<this.nodes.length;n++)this.nodes[n].afterFrame()},allocateTexture:function(e){return this._texturePool.get(e)},releaseTexture:function(e){this._texturePool.put(e)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(e){this._texturePool.clear(e)}}),KQ=YQ.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},(function(){this.frameBuffer=new k$}),{render:function(e){this._rendering=!0;var t,n=e.gl;if(this.trigger("beforerender"),this.outputs){var r=this.frameBuffer;for(var i in this.outputs){var o=this.updateParameter(i,e),a=this.outputs[i],s=this._compositor.allocateTexture(o);this._outputTextures[i]=s,"string"==typeof(c=a.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),r.attach(s,c)}r.bind(e);var l=e.getGLExtension("EXT_draw_buffers");if(l){var u=[];for(var c in this.outputs)(c=parseInt(c))>=n.COLOR_ATTACHMENT0&&c<=n.COLOR_ATTACHMENT0+8&&u.push(c);l.drawBuffersEXT(u)}e.saveClear(),e.clearBit=MY|DY,t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),r.unbind(e)}else t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",t),this._rendering=!1,this._rendered=!0}}),$Q=YQ.extend((function(){return{texture:null,outputs:{color:{}}}}),(function(){}),{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),JQ=YQ.extend((function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),(function(){var e=new lJ({fragment:this.shader});this.pass=e}),{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var r in this.inputLinks){var i=(h=this.inputLinks[r]).node.getOutput(e,h.pin);this.pass.setUniform(r,i)}if(this.outputs){this.pass.outputs={};var o={};for(var a in this.outputs){var s=this.updateParameter(a,e);isNaN(s.width)&&this.updateParameter(a,e);var l=this.outputs[a],u=this._compositor.allocateTexture(s);this._outputTextures[a]=u,"string"==typeof(c=l.attachment||n.COLOR_ATTACHMENT0)&&(c=n[c]),o[c]=u}for(var c in this._compositor.getFrameBuffer().bind(e),o)this._compositor.getFrameBuffer().attach(o[c],c);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var r in this.inputLinks){var h;(h=this.inputLinks[r]).node.removeReference(h.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n,r,i=this.outputs[e],o=i.parameters,a=i._parametersCopy;if(a||(a=i._parametersCopy={}),o)for(var s in o)"width"!==s&&"height"!==s&&(a[s]=o[s]);return n="function"==typeof o.width?o.width.call(this,t):o.width,r="function"==typeof o.height?o.height.call(this,t):o.height,n=Math.ceil(n),r=Math.ceil(r),a.width===n&&a.height===r||this._outputTextures[e]&&this._outputTextures[e].dispose(t),a.width=n,a.height=r,a},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){(this._outputReferences[e]--,0===this._outputReferences[e])&&(this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e]))},clear:function(){YQ.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),QQ="@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n",e0="\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end",t0="@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",n0="@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n",r0="@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end",i0="\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end",o0="@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",a0="@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end",s0="@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";!function(e){e.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),e.import(QQ),e.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),e.import(e0),e.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),e.import(t0),e.import(n0),e.import(r0),e.import(i0),e.import(o0),e.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),e.import(a0),e.import(s0)}(bq);var l0=/^#source\((.*?)\)/;function u0(e,t){var n=new qQ;t=t||{};var r={textures:{},parameters:{}};for(var i in e.parameters){var o=e.parameters[i];r.parameters[i]=p0(o)}return function(e,t,n,r){if(!e.textures)return void r({});var i={},o=0,a=!1,s=n.textureRootPath;xY.each(e.textures,(function(e,t){var n,l=e.path,u=p0(e.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map((function(e){return xY.relative2absolute(e,s)}))),n=new S$(u);else{if("string"!=typeof l)return;s&&(l=xY.relative2absolute(l,s)),n=new PK(u)}n.load(l),o++,n.once("success",(function(){i[t]=n,0===--o&&(r(i),a=!0)}))})),0!==o||a||r(i)}(e,0,t,(function(i){r.textures=i,function(){for(var i=0;i<e.nodes.length;i++){var o=c0(e.nodes[i],r,t);o&&n.addNode(o)}}()})),n}function c0(e,t,n){var r,i,o,a,s=e.type||"filter";if("filter"===s){var l=e.shader.trim(),u=l0.exec(l);if(u?r=bq.source(u[1].trim()):"#"===l.charAt(0)&&(r=t.shaders[l.substr(1)]),r||(r=l),!r)return}if(e.inputs)for(var c in i={},e.inputs)"string"==typeof e.inputs[c]?i[c]=e.inputs[c]:i[c]={node:e.inputs[c].node,pin:e.inputs[c].pin};if(e.outputs)for(var c in o={},e.outputs){var h=e.outputs[c];o[c]={},null!=h.attachment&&(o[c].attachment=h.attachment),null!=h.keepLastFrame&&(o[c].keepLastFrame=h.keepLastFrame),null!=h.outputLastFrame&&(o[c].outputLastFrame=h.outputLastFrame),h.parameters&&(o[c].parameters=p0(h.parameters))}if(a="scene"===s?new KQ({name:e.name,scene:n.scene,camera:n.camera,outputs:o}):"texture"===s?new $Q({name:e.name,outputs:o}):new JQ({name:e.name,shader:r,inputs:i,outputs:o})){if(e.parameters)for(var c in e.parameters){"string"==typeof(d=e.parameters[c])?"#"===(d=d.trim()).charAt(0)?d=t.textures[d.substr(1)]:a.on("beforerender",f0(c,g0(d))):"function"==typeof d&&a.on("beforerender",d),a.setParameter(c,d)}if(e.defines&&a.pass)for(var c in e.defines){var d=e.defines[c];a.pass.material.define("fragment",c,d)}}return a}function h0(e,t){return e}function d0(e,t){return t}function p0(e){var t={};if(!e)return t;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach((function(n){var r=e[n];null!=r&&("string"==typeof r&&(r=AK[r]),t[n]=r)}));var n=e.scale||1;return["width","height"].forEach((function(r){if(null!=e[r]){var i=e[r];"string"==typeof i?(i=i.trim(),t[r]=function(e,t,n){return n=n||1,function(e){var r=e.getDevicePixelRatio(),i=e.getWidth()*n,o=e.getHeight()*n;return t(i,o,r)}}(0,g0(i),n)):t[r]=i}})),t.width||(t.width=h0),t.height||(t.height=d0),null!=e.useMipmap&&(t.useMipmap=e.useMipmap),t}function f0(e,t){return function(n){var r=n.getDevicePixelRatio(),i=n.getWidth(),o=n.getHeight(),a=t(i,o,r);this.setParameter(e,a)}}function g0(e){var t=/^expr\((.*)\)$/.exec(e);if(t)try{var n=new Function("width","height","dpr","return "+t[1]);return n(1,1),n}catch(e){throw new Error("Invalid expression.")}}function m0(e,t){for(var n=0,r=1/t,i=e;i>0;)n+=r*(i%t),i=Math.floor(i/t),r/=t;return n}function v0(e){for(var t=new Uint8Array(e*e*4),n=0,r=new Bq,i=0;i<e;i++)for(var o=0;o<e;o++)r.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),t[n++]=255*(.5*r.x+.5),t[n++]=255*(.5*r.y+.5),t[n++]=0,t[n++]=255;return t}function y0(e){return new PK({pixels:v0(e),wrapS:AK.REPEAT,wrapT:AK.REPEAT,width:e,height:e})}function _0(e,t,n){var r=new Float32Array(3*e);t=t||0;for(var i=0;i<e;i++){var o=m0(i+t,2)*(n?1:2)*Math.PI,a=m0(i+t,3)*Math.PI,s=Math.random(),l=Math.cos(o)*Math.sin(a)*s,u=Math.cos(a)*s,c=Math.sin(o)*Math.sin(a)*s;r[3*i]=l,r[3*i+1]=u,r[3*i+2]=c}return r}function x0(e){e=e||{},this._ssaoPass=new lJ({fragment:bq.source("ecgl.ssao.estimate")}),this._blurPass=new lJ({fragment:bq.source("ecgl.ssao.blur")}),this._framebuffer=new k$({depthBuffer:!1}),this._ssaoTexture=new PK,this._blurTexture=new PK,this._blurTexture2=new PK,this._depthTex=e.depthTexture,this._normalTex=e.normalTexture,this.setNoiseSize(4),this.setKernelSize(e.kernelSize||12),null!=e.radius&&this.setParameter("radius",e.radius),null!=e.power&&this.setParameter("power",e.power),this._normalTex||(this._ssaoPass.material.disableTexture("normalTex"),this._blurPass.material.disableTexture("normalTex")),this._depthTex||this._blurPass.material.disableTexture("depthTex"),this._blurPass.material.setUniform("normalTex",this._normalTex),this._blurPass.material.setUniform("depthTex",this._depthTex)}bq.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),x0.prototype.setDepthTexture=function(e){this._depthTex=e},x0.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},x0.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._ssaoPass,a=this._blurPass;o.setUniform("kernel",this._kernels[n%this._kernels.length]),o.setUniform("depthTex",this._depthTex),null!=this._normalTex&&o.setUniform("normalTex",this._normalTex),o.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new iK;iK.transpose(s,t.worldTransform),o.setUniform("projection",t.projectionMatrix.array),o.setUniform("projectionInv",t.invProjectionMatrix.array),o.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,u=this._blurTexture,c=this._blurTexture2;l.width=r/2,l.height=i/2,u.width=r,u.height=i,c.width=r,c.height=i,this._framebuffer.attach(l),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),o.render(e),a.setUniform("textureSize",[r/2,i/2]),a.setUniform("projection",t.projectionMatrix.array),this._framebuffer.attach(u),a.setUniform("direction",0),a.setUniform("ssaoTexture",l),a.render(e),this._framebuffer.attach(c),a.setUniform("textureSize",[r,i]),a.setUniform("direction",1),a.setUniform("ssaoTexture",u),a.render(e),this._framebuffer.unbind(e);var h=e.clearColor;e.gl.clearColor(h[0],h[1],h[2],h[3])},x0.prototype.getTargetTexture=function(){return this._blurTexture2},x0.prototype.setParameter=function(e,t){"noiseTexSize"===e?this.setNoiseSize(t):"kernelSize"===e?this.setKernelSize(t):"intensity"===e?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)},x0.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=_0(e,t*e,!!this._normalTex)},x0.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=v0(e),t.width=t.height=e,t.dirty()):(t=y0(e),this._ssaoPass.setUniform("noiseTex",y0(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},x0.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e),this._blurTexture2.dispose(e)};function b0(e){e=e||{},this._ssrPass=new lJ({fragment:bq.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new lJ({fragment:bq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new lJ({fragment:bq.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new lJ({fragment:bq.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",e.normalTexture),this._ssrPass.setUniform("gBufferTexture2",e.depthTexture),this._blurPass1.setUniform("gBufferTexture1",e.normalTexture),this._blurPass1.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.setUniform("gBufferTexture1",e.normalTexture),this._blurPass2.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new PK({type:AK.HALF_FLOAT}),this._texture2=new PK({type:AK.HALF_FLOAT}),this._texture3=new PK({type:AK.HALF_FLOAT}),this._prevTexture=new PK({type:AK.HALF_FLOAT}),this._currentTexture=new PK({type:AK.HALF_FLOAT}),this._frameBuffer=new k$({depthBuffer:!1}),this._normalDistribution=null,this._totalSamples=256,this._samplePerFrame=4,this._ssrPass.material.define("fragment","SAMPLE_PER_FRAME",this._samplePerFrame),this._ssrPass.material.define("fragment","TOTAL_SAMPLES",this._totalSamples),this._downScale=1}bq.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),b0.prototype.setAmbientCubemap=function(e,t){this._ssrPass.material.set("specularCubemap",e),this._ssrPass.material.set("specularIntensity",t);var n=e&&t;this._ssrPass.material[n?"enableTexture":"disableTexture"]("specularCubemap")},b0.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._ssrTexture,s=this._texture2,l=this._texture3;a.width=this._prevTexture.width=this._currentTexture.width=i/this._downScale,a.height=this._prevTexture.height=this._currentTexture.height=o/this._downScale,s.width=l.width=i,s.height=l.height=o;var u=this._frameBuffer,c=this._ssrPass,h=this._blurPass1,d=this._blurPass2,p=this._blendPass,f=new iK,g=new iK;iK.transpose(f,t.worldTransform),iK.transpose(g,t.viewMatrix),c.setUniform("sourceTexture",n),c.setUniform("projection",t.projectionMatrix.array),c.setUniform("projectionInv",t.invProjectionMatrix.array),c.setUniform("toViewSpace",f.array),c.setUniform("toWorldSpace",g.array),c.setUniform("nearZ",t.near);var m=r/this._totalSamples*this._samplePerFrame;if(c.setUniform("jitterOffset",m),c.setUniform("sampleOffset",r*this._samplePerFrame),h.setUniform("textureSize",[a.width,a.height]),d.setUniform("textureSize",[i,o]),d.setUniform("sourceTexture",n),h.setUniform("projection",t.projectionMatrix.array),d.setUniform("projection",t.projectionMatrix.array),u.attach(a),u.bind(e),c.render(e),this._physicallyCorrect&&(u.attach(this._currentTexture),p.setUniform("texture1",this._prevTexture),p.setUniform("texture2",a),p.material.set({weight1:r>=1?.95:0,weight2:r>=1?.05:1}),p.render(e)),u.attach(s),h.setUniform("texture",this._physicallyCorrect?this._currentTexture:a),h.render(e),u.attach(l),d.setUniform("texture",s),d.render(e),u.unbind(e),this._physicallyCorrect){var v=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=v}},b0.prototype.getTargetTexture=function(){return this._texture3},b0.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},b0.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=uJ.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e},b0.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},b0.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},b0.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)};var w0=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925];function S0(e,t,n,r,i){var o=e.gl;t.setUniform(o,"1i",n,i),o.activeTexture(o.TEXTURE0+i),r.isRenderable()?r.bind(e):r.unbind(e)}function T0(e,t,n,r,i){var o,a,s,l,u=e.gl;return function(i,c,h){if(!l||l.material!==i.material){var d=i.material,p=i.__program,f=d.get("roughness");null==f&&(f=1);var g=d.get("normalMap")||t,m=d.get("roughnessMap"),v=d.get("bumpMap"),y=d.get("uvRepeat"),_=d.get("uvOffset"),x=d.get("detailUvRepeat"),b=d.get("detailUvOffset"),w=!!v&&d.isTextureEnabled("bumpMap"),S=!!m&&d.isTextureEnabled("roughnessMap"),T=d.isDefined("fragment","DOUBLE_SIDED");v=v||n,m=m||r,h!==c?(c.set("normalMap",g),c.set("bumpMap",v),c.set("roughnessMap",m),c.set("useBumpMap",w),c.set("useRoughnessMap",S),c.set("doubleSide",T),null!=y&&c.set("uvRepeat",y),null!=_&&c.set("uvOffset",_),null!=x&&c.set("detailUvRepeat",x),null!=b&&c.set("detailUvOffset",b),c.set("roughness",f)):(p.setUniform(u,"1f","roughness",f),o!==g&&S0(e,p,"normalMap",g,0),a!==v&&v&&S0(e,p,"bumpMap",v,1),s!==m&&m&&S0(e,p,"roughnessMap",m,2),null!=y&&p.setUniform(u,"2f","uvRepeat",y),null!=_&&p.setUniform(u,"2f","uvOffset",_),null!=x&&p.setUniform(u,"2f","detailUvRepeat",x),null!=b&&p.setUniform(u,"2f","detailUvOffset",b),p.setUniform(u,"1i","useBumpMap",+w),p.setUniform(u,"1i","useRoughnessMap",+S),p.setUniform(u,"1i","doubleSide",+T)),o=g,a=v,s=m,l=i}}}function M0(e){this._depthTex=new PK({format:AK.DEPTH_COMPONENT,type:AK.UNSIGNED_INT}),this._normalTex=new PK({type:AK.HALF_FLOAT}),this._framebuffer=new k$,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,k$.DEPTH_ATTACHMENT),this._normalMaterial=new WZ({shader:new bq(bq.source("ecgl.normal.vertex"),bq.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=eJ.createBlank("#000"),this._defaultBumpMap=eJ.createBlank("#000"),this._defaultRoughessMap=eJ.createBlank("#000"),this._debugPass=new lJ({fragment:bq.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}function C0(e){e=e||{},this._edgePass=new lJ({fragment:bq.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new PK({type:AK.HALF_FLOAT}),this._frameBuffer=new k$,this._frameBuffer.attach(this._targetTexture)}bq.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),M0.prototype.getDepthTexture=function(){return this._depthTex},M0.prototype.getNormalTexture=function(){return this._normalTex},M0.prototype.update=function(e,t,n){var r=e.getWidth(),i=e.getHeight(),o=this._depthTex,a=this._normalTex,s=this._normalMaterial;o.width=r,o.height=i,a.width=r,a.height=i;var l=t.getRenderList(n).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,n,{getMaterial:function(){return s},ifRender:function(e){return e.renderNormal},beforeRender:T0(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},M0.prototype.renderDebug=function(e){this._debugPass.render(e)},M0.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},C0.prototype.update=function(e,t,n,r){var i=e.getWidth(),o=e.getHeight(),a=this._targetTexture;a.width=i,a.height=o;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,o]),this._edgePass.setUniform("texture",n),this._edgePass.render(e),s.unbind(e)},C0.prototype.getTargetTexture=function(){return this._targetTexture},C0.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},C0.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};var D0={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]};function A0(e,t){return{color:{parameters:{width:e,height:t}}}}bq.import(QQ),bq.import(e0),bq.import(t0),bq.import(n0),bq.import(r0),bq.import(i0),bq.import(o0),bq.import(a0),bq.import(s0),bq.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),bq.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");var I0=["composite","FXAA"];function E0(){this._width,this._height,this._dpr,this._sourceTexture=new PK({type:AK.HALF_FLOAT}),this._depthTexture=new PK({format:AK.DEPTH_COMPONENT,type:AK.UNSIGNED_INT}),this._framebuffer=new k$,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,k$.DEPTH_ATTACHMENT),this._normalPass=new M0,this._compositor=u0(D0);var e=this._compositor.getNodeByName("source");e.texture=this._sourceTexture;var t=this._compositor.getNodeByName("coc");this._sourceNode=e,this._cocNode=t,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map((function(e){return this._compositor.getNodeByName(e)}),this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=I0.map((function(e){return this._compositor.getNodeByName(e)}),this);var n={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new x0(n),this._ssrPass=new b0(n),this._edgePass=new C0(n)}function L0(e){for(var t=[],n=0;n<30;n++)t.push([m0(n,2),m0(n,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new PK,this._sourceFb=new k$,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new PK,this._outputTex=new PK;var r=this._blendPass=new lJ({fragment:bq.source("clay.compositor.blend")});r.material.disableTexturesAll(),r.material.enableTexture(["texture1","texture2"]),this._blendFb=new k$({depthBuffer:!1}),this._outputPass=new lJ({fragment:bq.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}function N0(e){e=e||"perspective",this.layer=null,this.scene=new _$,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new E0,this._temporalSS=new L0,this._shadowMapPass=new XQ;for(var t=[],n=0,r=0;r<30;r++){for(var i=[],o=0;o<6;o++)i.push(4*m0(n,2)-2),i.push(4*m0(n,3)-2),n++;t.push(i)}this._pcfKernels=t,this.scene.on("beforerender",(function(e,t,n){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,n)}),this)}E0.prototype.resize=function(e,t,n){e*=n=n||1,t*=n;var r=this._sourceTexture,i=this._depthTexture;r.width=e,r.height=t,i.width=e,i.height=t;var o={getWidth:function(){return e},getHeight:function(){return t},getDevicePixelRatio:function(){return n}};function a(e,t){if("function"==typeof e[t]){var n=e[t].__original||e[t];e[t]=function(e){return n.call(this,o)},e[t].__original=n}}this._compositor.nodes.forEach((function(e){for(var t in e.outputs){var n=e.outputs[t].parameters;n&&(a(n,"width"),a(n,"height"))}for(var r in e.parameters)a(e.parameters,r)})),this._width=e,this._height=t,this._dpr=n},E0.prototype.getWidth=function(){return this._width},E0.prototype.getHeight=function(){return this._height},E0.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},E0.prototype._getPrevNode=function(e){for(var t=I0.indexOf(e.name)-1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t-=1,n=this._finalNodesChain[t];return n},E0.prototype._getNextNode=function(e){for(var t=I0.indexOf(e.name)+1,n=this._finalNodesChain[t];n&&!this._compositor.getNodeByName(n.name);)t+=1,n=this._finalNodesChain[t];return n},E0.prototype._addChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(e.inputs.texture=t.name,n?(e.outputs=A0(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},E0.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),n=this._getNextNode(e);t&&(n?(t.outputs=A0(this.getWidth.bind(this),this.getHeight.bind(this)),n.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},E0.prototype.updateNormal=function(e,t,n,r){this._ifRenderNormalPass()&&this._normalPass.update(e,t,n)},E0.prototype.updateSSAO=function(e,t,n,r){this._ssaoPass.update(e,n,r)},E0.prototype.enableSSAO=function(){this._enableSSAO=!0},E0.prototype.disableSSAO=function(){this._enableSSAO=!1},E0.prototype.enableSSR=function(){this._enableSSR=!0},E0.prototype.disableSSR=function(){this._enableSSR=!1},E0.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},E0.prototype.getSourceFrameBuffer=function(){return this._framebuffer},E0.prototype.getSourceTexture=function(){return this._sourceTexture},E0.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},E0.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},E0.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},E0.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},E0.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},E0.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},E0.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},E0.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},E0.prototype.enableEdge=function(){this._enableEdge=!0},E0.prototype.disableEdge=function(){this._enableEdge=!1},E0.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)},E0.prototype.setSSAOParameter=function(e,t){switch(e){case"quality":var n={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",n);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/200);break;case"intensity":this._ssaoPass.setParameter(e,t);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown SSAO parameter "+e)}},E0.prototype.setDOFParameter=function(e,t){switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].setParameter("blurRadius",t);break;case"quality":var r={low:4,medium:8,high:16,ultra:32}[t]||8;this._dofBlurKernelSize=r;for(n=0;n<this._dofBlurNodes.length;n++)this._dofBlurNodes[n].pass.material.define("POISSON_KERNEL_SIZE",r);this._dofBlurKernel=new Float32Array(2*r);break;default:"production"!==process.env.NODE_ENV&&console.warn("Unkown DOF parameter "+e)}},E0.prototype.setSSRParameter=function(e,t){if(null!=t)switch(e){case"quality":var n={low:10,medium:15,high:30,ultra:80}[t]||20,r={low:32,medium:16,high:8,ultra:4}[t]||16;this._ssrPass.setParameter("maxIteration",n),this._ssrPass.setParameter("pixelStride",r);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-t,1),0));break;case"physical":this.setPhysicallyCorrectSSR(t);break;default:console.warn("Unkown SSR parameter "+e)}},E0.prototype.setPhysicallyCorrectSSR=function(e){this._ssrPass.setPhysicallyCorrect(e)},E0.prototype.setEdgeColor=function(e){var t=zJ.parseColor(e);this._edgePass.setParameter("edgeColor",t)},E0.prototype.setExposure=function(e){this._compositeNode.setParameter("exposure",Math.pow(2,e))},E0.prototype.setColorLookupTexture=function(e,t){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?e:"none",t,{minFilter:zJ.Texture.NEAREST,magFilter:zJ.Texture.NEAREST,flipY:!1})},E0.prototype.setColorCorrection=function(e,t){this._compositeNode.setParameter(e,t)},E0.prototype.isSSREnabled=function(){return this._enableSSR},E0.prototype.composite=function(e,t,n,r,i){var o=this._sourceTexture,a=o;this._enableEdge&&(this._edgePass.update(e,n,o,i),o=a=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(e,n,o,i),a=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=a,this._cocNode.setParameter("depth",this._depthTexture);for(var s=this._dofBlurKernel,l=this._dofBlurKernelSize,u=i%Math.floor(w0.length/2/l),c=0;c<2*l;c++)s[c]=w0[c+u*l*2];for(c=0;c<this._dofBlurNodes.length;c++)this._dofBlurNodes[c].setParameter("percent",i/30),this._dofBlurNodes[c].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",n.near),this._cocNode.setParameter("zFar",n.far),this._compositor.render(e,r)},E0.prototype.dispose=function(e){this._sourceTexture.dispose(e),this._depthTexture.dispose(e),this._framebuffer.dispose(e),this._compositor.dispose(e),this._normalPass.dispose(e),this._ssaoPass.dispose(e)},L0.prototype={constructor:L0,jitterProjection:function(e,t){var n=e.viewport,r=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*r,o=n.height*r,a=this._haltonSequence[this._frame%this._haltonSequence.length],s=new iK;s.array[12]=(2*a[0]-1)/i,s.array[13]=(2*a[1]-1)/o,iK.mul(t.projectionMatrix,s,t.projectionMatrix),iK.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,n){var r=this._blendPass;0===this._frame?(r.setUniform("weight1",0),r.setUniform("weight2",1)):(r.setUniform("weight1",.9),r.setUniform("weight2",.1)),r.setUniform("texture1",this._prevFrameTex),r.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),r.render(e),this._blendFb.unbind(e),n||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},N0.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof M$||(this.camera=new M$,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof iJ||(this.camera=new iJ,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},N0.prototype.setViewport=function(e,t,n,r,i){this.camera instanceof M$&&(this.camera.aspect=n/r),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=n,this.viewport.height=r,this.viewport.devicePixelRatio=i,this._compositor.resize(n*i,r*i),this._temporalSS.resize(n*i,r*i)},N0.prototype.containPoint=function(e,t){var n=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var P0=new qZ;function O0(e,t){var n=Wd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=e.get("boxWidth"),i=e.get("boxHeight"),o=e.get("boxDepth");"production"!==process.env.NODE_ENV&&["x","y","z"].forEach((function(t){if(!this.getAxis(t))throw new Error("Grid"+e.id+" don't have "+t+"Axis")}),this),this.getAxis("x").setExtent(-r/2,r/2),this.getAxis("y").setExtent(o/2,-o/2),this.getAxis("z").setExtent(-i/2,i/2),this.size=[r,i,o]}function R0(e,t){var n={};e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData();["x","y","z"].forEach((function(e){t.mapDimensionsAll(e,!0).forEach((function(r){!function(e,t){n[e]=n[e]||[1/0,-1/0],n[e][0]=Math.min(t[0],n[e][0]),n[e][1]=Math.max(t[1],n[e][1])}(e,t.getDataExtent(r,!0))}))}))}}),this),["xAxis3D","yAxis3D","zAxis3D"].forEach((function(t){e.eachComponent(t,(function(e){var r=t.charAt(0),i=e.getReferringComponents("grid3D").models[0],o=i.coordinateSystem;if(o===this){var a=o.getAxis(r);if(a)"production"!==process.env.NODE_ENV&&console.warn("Can't have two %s in one grid3D",t);else{(a=new LQ(r,Jx(n[r]||[1/0,-1/0],e))).type=e.get("type");var s="category"===a.type;a.onBand=s&&e.get("boundaryGap"),a.inverse=e.get("inverse"),e.axis=a,a.model=e,a.getLabelModel=function(){return e.getModel("axisLabel",i.getModel("axisLabel"))},a.getTickModel=function(){return e.getModel("axisTick",i.getModel("axisTick"))},o.addAxis(a)}}}),this)}),this),this.resize(this.model,t)}N0.prototype.castRay=function(e,t,n){var r=this.layer.renderer,i=r.viewport;return r.viewport=this.viewport,r.screenToNDC(e,t,P0),this.camera.castRay(P0,n),r.viewport=i,n},N0.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t<e.transparent.length;t++){var n=e.transparent[t].geometry;n.needsSortVerticesProgressively&&n.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),n.needsSortTrianglesProgressively&&n.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},N0.prototype.render=function(e,t){this._doRender(e,t,this._frame),this._frame++},N0.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},N0.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"===e&&(e=this._enablePostEffect),e},N0.prototype.hasDOF=function(){return this._enableDOF},N0.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},N0.prototype._doRender=function(e,t,n){var r=this.scene,i=this.camera;n=n||0,this._updateTransparent(e,r,i,n),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,r,i,!0)),this._updateShadowPCFKernel(n);var o,a=e.clearColor;(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,r,i,this._temporalSS.getFrame())),this._updateSSAO(e,r,i,this._temporalSS.getFrame()),this._enablePostEffect)?((o=this._compositor.getSourceFrameBuffer()).bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(r,i,!0,!0),o.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,r,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,r,i,null,0))):this.needsTemporalSS()&&t?((o=this._temporalSS.getSourceFrameBuffer()).bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(r,i,!0,!0),e.restoreClear(),o.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),e.render(r,i,!0,!0))},N0.prototype._updateTransparent=function(e,t,n,r){for(var i=new Bq,o=new iK,a=n.getWorldPosition(),s=t.getRenderList(n).transparent,l=0;l<s.length;l++){var u=s[l],c=u.geometry;iK.invert(o,u.worldTransform),Bq.transformMat4(i,a,o),c.needsSortTriangles&&c.needsSortTriangles()&&c.doSortTriangles(i,r),c.needsSortVertices&&c.needsSortVertices()&&c.doSortVertices(i,r)}},N0.prototype._updateSSAO=function(e,t,n){var r=this._enableSSAO&&this._enablePostEffect;r&&this._compositor.updateSSAO(e,t,n,this._temporalSS.getFrame());for(var i=t.getRenderList(n),o=0;o<i.opaque.length;o++){var a=i.opaque[o];a.renderNormal&&a.material[r?"enableTexture":"disableTexture"]("ssaoMap"),r&&a.material.set("ssaoMap",this._compositor.getSSAOTexture())}},N0.prototype._updateShadowPCFKernel=function(e){for(var t=this._pcfKernels[e%this._pcfKernels.length],n=this.scene.getRenderList(this.camera).opaque,r=0;r<n.length;r++)n[r].receiveShadow&&(n[r].material.set("pcfKernel",t),n[r].material.define("fragment","PCF_KERNEL_SIZE",t.length/2))},N0.prototype.dispose=function(e){this._compositor.dispose(e.gl),this._temporalSS.dispose(e.gl),this._shadowMapPass.dispose(e)},N0.prototype.setPostEffect=function(e,t){var n=this._compositor;this._enablePostEffect=e.get("enable");var r=e.getModel("bloom"),i=e.getModel("edge"),o=e.getModel("DOF",e.getModel("depthOfField")),a=e.getModel("SSAO",e.getModel("screenSpaceAmbientOcclusion")),s=e.getModel("SSR",e.getModel("screenSpaceReflection")),l=e.getModel("FXAA"),u=e.getModel("colorCorrection");r.get("enable")?n.enableBloom():n.disableBloom(),o.get("enable")?n.enableDOF():n.disableDOF(),s.get("enable")?n.enableSSR():n.disableSSR(),u.get("enable")?n.enableColorCorrection():n.disableColorCorrection(),i.get("enable")?n.enableEdge():n.disableEdge(),l.get("enable")?n.enableFXAA():n.disableFXAA(),this._enableDOF=o.get("enable"),this._enableSSAO=a.get("enable"),this._enableSSAO?n.enableSSAO():n.disableSSAO(),n.setBloomIntensity(r.get("intensity")),n.setEdgeColor(i.get("color")),n.setColorLookupTexture(u.get("lookupTexture"),t),n.setExposure(u.get("exposure")),["radius","quality","intensity"].forEach((function(e){n.setSSAOParameter(e,a.get(e))})),["quality","maxRoughness","physical"].forEach((function(e){n.setSSRParameter(e,s.get(e))})),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach((function(e){n.setDOFParameter(e,o.get(e))})),["brightness","contrast","saturation"].forEach((function(e){n.setColorCorrection(e,u.get(e))}))},N0.prototype.setDOFFocusOnPoint=function(e){if(this._enablePostEffect){if(e>this.camera.far||e<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",e),!0}},N0.prototype.setTemporalSuperSampling=function(e){this._enableTemporalSS=e.get("enable")},N0.prototype.isLinearSpace=function(){return this._enablePostEffect},N0.prototype.setRootNode=function(e){if(this.rootNode!==e){for(var t=this.rootNode.children(),n=0;n<t.length;n++)e.add(t[n]);e!==this.scene&&this.scene.add(e),this.rootNode=e}},N0.prototype.add=function(e){this.rootNode.add(e)},N0.prototype.remove=function(e){this.rootNode.remove(e)},N0.prototype.removeAll=function(e){this.rootNode.removeAll(e)},Object.assign(N0.prototype,vY);var k0={dimensions:EQ.prototype.dimensions,create:function(e,t){var n=[];e.eachComponent("grid3D",(function(e){e.__viewGL=e.__viewGL||new N0;var t=new EQ;t.model=e,t.viewGL=e.__viewGL,e.coordinateSystem=t,n.push(t),t.resize=O0,t.update=R0}));var r=["xAxis3D","yAxis3D","zAxis3D"];return e.eachSeries((function(t){if("cartesian3D"===t.get("coordinateSystem")){if(null==(i=t.getReferringComponents("grid3D").models[0])){var n=function(e,t){return r.map((function(n){var r=e.getReferringComponents(n).models[0];if(null==r&&(r=t.getComponent(n)),"production"!==process.env.NODE_ENV&&!r)throw new Error(n+' "'+vJ(e.get(n+"Index"),e.get(n+"Id"),0)+'" not found');return r}))}(t,e),i=n[0].getCoordSysModel();n.forEach((function(e){var t=e.getCoordSysModel();if("production"!==process.env.NODE_ENV){if(!t)throw new Error('grid3D "'+vJ(e.get("gridIndex"),e.get("gridId"),0)+'" not found');if(t!==i)throw new Error("xAxis3D, yAxis3D, zAxis3D must use the same grid")}}))}var o=i.coordinateSystem;t.coordinateSystem=o}})),n}},z0=$d.extend({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});Qx(z0);var V0={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},B0=R({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},V0),F0=R({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},V0),G0=V({scale:!0,min:"dataMin",max:"dataMax"},F0),H0=V({logBase:10},F0);H0.scale=!0;var U0={categoryAxis3D:B0,valueAxis3D:F0,timeAxis3D:G0,logAxis3D:H0},W0=["value","category","time","log"];function j0(e,t){return t.type||(t.data?"category":"value")}i_((function(e){e.registerComponentModel(tQ),e.registerComponentView(IQ),e.registerCoordinateSystem("grid3D",k0),["x","y","z"].forEach((function(t){!function(e,t,n,r,i){W0.forEach((function(o){var a=n.extend({type:t+"Axis3D."+o,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){R(e,n.getTheme().get(o+"Axis3D")),R(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=W_.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:R(O(U0[o+"Axis3D"]),i,!0)});e.registerComponentModel(a)})),e.registerSubTypeDefaulter(t+"Axis3D",$(r,t))}(e,t,z0,j0,{name:t.toUpperCase()});const n=e.ComponentView.extend({type:t+"Axis3D"});e.registerComponentView(n)})),e.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"grid3D",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},(function(e,t){})),e.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},(function(e,t){}))}));var X0={defaultOption:{shading:null,realisticMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},lambertMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},colorMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},hatchingMaterial:{textureTiling:1,textureOffset:0,paperColor:"#fff"}}},Y0={getFilledRegions:function(e,t){var n,r=(e||[]).slice();if("string"==typeof t?n=(t=e_(t))&&t.geoJson:t&&t.features&&(n=t),!n)return"production"!==process.env.NODE_ENV&&(console.error("Map "+t+" not exists. You can download map file on http://echarts.baidu.com/download-map.html"),n.features||console.error("Invalid GeoJSON for map3D")),[];for(var i={},o=n.features,a=0;a<r.length;a++)i[r[a].name]=r[a];for(a=0;a<o.length;a++){var s=o[a].properties.name;i[s]||r.push({name:s})}return r},defaultOption:{show:!0,zlevel:-10,map:"",left:0,top:0,width:"100%",height:"100%",boxWidth:100,boxHeight:10,boxDepth:"auto",regionHeight:3,environment:"auto",groundPlane:{show:!1,color:"#aaa"},shading:"lambert",light:{main:{alpha:40,beta:30}},viewControl:{alpha:40,beta:0,distance:100,orthographicSize:60,minAlpha:5,minBeta:-80,maxBeta:80},label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}},Z0=$d.extend({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=N_(e.data||[],{coordDimensions:["value"],encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),n=new L_(t,this);n.initData(e.regions);var r={};n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,this._data=n},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Fh(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),n=this.coordinateSystem.getRegion(t);return n?n.geometries:[]},getFormattedLabel:function(e,t){var n=this._data.getName(e),r=this.getRegionModel(e),i=r.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=r.get(["label","formatter"]));var o={name:n};if("function"==typeof i)return o.status=t,i(o);if("string"==typeof i){var a=o.seriesName;return i.replace("{a}",null!=a?a:"")}return n},defaultOption:{regions:[]}});function q0(e,t,n){n=n||2;var r,i,o,a,s,l,u,c=t&&t.length,h=c?t[0]*n:e.length,d=K0(e,0,h,n,!0),p=[];if(!d)return p;if(c&&(d=function(e,t,n,r){var i,o,a,s=[];for(i=0,o=t.length;i<o;i++)(a=K0(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(a1(a));for(s.sort(r1),i=0;i<s.length;i++)i1(s[i],n),n=$0(n,n.next);return n}(e,t,d,n)),e.length>80*n){r=o=e[0],i=a=e[1];for(var f=n;f<h;f+=n)(s=e[f])<r&&(r=s),(l=e[f+1])<i&&(i=l),s>o&&(o=s),l>a&&(a=l);u=Math.max(o-r,a-i)}return J0(d,p,n,r,i,u),p}function K0(e,t,n,r,i){var o,a;if(i===v1(e,t,n,r)>0)for(o=t;o<n;o+=r)a=f1(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=f1(o,e[o],e[o+1],a);return a&&c1(a,a.next)&&(g1(a),a=a.next),a}function $0(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!c1(r,r.next)&&0!==u1(r.prev,r,r.next))r=r.next;else{if(g1(r),(r=t=r.prev)===r.next)return null;n=!0}}while(n||r!==t);return t}function J0(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=o1(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<u&&(s++,r=r.nextZ);t++);for(l=u;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?e1(e,r,i,o):Q0(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),g1(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?J0(e=t1(e,t,n),t,n,r,i,o,2):2===a&&n1(e,t,n,r,i,o):J0($0(e),t,n,r,i,o,1);break}}}function Q0(e){var t=e.prev,n=e,r=e.next;if(u1(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(s1(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&u1(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function e1(e,t,n,r){var i=e.prev,o=e,a=e.next;if(u1(i,o,a)>=0)return!1;for(var s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=o1(s,l,t,n,r),d=o1(u,c,t,n,r),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&s1(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&u1(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&s1(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&u1(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function t1(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!c1(i,o)&&h1(i,r,r.next,o)&&d1(i,o)&&d1(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),g1(r),g1(r.next),r=e=o),r=r.next}while(r!==e);return r}function n1(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&l1(a,s)){var l=p1(a,s);return a=$0(a,a.next),l=$0(l,l.next),J0(a,t,n,r,i,o),void J0(l,t,n,r,i,o)}s=s.next}a=a.next}while(a!==e)}function r1(e,t){return e.x-t.x}function i1(e,t){if(t=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===a)return n.prev;var l,u=n,c=n.x,h=n.y,d=1/0;r=n.next;for(;r!==u;)i>=r.x&&r.x>=c&&i!==r.x&&s1(o<h?i:a,o,c,h,o<h?a:i,o,r.x,r.y)&&((l=Math.abs(o-r.y)/(i-r.x))<d||l===d&&r.x>n.x)&&d1(r,e)&&(n=r,d=l),r=r.next;return n}(e,t),t){var n=p1(t,e);$0(n,n.next)}}function o1(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)/i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function a1(e){var t=e,n=e;do{t.x<n.x&&(n=t),t=t.next}while(t!==e);return n}function s1(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function l1(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&h1(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&d1(e,t)&&d1(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)}function u1(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function c1(e,t){return e.x===t.x&&e.y===t.y}function h1(e,t,n,r){return!!(c1(e,t)&&c1(n,r)||c1(e,r)&&c1(n,t))||u1(e,t,n)>0!=u1(e,t,r)>0&&u1(n,r,e)>0!=u1(n,r,t)>0}function d1(e,t){return u1(e.prev,e,e.next)<0?u1(e,t,e.next)>=0&&u1(e,e.prev,t)>=0:u1(e,t,e.prev)<0||u1(e,e.next,t)<0}function p1(e,t){var n=new m1(e.i,e.x,e.y),r=new m1(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function f1(e,t,n,r){var i=new m1(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function g1(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function m1(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function v1(e,t,n,r){for(var i=0,o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}function y1(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _1(e,t,n,r,i){var o=n,a=e[t];y1(e,t,r);for(var s=n;s<r;s++)i(e[s],a)<0&&(y1(e,s,o),o++);return y1(e,r,o),o}function x1(e,t,n,r){if(n<r){var i=_1(e,Math.floor((n+r)/2),n,r,t);x1(e,t,n,i-1),x1(e,t,i+1,r)}}function b1(){this._parts=[]}R(Z0.prototype,Y0),R(Z0.prototype,JJ),R(Z0.prototype,QJ),R(Z0.prototype,eQ),R(Z0.prototype,X0),q0.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,a=Math.abs(v1(e,0,o,n));if(i)for(var s=0,l=t.length;s<l;s++){var u=t[s]*n,c=s<l-1?t[s+1]*n:e.length;a-=Math.abs(v1(e,u,c,n))}var h=0;for(s=0;s<r.length;s+=3){var d=r[s]*n,p=r[s+1]*n,f=r[s+2]*n;h+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===a&&0===h?0:Math.abs((h-a)/a)},b1.prototype.step=function(e,t,n){var r=e.length;if(0===n){this._parts=[],this._sorted=!1;var i=Math.floor(r/2);this._parts.push({pivot:i,left:0,right:r-1}),this._currentSortPartIdx=0}if(!this._sorted){var o=this._parts;if(0===o.length)return this._sorted=!0,!0;if(o.length<512){for(var a=0;a<o.length;a++)o[a].pivot=_1(e,o[a].pivot,o[a].left,o[a].right,t);var s=[];for(a=0;a<o.length;a++){var l=o[a].left;(u=o[a].pivot-1)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u});var u;l=o[a].pivot+1;(u=o[a].right)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u})}o=this._parts=s}else for(a=0;a<Math.floor(o.length/10);a++){var c=o.length-1-this._currentSortPartIdx;if(x1(e,t,o[c].left,o[c].right),this._currentSortPartIdx++,this._currentSortPartIdx===o.length)return this._sorted=!0,!0}return!1}},b1.sort=x1;var w1=sQ.vec3,S1=w1.create(),T1=w1.create(),M1=w1.create(),C1={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(e,t){var n=this.indices;if(0===t){var r=this.attributes.position;e=e.array;this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new n.constructor(n.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,o=0,a=0;a<n.length;){r.get(n[a++],S1),r.get(n[a++],T1),r.get(n[a++],M1);var s=w1.sqrDist(S1,e),l=w1.sqrDist(T1,e),u=w1.sqrDist(M1,e),c=Math.min(s,l);c=Math.min(c,u),3===a?(i=c,c=0):c-=i,this._triangleZList[o++]=c}}var h=this._sortedTriangleIndices;for(a=0;a<h.length;a++)h[a]=a;if(this.triangleCount<2e4)0===t&&this._simpleSort(!0);else for(a=0;a<3;a++)this._progressiveQuickSort(3*t+a);var d=this._indicesTmp,p=this._triangleZListTmp,f=this._triangleZList;for(a=0;a<this.triangleCount;a++){var g=3*h[a],m=3*a;d[m++]=n[g++],d[m++]=n[g++],d[m]=n[g],p[a]=f[h[a]]}var v=this._indicesTmp;this._indicesTmp=this.indices,this.indices=v;v=this._triangleZListTmp;this._triangleZListTmp=this._triangleZList,this._triangleZList=v,this.dirtyIndices()},_simpleSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):b1.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._triangleZList,n=this._sortedTriangleIndices;this._quickSort=this._quickSort||new b1,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}};function D1(e,t){const n=e.getItemVisual(t,"style");if(n){return n[e.getVisual("drawType")]}}function A1(e,t){const n=e.getItemVisual(t,"style");return n&&n.opacity}function I1(e,t,n){this._labelsMesh=new bQ,this._labelTextureSurface=new dQ({width:512,height:512,devicePixelRatio:n.getDevicePixelRatio(),onupdate:function(){n.getZr().refresh()}}),this._api=n,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}I1.prototype.getLabelPosition=function(e,t,n){return[0,0,0]},I1.prototype.getLabelDistance=function(e,t,n){return 0},I1.prototype.getMesh=function(){return this._labelsMesh},I1.prototype.updateData=function(e,t,n){null==t&&(t=0),null==n&&(n=e.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===n-t||(this._labelsVisibilitiesBits=new Uint8Array(n-t));for(var r=["label","show"],i=["emphasis","label","show"],o=t;o<n;o++){var a=e.getItemModel(o),s=a.get(r),l=a.get(i);null==l&&(l=s);var u=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[o-t]=u}this._start=t,this._end=n,this._data=e},I1.prototype.updateLabels=function(e){if(this._data){for(var t=(e=e||[]).length>0,n={},r=0;r<e.length;r++)n[e[r]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var i=["label"],o=["emphasis","label"],a=this._data.hostModel,s=this._data,l=a.getModel(i),u=a.getModel(o,l),c={left:"right",right:"left",top:"center",bottom:"center"},h={left:"middle",right:"middle",top:"bottom",bottom:"top"},d=this._start;d<this._end;d++){var p=!1;if(t&&n[d]&&(p=!0),this._labelsVisibilitiesBits[d-this._start]&(p?2:1)){var f=s.getItemModel(d).getModel(p?o:i,p?u:l),g=f.get("distance")||0,m=f.get("position"),v=this._api.getDevicePixelRatio(),y=a.getFormattedLabel(d,p?"emphasis":"normal");if(null==y||""===y)return;var _=new il({style:yh(f,{text:y,fill:f.get("color")||D1(s,d)||"#000",align:"left",verticalAlign:"top",opacity:vJ(f.get("opacity"),A1(s,d),1)})}),x=_.getBoundingRect();x.height*=1.2;var b=this._labelTextureSurface.add(_),w=c[m]||"center",S=h[m]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(d,m,g),[x.width*v,x.height*v],b,w,S,this.getLabelDistance(d,m,g)*v)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}},I1.prototype.dispose=function(){this._labelTextureSurface.dispose()};var E1=sQ.vec3;function L1(e){this.rootNode=new zJ.Node,this._triangulationResults={},this._shadersMap=zJ.COMMON_SHADERS.filter((function(e){return"shadow"!==e})).reduce((function(e,t){return e[t]=zJ.createShader("ecgl."+t),e}),{}),this._linesShader=zJ.createShader("ecgl.meshLines3D");var t={};zJ.COMMON_SHADERS.forEach((function(e){t[e]=new zJ.Material({shader:zJ.createShader("ecgl."+e)})})),this._groundMaterials=t,this._groundMesh=new zJ.Mesh({geometry:new zJ.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new I1(512,512,e),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=e}zJ.Shader.import(CQ),L1.prototype={constructor:L1,extrudeY:!0,update:function(e,t,n,r,i){var o=e.getData();null==r&&(r=0),null==i&&(i=o.count()),this._startIndex=r,this._endIndex=i-1,this._triangulation(e,r,i);var a=this._getShader(e.get("shading"));this._prepareMesh(e,a,n,r,i),this.rootNode.updateWorldTransform(),this._updateRegionMesh(e,n,r,i);var s=e.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(e,s,n);var l=this;this._labelsBuilder.updateData(o,r,i),this._labelsBuilder.getLabelPosition=function(e,t,n){var r=o.getName(e),i=n;if("geo3D"===s.type){var a=s.getRegion(r);return a?(c=a.getCenter(),s.dataToPoint([c[0],c[1],i])):[NaN,NaN,NaN]}var u=l._triangulationResults[e-l._startIndex],c=l.extrudeY?[(u.max[0]+u.min[0])/2,u.max[1]+i,(u.max[2]+u.min[2])/2]:[(u.max[0]+u.min[0])/2,(u.max[1]+u.min[1])/2,u.max[2]+i]},this._data=o,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(e),this._lastHoverDataIndex=0},_initMeshes:function(){var e=this;var t=function(){var t=new zJ.Mesh({name:"Polygon",material:new zJ.Material({shader:e._shadersMap.lambert}),geometry:new zJ.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return Object.assign(t.geometry,C1),t}(),n=new zJ.Mesh({material:new zJ.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new cQ({useNativeLine:!1})});this.rootNode.add(t),this.rootNode.add(n),t.material.define("both","VERTEX_COLOR"),t.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=t,this._linesMesh=n,this.rootNode.add(this._groundMesh)},_getShader:function(e){var t=this._shadersMap[e];return t||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+e),t=this._shadersMap.lambert),t.__shading=e,t},_prepareMesh:function(e,t,n,r,i){for(var o=0,a=0,s=0,l=0,u=r;u<i;u++){var c=this._getRegionPolygonInfo(u),h=this._getRegionLinesInfo(u,e,this._linesMesh.geometry);o+=c.vertexCount,a+=c.triangleCount,s+=h.vertexCount,l+=h.triangleCount}var d=this._polygonMesh,p=d.geometry;["position","normal","texcoord0","color"].forEach((function(e){p.attributes[e].init(o)})),p.indices=o>65535?new Uint32Array(3*a):new Uint16Array(3*a),d.material.shader!==t&&d.material.attachShader(t,!0),zJ.setMaterialFromModel(t.__shading,d.material,e,n),s>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(s),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(o),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-r))},_updateRegionMesh:function(e,t,n,r){for(var i=e.getData(),o=0,a=0,s=!1,l=this._polygonMesh,u=this._linesMesh,c=n;c<r;c++){var h=e.getRegionModel(c),d=h.getModel("itemStyle"),p=vJ(D1(i,c),d.get("color"),"#fff"),f=vJ(A1(i,c),d.get("opacity"),1),g=zJ.parseColor(p),m=zJ.parseColor(d.get("borderColor"));g[3]*=f,m[3]*=f;var v=g[3]<.99;l.material.set("color",[1,1,1,1]),s=s||v;for(var y=vJ(h.get("height",!0),e.get("regionHeight")),_=this._updatePolygonGeometry(e,l.geometry,c,y,o,a,g),x=o;x<_.vertexOffset;x++)this._dataIndexOfVertex[x]=c;this._vertexRangeOfDataIndex[2*(c-n)]=o,this._vertexRangeOfDataIndex[2*(c-n)+1]=_.vertexOffset,o=_.vertexOffset,a=_.triangleOffset;var b=d.get("borderWidth"),w=b>0;w&&(b*=t.getDevicePixelRatio(),this._updateLinesGeometry(u.geometry,e,c,y,b,e.coordinateSystem.transform)),u.invisible=!w,u.material.set({color:m})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?zJ.Mesh.CCW:zJ.Mesh.CW,l.material.get("normalMap")&&l.geometry.generateTangents(),l.seriesIndex=e.seriesIndex,l.on("mousemove",this._onmousemove,this),l.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(e){var t=e.getModel("debug.wireframe");if(t.get("show")){var n=zJ.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),r=vJ(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",n),i.material.set("wireframeLineWidth",r)}},_onmousemove:function(e){var t=this._dataIndexOfVertex[e.triangle[0]];null==t&&(t=-1),t!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(t),this._labelsBuilder.updateLabels([t])),this._lastHoverDataIndex=t,this._polygonMesh.dataIndex=t},_onmouseout:function(e){e.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(e,t,n){var r=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!r.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),o=this._groundMaterials[i];o||("production"!==process.env.NODE_ENV&&console.warn("Unkown shading "+i),o=this._groundMaterials.lambert),zJ.setMaterialFromModel(i,o,r,n),o.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=o,this._groundMesh.material.set("color",zJ.parseColor(r.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,n){this._triangulationResults=[];for(var r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],o=e.coordinateSystem,a=t;a<n;a++){for(var s=[],l=e.getRegionPolygonCoords(a),u=0;u<l.length;u++){var c=l[u].exterior,h=l[u].interiors,d=[],p=[];if(!(c.length<3)){for(var f=0,g=0;g<c.length;g++){var m=c[g];d[f++]=m[0],d[f++]=m[1]}for(g=0;g<h.length;g++)if(!(h[g].length<3)){for(var v=d.length/2,y=0;y<h[g].length;y++){m=h[g][y];d.push(m[0]),d.push(m[1])}p.push(v)}var _=q0(d,p),x=new Float64Array(d.length/2*3),b=[],w=[1/0,1/0,1/0],S=[-1/0,-1/0,-1/0],T=0;for(g=0;g<d.length;)E1.set(b,d[g++],0,d[g++]),o&&o.transform&&E1.transformMat4(b,b,o.transform),E1.min(w,w,b),E1.max(S,S,b),x[T++]=b[0],x[T++]=b[1],x[T++]=b[2];E1.min(r,r,w),E1.max(i,i,S),s.push({points:x,indices:_,min:w,max:S})}}this._triangulationResults.push(s)}this._geoBoundingBox=[r,i]},_getRegionPolygonInfo:function(e){for(var t=this._triangulationResults[e-this._startIndex],n=0,r=0,i=0;i<t.length;i++)n+=t[i].points.length/3,r+=t[i].indices.length/3;return{vertexCount:2*n+4*n,triangleCount:2*r+2*n}},_updatePolygonGeometry:function(e,t,n,r,i,o,a){var s=e.get("projectUVOnGround"),l=t.attributes.position,u=t.attributes.normal,c=t.attributes.texcoord0,h=t.attributes.color,d=this._triangulationResults[n-this._startIndex],p=h.value&&a,f=t.indices,g=this.extrudeY?1:2,m=this.extrudeY?2:1,v=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],y=E1.mul([],this._geoBoundingBox[0],v),_=E1.mul([],this._geoBoundingBox[1],v),x=Math.max(_[0]-y[0],_[2]-y[2]);function b(e,t,n){var r=i;!function(e,t){for(var n=e.points,r=n.length,o=[],s=[],u=0;u<r;u+=3)o[0]=n[u],o[g]=t,o[m]=n[u+2],s[0]=(n[u]*v[0]-y[0])/x,s[1]=(n[u+2]*v[m]-y[2])/x,l.set(i,o),p&&h.set(i,a),c.set(i++,s)}(e,t);for(var s=e.indices.length,u=0;u<s;u++)f[3*o+u]=e.indices[u]+r;o+=e.indices.length/3}for(var w=this.extrudeY?[0,1,0]:[0,0,1],S=E1.negate([],w),T=0;T<d.length;T++){var M=i,C=d[T];b(C,0),b(C,r);for(var D=C.points.length/3,A=0;A<D;A++)u.set(M+A,S),u.set(M+A+D,w);var I=[0,3,1,1,3,2],E=[[],[],[],[]],L=[],N=[],P=[],O=[],R=0;for(A=0;A<D;A++){for(var k=(A+1)%D,z=(C.points[3*k]-C.points[3*A])*v[0],V=(C.points[3*k+2]-C.points[3*A+2])*v[m],B=Math.sqrt(z*z+V*V),F=0;F<4;F++){var G=0===F||3===F,H=3*(G?A:k);E[F][0]=C.points[H],E[F][g]=F>1?r:0,E[F][m]=C.points[H+2],l.set(i+F,E[F]),s?(O[0]=(C.points[H]*v[0]-y[0])/x,O[1]=(C.points[H+2]*v[m]-y[m])/x):(O[0]=(G?R:R+B)/x,O[1]=(E[F][g]*v[g]-y[g])/x),c.set(i+F,O)}E1.sub(L,E[1],E[0]),E1.sub(N,E[3],E[0]),E1.cross(P,L,N),E1.normalize(P,P);for(F=0;F<4;F++)u.set(i+F,P),p&&h.set(i+F,a);for(F=0;F<6;F++)f[3*o+F]=I[F]+i;i+=4,o+=2,R+=B}}return t.dirty(),{vertexOffset:i,triangleOffset:o}},_getRegionLinesInfo:function(e,t,n){var r=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach((function(e){var t=e.exterior,o=e.interiors;r+=n.getPolylineVertexCount(t),i+=n.getPolylineTriangleCount(t);for(var a=0;a<o.length;a++)r+=n.getPolylineVertexCount(o[a]),i+=n.getPolylineTriangleCount(o[a])}),this);return{vertexCount:r,triangleCount:i}},_updateLinesGeometry:function(e,t,n,r,i,o){function a(e){for(var t=new Float64Array(3*e.length),n=0,i=[],a=0;a<e.length;a++)i[0]=e[a][0],i[1]=r+.1,i[2]=e[a][1],o&&E1.transformMat4(i,i,o),t[n++]=i[0],t[n++]=i[1],t[n++]=i[2];return t}var s=[1,1,1,1];t.getRegionPolygonCoords(n).forEach((function(t){var n=t.exterior,r=t.interiors;e.addPolyline(a(n),s,i);for(var o=0;o<r.length;o++)e.addPolyline(a(r[o]),s,i)}))},highlight:function(e){var t=this._data;if(t){var n=t.getItemModel(e).getModel(["emphasis","itemStyle"]),r=n.get("color"),i=vJ(n.get("opacity"),A1(t,e),1);if(null==r)r=ir(D1(t,e),-.4);null==i&&(i=A1(t,e));var o=zJ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},downplay:function(e){var t=this._data;if(t){var n=t.getItemModel(e),r=vJ(D1(t,e),n.get(["itemStyle","color"]),"#fff"),i=vJ(A1(t,e),n.get(["itemStyle","opacity"]),1),o=zJ.parseColor(r);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},dispose:function(){this._labelsBuilder.dispose()},_setColorOfDataIndex:function(e,t,n){if(!(t<this._startIndex&&t>this._endIndex)){t-=this._startIndex;for(var r=this._vertexRangeOfDataIndex[2*t];r<this._vertexRangeOfDataIndex[2*t+1];r++)this._polygonMesh.geometry.attributes.color.set(r,n);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};var N1=Xg.extend({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new L1(t),this.groupGL=new zJ.Node,this._lightRoot=new zJ.Node,this._sceneHelper=new pQ(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new oQ({zr:t.getZr()}),this._control.init()},render:function(e,t,n){this.groupGL.add(this._geo3DBuilder.rootNode);var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(r.viewGL);var o=e.getModel("viewControl");i.setFromViewControlModel(o,0),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")})),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"geo3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),center:i.getCenter(),from:this.uid,geo3DId:e.id})})),i.update()}},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},dispose:function(){this._control.dispose(),this._geo3DBuilder.dispose()}}),P1={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]};var O1=sQ.vec3,R1=sQ.mat4,k1=[dD,function(e,t){if("world"===e){var n=P1[t.name];if(n){var r=[n[0],n[1]];t.setCenter(r)}}}];function z1(e,t,n,r,i){this.name=e,this.map=t,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(n,r,i),this.transform=R1.identity(new Float64Array(16)),this.invTransform=R1.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}function V1(e,t){var n=Wd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio());var r=this.getGeoBoundingRect(),i=r.width/r.height*(e.get("aspectScale")||.75),o=e.get("boxWidth"),a=e.get("boxDepth"),s=e.get("boxHeight");null==s&&(s=5),isNaN(o)&&isNaN(a)&&(o=100),isNaN(a)?a=o/i:isNaN(o)&&(o=a/i),this.setSize(o,s,a),this.regionHeight=e.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(s-this.regionHeight,0))}function B1(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this&&"series.map3D"!==e.type){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),isFinite(n[1]-n[0])){var r=Jx(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Eb("altitude",r),this.resize(this.model,t)}}if(z1.prototype={constructor:z1,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(e,t,n){var r=pb;try{this.regions=e?r(e):[]}catch(e){throw"Invalid geoJson format\n"+e}t=t||{},n=n||{};for(var i=this.regions,o={},a=0;a<i.length;a++){var s=i[a].name;s=n[s]||s,i[a].name=s,o[s]=i[a],this.addGeoCoord(s,i[a].getCenter());var l=t[s];l&&i[a].transformTo(l.left,l.top,l.width,l.height)}this._regionsMap=o,this._geoRect=null,k1.forEach((function(e){e(this)}),this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var e,t=this.regions,n=0;n<t.length;n++){var r=t[n].getBoundingRect();(e=e||r.clone()).union(r)}return this._geoRect=e||new jt(0,0,0,0)},addGeoCoord:function(e,t){this._nameCoordMap[e]=t},getRegion:function(e){return this._regionsMap[e]},getRegionByCoord:function(e){for(var t=this.regions,n=0;n<t.length;n++)if(t[n].contain(e))return t[n]},setSize:function(e,t,n){this.size=[e,t,n];var r=this.getGeoBoundingRect(),i=e/r.width,o=-n/r.height,a=-e/2-r.x*i,s=n/2-r.y*o,l=this.extrudeY?[a,0,s]:[a,s,0],u=this.extrudeY?[i,1,o]:[i,o,1],c=this.transform;R1.identity(c),R1.translate(c,c,l),R1.scale(c,c,u),R1.invert(this.invTransform,c)},dataToPoint:function(e,t){t=t||[];var n=this.extrudeY?1:2,r=this.extrudeY?2:1,i=e[2];return isNaN(i)&&(i=0),t[0]=e[0],t[r]=e[1],this.altitudeAxis?t[n]=this.altitudeAxis.dataToCoord(i):t[n]=0,t[n]+=this.regionHeight,O1.transformMat4(t,t,this.transform),t},pointToData:function(e,t){}},"production"!==process.env.NODE_ENV)var F1=function(e){console.error("Map "+e+" not exists. You can download map file on http://echarts.baidu.com/download-map.html")};var G1=0,H1={dimensions:z1.prototype.dimensions,create:function(e,t){var n=[];if(!e_)throw new Error("geo3D component depends on geo component");function r(e,r){var i=H1.createGeo3D(e);e.__viewGL=e.__viewGL||new N0,i.viewGL=e.__viewGL,e.coordinateSystem=i,i.model=e,n.push(i),i.resize=V1,i.resize(e,t),i.update=B1}return e.eachComponent("geo3D",(function(e,t){r(e)})),e.eachSeriesByType("map3D",(function(e,t){var n=e.get("coordinateSystem");null==n&&(n="geo3D"),"geo3D"===n&&r(e)})),e.eachSeries((function(t){if("geo3D"===t.get("coordinateSystem")){if("series.map3D"===t.type)return;var n=t.getReferringComponents("geo3D").models[0];if(n||(n=e.getComponent("geo3D")),!n)throw new Error('geo "'+vJ(t.get("geo3DIndex"),t.get("geo3DId"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n},createGeo3D:function(e){var t,n=e.get("map");if("string"==typeof n?(t=n,n=e_(n)):n&&n.features&&(n={geoJson:n}),"production"!==process.env.NODE_ENV&&(n||F1(n),!n.geoJson.features))throw new Error("Invalid GeoJSON for map3D");return null==t&&(t="GEO_ANONYMOUS_"+G1++),new z1(t+G1++,t,n&&n.geoJson,n&&n.specialAreas,e.get("nameMap"))}};function U1(e){e.registerComponentModel(Z0),e.registerComponentView(N1),e.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"geo3D",query:e},(function(t){t.setView(e)}))})),e.registerCoordinateSystem("geo3D",H1)}function W1(e,t){e.id=e.id||e.name||t+""}i_(U1);var j1=$d.extend({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){j1.superApply(this,"init",arguments),W(this.option.layers,(function(e,t){R(e,this.defaultLayerOption),W1(e,t)}),this)},mergeOption:function(e){var t=this.option.layers;function n(e){return X(e,(function(e,t,n){return W1(t,n),e[t.id]=t,e}),{})}if(this.option.layers=null,j1.superApply(this,"mergeOption",arguments),t&&t.length){var r=n(e.layers),i=n(t);for(var o in r)i[o]?R(i[o],r[o],!0):t.push(e.layers[o]);this.option.layers=t}W(this.option.layers,(function(e){R(e,this.defaultLayerOption)}),this)},optionUpdated:function(){this.updateDisplacementHash()},defaultLayerOption:{show:!0,type:"overlay"},defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",baseColor:"#fff",baseTexture:"",heightTexture:"",displacementTexture:"",displacementScale:0,displacementQuality:"medium",globeRadius:100,globeOuterRadius:150,shading:"lambert",light:{main:{time:""}},atmosphere:{show:!1,offset:5,color:"#ffffff",glowPower:6,innerGlowPower:2},viewControl:{autoRotate:!0,panSensitivity:0,targetCoord:null},layers:[]},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},getDisplacementTexture:function(){return this.get("displacementTexture")||this.get("heightTexture")},getDisplacemenScale:function(){var e=this.getDisplacementTexture(),t=this.get("displacementScale");return e&&"none"!==e||(t=0),t},hasDisplacement:function(){return this.getDisplacemenScale()>0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var e=this.getDisplacementTexture(),t=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==e||this._displacementScale!==t,this._displacementTexture=e,this._displacementScale=t},isDisplacementChanged:function(){return this._displacementChanged}});R(j1.prototype,JJ),R(j1.prototype,QJ),R(j1.prototype,eQ),R(j1.prototype,X0);var X1=Math.PI,Y1=Math.sin,Z1=Math.cos,q1=Math.tan,K1=Math.asin,$1=Math.atan2,J1=X1/180;var Q1=23.4397*J1;function e2(e,t){return $1(Y1(e)*Z1(Q1)-q1(t)*Y1(Q1),Z1(e))}function t2(e,t,n){return $1(Y1(e),Z1(e)*Y1(t)-q1(n)*Z1(t))}function n2(e,t,n){return K1(Y1(t)*Y1(n)+Z1(t)*Z1(n)*Z1(e))}function r2(e){var t,n,r=function(e){return J1*(357.5291+.98560028*e)}(e),i=function(e){return e+J1*(1.9148*Y1(e)+.02*Y1(2*e)+3e-4*Y1(3*e))+102.9372*J1+X1}(r);return{dec:(t=i,n=0,K1(Y1(n)*Z1(Q1)+Z1(n)*Y1(Q1)*Y1(t))),ra:e2(i,0)}}var i2={};i2.getPosition=function(e,t,n){var r=J1*-n,i=J1*t,o=function(e){return function(e){return e.valueOf()/864e5-.5+2440588}(e)-2451545}(e),a=r2(o),s=function(e,t){return J1*(280.16+360.9856235*e)-t}(o,r)-a.ra;return{azimuth:t2(s,i,a.dec),altitude:n2(s,i,a.dec)}};zJ.Shader.import(PJ),zJ.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end");var o2=Xg.extend({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new zJ.Node,this._sphereGeometry=new zJ.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new zJ.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new zJ.PlaneGeometry,this._earthMesh=new zJ.Mesh({renderNormal:!0}),this._atmosphereMesh=new zJ.Mesh,this._atmosphereGeometry=new zJ.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.atmosphere.vertex"),zJ.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=zJ.Mesh.CW,this._lightRoot=new zJ.Node,this._sceneHelper=new pQ,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new oQ({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,n){var r=e.coordinateSystem,i=e.get("shading");r.viewGL.add(this._lightRoot),e.get("show")?r.viewGL.add(this.groupGL):r.viewGL.remove(this.groupGL),this._sceneHelper.setScene(r.viewGL.scene),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var o=this._earthMesh;o.geometry=this._sphereGeometry;var a="ecgl."+i;o.material&&o.material.shader.name===a||(o.material=zJ.createMaterial(a)),zJ.setMaterialFromModel(i,o.material,e,n),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach((function(e){var t=o.material.get(e);t&&(t.flipY=!1)})),o.material.set("color",zJ.parseColor(e.get("baseColor")));var s=.99*r.radius;if(o.scale.set(s,s,s),e.get("atmosphere.show")){o.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:e.get("atmosphere.glowPower")||6,glowColor:e.get("atmosphere.color")||"#ffffff"}),o.material.setUniforms({glowPower:e.get("atmosphere.innerGlowPower")||2,glowColor:e.get("atmosphere.color")||"#ffffff"});var l=e.get("atmosphere.offset")||5;this._atmosphereMesh.scale.set(s+l,s+l,s+l)}else o.material.undefine("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!0;var u=o.material.setTextureImage("diffuseMap",e.get("baseTexture"),n,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(o);var c=o.material.setTextureImage("bumpMap",e.get("heightTexture"),n,{flipY:!1,anisotropic:8});c&&c.surface&&c.surface.attachToMesh(o),o.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,n),this._displaceVertices(e,n),this._updateViewControl(e,n),this._updateLayers(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n)},_updateLayers:function(e,t){var n=e.coordinateSystem,r=e.get("layers"),i=n.radius,o=[],a=[],s=[],l=[];W(r,(function(e){var r=new Fh(e),u=r.get("type"),c=zJ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8});if(c.surface&&c.surface.attachToMesh(this._earthMesh),"blend"===u){var h=r.get("blendTo"),d=vJ(r.get("intensity"),1);"emission"===h?(s.push(c),l.push(d)):(o.push(c),a.push(d))}else{var p=r.get("id"),f=this._layerMeshes[p];f||(f=this._layerMeshes[p]=new zJ.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===r.get("shading")?(f.material=f.__lambertMaterial||new zJ.Material({autoUpdateTextureStatus:!1,shader:zJ.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),f.__lambertMaterial=f.material):(f.material=f.__colorMaterial||new zJ.Material({autoUpdateTextureStatus:!1,shader:zJ.createShader("ecgl.color"),transparent:!0,depthMask:!1}),f.__colorMaterial=f.material),f.material.enableTexture("diffuseMap");var g=r.get("distance"),m=i+(null==g?n.radius/100:g);f.scale.set(m,m,m),i=m;var v=this._blankTexture||(this._blankTexture=zJ.createBlankTexture("rgba(255, 255, 255, 0)"));f.material.set("diffuseMap",v),zJ.loadTexture(r.get("texture"),t,{flipY:!1,anisotropic:8},(function(e){e.surface&&e.surface.attachToMesh(f),f.material.set("diffuseMap",e),t.getZr().refresh()})),r.get("show")?this.groupGL.add(f):this.groupGL.remove(f)}}),this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",o.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",s.length),u.set("layerDiffuseMap",o),u.set("layerDiffuseIntensity",a),u.set("layerEmissiveMap",s),u.set("layerEmissionIntensity",l);var c=e.getModel("debug.wireframe");if(c.get("show")){u.define("both","WIREFRAME_TRIANGLE");var h=zJ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),d=vJ(c.get("lineStyle.width"),1);u.set("wireframeLineWidth",d),u.set("wireframeLineColor",h)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){var n=e.coordinateSystem,r=e.getModel("viewControl");n.viewGL.camera;var i=this;var o=this._control;o.setViewGL(n.viewGL);var a,s,l=r.get("targetCoord");null!=l&&(s=l[0]+90,a=l[1]),o.setFromViewControlModel(r,{baseDistance:n.radius,alpha:a,beta:s}),o.off("update"),o.on("update",(function(){t.dispatchAction({type:"globeChangeCamera",alpha:o.getAlpha(),beta:o.getBeta(),distance:o.getDistance()-n.radius,center:o.getCenter(),from:i.uid,globeId:e.id})}))},_displaceVertices:function(e,t){var n=e.get("displacementQuality"),r=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||n!==this._displacementQuality||r!==this._showDebugWireframe){this._displacementQuality=n,this._showDebugWireframe=r;var o=this._sphereGeometry,a={low:100,medium:200,high:400,ultra:800}[n]||200,s=a/2;(o.widthSegments!==a||r)&&(o.widthSegments=a,o.heightSegments=s,o.build()),this._doDisplaceVertices(o,i),r&&o.generateBarycentric()}},_doDisplaceVertices:function(e,t){var n=e.attributes.position.value,r=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===n.length||((i=new Float32Array(n.length)).set(n),e.__originalPosition=i);for(var o=t.displacementWidth,a=t.displacementHeight,s=t.displacementData,l=0;l<e.vertexCount;l++){var u=3*l,c=2*l,h=i[u+1],d=i[u+2],p=i[u+3],f=r[c++],g=r[c++],m=Math.round(f*(o-1)),v=Math.round(g*(a-1)),y=s?s[v*o+m]:0;n[u+1]=h+h*y,n[u+2]=d+d*y,n[u+3]=p+p*y}e.generateVertexNormals(),e.dirty(),e.updateBoundingBox()},_updateLight:function(e,t){var n=this._earthMesh;this._sceneHelper.updateLight(e);var r=this._sceneHelper.mainLight,i=e.get("light.main.time")||new Date,o=i2.getPosition(fo(i),0,0),a=Math.cos(o.altitude);r.position.y=-a*Math.cos(o.azimuth),r.position.x=Math.sin(o.altitude),r.position.z=a*Math.sin(o.azimuth),r.lookAt(n.getWorldPosition())},dispose:function(e,t){this.groupGL.removeAll(),this._control.dispose()}}),a2=sQ.vec3;function s2(e){this.radius=e,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}function l2(e,t){var n=Wd(e.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()});n.y=t.getHeight()-n.y-n.height,this.viewGL.setViewport(n.x,n.y,n.width,n.height,t.getDevicePixelRatio()),this.radius=e.get("globeRadius");var r=e.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,r-this.radius)}function u2(e,t){var n=[1/0,-1/0];if(e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt"),i=r&&r[0];if(i){var o=t.getDataExtent(i,!0);n[0]=Math.min(n[0],o[0]),n[1]=Math.max(n[1],o[1])}}}),this),isFinite(n[1]-n[0])){var r=Jx(n,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new Eb("altitude",r),this.resize(this.model,t)}}s2.prototype={constructor:s2,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(e,t,n){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=n},_getDisplacementScale:function(e,t){var n=(e+180)/360*(this.displacementWidth-1),r=(90-t)/180*(this.displacementHeight-1),i=Math.round(n)+Math.round(r)*this.displacementWidth;return this.displacementData[i]},dataToPoint:function(e,t){var n=e[0],r=e[1],i=e[2]||0,o=this.radius;this.displacementData&&(o*=1+this._getDisplacementScale(n,r)),this.altitudeAxis&&(o+=this.altitudeAxis.dataToCoord(i)),n=n*Math.PI/180,r=r*Math.PI/180;var a=Math.cos(r)*o;return(t=t||[])[0]=-a*Math.cos(n+Math.PI),t[1]=Math.sin(r)*o,t[2]=a*Math.sin(n+Math.PI),t},pointToData:function(e,t){var n=e[0],r=e[1],i=e[2],o=a2.len(e);n/=o,r/=o,i/=o;var a=Math.asin(r),s=Math.atan2(i,-n);s<0&&(s=2*Math.PI+s);var l=180*a/Math.PI,u=180*s/Math.PI-180;return(t=t||[])[0]=u,t[1]=l,t[2]=o-this.radius,this.altitudeAxis&&(t[2]=this.altitudeAxis.coordToData(t[2])),t}};var c2={dimensions:s2.prototype.dimensions,create:function(e,t){var n=[];return e.eachComponent("globe",(function(e){e.__viewGL=e.__viewGL||new N0;var r=new s2;r.viewGL=e.__viewGL,e.coordinateSystem=r,r.model=e,n.push(r),r.resize=l2,r.resize(e,t),r.update=u2})),e.eachSeries((function(t){if("globe"===t.get("coordinateSystem")){var n=t.getReferringComponents("globe").models[0];if(n||(n=e.getComponent("globe")),!n)throw new Error('globe "'+vJ(t.get("globe3DIndex"),t.get("globe3DId"),0)+'" not found');var r=n.coordinateSystem;t.coordinateSystem=r}})),e.eachComponent("globe",(function(e,n){var r=e.coordinateSystem,i=e.getDisplacementTexture(),o=e.getDisplacemenScale();if(e.isDisplacementChanged()){if(e.hasDisplacement()){var a=!0;zJ.loadTexture(i,t,(function(n){var r=function(e,t){var n=document.createElement("canvas"),r=n.getContext("2d"),i=e.width,o=e.height;n.width=i,n.height=o,r.drawImage(e,0,0,i,o);for(var a=r.getImageData(0,0,i,o).data,s=new Float32Array(a.length/4),l=0;l<a.length/4;l++){var u=a[4*l];s[l]=u/255*t}return{data:s,width:i,height:o}}(n.image,o);e.setDisplacementData(r.data,r.width,r.height),a||t.dispatchAction({type:"globeUpdateDisplacment"})})),a=!1}else r.setDisplacementData(null,0,0);r.setDisplacementData(e.displacementData,e.displacementWidth,e.displacementHeight)}})),n}};i_((function(e){e.registerComponentModel(j1),e.registerComponentView(o2),e.registerCoordinateSystem("globe",c2),e.registerAction({type:"globeChangeCamera",event:"globecamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"globe",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"globeUpdateDisplacment",event:"globedisplacementupdated",update:"update"},(function(e,t){}))}));var h2=["zoom","center","pitch","bearing"],d2=$d.extend({type:"mapbox3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,style:"mapbox://styles/mapbox/light-v9",center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMapboxCameraOption:function(){var e=this;return h2.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMapboxCameraOption:function(e){null!=e&&h2.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMapbox:function(){return this._mapbox},setMapbox:function(e){this._mapbox=e}});function p2(e,t){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!mapboxgl)throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");this._mapbox=new mapboxgl.Map({container:this.dom}),this._initEvents()}R(d2.prototype,QJ),R(d2.prototype,eQ),p2.prototype.setUnpainted=function(){},p2.prototype.resize=function(){this._mapbox.resize()},p2.prototype.getMapbox=function(){return this._mapbox},p2.prototype.clear=function(){},p2.prototype.refresh=function(){this._mapbox.resize()};var f2=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];p2.prototype._initEvents=function(){var e=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},f2.forEach((function(t){this._handlers[t]=function(t){var n={};for(var r in t)n[r]=t[r];n.bubbles=!1;var i=new t.constructor(t.type,n);e.dispatchEvent(i)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},p2.prototype.dispose=function(){f2.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this)};var g2="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";zJ.Shader.import(g2);var m2=Xg.extend({type:"mapbox3D",__ecgl__:!0,init:function(e,t){var n=t.getZr();this._zrLayer=new p2("mapbox3D",n),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new zJ.Node,this._sceneHelper=new pQ(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMapbox(),i=this._dispatchInteractAction.bind(this,t,r);["zoom","rotate","drag","pitch","rotate","move"].forEach((function(e){r.on(e,i)})),this._groundMesh=new zJ.Mesh({geometry:new zJ.PlaneGeometry,material:new zJ.Material({shader:new zJ.Shader({vertex:zJ.Shader.source("ecgl.displayShadow.vertex"),fragment:zJ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(e,t,n){var r=this._zrLayer.getMapbox(),i=e.get("style"),o=JSON.stringify(i);o!==this._oldStyleStr&&i&&r.setStyle(i),this._oldStyleStr=o,r.setCenter(e.get("center")),r.setZoom(e.get("zoom")),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMapbox(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._mapbox3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){e.dispatchAction({type:"mapbox3DChangeCamera",pitch:t.getPitch(),zoom:t.getZoom(),center:t.getCenter().toArray(),bearing:t.getBearing(),mapbox3DId:this._mapbox3DModel&&this._mapbox3DModel.id})},_updateGroundMesh:function(){if(this._mapbox3DModel){var e=this._mapbox3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new zJ.Plane(new zJ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new zJ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new zJ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}}),v2=sQ.mat4,y2=512,_2=.6435011087932844,x2=Math.PI,b2=.1;function w2(){this.width=0,this.height=0,this.altitudeScale=1,this.boxHeight="auto",this.altitudeExtent,this.bearing=0,this.pitch=0,this.center=[0,0],this._origin,this.zoom=0,this._initialZoom,this.maxPitch=60,this.zoomOffset=0}function S2(){w2.apply(this,arguments)}function T2(e,t,n){function r(e,t){var n=t.getWidth(),r=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,n,r,i),this.width=n,this.height=r,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function i(e,t){if("auto"!==this.model.get("boxHeight")){var n=[1/0,-1/0];e.eachSeries((function(e){if(e.coordinateSystem===this){var t=e.getData(),r=e.coordDimToDataDim("alt")[0];if(r){var i=t.getDataExtent(r,!0);n[0]=Math.min(n[0],i[0]),n[1]=Math.max(n[1],i[1])}}}),this),isFinite(n[1]-n[0])&&(this.altitudeExtent=n)}}return{dimensions:t.prototype.dimensions,create:function(o,a){var s=[];return o.eachComponent(e,(function(e){var n=e.__viewGL;n||(n=e.__viewGL=new N0).setRootNode(new zJ.Node);var o=new t;o.viewGL=e.__viewGL,o.resize=r,o.resize(e,a),s.push(o),e.coordinateSystem=o,o.model=e,o.update=i})),o.eachSeries((function(t){if(t.get("coordinateSystem")===e){var n=t.getReferringComponents(e).models[0];if(n||(n=o.getComponent(e)),!n)throw new Error(e+' "'+vJ(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=n.coordinateSystem}})),n&&n(s,o,a),s}}}w2.prototype={constructor:w2,dimensions:["lng","lat","alt"],containPoint:function(){},setCameraOption:function(e){this.bearing=e.bearing,this.pitch=e.pitch,this.center=e.center,this.zoom=e.zoom,this._origin||(this._origin=this.projectOnTileWithScale(this.center,y2)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var e=.5/Math.tan(_2/2)*this.height*b2,t=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,n=_2/2,r=Math.PI/2+t,i=Math.sin(n)*e/Math.sin(Math.PI-r-n),o=1.1*(Math.cos(Math.PI/2-t)*i+e);this.pitch>50&&(o=1e3);var a=[];v2.perspective(a,_2,this.width/this.height,1,o),this.viewGL.camera.projectionMatrix.setArray(a),this.viewGL.camera.decomposeProjectionMatrix();a=v2.identity([]);var s=this.dataToPoint(this.center);v2.scale(a,a,[1,-1,1]),v2.translate(a,a,[0,0,-e]),v2.rotateX(a,a,t),v2.rotateZ(a,a,-this.bearing/180*Math.PI),v2.translate(a,a,[-s[0]*this.getScale()*b2,-s[1]*this.getScale()*b2,0]),this.viewGL.camera.viewMatrix.array=a;var l=[];v2.invert(l,a),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var u,c=y2*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var h=this.altitudeExtent[1]-this.altitudeExtent[0];u=this.boxHeight/h*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else u=c/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*b2;this.viewGL.rootNode.scale.set(this.getScale()*b2,this.getScale()*b2,u)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,this.getScale()*y2,t)},projectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1]*x2/180,o=t*(r*x2/180+x2)/(2*x2),a=t*(x2-Math.log(Math.tan(x2/4+.5*i)))/(2*x2);return(n=n||[])[0]=o,n[1]=a,n},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,this.getScale()*y2,t)},unprojectOnTileWithScale:function(e,t,n){var r=e[0],i=e[1],o=r/t*(2*x2)-x2,a=2*(Math.atan(Math.exp(x2-i/t*(2*x2)))-x2/4);return(n=n||[])[0]=180*o/x2,n[1]=180*a/x2,n},dataToPoint:function(e,t){return(t=this.projectOnTileWithScale(e,y2,t))[0]-=this._origin[0],t[1]-=this._origin[1],t[2]=isNaN(e[2])?0:e[2],isNaN(e[2])||(t[2]=e[2],this.altitudeExtent&&(t[2]-=this.altitudeExtent[0])),t}},S2.prototype=new w2,S2.prototype.constructor=S2,S2.prototype.type="mapbox3D";var M2=T2("mapbox3D",S2,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMapboxCameraOption())}))}));i_((function(e){e.registerComponentModel(d2),e.registerComponentView(m2),e.registerCoordinateSystem("mapbox3D",M2),e.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"mapbox3D",query:e},(function(t){t.setMapboxCameraOption(e)}))}))}));var C2=["zoom","center","pitch","bearing"],D2=$d.extend({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var e=this;return C2.reduce((function(t,n){return t[n]=e.get(n),t}),{})},setMaptalksCameraOption:function(e){null!=e&&C2.forEach((function(t){null!=e[t]&&(this.option[t]=e[t])}),this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});function A2(e,t,n,r){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:n,zoom:r,doubleClickZoom:!1,fog:!1}),this._initEvents()}R(D2.prototype,QJ),R(D2.prototype,eQ),A2.prototype.setUnpainted=function(){},A2.prototype.resize=function(){this._maptalks.checkSize()},A2.prototype.getMaptalks=function(){return this._maptalks},A2.prototype.clear=function(){},A2.prototype.refresh=function(){this._maptalks.checkSize()};var I2=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];A2.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},I2.forEach((function(t){this._handlers[t]=function(n){var r={};for(var i in n)r[i]=n[i];r.bubbles=!1;var o=new n.constructor(n.type,r);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(o):e.firstElementChild.dispatchEvent(o)},this.zr.dom.addEventListener(t,this._handlers[t])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},A2.prototype.dispose=function(){I2.forEach((function(e){this.zr.dom.removeEventListener(e,this._handlers[e])}),this),this._maptalks.remove()},zJ.Shader.import(g2);var E2=Xg.extend({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new zJ.Mesh({geometry:new zJ.PlaneGeometry,material:new zJ.Material({shader:new zJ.Shader({vertex:zJ.Shader.source("ecgl.displayShadow.vertex"),fragment:zJ.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var n=t.getZr();this._zrLayer=new A2("maptalks3D",n,e.get("center"),e.get("zoom")),n.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new zJ.Node,this._sceneHelper=new pQ(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var r=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,r);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach((function(e){r.on(e,i)}))},render:function(e,t,n){this._zrLayer||this._initMaptalksLayer(e,n);var r=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),o=r.getBaseLayer();i!==this._oldUrlTemplate&&(o?o.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(o=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),r.setBaseLayer(o))),this._oldUrlTemplate=i,r.setCenter(e.get("center")),r.setZoom(e.get("zoom"),{animation:!1}),r.setPitch(e.get("pitch")),r.setBearing(e.get("bearing")),e.setMaptalks(r);var a=e.coordinateSystem;a.viewGL.scene.add(this._lightRoot),a.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(a.viewGL.scene),this._sceneHelper.updateLight(e),a.viewGL.setPostEffect(e.getModel("postEffect"),n),a.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,n,r){var i=r.renderer;this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n),e.coordinateSystem.viewGL.scene.traverse((function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(e,t,n,r){e.coordinateSystem.setCameraOption(r),this._updateGroundMesh(),n.getZr().refresh()},_dispatchInteractAction:function(e,t,n){var r;e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:(r=t.getResolution(),19-Math.log(r/L2)/Math.LN2+1),center:t.getCenter().toArray(),bearing:t.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var e=this._maptalks3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var n=new zJ.Plane(new zJ.Vector3(0,0,1),0),r=e.viewGL.camera.castRay(new zJ.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new zJ.Vector2(1,1)),o=r.intersectPlane(n),a=i.intersectPlane(n),s=o.dist(a)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}});const L2=12756274*Math.PI/(256*Math.pow(2,20));function N2(){w2.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}N2.prototype=new w2,N2.prototype.constructor=N2,N2.prototype.type="maptalks3D";var P2=T2("maptalks3D",N2,(function(e){e.forEach((function(e){e.setCameraOption(e.model.getMaptalksCameraOption())}))}));i_((function(e){e.registerComponentModel(D2),e.registerComponentView(E2),e.registerCoordinateSystem("maptalks3D",P2),e.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},(function(e,t){t.eachComponent({mainType:"maptalks3D",query:e},(function(t){t.setMaptalksCameraOption(e)}))}))}));var O2=sQ.vec3,R2=$x.isDimensionStacked;function k2(e,t,n){for(var r=e.getDataExtent(t),i=e.getDataExtent(n),o=r[1]-r[0]||r[0],a=i[1]-i[0]||i[0],s=new Uint8Array(2500),l=0;l<e.count();l++){var u=e.get(t,l),c=e.get(n,l),h=Math.floor((u-r[0])/o*49),d=50*Math.floor((c-i[0])/a*49)+h;s[d]=s[d]||1}var p=0;for(l=0;l<s.length;l++)s[l]&&p++;return p/s.length}var z2=sQ.vec3,V2=$x.isDimensionStacked;function B2(e,t){var n=V2(e,t[2]);return{dimension:n?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:n}}function F2(e){e.registerLayout((function(e,t){e.eachSeriesByType("bar3D",(function(e){var t=e.coordinateSystem,n=t&&t.type;if("globe"===n)!function(e,t){var n=e.getData(),r=e.get("minHeight")||0,i=e.get("barSize"),o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==i){var a=t.radius*Math.PI,s=k2(n,o[0],o[1]);i=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(i)||(i=[i,i]);var l=B2(n,o);n.each(o,(function(e,o,a,s){var u=n.get(l.dimension,s),c=l.isStacked?u-a:t.altitudeAxis.scale.getExtent()[0],h=Math.max(t.altitudeAxis.dataToCoord(a),r),d=t.dataToPoint([e,o,c]),p=t.dataToPoint([e,o,u]),f=z2.sub([],p,d);z2.normalize(f,f);var g=[i[0],h,i[1]];n.setItemLayout(s,[d,f,g])})),n.setLayout("orient",Bq.UP.array)}(e,t);else if("cartesian3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize");if(null==r){var i,o,a=t.size,s=t.getAxis("x"),l=t.getAxis("y");i="category"===s.type?.7*s.getBandWidth():.6*Math.round(a[0]/Math.sqrt(n.count())),o="category"===l.type?.7*l.getBandWidth():.6*Math.round(a[1]/Math.sqrt(n.count())),r=[i,o]}else J(r)||(r=[r,r]);var u=t.getAxis("z").scale.getExtent(),c=function(e){var t=e[0],n=e[1];return!(t>0&&n>0||t<0&&n<0)}(u),h=["x","y","z"].map((function(t){return e.coordDimToDataDim(t)[0]})),d=R2(n,h[2]),p=d?n.getCalculationInfo("stackResultDimension"):h[2];n.each(h,(function(e,i,o,a){var s=n.get(p,a),l=d?s-o:c?0:u[0],h=t.dataToPoint([e,i,l]),f=t.dataToPoint([e,i,s]),g=O2.dist(h,f),m=[0,f[1]<h[1]?-1:1,0];0===Math.abs(g)&&(g=.1);var v=[r[0],g,r[1]];n.setItemLayout(a,[h,m,v])})),n.setLayout("orient",[1,0,0])}(e,t);else if("geo3D"===n)!function(e,t){var n=e.getData(),r=e.get("barSize"),i=e.get("minHeight")||0,o=["lng","lat","alt"].map((function(t){return e.coordDimToDataDim(t)[0]}));if(null==r){var a=Math.min(t.size[0],t.size[2]),s=k2(n,o[0],o[1]);r=[a/Math.sqrt(n.count()/s),a/Math.sqrt(n.count()/s)]}else J(r)||(r=[r,r]);var l=[0,1,0],u=B2(n,o);n.each(o,(function(e,o,a,s){var c=n.get(u.dimension,s),h=u.isStacked?c-a:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(a),i),p=t.dataToPoint([e,o,h]),f=[r[0],d,r[1]];n.setItemLayout(s,[p,l,f])})),n.setLayout("orient",[1,0,0])}(e,t);else if("mapbox3D"===n||"maptalks3D"===n)!function(e,t){var n=e.getData(),r=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],o=e.coordDimToDataDim("alt")[0],a=e.get("barSize"),s=e.get("minHeight")||0;if(null==a){var l=n.getDataExtent(r),u=n.getDataExtent(i),c=t.dataToPoint([l[0],u[0]]),h=t.dataToPoint([l[1],u[1]]),d=Math.min(Math.abs(c[0]-h[0]),Math.abs(c[1]-h[1]))||1,p=k2(n,r,i);a=[d/Math.sqrt(n.count()/p),d/Math.sqrt(n.count()/p)]}else J(a)||(a=[a,a]),a[0]/=t.getScale()/16,a[1]/=t.getScale()/16;var f=[0,0,1],g=[r,i,o],m=B2(n,g);n.each(g,(function(e,r,i,o){var l=n.get(m.dimension,o),u=m.isStacked?l-i:0,c=t.dataToPoint([e,r,u]),h=t.dataToPoint([e,r,l]),d=Math.max(h[2]-c[2],s),p=[a[0],d,a[1]];n.setItemLayout(o,[c,f,p])})),n.setLayout("orient",[1,0,0])}(e,t);else if("production"!==process.env.NODE_ENV)throw t?new Error("bar3D doesn't support coordinate system "+t.type):new Error("bar3D doesn't have coordinate system.")}))}))}var G2={};function H2(e,t,n){var r=e.getData(),i=e.getRawValue(t),o=J(i)?function(e){var i=[],o=function(e,t){var n=[];return W(e.dimensions,(function(r){var i=e.getDimensionInfo(r),o=i.otherDims[t];null!=o&&!1!==o&&(n[o]=i.name)})),n}(r,"tooltip");function a(e,t){var o=r.getDimensionInfo(t);if(o&&!1!==o.otherDims.tooltip){var a=o.type,s="- "+(o.tooltipName||o.name)+": "+("ordinal"===a?e+"":"time"===a?n?"":kd("yyyy/MM/dd hh:mm:ss",e):Ad(e));s&&i.push(dt(s))}}return o.length?W(o,(function(e){a(r.get(e,t),e)})):W(e,a),"<br/>"+i.join("<br/>")}(i):dt(Ad(i)),a=r.getName(t),s=D1(r,t);re(s)&&s.colorStops&&(s=(s.colorStops[0]||{}).color);var l=Rd(s=s||"transparent"),u=e.name;return"\0-"===u&&(u=""),u=u?dt(u)+(n?": ":"<br/>"):"",n?l+u+o:u+l+(a?dt(a)+": "+o:o)}function U2(e,t,n){n=n||e.getSource();var r=t||Yy(e.get("coordinateSystem"))||["x","y","z"],i=N_(n,{dimensionsDefine:n.dimensionsDefine||e.get("dimensions"),encodeDefine:n.encodeDefine||e.get("encode"),coordDimensions:r.map((function(t){var n=e.getReferringComponents(t+"Axis3D").models[0];return{type:n&&"category"===n.get("type")?"ordinal":"float",name:t}}))});"cartesian3D"===e.get("coordinateSystem")&&i.forEach((function(t){if(r.indexOf(t.coordDim)>=0){var n=e.getReferringComponents(t.coordDim+"Axis3D").models[0];n&&"category"===n.get("type")&&(t.ordinalMeta=n.getOrdinalMeta())}}));var o=$x.enableDataStack(e,i,{byIndex:!0,stackedCoordDimension:"z"}),a=new L_(i,e);return a.setCalculationInfo(o),a.initData(n),a}G2.getFormattedLabel=function(e,t,n,r,i){n=n||"normal";var o=e.getData(r).getItemModel(t),a=e.getDataParams(t,r);null!=i&&a.value instanceof Array&&(a.value=a.value[i]);var s,l=o.get("normal"===n?["label","formatter"]:["emphasis","label","formatter"]);return null==l&&(l=o.get(["label","formatter"])),"function"==typeof l?(a.status=n,s=l(a)):"string"==typeof l&&(s=Od(l,a)),s},G2.normalizeToArray=function(e){return e instanceof Array?e:null==e?[]:[e]};var W2=Vg.extend({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(e,t){return U2(this)},getFormattedLabel:function(e,t,n,r){var i=G2.getFormattedLabel(this,e,t,n,r);return null==i&&(i=this.getData().get("z",e)),i},formatTooltip:function(e){return H2(this,e)},defaultOption:{coordinateSystem:"cartesian3D",globeIndex:0,grid3DIndex:0,zlevel:-10,bevelSize:0,bevelSmoothness:2,onGridPlane:"xy",shading:"color",minHeight:0,itemStyle:{opacity:1},label:{show:!1,distance:2,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},emphasis:{label:{show:!0}},animationDurationUpdate:500}});R(W2.prototype,X0);var j2,X2,Y2,Z2,q2,K2,$2,J2,Q2=sQ.vec3,e3=sQ.mat3,t3=WK.extend((function(){return{attributes:{position:new WK.Attribute("position","float",3,"POSITION"),normal:new WK.Attribute("normal","float",3,"NORMAL"),color:new WK.Attribute("color","float",4,"COLOR"),prevPosition:new WK.Attribute("prevPosition","float",3),prevNormal:new WK.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(e){var t=this.enableNormal,n=this.getBarVertexCount()*e,r=this.getBarTriangleCount()*e;this.vertexCount!==n&&(this.attributes.position.init(n),t?this.attributes.normal.init(n):this.attributes.normal.value=null,this.attributes.color.init(n)),this.triangleCount!==r&&(this.indices=n>65535?new Uint32Array(3*r):new Uint16Array(3*r),this._dataIndices=new Uint32Array(n))},getBarVertexCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarVertexCount(e):this.enableNormal?24:8},getBarTriangleCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarTriangleCount(e):12},_getBevelBarVertexCount:function(e){return 4*(e+1)*(e+1)*2},_getBevelBarTriangleCount:function(e){return(4*e+3+1)*(2*e+1)*2+4},setColor:function(e,t){for(var n=this.getBarVertexCount(),r=n*(e+1),i=n*e;i<r;i++)this.attributes.color.set(i,t);this.dirtyAttribute("color")},getDataIndexOfVertex:function(e){return this._dataIndices?this._dataIndices[e]:null},addBar:function(){for(var e=Q2.create,t=Q2.scaleAndAdd,n=e(),r=e(),i=e(),o=e(),a=e(),s=e(),l=e(),u=[],c=[],h=0;h<8;h++)u[h]=e();var d=[[0,1,5,4],[2,3,7,6],[4,5,6,7],[3,2,1,0],[0,4,7,3],[1,2,6,5]],p=[0,1,2,0,2,3],f=[];for(h=0;h<d.length;h++)for(var g=d[h],m=0;m<2;m++){for(var v=[],y=0;y<3;y++)v.push(g[p[3*m+y]]);f.push(v)}return function(e,h,g,m,v,y){var _=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(e,h,g,m,this.bevelSize,this.bevelSegments,v);else{Q2.copy(i,h),Q2.normalize(i,i),Q2.cross(o,g,i),Q2.normalize(o,o),Q2.cross(r,i,o),Q2.normalize(o,o),Q2.negate(a,r),Q2.negate(s,i),Q2.negate(l,o),t(u[0],e,r,m[0]/2),t(u[0],u[0],o,m[2]/2),t(u[1],e,r,m[0]/2),t(u[1],u[1],l,m[2]/2),t(u[2],e,a,m[0]/2),t(u[2],u[2],l,m[2]/2),t(u[3],e,a,m[0]/2),t(u[3],u[3],o,m[2]/2),t(n,e,i,m[1]),t(u[4],n,r,m[0]/2),t(u[4],u[4],o,m[2]/2),t(u[5],n,r,m[0]/2),t(u[5],u[5],l,m[2]/2),t(u[6],n,a,m[0]/2),t(u[6],u[6],l,m[2]/2),t(u[7],n,a,m[0]/2),t(u[7],u[7],o,m[2]/2);var x=this.attributes;if(this.enableNormal){c[0]=r,c[1]=a,c[2]=i,c[3]=s,c[4]=o,c[5]=l;for(var b=this._vertexOffset,w=0;w<d.length;w++){for(var S=3*this._triangleOffset,T=0;T<6;T++)this.indices[S++]=b+p[T];b+=4,this._triangleOffset+=2}for(w=0;w<d.length;w++){var M=c[w];for(T=0;T<4;T++){var C=d[w][T];x.position.set(this._vertexOffset,u[C]),x.normal.set(this._vertexOffset,M),x.color.set(this._vertexOffset++,v)}}}else{for(w=0;w<f.length;w++){for(S=3*this._triangleOffset,T=0;T<3;T++)this.indices[S+T]=f[w][T]+this._vertexOffset;this._triangleOffset++}for(w=0;w<u.length;w++)x.position.set(this._vertexOffset,u[w]),x.color.set(this._vertexOffset++,v)}}var D=this._vertexOffset;for(w=_;w<D;w++)this._dataIndices[w]=y}}(),_addBevelBar:(j2=Q2.create(),X2=Q2.create(),Y2=Q2.create(),Z2=e3.create(),q2=[],K2=[1,-1,-1,1],$2=[1,1,-1,-1],J2=[2,0],function(e,t,n,r,i,o,a){Q2.copy(X2,t),Q2.normalize(X2,X2),Q2.cross(Y2,n,X2),Q2.normalize(Y2,Y2),Q2.cross(j2,X2,Y2),Q2.normalize(Y2,Y2),Z2[0]=j2[0],Z2[1]=j2[1],Z2[2]=j2[2],Z2[3]=X2[0],Z2[4]=X2[1],Z2[5]=X2[2],Z2[6]=Y2[0],Z2[7]=Y2[1],Z2[8]=Y2[2],i=Math.min(r[0],r[2])/2*i;for(var s=0;s<3;s++)q2[s]=Math.max(r[s]-2*i,0);var l=(r[0]-q2[0])/2,u=(r[1]-q2[1])/2,c=(r[2]-q2[2])/2,h=[],d=[],p=this._vertexOffset,f=[];for(s=0;s<2;s++){f[s]=f[s]=[];for(var g=0;g<=o;g++)for(var m=0;m<4;m++){(0===g&&0===s||1===s&&g===o)&&f[s].push(p);for(var v=0;v<=o;v++){var y=v/o*Math.PI/2+Math.PI/2*m,_=g/o*Math.PI/2+Math.PI/2*s;d[0]=l*Math.cos(y)*Math.sin(_),d[1]=u*Math.cos(_),d[2]=c*Math.sin(y)*Math.sin(_),h[0]=d[0]+K2[m]*q2[0]/2,h[1]=d[1]+u+J2[s]*q2[1]/2,h[2]=d[2]+$2[m]*q2[2]/2,Math.abs(l-u)<1e-6&&Math.abs(u-c)<1e-6||(d[0]/=l*l,d[1]/=u*u,d[2]/=c*c),Q2.normalize(d,d),Q2.transformMat3(h,h,Z2),Q2.transformMat3(d,d,Z2),Q2.add(h,h,e),this.attributes.position.set(p,h),this.enableNormal&&this.attributes.normal.set(p,d),this.attributes.color.set(p,a),p++}}}var x=4*o+3,b=2*o+1,w=x+1;for(m=0;m<b;m++)for(s=0;s<=x;s++){var S=m*w+s+this._vertexOffset,T=m*w+(s+1)%w+this._vertexOffset,M=(m+1)*w+(s+1)%w+this._vertexOffset,C=(m+1)*w+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[M,S,T]),this.setTriangleIndices(this._triangleOffset++,[M,C,S])}this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][2],f[0][1]]),this.setTriangleIndices(this._triangleOffset++,[f[0][0],f[0][3],f[0][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][1],f[1][2]]),this.setTriangleIndices(this._triangleOffset++,[f[1][0],f[1][2],f[1][3]]),this._vertexOffset=p})});V(t3.prototype,aQ),V(t3.prototype,C1);var n3=sQ.vec3,r3=Kg.extend({type:"bar3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._api=t,this._labelsBuilder=new I1(256,256,t);var n=this;this._labelsBuilder.getLabelPosition=function(e,t,r){if(n._data){var i=n._data.getItemLayout(e),o=i[0],a=i[1],s=i[2][1];return n3.scaleAndAdd([],o,a,r+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(e,t,n){var r=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=r,this._barMesh||(this._barMesh=new zJ.Mesh({geometry:new t3,shadowDepthMaterial:new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.sm.depth.vertex"),zJ.Shader.source("ecgl.sm.depth.fragment"))}),culling:"cartesian3D"===e.coordinateSystem.type,renderOrder:10,renderNormal:!0})),this.groupGL.remove(this._prevBarMesh),this.groupGL.add(this._barMesh),this.groupGL.add(this._labelsBuilder.getMesh());var i=e.coordinateSystem;if(this._doRender(e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[o]("fragment","SRGB_DECODE")}this._data=e.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(e)},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,e)},_doRender:function(e,t){var n=e.getData(),r=e.get("shading"),i="color"!==r,o=this,a=this._barMesh,s="ecgl."+r;a.material&&a.material.shader.name===s||(a.material=zJ.createMaterial(s,["VERTEX_COLOR"])),zJ.setMaterialFromModel(r,a.material,e,t),a.geometry.enableNormal=i,a.geometry.resetOffset();var l=e.get("bevelSize"),u=e.get("bevelSmoothness");a.geometry.bevelSegments=u,a.geometry.bevelSize=l;var c=[],h=new Float32Array(4*n.count()),d=0,p=0,f=!1;n.each((function(e){if(n.hasValue(e)){var t=D1(n,e),r=A1(n,e);null==r&&(r=1),zJ.parseColor(t,c),c[3]*=r,h[d++]=c[0],h[d++]=c[1],h[d++]=c[2],h[d++]=c[3],c[3]>0&&(p++,c[3]<.99&&(f=!0))}})),a.geometry.setBarCount(p);var g=n.getLayout("orient"),m=this._barIndexOfData=new Int32Array(n.count());p=0;n.each((function(e){if(n.hasValue(e)){var t=n.getItemLayout(e),r=t[0],i=t[1],a=t[2],s=4*e;c[0]=h[s++],c[1]=h[s++],c[2]=h[s++],c[3]=h[s++],c[3]>0&&(o._barMesh.geometry.addBar(r,i,g,a,c,e),m[e]=p++)}else m[e]=-1})),a.geometry.dirty(),a.geometry.updateBoundingBox();var v=a.material;v.transparent=f,v.depthMask=!f,a.geometry.sortTriangles=f,this._initHandler(e,t)},_initHandler:function(e,t){var n=e.getData(),r=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=r.geometry.getDataIndexOfVertex(e.triangle[0]);a!==o&&(this._downplay(o),this._highlight(a),this._labelsBuilder.updateLabels([a]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",a),n.get("y",a),n.get("z",a,!0)]})),o=a,r.dataIndex=a}),this),r.on("mouseout",(function(e){this._downplay(o),this._labelsBuilder.updateLabels(),o=-1,r.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_highlight:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=t.getItemModel(e).getModel("emphasis.itemStyle"),i=r.get("color"),o=r.get("opacity");if(null==i)i=ir(D1(t,e),-.4);null==o&&(o=A1(t,e));var a=zJ.parseColor(i);a[3]*=o,this._barMesh.geometry.setColor(n,a),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var n=this._barIndexOfData[e];if(!(n<0)){var r=D1(t,e),i=A1(t,e),o=zJ.parseColor(r);o[3]*=i,this._barMesh.geometry.setColor(n,o),this._api.getZr().refresh()}}},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=yJ(o,i),s=this;null!=a?W(G2.normalizeToArray(a),(function(t){"highlight"===e?this._highlight(t):this._downplay(t)}),this):o.each((function(t){"highlight"===e?s._highlight(t):s._downplay(t)}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this._labelsBuilder.dispose(),this.groupGL.removeAll()}});i_((function(e){e.registerChartView(r3),e.registerSeriesModel(W2),F2(e),e.registerProcessor((function(e,t){e.eachSeriesByType("bar3d",(function(e){var t=e.getData();t.filterSelf((function(e){return t.hasValue(e)}))}))}))}));var i3=Vg.extend({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){return U2(this)},formatTooltip:function(e){return H2(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}}),o3=sQ.vec3;zJ.Shader.import(CQ);var a3=Kg.extend({type:"line3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._api=t},render:function(e,t,n){var r=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=r,this._line3DMesh||(this._line3DMesh=new zJ.Mesh({geometry:new cQ({useNativeLine:!1,sortTriangles:!0}),material:new zJ.Material({shader:zJ.createShader("ecgl.meshLines3D")}),renderOrder:10}),this._line3DMesh.geometry.pick=this._pick.bind(this)),this.groupGL.remove(this._prevLine3DMesh),this.groupGL.add(this._line3DMesh);var i=e.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this.groupGL);var o=i.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[o]("fragment","SRGB_DECODE")}this._doRender(e,n),this._data=e.getData(),this._camera=i.viewGL.camera,this.updateCamera(),this._updateAnimation(e)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(e,t){var n=e.getData(),r=this._line3DMesh;r.geometry.resetOffset();var i=n.getLayout("points"),o=[],a=new Float32Array(i.length/3*4),s=0,l=!1;n.each((function(e){var t=D1(n,e),r=A1(n,e);null==r&&(r=1),zJ.parseColor(t,o),o[3]*=r,a[s++]=o[0],a[s++]=o[1],a[s++]=o[2],a[s++]=o[3],o[3]<.99&&(l=!0)})),r.geometry.setVertexCount(r.geometry.getPolylineVertexCount(i)),r.geometry.setTriangleCount(r.geometry.getPolylineTriangleCount(i)),r.geometry.addPolyline(i,a,vJ(e.get("lineStyle.width"),1)),r.geometry.dirty(),r.geometry.updateBoundingBox();var u=r.material;u.transparent=l,u.depthMask=!l;var c=e.getModel("debug.wireframe");c.get("show")?(r.geometry.createAttribute("barycentric","float",3),r.geometry.generateBarycentric(),r.material.set("both","WIREFRAME_TRIANGLE"),r.material.set("wireframeLineColor",zJ.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)")),r.material.set("wireframeLineWidth",vJ(c.get("lineStyle.width"),1))):r.material.set("both","WIREFRAME_TRIANGLE"),this._points=i,this._initHandler(e,t)},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,e)},_initHandler:function(e,t){var n=e.getData(),r=e.coordinateSystem,i=this._line3DMesh,o=-1;i.seriesIndex=e.seriesIndex,i.off("mousemove"),i.off("mouseout"),i.on("mousemove",(function(e){var a=r.pointToData(e.point.array),s=n.indicesOfNearest("x",a[0])[0];s!==o&&(t.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get("x",s),n.get("y",s),n.get("z",s)]}),i.dataIndex=s),o=s}),this),i.on("mouseout",(function(e){o=-1,i.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateNDCPosition:function(){var e=new iK,t=this._camera;iK.multiply(e,t.projectionMatrix,t.viewMatrix);var n=this._positionNDC,r=this._points,i=r.length/3;n&&n.length/2===i||(n=this._positionNDC=new Float32Array(2*i));for(var o=[],a=0;a<i;a++){var s=3*a,l=2*a;o[0]=r[s],o[1]=r[s+1],o[2]=r[s+2],o[3]=1,o3.transformMat4(o,o,e.array),n[l]=o[0]/o[3],n[l+1]=o[1]/o[3]}},_pick:function(e,t,n,r,i,o){var a=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,u=.5*n.viewport.width,c=.5*n.viewport.height;e=(e+1)*u,t=(t+1)*c;for(var h=1;h<a.length/2;h++){var d=(a[2*(h-1)]+1)*u,p=(a[2*(h-1)+1]+1)*c,f=(a[2*h]+1)*u,g=(a[2*h+1]+1)*c;if(Ts(d,p,f,g,s,e,t))l=(d-e)*(d-e)+(p-t)*(p-t)<(f-e)*(f-e)+(g-t)*(g-t)?h-1:h}if(l>=0){var m=3*l,v=new Bq(this._points[m],this._points[m+1],this._points[m+2]);o.push({dataIndex:l,point:v,pointWorld:v.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(v)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(a3),e.registerSeriesModel(i3),e.registerLayout((function(e,t){e.eachSeriesByType("line3D",(function(e){var t=e.getData(),n=e.coordinateSystem;if(n){if("cartesian3D"!==n.type)return void("production"!==process.env.NODE_ENV&&console.error("line3D needs cartesian3D coordinateSystem"));var r=new Float32Array(3*t.count()),i=[],o=[],a=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n&&t.each(a,(function(e,t,a,s){i[0]=e,i[1]=t,i[2]=a,n.dataToPoint(i,o),r[3*s]=o[0],r[3*s+1]=o[1],r[3*s+2]=o[2]})),t.setLayout("points",r)}}))}))}));var s3=Vg.extend({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(e,t){return U2(this)},getFormattedLabel:function(e,t,n,r){var i=G2.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},formatTooltip:function(e){return H2(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,progressive:1e5,progressiveThreshold:1e5,grid3DIndex:0,globeIndex:0,symbol:"circle",symbolSize:10,blendMode:"source-over",label:{show:!1,position:"right",distance:5,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},itemStyle:{opacity:.8},emphasis:{label:{show:!0}},animationDurationUpdate:500}});function l3(e,t,n){(t=t||document.createElement("canvas")).width=e,t.height=e;var r=t.getContext("2d");return n&&n(r),t}var u3={getMarginByStyle:function(e){var t=e.minMargin||0,n=0;e.stroke&&"none"!==e.stroke&&(n=null==e.lineWidth?1:e.lineWidth);var r=e.shadowBlur||0,i=e.shadowOffsetX||0,o=e.shadowOffsetY||0,a={};return a.left=Math.max(n/2,-i+r,t),a.right=Math.max(n/2,i+r,t),a.top=Math.max(n/2,-o+r,t),a.bottom=Math.max(n/2,o+r,t),a},createSymbolSprite:function(e,t,n,r){var i=function(e,t,n,r){J(t)||(t=[t,t]);var i=u3.getMarginByStyle(n,r),o=t[0]+i.left+i.right,a=t[1]+i.top+i.bottom,s=lv(e,0,0,t[0],t[1]),l=Math.max(o,a);s.x=i.left,s.y=i.top,o>a?s.y+=(l-a)/2:s.x+=(l-o)/2;var u=s.getBoundingRect();return s.x-=u.x,s.y-=u.y,s.setStyle(n),s.update(),s.__size=l,s}(e,t,n),o=u3.getMarginByStyle(n);return{image:l3(i.__size,r,(function(e){Ev(e,i)})),margin:o}},createSDFFromCanvas:function(e,t,n,r){return l3(t,r,(function(t){var r=e.getContext("2d").getImageData(0,0,e.width,e.height);t.putImageData(function(e,t,n){var r=t.width,i=t.height,o=e.canvas.width,a=e.canvas.height,s=r/o,l=i/a;function u(e){return e<128?1:-1}function c(e,o){var a=1/0;e=Math.floor(e*s);for(var c=(o=Math.floor(o*l))*r+e,h=u(t.data[4*c]),d=Math.max(o-n,0);d<Math.min(o+n,i);d++)for(var p=Math.max(e-n,0);p<Math.min(e+n,r);p++){c=d*r+p;var f=p-e,g=d-o;if(h!==u(t.data[4*c])){var m=f*f+g*g;m<a&&(a=m)}}return h*Math.sqrt(a)}for(var h=e.createImageData(o,a),d=0;d<a;d++)for(var p=0;p<o;p++){var f=c(p,d)/n*.5+.5,g=4*(d*o+p);h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255*(1-f),h.data[g++]=255}return h}(t,r,n),0,0)}))},createSimpleSprite:function(e,t){return l3(e,t,(function(t){var n=e/2;t.beginPath(),t.arc(n,n,60,0,2*Math.PI,!1),t.closePath();var r=t.createRadialGradient(n,n,0,n,n,n);r.addColorStop(0,"rgba(255, 255, 255, 1)"),r.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),r.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=r,t.fill()}))}},c3=sQ.vec3,h3={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(e,t){var n=this.indices,r=c3.create();if(!n){n=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i<n.length;i++)n[i]=i}if(0===t){var o,a=this.attributes.position,s=(e=e.array,0);this._zList&&this._zList.length===this.vertexCount||(this._zList=new Float32Array(this.vertexCount));for(i=0;i<this.vertexCount;i++){a.get(i,r);var l=c3.sqrDist(r,e);isNaN(l)&&(l=1e7,s++),0===i?(o=l,l=0):l-=o,this._zList[i]=l}this._noneCount=s}if(this.vertexCount<2e4)0===t&&this._simpleSort(this._noneCount/this.vertexCount>.05);else for(i=0;i<3;i++)this._progressiveQuickSort(3*t+i);this.dirtyIndices()},_simpleSort:function(e){var t=this._zList,n=this.indices;function r(e,n){return t[n]-t[e]}e?Array.prototype.sort.call(n,r):b1.sort(n,r,0,n.length-1)},_progressiveQuickSort:function(e){var t=this._zList,n=this.indices;this._quickSort=this._quickSort||new b1,this._quickSort.step(n,(function(e,n){return t[n]-t[e]}),e)}},d3=sQ.vec4;zJ.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");var p3=zJ.Mesh.extend((function(){var e=new zJ.Geometry({dynamic:!0,attributes:{color:new zJ.Geometry.Attribute("color","float",4,"COLOR"),position:new zJ.Geometry.Attribute("position","float",3,"POSITION"),size:new zJ.Geometry.Attribute("size","float",1),prevPosition:new zJ.Geometry.Attribute("prevPosition","float",3),prevSize:new zJ.Geometry.Attribute("prevSize","float",1)}});Object.assign(e,h3);var t=new zJ.Material({shader:zJ.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});t.enableTexture("sprite"),t.define("both","VERTEX_COLOR"),t.define("both","VERTEX_SIZE");var n=new zJ.Texture2D({image:document.createElement("canvas"),flipY:!1});return t.set("sprite",n),e.pick=this._pick.bind(this),{geometry:e,material:t,mode:zJ.Mesh.POINTS,sizeScale:1}}),{_pick:function(e,t,n,r,i,o){var a=this._positionNDC;if(a)for(var s=n.viewport,l=2/s.width,u=2/s.height,c=this.geometry.vertexCount-1;c>=0;c--){var h,d=a[2*(h=this.geometry.indices?this.geometry.indices[c]:c)],p=a[2*h+1],f=this.geometry.attributes.size.get(h)/this.sizeScale/2;if(e>d-f*l&&e<d+f*l&&t>p-f*u&&t<p+f*u){var g=new zJ.Vector3,m=new zJ.Vector3;this.geometry.attributes.position.get(h,g.array),zJ.Vector3.transformMat4(m,g,this.worldTransform),o.push({vertexIndex:h,point:g,pointWorld:m,target:this,distance:m.distance(r.getWorldPosition())})}}},updateNDCPosition:function(e,t,n){var r=this._positionNDC,i=this.geometry;r&&r.length/2===i.vertexCount||(r=this._positionNDC=new Float32Array(2*i.vertexCount));for(var o=d3.create(),a=0;a<i.vertexCount;a++)i.attributes.position.get(a,o),o[3]=1,d3.transformMat4(o,o,e.array),d3.scale(o,o,1/o[3]),r[2*a]=o[0],r[2*a+1]=o[1]}});function f3(e,t){this.rootNode=new zJ.Node,this.is2D=e,this._labelsBuilder=new I1(256,256,t),this._labelsBuilder.getMesh().renderOrder=100,this.rootNode.add(this._labelsBuilder.getMesh()),this._api=t,this._spriteImageCanvas=document.createElement("canvas"),this._startDataIndex=0,this._endDataIndex=0,this._sizeScale=1}f3.prototype={constructor:f3,highlightOnMouseover:!0,update:function(e,t,n,r,i){var o=this._prevMesh;this._prevMesh=this._mesh,this._mesh=o;var a=e.getData();if(null==r&&(r=0),null==i&&(i=a.count()),this._startDataIndex=r,this._endDataIndex=i-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new p3({renderOrder:10,frustumCulling:!1}),s&&(this._mesh.material=s)}s=this._mesh.material;var l=this._mesh.geometry,u=l.attributes;this.rootNode.remove(this._prevMesh),this.rootNode.add(this._mesh),this._setPositionTextureToMesh(this._mesh,this._positionTexture);var c=this._getSymbolInfo(e,r,i),h=n.getDevicePixelRatio(),d=e.getModel("itemStyle").getItemStyle(),p=e.get("large"),f=1;c.maxSize>2?(f=this._updateSymbolSprite(e,d,c,h),s.enableTexture("sprite")):s.disableTexture("sprite"),u.position.init(i-r);var g=[];if(p){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var m=function(e){const t=e.getVisual("style");if(t)return t[e.getVisual("drawType")]}(a),v=function(e){return e.getVisual("style").opacity}(a);zJ.parseColor(m,g),g[3]*=v,s.set({color:g,u_Size:c.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),u.size.init(i-r),u.color.init(i-r),this._originalOpacity=new Float32Array(i-r);for(var y=a.getLayout("points"),_=u.position.value,x=0;x<i-r;x++){var b=3*x,w=2*x;if(this.is2D?(_[b]=y[w],_[b+1]=y[w+1],_[b+2]=-10):(_[b]=y[b],_[b+1]=y[b+1],_[b+2]=y[b+2]),!p){m=D1(a,x),v=A1(a,x);zJ.parseColor(m,g),g[3]*=v,u.color.set(x,g),g[3];var S=a.getItemVisual(x,"symbolSize");S=S instanceof Array?Math.max(S[0],S[1]):S,isNaN(S)&&(S=0),u.size.value[x]=S*f*this._sizeScale,this._originalOpacity[x]=g[3]}}this._mesh.sizeScale=f,l.updateBoundingBox(),l.dirty(),this._updateMaterial(e,d);var T=e.coordinateSystem;T&&T.viewGL&&s[T.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE");p||this._updateLabelBuilder(e,r,i),this._updateHandler(e,t,n),this._updateAnimation(e),this._api=n},getPointsMesh:function(){return this._mesh},updateLabels:function(e){this._labelsBuilder.updateLabels(e)},hideLabels:function(){this.rootNode.remove(this._labelsBuilder.getMesh())},showLabels:function(){this.rootNode.add(this._labelsBuilder.getMesh())},dispose:function(){this._labelsBuilder.dispose()},_updateSymbolSprite:function(e,t,n,r){n.maxSize=Math.min(2*n.maxSize,200);var i,o,a=[];return n.aspect>1?(a[0]=n.maxSize,a[1]=n.maxSize/n.aspect):(a[1]=n.maxSize,a[0]=n.maxSize*n.aspect),a[0]=a[0]||1,a[1]=a[1]||1,this._symbolType===n.type&&(i=this._symbolSize,o=a,i&&o&&i[0]===o[0]&&i[1]===o[1])&&this._lineWidth===t.lineWidth||(u3.createSymbolSprite(n.type,a,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(a[0]/2,10)},this._spriteImageCanvas),u3.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=n.type,this._symbolSize=a,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/n.maxSize*r},_updateMaterial:function(e,t){var n="lighter"===e.get("blendMode")?zJ.additiveBlend:null,r=this._mesh.material;r.blend=n,r.set("lineWidth",t.lineWidth/20);var i=zJ.parseColor(t.stroke);r.set("strokeColor",i),r.transparent=!0,r.depthMask=!1,r.depthTest=!this.is2D,r.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,n){var r=e.getData(),i=this._mesh.geometry,o=i.attributes.position.value,a=(t=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(r,t,n),this._labelsBuilder.getLabelPosition=function(e,n,r){var i=3*(e-t);return[o[i],o[i+1],o[i+2]]},this._labelsBuilder.getLabelDistance=function(e,n,r){return i.attributes.size.get(e-t)/a/2+r},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,n){var r,i=e.getData(),o=this._mesh,a=this,s=-1,l=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;l&&(r=e.coordinateSystem.model),o.seriesIndex=e.seriesIndex,o.off("mousemove"),o.off("mouseout"),o.on("mousemove",(function(t){var u=t.vertexIndex+a._startDataIndex;u!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,u),this._labelsBuilder.updateLabels([u])),l&&n.dispatchAction({type:"grid3DShowAxisPointer",value:[i.get(e.coordDimToDataDim("x")[0],u),i.get(e.coordDimToDataDim("y")[0],u),i.get(e.coordDimToDataDim("z")[0],u)],grid3DIndex:r.componentIndex})),o.dataIndex=u,s=u}),this),o.on("mouseout",(function(e){var t=e.vertexIndex+a._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,o.dataIndex=-1,l&&n.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:r.componentIndex})}),this)},updateLayout:function(e,t,n){var r=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,o=r.getLayout("points");if(this.is2D)for(var a=0;a<o.length/2;a++){var s=3*a,l=2*a;i[s]=o[l],i[s+1]=o[l+1],i[s+2]=-10}else for(a=0;a<o.length;a++)i[a]=o[a];this._mesh.geometry.dirty(),n.getZr().refresh()}},updateView:function(e){if(this._mesh){var t=new iK;iK.mul(t,e.viewMatrix,this._mesh.worldTransform),iK.mul(t,e.projectionMatrix,t),this._mesh.updateNDCPosition(t,this.is2D,this._api)}},highlight:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=e.getItemModel(t).getModel("emphasis.itemStyle"),r=n.get("color"),i=n.get("opacity");if(null==r)r=ir(D1(e,t),-.4);null==i&&(i=A1(e,t));var o=zJ.parseColor(r);o[3]*=i,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,o),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},downplay:function(e,t){if(!(t>this._endDataIndex||t<this._startDataIndex)){var n=D1(e,t),r=A1(e,t),i=zJ.parseColor(n);i[3]*=r,this._mesh.geometry.attributes.color.set(t-this._startDataIndex,i),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeOutAll:function(e){if(this._originalOpacity){for(var t=this._mesh.geometry,n=0;n<t.vertexCount;n++){var r=this._originalOpacity[n]*e;t.attributes.color.value[4*n+3]=r}t.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeInAll:function(){this.fadeOutAll(1)},setPositionTexture:function(e){this._mesh&&this._setPositionTextureToMesh(this._mesh,e),this._positionTexture=e},removePositionTexture:function(){this._positionTexture=null,this._mesh&&this._setPositionTextureToMesh(this._mesh,null)},setSizeScale:function(e){if(e!==this._sizeScale){if(this._mesh){var t=this._mesh.material.get("u_Size");this._mesh.material.set("u_Size",t/this._sizeScale*e);var n=this._mesh.geometry.attributes;if(n.size.value)for(var r=0;r<n.size.value.length;r++)n.size.value[r]=n.size.value[r]/this._sizeScale*e}this._sizeScale=e}},_setPositionTextureToMesh:function(e,t){t&&e.material.set("positionTexture",t),e.material[t?"enableTexture":"disableTexture"]("positionTexture")},_getSymbolInfo:function(e,t,n){if(e.get("large"))return(h=vJ(e.get("symbolSize"),1))instanceof Array?(l=Math.max(h[0],h[1]),r=h[0]/h[1]):(l=h,r=1),{maxSize:h,type:e.get("symbol"),aspect:r};for(var r,i=e.getData(),o=!1,a=i.getItemVisual(0,"symbol")||"circle",s=!1,l=0,u=t;u<n;u++){var c,h=i.getItemVisual(u,"symbolSize"),d=i.getItemVisual(u,"symbol");if(h instanceof Array)c=h[0]/h[1],l=Math.max(Math.max(h[0],h[1]),l);else{if(isNaN(h))continue;c=1,l=Math.max(h,l)}"production"!==process.env.NODE_ENV&&(null!=r&&Math.abs(c-r)>.05&&(o=!0),d!==a&&(s=!0)),a=d,r=c}return"production"!==process.env.NODE_ENV&&(o&&console.warn("Different symbol width / height ratio will be ignored."),s&&console.warn("Different symbol type will be ignored.")),{maxSize:l,type:a,aspect:r}}};var g3=Kg.extend({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(e,t,n){if(this.groupGL.removeAll(),e.getData().count()){var r=e.coordinateSystem;if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new f3(!1,n)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),i.update(e,t,n),i.updateView(r.viewGL.camera)}else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system")}},incrementalPrepareRender:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL)r.viewGL.add(this.groupGL),this._camera=r.viewGL.camera;else if("production"!==process.env.NODE_ENV)throw new Error("Invalid coordinate system");this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new f3(!1,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),i.update(t,n,r,e.start,e.end),i.updateView(t.coordinateSystem.viewGL.camera),this._currentStep++}},updateCamera:function(){this._pointsBuilderList.forEach((function(e){e.updateView(this._camera)}),this)},highlight:function(e,t,n,r){this._toggleStatus("highlight",e,t,n,r)},downplay:function(e,t,n,r){this._toggleStatus("downplay",e,t,n,r)},_toggleStatus:function(e,t,n,r,i){var o=t.getData(),a=yJ(o,i),s="highlight"===e;null!=a?W(G2.normalizeToArray(a),(function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}),this):o.each((function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var n=this._pointsBuilderList[t];s?n.highlight(o,e):n.downplay(o,e)}}))},dispose:function(){this._pointsBuilderList.forEach((function(e){e.dispose()})),this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(g3),e.registerSeriesModel(s3),e.registerLayout({seriesType:"scatter3D",reset:function(e){var t=e.coordinateSystem;if(t){var n=t.dimensions;if(n.length<3)return void("production"!==process.env.NODE_ENV&&console.error("scatter3D needs 3D coordinateSystem"));var r=n.map((function(t){return e.coordDimToDataDim(t)[0]})),i=[],o=[];return{progress:function(e,n){for(var a=new Float32Array(3*(e.end-e.start)),s=e.start;s<e.end;s++){var l=3*(s-e.start);i[0]=n.get(r[0],s),i[1]=n.get(r[1],s),i[2]=n.get(r[2],s),t.dataToPoint(i,o),a[l]=o[0],a[l+1]=o[1],a[l+2]=o[2]}n.setLayout("points",a)}}}}})}));var m3=sQ.vec3,v3=sQ.vec2,y3=m3.normalize,_3=m3.cross,x3=m3.sub,b3=m3.add,w3=m3.create,S3=w3(),T3=w3(),M3=w3(),C3=w3(),D3=[],A3=[];function I3(e,t){v3.copy(D3,e[0]),v3.copy(A3,e[1]);var n=[],r=n[0]=w3(),i=n[1]=w3(),o=n[2]=w3(),a=n[3]=w3();t.dataToPoint(D3,r),t.dataToPoint(A3,a),y3(S3,r),x3(T3,a,r),y3(T3,T3),_3(M3,T3,S3),y3(M3,M3),_3(T3,S3,M3),b3(i,S3,T3),y3(i,i),y3(S3,a),x3(T3,r,a),y3(T3,T3),_3(M3,T3,S3),y3(M3,M3),_3(T3,S3,M3),b3(o,S3,T3),y3(o,o),b3(C3,r,a),y3(C3,C3);var s=m3.dot(r,C3),l=m3.dot(C3,i),u=(Math.max(m3.len(r),m3.len(a))-s)/l*2;return m3.scaleAndAdd(i,r,i,u),m3.scaleAndAdd(o,a,o,u),n}function E3(e,t){for(var n=new Float32Array(3*e.length),r=0,i=[],o=0;o<e.length;o++)t.dataToPoint(e[o],i),n[r++]=i[0],n[r++]=i[1],n[r++]=i[2];return n}function L3(e){var t=[];return e.each((function(n){var r=e.getItemModel(n),i=r.option instanceof Array?r.option:r.getShallow("coords",!0);if("production"!==process.env.NODE_ENV&&!(i instanceof Array&&i.length>0&&i[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(i)+". Lines must have 2d coords array in data item.");t.push(i)})),{coordsList:t}}function N3(e,t,n){var r=e.getData(),i=e.get("polyline"),o=L3(r);r.setLayout("lineType",i?"polyline":"cubicBezier"),r.each((function(e){var a=o.coordsList[e],s=i?E3(a,t):function(e,t,n){var r=[],i=r[0]=m3.create(),o=r[1]=m3.create(),a=r[2]=m3.create(),s=r[3]=m3.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var l=m3.dist(i,s);return m3.lerp(o,i,s,.3),m3.lerp(a,i,s,.3),m3.scaleAndAdd(o,o,n,Math.min(.1*l,10)),m3.scaleAndAdd(a,a,n,Math.min(.1*l,10)),r}(a,t,n);r.setItemLayout(e,s)}))}function P3(e,t){e.eachSeriesByType("lines3D",(function(e){var t=e.coordinateSystem;"globe"===t.type?function(e,t){var n=e.getData(),r=e.get("polyline");n.setLayout("lineType",r?"polyline":"cubicBezier");var i=L3(n);n.each((function(e){var o=i.coordsList[e],a=r?E3:I3;n.setItemLayout(e,a(o,t))}))}(e,t):"geo3D"===t.type?N3(e,t,[0,1,0]):"mapbox3D"!==t.type&&"maptalks3D"!==t.type||N3(e,t,[0,0,1])}))}var O3=Vg.extend({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){var n=new L_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"globe",globeIndex:0,geo3DIndex:0,zlevel:-10,polyline:!1,effect:{show:!1,period:4,trailWidth:4,trailLength:.2,spotIntensity:6},silent:!0,blendMode:"source-over",lineStyle:{width:1,opacity:.5}}}),R3=sQ.vec3;zJ.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");var k3=zJ.Mesh.extend((function(){var e=new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.trail2.vertex"),zJ.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new cQ({dynamic:!0});return t.createAttribute("dist","float",1),t.createAttribute("distAll","float",1),t.createAttribute("start","float",1),{geometry:t,material:e,culling:!1,$ignorePicking:!0}}),{updateData:function(e,t,n){var r=e.hostModel,i=this.geometry,o=r.getModel("effect"),a=o.get("trailWidth")*t.getDevicePixelRatio(),s=o.get("trailLength"),l=r.get("effect.constantSpeed"),u=1e3*r.get("effect.period"),c=null!=l;"production"!==process.env.NODE_ENV&&(this.getScene()||console.error("TrailMesh must been add to scene before updateData")),c?this.material.set("speed",l/1e3):this.material.set("period",u),this.material[c?"define":"undefine"]("vertex","CONSTANT_SPEED");var h=r.get("polyline");i.trailLength=s,this.material.set("trailLength",s),i.resetOffset(),["position","positionPrev","positionNext"].forEach((function(e){i.attributes[e].value=n.attributes[e].value}));["dist","distAll","start","offset","color"].forEach((function(e){i.attributes[e].init(i.vertexCount)})),i.indices=n.indices;var d=[],p=o.get("trailColor"),f=o.get("trailOpacity"),g=null!=p,m=null!=f;this.updateWorldTransform();var v=this.worldTransform.x.len(),y=this.worldTransform.y.len(),_=this.worldTransform.z.len(),x=0,b=0;e.each((function(t){var r=e.getItemLayout(t),o=m?f:A1(e,t),s=D1(e,t);null==o&&(o=1),(d=zJ.parseColor(g?p:s,d))[3]*=o;for(var l=h?n.getPolylineVertexCount(r):n.getCubicCurveVertexCount(r[0],r[1],r[2],r[3]),w=0,S=[],T=[],M=x;M<x+l;M++)i.attributes.position.get(M,S),S[0]*=v,S[1]*=y,S[2]*=_,M>x&&(w+=R3.dist(S,T)),i.attributes.dist.set(M,w),R3.copy(T,S);b=Math.max(b,w);var C=Math.random()*(c?w:u);for(M=x;M<x+l;M++)i.attributes.distAll.set(M,w),i.attributes.start.set(M,C),i.attributes.offset.set(M,(n.attributes.offset.get(M)>0?1:-1)*a/2),i.attributes.color.set(M,d);x+=l})),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",o.get("spotIntensity")),i.dirty()},setAnimationTime:function(e){this.material.set("time",e)}});zJ.Shader.import(CQ);var z3=Kg.extend({type:"lines3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._meshLinesMaterial=new zJ.Material({shader:zJ.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new zJ.Mesh({geometry:new cQ,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new k3},render:function(e,t,n){this.groupGL.add(this._linesMesh);var r=e.coordinateSystem,i=e.getData();if(r&&r.viewGL){r.viewGL.add(this.groupGL),this._updateLines(e,t,n);var o=r.viewGL.isLinearSpace()?"define":"undefine";this._linesMesh.material[o]("fragment","SRGB_DECODE"),this._trailMesh.material[o]("fragment","SRGB_DECODE")}var a=this._trailMesh;if(a.stopAnimation(),e.get("effect.show")){this.groupGL.add(a),a.updateData(i,n,this._linesMesh.geometry),a.__time=a.__time||0;var s=36e5;this._curveEffectsAnimator=a.animate("",{loop:!0}).when(s,{__time:s}).during((function(){a.setAnimationTime(a.__time)})).start()}else this.groupGL.remove(a),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===e.get("blendMode")?zJ.additiveBlend:null},pauseEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.pause()},resumeEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.resume()},toggleEffect:function(){var e=this._curveEffectsAnimator;e&&(e.isPaused()?e.resume():e.pause())},_updateLines:function(e,t,n){var r=e.getData(),i=e.coordinateSystem,o=this._linesMesh.geometry,a=e.get("polyline");o.expandLine=!0;var s=function(e){return null!=e.radius?e.radius:null!=e.size?Math.max(e.size[0],e.size[1],e.size[2]):100}(i);o.segmentScale=s/20;var l="lineStyle.width".split("."),u=n.getDevicePixelRatio();r.each((function(e){var t=r.getItemModel(e).get(l);null==t&&(t=1),r.setItemVisual(e,"lineWidth",t)})),o.useNativeLine=!1;var c=0,h=0;r.each((function(e){var t=r.getItemLayout(e);a?(c+=o.getPolylineVertexCount(t),h+=o.getPolylineTriangleCount(t)):(c+=o.getCubicCurveVertexCount(t[0],t[1],t[2],t[3]),h+=o.getCubicCurveTriangleCount(t[0],t[1],t[2],t[3]))})),o.setVertexCount(c),o.setTriangleCount(h),o.resetOffset();var d=[];r.each((function(e){var t=r.getItemLayout(e),n=D1(r,e),i=A1(r,e),s=r.getItemVisual(e,"lineWidth")*u;null==i&&(i=1),(d=zJ.parseColor(n,d))[3]*=i,a?o.addPolyline(t,d,s):o.addCubicCurve(t[0],t[1],t[2],t[3],d,s)})),o.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function V3(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}i_((function(e){e.registerChartView(z3),e.registerSeriesModel(O3),e.registerLayout(P3),e.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},(function(){})),e.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},(function(){})),e.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},(function(){}))}));var B3=Vg.extend({type:"series.polygons3D",getRegionModel:function(e){return this.getData().getItemModel(e)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getItemModel(e),r=n.option instanceof Array?n.option:n.getShallow("coords");n.get("multiPolygon")||(r=[r]);for(var i=[],o=0;o<r.length;o++){for(var a=[],s=1;s<r[o].length;s++)a.push(V3(t,r[o][s]));i.push({exterior:V3(t,r[o][0]),interiors:a})}return i},getInitialData:function(e){var t=new L_(["value"],this);return t.hasItemOption=!1,t.initData(e.data,[],(function(e,n,r,i){if(e instanceof Array)return NaN;t.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),t},defaultOption:{show:!0,data:null,multiPolygon:!1,progressiveThreshold:1e3,progressive:1e3,zlevel:-10,label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}});R(B3.prototype,X0);var F3=Kg.extend({type:"polygons3D",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL);var i=this._geo3DBuilderList[0];i||((i=new L1(n)).extrudeY="mapbox3D"!==r.type&&"maptalks3D"!==r.type,this._geo3DBuilderList[0]=i),this._updateShaderDefines(r,i),i.update(e,t,n),this._geo3DBuilderList.length=1,this.groupGL.add(i.rootNode)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll();var r=e.coordinateSystem;r&&r.viewGL&&r.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(e,t,n,r){var i=this._geo3DBuilderList[this._currentStep],o=t.coordinateSystem;i||((i=new L1(r)).extrudeY="mapbox3D"!==o.type&&"maptalks3D"!==o.type,this._geo3DBuilderList[this._currentStep]=i),i.update(t,n,r,e.start,e.end),this.groupGL.add(i.rootNode),this._updateShaderDefines(o,i),this._currentStep++},_updateShaderDefines:function(e,t){var n=e.viewGL.isLinearSpace()?"define":"undefine";t.rootNode.traverse((function(t){t.material&&(t.material[n]("fragment","SRGB_DECODE"),"mapbox3D"!==e.type&&"maptalks3D"!==e.type||(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1)))}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll(),this._geo3DBuilderList.forEach((function(e){e.dispose()}))}});i_((function(e){e.registerChartView(F3),e.registerSeriesModel(B3)}));var G3=Vg.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return H2(this,e)},getInitialData:function(e,t){var n=e.data;function r(e){return!(isNaN(e.min)||isNaN(e.max)||isNaN(e.step))}function i(e){var t=oo;return Math.max(t(e.min),t(e.max),t(e.step))+1}if(!n)if(e.parametric){var o=e.parametricEquation||{},a=o.u||{},s=o.v||{};["u","v"].forEach((function(e){r(o[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid parametricEquation.%s",e)})),["x","y","z"].forEach((function(e){"function"==typeof o[e]||"production"!==process.env.NODE_ENV&&console.error("parametricEquation.%s needs to be function",e)}));var l=Math.floor((a.max+a.step-a.min)/a.step),u=Math.floor((s.max+s.step-s.min)/s.step);n=new Float32Array(l*u*5);var c=i(a),h=i(s);for(S=0,T=0;T<u;T++)for(M=0;M<l;M++){var d=M*a.step+a.min,p=T*s.step+s.min,f=no(Math.min(d,a.max),c),g=no(Math.min(p,s.max),h);C=o.x(f,g),D=o.y(f,g),E=o.z(f,g);n[S++]=C,n[S++]=D,n[S++]=E,n[S++]=f,n[S++]=g}}else{var m=e.equation||{},v=m.x||{},y=m.y||{};if(["x","y"].forEach((function(e){r(m[e])||"production"!==process.env.NODE_ENV&&console.error("Invalid equation.%s",e)})),"function"!=typeof m.z)return void("production"!==process.env.NODE_ENV&&console.error("equation.z needs to be function"));var _=Math.floor((v.max+v.step-v.min)/v.step),x=Math.floor((y.max+y.step-y.min)/y.step);n=new Float32Array(_*x*3);for(var b=i(v),w=i(y),S=0,T=0;T<x;T++)for(var M=0;M<_;M++){var C=M*v.step+v.min,D=T*y.step+y.min,A=no(Math.min(C,v.max),b),I=no(Math.min(D,y.max),w),E=m.z(A,I);n[S++]=A,n[S++]=I,n[S++]=E}}var L=["x","y","z"];return e.parametric&&L.push("u","v"),U2(this,L,n)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,shading:"lambert",parametric:!1,wireframe:{show:!0,lineStyle:{color:"rgba(0,0,0,0.5)",width:1}},equation:{x:{min:-1,max:1,step:.1},y:{min:-1,max:1,step:.1},z:null},parametricEquation:{u:{min:-1,max:1,step:.1},v:{min:-1,max:1,step:.1},x:null,y:null,z:null},dataShape:null,itemStyle:{},animationDurationUpdate:500}});R(G3.prototype,X0);var H3=sQ.vec3;function U3(e){return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])}var W3=Kg.extend({type:"surface",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node},render:function(e,t,n){var r=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=r,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var i=e.coordinateSystem,o=e.get("shading"),a=e.getData(),s="ecgl."+o;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=zJ.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),zJ.setMaterialFromModel(o,this._surfaceMesh.material,e,n),i&&i.viewGL){i.viewGL.add(this.groupGL);var l=i.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var u=e.get("parametric"),c=e.get("dataShape");c||(c=this._getDataShape(a,u),"production"!==process.env.NODE_ENV&&e.get("data")&&console.warn("dataShape is not provided. Guess it is ",c));var h=e.getModel("wireframe"),d=h.get("lineStyle.width"),p=h.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,e,c,p);var f=this._surfaceMesh.material;p?(f.define("WIREFRAME_QUAD"),f.set("wireframeLineWidth",d),f.set("wireframeLineColor",zJ.parseColor(h.get("lineStyle.color")))):f.undefine("WIREFRAME_QUAD"),this._initHandler(e,n),this._updateAnimation(e)},_updateAnimation:function(e){zJ.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new zJ.Mesh({geometry:new zJ.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new zJ.Material({shader:new zJ.Shader(zJ.Shader.source("ecgl.sm.depth.vertex"),zJ.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),Object.assign(e.geometry,C1),e},_initHandler:function(e,t){var n=e.getData(),r=this._surfaceMesh,i=e.coordinateSystem;r.seriesIndex=e.seriesIndex;var o=-1;r.off("mousemove"),r.off("mouseout"),r.on("mousemove",(function(e){var a=function(e,t){for(var n=1/0,i=-1,o=[],a=0;a<e.length;a++){r.geometry.attributes.position.get(e[a],o);var s=H3.dist(t.array,o);s<n&&(n=s,i=e[a])}return i}(e.triangle,e.point);if(a>=0){var s=[];r.geometry.attributes.position.get(a,s);for(var l=i.pointToData(s),u=1/0,c=-1,h=[],d=0;d<n.count();d++){h[0]=n.get("x",d),h[1]=n.get("y",d),h[2]=n.get("z",d);var p=H3.squaredDistance(h,l);p<u&&(c=d,u=p)}c!==o&&t.dispatchAction({type:"grid3DShowAxisPointer",value:l}),o=c,r.dataIndex=c}else r.dataIndex=-1}),this),r.on("mouseout",(function(e){o=-1,r.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateSurfaceMesh:function(e,t,n,r){var i=e.geometry,o=t.getData(),a=o.getLayout("points"),s=0;o.each((function(e){o.hasValue(e)||s++}));var l=s||r,u=i.attributes.position,c=i.attributes.normal,h=i.attributes.texcoord0,d=i.attributes.barycentric,p=i.attributes.color,f=n[0],g=n[1],m="color"!==t.get("shading");if(l){var v=(f-1)*(g-1)*4;u.init(v),r&&d.init(v)}else u.value=new Float32Array(a);p.init(i.vertexCount),h.init(i.vertexCount);var y=[0,3,1,1,3,2],_=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],x=i.indices=new(i.vertexCount>65535?Uint32Array:Uint16Array)((f-1)*(g-1)*6),b=function(e,t,n){n[1]=e*g+t,n[0]=e*g+t+1,n[3]=(e+1)*g+t+1,n[2]=(e+1)*g+t},w=!1;if(l){var S=[],T=[],M=0;m?c.init(i.vertexCount):c.value=null;for(var C=[[],[],[]],D=[],A=[],I=H3.create(),E=function(e,t,n){var r=3*t;return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n},L=new Float32Array(a.length),N=new Float32Array(a.length/3*4),P=0;P<o.count();P++)if(o.hasValue(P)){var O=zJ.parseColor(D1(o,P));null!=(j=A1(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0);for(var R=0;R<4;R++)N[4*P+R]=O[R]}var k=[1e7,1e7,1e7];for(P=0;P<f-1;P++)for(var z=0;z<g-1;z++){var V=4*(P*(g-1)+z);b(P,z,S);var B=!1;for(R=0;R<4;R++)E(a,S[R],T),U3(T)&&(B=!0);for(R=0;R<4;R++)B?u.set(V+R,k):(E(a,S[R],T),u.set(V+R,T)),r&&d.set(V+R,_[R]);for(R=0;R<6;R++)x[M++]=y[R]+V;if(m&&!B)for(R=0;R<2;R++){for(var F=3*R,G=0;G<3;G++){E(a,W=S[y[F]+G],C[G])}H3.sub(D,C[0],C[1]),H3.sub(A,C[1],C[2]),H3.cross(I,D,A);for(G=0;G<3;G++){var H=3*S[y[F]+G];L[H]=L[H]+I[0],L[H+1]=L[H+1]+I[1],L[H+2]=L[H+2]+I[2]}}}if(m)for(P=0;P<L.length/3;P++)E(L,P,I),H3.normalize(I,I),L[3*P]=I[0],L[3*P+1]=I[1],L[3*P+2]=I[2];O=[];var U=[];for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){V=4*(P*(g-1)+z);b(P,z,S);for(R=0;R<4;R++){for(G=0;G<4;G++)O[G]=N[4*S[R]+G];p.set(V+R,O),m&&(E(L,S[R],I),c.set(V+R,I));var W=S[R];U[0]=W%g/(g-1),U[1]=Math.floor(W/g)/(f-1),h.set(V+R,U)}0}}else{for(U=[],P=0;P<o.count();P++){U[0]=P%g/(g-1),U[1]=Math.floor(P/g)/(f-1);var j;O=zJ.parseColor(D1(o,P));null!=(j=A1(o,P))&&(O[3]*=j),O[3]<.99&&(w=!0),p.set(P,O),h.set(P,U)}S=[];var X=0;for(P=0;P<f-1;P++)for(z=0;z<g-1;z++){b(P,z,S);for(R=0;R<6;R++)x[X++]=S[y[R]]}m?i.generateVertexNormals():c.value=null}e.material.get("normalMap")&&i.generateTangents(),i.updateBoundingBox(),i.dirty(),e.material.transparent=w,e.material.depthMask=!w},_getDataShape:function(e,t){for(var n=-1/0,r=0,i=0,o=0,a=!1,s=t?"u":"x",l=e.count(),u=0;u<l;u++){var c=e.get(s,u);c<n&&(o&&o!==i&&"production"!==process.env.NODE_ENV&&(a=!0),o=i,i=0,r++),n=c,i++}if(r&&1!==i||(a=!0),!a)return[r+1,i];for(var h=Math.floor(Math.sqrt(l));h>0;){if(Math.floor(l/h)===l/h)return[h,l/h];h--}return[h=Math.floor(Math.sqrt(l)),h]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function j3(e,t){for(var n=[],r=0;r<t.length;r++)n.push(e.dataToPoint(t[r]));return n}i_((function(e){e.registerChartView(W3),e.registerSeriesModel(G3),e.registerLayout((function(e,t){e.eachSeriesByType("surface",(function(e){var t=e.coordinateSystem;t&&"cartesian3D"===t.type||"production"!==process.env.NODE_ENV&&console.error("Surface chart only support cartesian3D coordinateSystem");var n=e.getData(),r=new Float32Array(3*n.count()),i=[NaN,NaN,NaN];if(t&&"cartesian3D"===t.type){var o=t.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]}));n.each(o,(function(e,o,a,s){var l;l=n.hasValue(s)?t.dataToPoint([e,o,a]):i,r[3*s]=l[0],r[3*s+1]=l[1],r[3*s+2]=l[2]}))}n.setLayout("points",r)}))}))}));var X3=Vg.extend({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(e){e=e||{};var t=this.get("coordinateSystem");if(null!=t&&"geo3D"!==t){if("production"!==process.env.NODE_ENV){var n=[];["left","top","width","height","boxWidth","boxDepth","boxHeight","light","viewControl","postEffect","temporalSuperSampling","environment","groundPlane"].forEach((function(t){null!=e[t]&&n.push(t)})),n.length&&console.warn("Property %s in map3D series will be ignored if coordinate system is %s",n.join(", "),t)}this.get("groundPlane.show")&&(this.option.groundPlane.show=!1),this._geo=null}},getInitialData:function(e){e.data=this.getFilledRegions(e.data,e.map);var t=N_(e.data,{coordDimensions:["value"]}),n=new L_(t,this);n.initData(e.data);var r={};return n.each((function(e){var t=n.getName(e),i=n.getItemModel(e);r[t]=i})),this._regionModelMap=r,n},formatTooltip:function(e){return H2(this,e)},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new Fh(null,this)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,n=this.getData().getName(e);if(t.transform)return(r=t.getRegion(n))?r.geometries:[];this._geo||(this._geo=H1.createGeo3D(this));for(var r=this._geo.getRegion(n),i=[],o=0;o<r.geometries.length;o++){var a=r.geometries[o],s=[],l=j3(t,a.exterior);if(s&&s.length)for(var u=0;u<a.interiors.length;u++)s.push(j3(t,s[u]));i.push({interiors:s,exterior:l})}return i},getFormattedLabel:function(e,t){var n=G2.getFormattedLabel(this,e,t);return null==n&&(n=this.getData().getName(e)),n},defaultOption:{coordinateSystem:"geo3D",data:null}});R(X3.prototype,Y0),R(X3.prototype,JJ),R(X3.prototype,QJ),R(X3.prototype,eQ),R(X3.prototype,X0);var Y3=Kg.extend({type:"map3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new L1(t),this.groupGL=new zJ.Node},render:function(e,t,n){var r=e.coordinateSystem;if(r&&r.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),r.viewGL.add(this.groupGL),"geo3D"===r.type){this._sceneHelper||(this._sceneHelper=new pQ,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(r.viewGL.scene),this._sceneHelper.updateLight(e),r.viewGL.setPostEffect(e.getModel("postEffect"),n),r.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var i=this._control;i||(i=this._control=new oQ({zr:n.getZr()}),this._control.init());var o=e.getModel("viewControl");i.setViewGL(r.viewGL),i.setFromViewControlModel(o,0),i.off("update"),i.on("update",(function(){n.dispatchAction({type:"map3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),from:this.uid,map3DId:e.id})})),this._geo3DBuilder.extrudeY=!0}else this._control&&(this._control.dispose(),this._control=null),this._sceneHelper&&(this._sceneHelper.dispose(),this._sceneHelper=null),e.getData().getLayout("geo3D"),this._geo3DBuilder.extrudeY=!1;this._geo3DBuilder.update(e,t,n,0,e.getData().count());var a=r.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(e){e.material&&e.material[a]("fragment","SRGB_DECODE")}))}},afterRender:function(e,t,n,r){var i=r.renderer,o=e.coordinateSystem;o&&"geo3D"===o.type&&(this._sceneHelper.updateAmbientCubemap(i,e,n),this._sceneHelper.updateSkybox(i,e,n))},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._geo3DBuilder.dispose()}});i_((function(e){U1(e),e.registerChartView(Y3),e.registerSeriesModel(X3),e.registerAction({type:"map3DChangeCamera",event:"map3dcamerachanged",update:"series:updateCamera"},(function(e,t){t.eachComponent({mainType:"series",subType:"map3D",query:e},(function(t){t.setView(e)}))}))}));var Z3=Vg.extend({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(){return Kx(this)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,progressive:1e5,progressiveThreshold:1e5,large:!1,symbol:"circle",symbolSize:10,zoomScale:0,blendMode:"source-over",itemStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}});function q3(e){this.viewGL=e}q3.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=[1,0,0,1,0,0],this.updateTransform(e,t)},q3.prototype.updateTransform=function(e,t){var n=e.coordinateSystem;n.getRoamTransform&&(Pt(this._viewTransform,n.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},q3.prototype.dataToPoint=function(e,t,n){n=e.dataToPoint(t,null,n);var r=this._viewTransform;r&&Ke(n,n,r)},q3.prototype.removeTransformInPoint=function(e){return this._viewTransform&&Ke(e,e,this._viewTransform),e},q3.prototype.getZoom=function(){if(this._viewTransform){var e=this._viewTransform;return 1/Math.max(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]))}return 1},q3.prototype._setCameraTransform=function(e){var t=this.viewGL.camera;t.position.set(e[4],e[5],0),t.scale.set(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]),1)},q3.prototype._updateCamera=function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.top=0,r.bottom=t,r.right=e,r.near=0,r.far=100};var K3=Kg.extend({type:"scatterGL",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this.viewGL=new N0("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new q3(this.viewGL)},render:function(e,t,n){if(this.groupGL.removeAll(),this._glViewHelper.reset(e,n),e.getData().count()){var r=this._pointsBuilderList[0];r||(r=this._pointsBuilderList[0]=new f3(!0,n)),this._pointsBuilderList.length=1,this.groupGL.add(r.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),r.update(e,t,n),this.viewGL.setPostEffect(e.getModel("postEffect"),n)}},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new f3(!0,r),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.setSizeScale(this._sizeScale),i.update(t,n,r,e.start,e.end),r.getZr().refresh(),this._currentStep++}},updateTransform:function(e,t,n){if(e.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(e,n);var r=this._glViewHelper.getZoom(),i=Math.max((e.get("zoomScale")||0)*(r-1)+1,0);this._sizeScale=i,this._pointsBuilderList.forEach((function(e){e.setSizeScale(i)}))}},_removeTransformInPoints:function(e){if(e)for(var t=[],n=0;n<e.length;n+=2)t[0]=e[n],t[1]=e[n+1],this._glViewHelper.removeTransformInPoint(t),e[n]=t[0],e[n+1]=t[1]},dispose:function(){this.groupGL.removeAll(),this._pointsBuilderList.forEach((function(e){e.dispose()}))},remove:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(K3),e.registerSeriesModel(Z3),e.registerLayout({seriesType:"scatterGL",reset:function(e){var t,n=e.coordinateSystem,r=e.getData();if(n){var i=n.dimensions.map((function(e){return r.mapDimension(e)})).slice(0,2),o=[];1===i.length?t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),o=e.start;o<e.end;o++){var a=2*(o-e.start),s=r.get(i[0],o),l=n.dataToPoint(s);t[a]=l[0],t[a+1]=l[1]}r.setLayout("points",t)}:2===i.length&&(t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),a=e.start;a<e.end;a++){var s=2*(a-e.start),l=r.get(i[0],a),u=r.get(i[1],a);o[0]=l,o[1]=u,o=n.dataToPoint(o),t[s]=o[0],t[s+1]=o[1]}r.setLayout("points",t)})}return{progress:t}}})}));var $3=Vg.extend({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(e){$3.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(e){$3.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(e,t,n,r){var i=G2.getFormattedLabel(this,e,t,n,r);if(null==i){var o=this.getData(),a=o.dimensions[o.dimensions.length-1];i=o.get(a,e)}return i},getInitialData:function(e,t){var n=e.edges||e.links||[],r=e.data||e.nodes||[],i=this;return function(e,t,n,r,i){for(var o=new NE(r),a=0;a<e.length;a++)o.addNode(vJ(e[a].id,e[a].name,a),a);var s,l=[],u=[],c=0;for(a=0;a<t.length;a++){var h=t[a],d=h.source,p=h.target;o.addEdge(d,p,c)&&(u.push(h),l.push(vJ(h.id,d+" > "+p)),c++)}var f=N_(e,{coordDimensions:["value"]});(s=new L_(f,n)).initData(e);var g=new L_(["value"],n);return g.initData(u,l),i(s,g),xA({mainData:s,struct:o,structAttr:"graph",datas:{node:s,edge:g},datasAttr:{node:"data",edge:"edgeData"}}),o.update(),o}(r,n,this,!0,(function(e,n){e.wrapMethod("getItemModel",(function(e){const t=i._categoriesModels[e.getShallow("category")];return t&&(t.parentModel=e.parentModel,e.parentModel=t),e}));const r=t.getModel([]).getModel;function o(e,t){const n=r.call(this,e,t);return n.resolveParentPath=a,n}function a(e){if(e&&("label"===e[0]||"label"===e[1])){const t=e.slice();return"label"===e[0]?t[0]="edgeLabel":"label"===e[1]&&(t[1]="edgeLabel"),t}return e}n.wrapMethod("getItemModel",(function(e){return e.resolveParentPath=a,e.getModel=o,e}))})).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(e,t,n){if("edge"===n){var r=this.getData(),i=this.getDataParams(e,n),o=r.graph.getEdgeByIndex(e),a=r.getName(o.node1.dataIndex),s=r.getName(o.node2.dataIndex),l=[];return null!=a&&l.push(a),null!=s&&l.push(s),l=dt(l.join(" > ")),i.value&&(l+=" : "+dt(i.value)),l}return $3.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var e=(this.option.categories||[]).map((function(e){return null!=e.value?e:Object.assign({value:0},e)})),t=new L_(["value"],this);t.initData(e),this._categoriesData=t,this._categoriesModels=t.mapArray((function(e){return t.getItemModel(e,!0)}))},setView:function(e){null!=e.zoom&&(this.option.zoom=e.zoom),null!=e.offset&&(this.option.offset=e.offset)},setNodePosition:function(e){for(var t=0;t<e.length/2;t++){var n=e[2*t],r=e[2*t+1],i=this.getData().getRawDataItem(t);i.x=n,i.y=r}},isAnimationEnabled:function(){return $3.superCall(this,"isAnimationEnabled")&&!("force"===this.get("layout")&&this.get("force.layoutAnimation"))},defaultOption:{zlevel:10,z:2,legendHoverLink:!0,layout:"forceAtlas2",forceAtlas2:{initLayout:null,GPU:!0,steps:1,maxSteps:1e3,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,edgeWeightInfluence:1,edgeWeight:[1,4],nodeWeight:[1,4],preventOverlap:!1,gravityCenter:null},focusNodeAdjacency:!0,focusNodeAdjacencyOn:"mouseover",left:"center",top:"center",symbol:"circle",symbolSize:5,roam:!1,center:null,zoom:1,label:{show:!1,formatter:"{b}",position:"right",distance:5,textStyle:{fontSize:14}},itemStyle:{},lineStyle:{color:"#aaa",width:1,opacity:.5},emphasis:{label:{show:!0}},animation:!1}}),J3=sQ.vec2,Q3=[[0,0],[1,1]],e5=WK.extend((function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new WK.Attribute("position","float",2,"POSITION"),normal:new WK.Attribute("normal","float",2),offset:new WK.Attribute("offset","float",1),color:new WK.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.offset.init(e),t.normal.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,n,r){return 1/(J3.dist(e,t)+J3.dist(n,t)+J3.dist(r,n)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?2*o:2*o+2},getCubicCurveTriangleCount:function(e,t,n,r){var i=this._getCubicCurveApproxStep(e,t,n,r),o=Math.ceil(1/i);return this.useNativeLine?0:2*o},getLineVertexCount:function(){return this.getPolylineVertexCount(Q3)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Q3)},getPolylineVertexCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;"number"==typeof e?t=e:t="number"!=typeof e[0]?e.length:e.length/2;return this.useNativeLine?0:2*(t-1)},addCubicCurve:function(e,t,n,r,i,o){null==o&&(o=1);var a=e[0],s=e[1],l=t[0],u=t[1],c=n[0],h=n[1],d=r[0],p=r[1],f=this._getCubicCurveApproxStep(e,t,n,r),g=f*f,m=g*f,v=3*f,y=3*g,_=6*g,x=6*m,b=a-2*l+c,w=s-2*u+h,S=3*(l-c)-a+d,T=3*(u-h)-s+p,M=a,C=s,D=(l-a)*v+b*y+S*m,A=(u-s)*v+w*y+T*m,I=b*_+S*x,E=w*_+T*x,L=S*x,N=T*x,P=0,O=0,R=Math.ceil(1/f),k=new Float32Array(3*(R+1)),z=(k=[],0);for(O=0;O<R+1;O++)k[z++]=M,k[z++]=C,M+=D,C+=A,D+=I,A+=E,I+=L,E+=N,(P+=f)>1&&(M=D>0?Math.min(M,d):Math.max(M,d),C=A>0?Math.min(C,p):Math.max(C,p));this.addPolyline(k,i,o)},addLine:function(e,t,n,r){this.addPolyline([e,t],n,r)},addPolyline:function(){var e=J3.create(),t=J3.create(),n=J3.create(),r=J3.create(),i=[],o=[],a=[];return function(s,l,u,c,h){if(s.length){var d="number"!=typeof s[0];if(null==h&&(h=d?s.length:s.length/2),!(h<2)){null==c&&(c=0),null==u&&(u=1),this._itemVertexOffsets.push(this._vertexOffset);for(var p,f=d?"number"!=typeof l[0]:l.length/4===h,g=this.attributes.position,m=this.attributes.color,v=this.attributes.offset,y=this.attributes.normal,_=this.indices,x=this._vertexOffset,b=0;b<h;b++){if(d)i=s[b+c],p=f?l[b+c]:l;else{var w=2*b+c;if((i=i||[])[0]=s[w],i[1]=s[w+1],f){var S=4*b+c;(p=p||[])[0]=l[S],p[1]=l[S+1],p[2]=l[S+2],p[3]=l[S+3]}else p=l}if(this.useNativeLine)b>1&&(g.copy(x,x-1),m.copy(x,x-1),x++);else{var T;if(b<h-1){if(d)J3.copy(o,s[b+1]);else{w=2*(b+1)+c;(o=o||[])[0]=s[w],o[1]=s[w+1]}if(b>0){J3.sub(e,i,a),J3.sub(t,o,i),J3.normalize(e,e),J3.normalize(t,t),J3.add(r,e,t),J3.normalize(r,r);var M=u/2*Math.min(1/J3.dot(e,r),2);n[0]=-r[1],n[1]=r[0],T=M}else J3.sub(e,o,i),J3.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2}else J3.sub(e,i,a),J3.normalize(e,e),n[0]=-e[1],n[1]=e[0],T=u/2;y.set(x,n),y.set(x+1,n),v.set(x,T),v.set(x+1,-T),J3.copy(a,i),g.set(x,i),g.set(x+1,i),m.set(x,p),m.set(x+1,p),x+=2}if(this.useNativeLine)m.set(x,p),g.set(x,i),x++;else if(b>0){var C=3*this._faceOffset;(_=this.indices)[C]=x-4,_[C+1]=x-3,_[C+2]=x-2,_[C+3]=x-3,_[C+4]=x-1,_[C+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(e,t){for(var n=this._itemVertexOffsets[e],r=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=n;i<r;i++)this.attributes.color.set(i,t);this.dirty("color")}});V(e5.prototype,aQ);zJ.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");var t5={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function n5(e){var t={type:zJ.Texture.FLOAT,minFilter:zJ.Texture.NEAREST,magFilter:zJ.Texture.NEAREST};this._positionSourceTex=new zJ.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new zJ.Texture2D(t),this._positionPrevTex=new zJ.Texture2D(t),this._forceTex=new zJ.Texture2D(t),this._forcePrevTex=new zJ.Texture2D(t),this._weightedSumTex=new zJ.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new zJ.Texture2D(t),this._globalSpeedPrevTex=new zJ.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new lJ({fragment:zJ.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new lJ({fragment:zJ.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new lJ({fragment:zJ.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new lJ({fragment:zJ.Shader.source("clay.compositor.output")});var n=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new zJ.Mesh({geometry:new zJ.Geometry({attributes:{node1:new zJ.Geometry.Attribute("node1","float",2),node2:new zJ.Geometry.Attribute("node2","float",2),weight:new zJ.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new zJ.Material({transparent:!0,shader:zJ.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:n,depthMask:!1,depthText:!1}),mode:zJ.Mesh.POINTS}),this._weightedSumMesh=new zJ.Mesh({geometry:new zJ.Geometry({attributes:{node:new zJ.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new zJ.Material({transparent:!0,shader:zJ.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:n,depthMask:!1,depthText:!1}),mode:zJ.Mesh.POINTS}),this._framebuffer=new k$({depthBuffer:!1}),this._dummyCamera=new zJ.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}n5.prototype.updateOption=function(e){for(var t in t5)this[t]=t5[t];var n=this._nodes.length;if(this.jitterTolerence=n>5e4?10:n>5e3?1:.1,this.scaling=n>100?2:10,e)for(var t in t5)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var r=this._positionSourceTex.pixels,i=0;i<this._nodes.length;i++)r[4*i+2]=(this._nodes[i].degree||0)+1},n5.prototype._updateGravityCenter=function(e){var t=this._nodes,n=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var r=[1/0,1/0],i=[-1/0,-1/0],o=0;o<t.length;o++)r[0]=Math.min(t[o].x,r[0]),r[1]=Math.min(t[o].y,r[1]),i[0]=Math.max(t[o].x,i[0]),i[1]=Math.max(t[o].y,i[1]);this._gravityCenter=[.5*(r[0]+i[0]),.5*(r[1]+i[1])]}for(o=0;o<n.length;o++){var a=n[o].node1,s=n[o].node2;t[a].degree=(t[a].degree||0)+1,t[s].degree=(t[s].degree||0)+1}},n5.prototype.initData=function(e,t){this._nodes=e,this._edges=t,this._updateGravityCenter();var n=Math.ceil(Math.sqrt(e.length)),r=n,i=new Float32Array(n*r*4);this._resize(n,r);for(var o=0,a=0;a<e.length;a++){var s=e[a];i[o++]=s.x||0,i[o++]=s.y||0,i[o++]=s.mass||1,i[o++]=s.size||1}this._positionSourceTex.pixels=i;var l=this._edgeForceMesh.geometry,u=t.length;l.attributes.node1.init(2*u),l.attributes.node2.init(2*u),l.attributes.weight.init(2*u);var c=[];for(a=0;a<t.length;a++){var h=l.attributes,d=t[a].weight;null==d&&(d=1),h.node1.set(a,this.getNodeUV(t[a].node1,c)),h.node2.set(a,this.getNodeUV(t[a].node2,c)),h.weight.set(a,d),h.node1.set(a+u,this.getNodeUV(t[a].node2,c)),h.node2.set(a+u,this.getNodeUV(t[a].node1,c)),h.weight.set(a+u,d)}var p=this._weightedSumMesh.geometry;p.attributes.node.init(e.length);for(a=0;a<e.length;a++)p.attributes.node.set(a,this.getNodeUV(a,c));l.dirty(),p.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",e.length),this._nodeRepulsionPass.material.setUniform("textureSize",[n,r]),this._inited=!1,this._frame=0},n5.prototype.getNodes=function(){return this._nodes},n5.prototype.getEdges=function(){return this._edges},n5.prototype.step=function(e){this._inited||(this._initFromSource(e),this._inited=!0),this._frame++,this._framebuffer.attach(this._forceTex),this._framebuffer.bind(e);var t=this._nodeRepulsionPass;t.setUniform("strongGravityMode",this.strongGravityMode),t.setUniform("gravity",this.gravity),t.setUniform("gravityCenter",this._gravityCenter),t.setUniform("scaling",this.scaling),t.setUniform("preventOverlap",this.preventOverlap),t.setUniform("positionTex",this._positionPrevTex),t.render(e);var n=this._edgeForceMesh;n.material.set("linLogMode",this.linLogMode),n.material.set("edgeWeightInfluence",this.edgeWeightInfluence),n.material.set("preventOverlap",this.preventOverlap),n.material.set("positionTex",this._positionPrevTex),e.gl.enable(e.gl.BLEND),e.renderPass([n],this._dummyCamera),this._framebuffer.attach(this._weightedSumTex),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT),e.gl.enable(e.gl.BLEND);var r=this._weightedSumMesh;r.material.set("positionTex",this._positionPrevTex),r.material.set("forceTex",this._forceTex),r.material.set("forcePrevTex",this._forcePrevTex),e.renderPass([r],this._dummyCamera),this._framebuffer.attach(this._globalSpeedTex);var i=this._globalSpeedPass;i.setUniform("globalSpeedPrevTex",this._globalSpeedPrevTex),i.setUniform("weightedSumTex",this._weightedSumTex),i.setUniform("jitterTolerence",this.jitterTolerence),e.gl.disable(e.gl.BLEND),i.render(e);var o=this._positionPass;this._framebuffer.attach(this._positionTex),o.setUniform("globalSpeedTex",this._globalSpeedTex),o.setUniform("positionTex",this._positionPrevTex),o.setUniform("forceTex",this._forceTex),o.setUniform("forcePrevTex",this._forcePrevTex),o.render(e),this._framebuffer.unbind(e),this._swapTexture()},n5.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1);for(var r=0;r<t;r++)this.step(e);n&&n()},n5.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},n5.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1)||0,t},n5.prototype.getNodePosition=function(e,t){var n=this._positionArr,r=this._positionTex.width,i=this._positionTex.height,o=r*i;n&&n.length===4*o||(n=this._positionArr=new Float32Array(4*o)),this._framebuffer.bind(e),this._framebuffer.attach(this._positionPrevTex),e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,n),this._framebuffer.unbind(e),t||(t=new Float32Array(2*this._nodes.length));for(var a=0;a<this._nodes.length;a++)t[2*a]=n[4*a],t[2*a+1]=n[4*a+1];return t},n5.prototype.getTextureData=function(e,t){var n=this["_"+t+"Tex"],r=n.width,i=n.height;this._framebuffer.bind(e),this._framebuffer.attach(n);var o=new Float32Array(r*i*4);return e.gl.readPixels(0,0,r,i,e.gl.RGBA,e.gl.FLOAT,o),this._framebuffer.unbind(e),o},n5.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},n5.prototype.isFinished=function(e){return this._frame>e},n5.prototype._swapTexture=function(){var e=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=e;e=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=e;e=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=e},n5.prototype._initFromSource=function(e){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(e),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(e),e.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(e)},n5.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach((function(n){this[n].width=e,this[n].height=t,this[n].dirty()}),this)},n5.prototype.dispose=function(e){this._framebuffer.dispose(e),this._copyPass.dispose(e),this._nodeRepulsionPass.dispose(e),this._positionPass.dispose(e),this._globalSpeedPass.dispose(e),this._edgeForceMesh.geometry.dispose(e),this._weightedSumMesh.geometry.dispose(e),this._positionSourceTex.dispose(e),this._positionTex.dispose(e),this._positionPrevTex.dispose(e),this._forceTex.dispose(e),this._forcePrevTex.dispose(e),this._weightedSumTex.dispose(e),this._globalSpeedTex.dispose(e),this._globalSpeedPrevTex.dispose(e)};var r5=function(){var e=function(){return new Float32Array(2)},t=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},n=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},r=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},i=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},o=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},a=function(e,t){return e[0]=t[0],e[1]=t[1],e},s=function(e,t,n){return e[0]=t,e[1]=n,e};function l(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var u=l.prototype;function c(){this.position=new Float32Array(2),this.force=e(),this.forcePrev=e(),this.mass=1,this.inDegree=0,this.outDegree=0}function h(e,t){this.source=e,this.target=t,this.weight=1}function d(){this.autoSettings=!0,this.barnesHutOptimize=!0,this.barnesHutTheta=1.5,this.repulsionByDegree=!0,this.linLogMode=!1,this.strongGravityMode=!1,this.gravity=1,this.scaling=1,this.edgeWeightInfluence=1,this.jitterTolerence=.1,this.preventOverlap=!1,this.dissuadeHubs=!1,this.rootRegion=new l,this.rootRegion.centerOfMass=e(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}u.beforeUpdate=function(){for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].beforeUpdate();this.mass=0,this.centerOfMass&&(this.centerOfMass[0]=0,this.centerOfMass[1]=0),this.nSubRegions=0,this.node=null},u.afterUpdate=function(){this.subRegions.length=this.nSubRegions;for(var e=0;e<this.nSubRegions;e++)this.subRegions[e].afterUpdate()},u.addNode=function(e){if(0===this.nSubRegions){if(null==this.node)return void(this.node=e);this._addNodeToSubRegion(this.node),this.node=null}this._addNodeToSubRegion(e),this._updateCenterOfMass(e)},u.findSubRegion=function(e,t){for(var n=0;n<this.nSubRegions;n++){var r=this.subRegions[n];if(r.contain(e,t))return r}},u.contain=function(e,t){return this.bbox[0]<=e&&this.bbox[2]>=e&&this.bbox[1]<=t&&this.bbox[3]>=t},u.setBBox=function(e,t,n,r){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r,this.size=(n-e+r-t)/2},u._newSubRegion=function(){var e=this.subRegions[this.nSubRegions];return e||(e=new l,this.subRegions[this.nSubRegions]=e),this.nSubRegions++,e},u._addNodeToSubRegion=function(e){var t=this.findSubRegion(e.position[0],e.position[1]),n=this.bbox;if(!t){var r=(n[0]+n[2])/2,i=(n[1]+n[3])/2,o=(n[2]-n[0])/2,a=(n[3]-n[1])/2,s=e.position[0]>=r?1:0,l=e.position[1]>=i?1:0;(t=this._newSubRegion()).setBBox(s*o+n[0],l*a+n[1],(s+1)*o+n[0],(l+1)*a+n[1])}t.addNode(e)},u._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,n=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,n+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=n/this.mass};var p=d.prototype;p.initNodes=function(e,t,n){var r=t.length;this.nodes.length=0;for(var i=void 0!==n,o=0;o<r;o++){var a=new c;a.position[0]=e[2*o],a.position[1]=e[2*o+1],a.mass=t[o],i&&(a.size=n[o]),this.nodes.push(a)}this._massArr=t,this._swingingArr=new Float32Array(r),i&&(this._sizeArr=n)},p.initEdges=function(e,t){var n=e.length/2;this.edges.length=0;for(var r=0;r<n;r++){var i=e[2*r],o=e[2*r+1],a=this.nodes[i],s=this.nodes[o];if(!a||!s)return void console.error("Node not exists, try initNodes before initEdges");a.outDegree++,s.inDegree++;var l=new h(a,s);t&&(l.weight=t[r]),this.edges.push(l)}},p.updateSettings=function(){if(this.repulsionByDegree)for(var e=0;e<this.nodes.length;e++){(t=this.nodes[e]).mass=t.inDegree+t.outDegree+1}else for(e=0;e<this.nodes.length;e++){var t;(t=this.nodes[e]).mass=this._massArr[e]}},p.update=function(){var o=this.nodes.length;if(this.updateSettings(),this.updateBBox(),this.barnesHutOptimize){this.rootRegion.setBBox(this.bbox[0],this.bbox[1],this.bbox[2],this.bbox[3]),this.rootRegion.beforeUpdate();for(var l=0;l<o;l++)this.rootRegion.addNode(this.nodes[l]);this.rootRegion.afterUpdate()}for(l=0;l<o;l++){var u=this.nodes[l];a(u.forcePrev,u.force),s(u.force,0,0)}for(l=0;l<o;l++){var c=this.nodes[l];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,c);else for(var h=l+1;h<o;h++){var d=this.nodes[h];this.applyNodeToNodeRepulsion(c,d,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(c):this.applyNodeGravity(c))}for(l=0;l<this.edges.length;l++)this.applyEdgeAttraction(this.edges[l]);var p=0,f=0,g=e();for(l=0;l<o;l++){u=this.nodes[l];p+=(v=t(u.force,u.forcePrev))*u.mass,i(g,u.force,u.forcePrev),f+=.5*n(g)*u.mass,this._swingingArr[l]=v}var m=this.jitterTolerence*this.jitterTolerence*f/p;this._globalSpeed>0&&(m=Math.min(m/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=m;for(l=0;l<o;l++){u=this.nodes[l];var v=this._swingingArr[l],y=.1*m/(1+m*Math.sqrt(v)),_=n(u.force);_>0&&(y=Math.min(_*y,10)/_,r(u.position,u.position,u.force,y))}},p.applyRegionToNodeRepulsion=function(){var t=e();return function(e,n){if(e.node)this.applyNodeToNodeRepulsion(e.node,n,!0);else{o(t,n.position,e.centerOfMass);var i=t[0]*t[0]+t[1]*t[1];if(i>this.barnesHutTheta*e.size*e.size){var a=this.scaling*n.mass*e.mass/i;r(n.force,n.force,t,a)}else for(var s=0;s<e.nSubRegions;s++)this.applyRegionToNodeRepulsion(e.subRegions[s],n)}}}(),p.applyNodeToNodeRepulsion=function(){var t=e();return function(e,n,i){if(e!=n){o(t,e.position,n.position);var a=t[0]*t[0]+t[1]*t[1];if(0!==a){var s;if(this.preventOverlap){var l=Math.sqrt(a);if((l=l-e.size-n.size)>0)s=this.scaling*e.mass*n.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*e.mass*n.mass}}else s=this.scaling*e.mass*n.mass/a;r(e.force,e.force,t,s),r(n.force,n.force,t,-s)}}}}(),p.applyEdgeAttraction=function(){var t=e();return function(e){var i=e.source,a=e.target;o(t,i.position,a.position);var s,l,u=n(t);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?e.weight:Math.pow(e.weight,this.edgeWeightInfluence),this.preventOverlap&&(u=u-i.size-a.size)<=0||(l=this.linLogMode?-s*Math.log(u+1)/(u+1):-s,r(i.force,i.force,t,l),r(a.force,a.force,t,-l))}}(),p.applyNodeGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position);var i=n(t);r(e.force,e.force,t,this.gravity*e.mass/(i+1))}}(),p.applyNodeStrongGravity=function(){var t=e();return function(e){o(t,this.gravityCenter,e.position),r(e.force,e.force,t,this.gravity*e.mass)}}(),p.updateBBox=function(){for(var e=1/0,t=1/0,n=-1/0,r=-1/0,i=0;i<this.nodes.length;i++){var o=this.nodes[i].position;e=Math.min(e,o[0]),t=Math.min(t,o[1]),n=Math.max(n,o[0]),r=Math.max(r,o[1])}this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=n,this.bbox[3]=r},p.getGlobalSpeed=function(){return this._globalSpeed};var f=null;self.onmessage=function(e){switch(e.data.cmd){case"init":(f=new d).initNodes(e.data.nodesPosition,e.data.nodesMass,e.data.nodesSize),f.initEdges(e.data.edges,e.data.edgesWeight);break;case"updateConfig":if(f)for(var t in e.data.config)f[t]=e.data.config[t];break;case"update":var n=e.data.steps;if(f){for(var r=0;r<n;r++)f.update();var i=f.nodes.length,o=new Float32Array(2*i);for(r=0;r<i;r++){var a=f.nodes[r];o[2*r]=a.position[0],o[2*r+1]=a.position[1]}self.postMessage({buffer:o.buffer,globalSpeed:f.getGlobalSpeed()},[o.buffer])}else{var s=new Float32Array;self.postMessage({buffer:s.buffer,globalSpeed:f.getGlobalSpeed()},[s.buffer])}}}}.toString();r5=r5.slice(r5.indexOf("{")+1,r5.lastIndexOf("}"));var i5={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},o5=function(e){for(var t in i5)this[t]=i5[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new PK({type:AK.FLOAT,flipY:!1,minFilter:AK.NEAREST,magFilter:AK.NEAREST})};o5.prototype.initData=function(e,t){var n=new Blob([r5]),r=window.URL.createObjectURL(n);this._worker=new Worker(r),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,o=t.length,a=new Float32Array(2*i),s=new Float32Array(i),l=new Float32Array(i),u=new Float32Array(2*o),c=new Float32Array(o),h=0;h<e.length;h++){var d=e[h];a[2*h]=d.x,a[2*h+1]=d.y,s[h]=null==d.mass?1:d.mass,l[h]=null==d.size?1:d.size}for(h=0;h<t.length;h++){var p=t[h],f=p.node1,g=p.node2;u[2*h]=f,u[2*h+1]=g,c[h]=null==p.weight?1:p.weight}var m=Math.ceil(Math.sqrt(e.length)),v=m,y=new Float32Array(m*v*4),_=this._positionTex;_.width=m,_.height=v,_.pixels=y,this._worker.postMessage({cmd:"init",nodesPosition:a,nodesMass:s,nodesSize:l,edges:u,edgesWeight:c}),this._globalSpeed=1/0},o5.prototype.updateOption=function(e){var t={};for(var n in i5)t[n]=i5[n];var r=this._nodes,i=this._edges,o=r.length;if(t.jitterTolerence=o>5e4?10:o>5e3?1:.1,t.scaling=o>100?2:10,t.barnesHutOptimize=o>1e3,e)for(var n in i5)null!=e[n]&&(t[n]=e[n]);if(!t.gravityCenter){for(var a=[1/0,1/0],s=[-1/0,-1/0],l=0;l<r.length;l++)a[0]=Math.min(r[l].x,a[0]),a[1]=Math.min(r[l].y,a[1]),s[0]=Math.max(r[l].x,s[0]),s[1]=Math.max(r[l].y,s[1]);t.gravityCenter=[.5*(a[0]+s[0]),.5*(a[1]+s[1])]}for(l=0;l<i.length;l++){var u=i[l].node1,c=i[l].node2;r[u].degree=(r[u].degree||0)+1,r[c].degree=(r[c].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:t})},o5.prototype.update=function(e,t,n){null==t&&(t=1),t=Math.max(t,1),this._frame+=t,this._onupdate=n,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(t)})},o5.prototype._$onupdate=function(e){if(!this._disposed){var t=new Float32Array(e.data.buffer);this._globalSpeed=e.data.globalSpeed,this._positionArr=t,this._updateTexture(t),this._onupdate&&this._onupdate()}},o5.prototype.getNodePositionTexture=function(){return this._positionTex},o5.prototype.getNodeUV=function(e,t){t=t||[];var n=this._positionTex.width,r=this._positionTex.height;return t[0]=e%n/(n-1),t[1]=Math.floor(e/n)/(r-1),t},o5.prototype.getNodes=function(){return this._nodes},o5.prototype.getEdges=function(){return this._edges},o5.prototype.isFinished=function(e){return this._frame>e},o5.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var n=0;n<this._positionArr.length;n++)t[n]=this._positionArr[n];return t},o5.prototype._updateTexture=function(e){for(var t=this._positionTex.pixels,n=0,r=0;r<e.length;)t[n++]=e[r++],t[n++]=e[r++],t[n++]=1,t[n++]=1;this._positionTex.dirty()},o5.prototype.dispose=function(e){this._disposed=!0,this._worker=null};var a5=bY.extend((function(){return{zr:null,viewGL:null,minZoom:.2,maxZoom:5,_needsUpdate:!1,_dx:0,_dy:0,_zoom:1}}),(function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._update=this._update.bind(this)}),{init:function(){var e=this.zr;e.on("mousedown",this._mouseDownHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("globalout",this._mouseUpHandler),e.animation.on("frame",this._update)},setTarget:function(e){this._target=e},setZoom:function(e){this._zoom=Math.max(Math.min(e,this.maxZoom),this.minZoom),this._needsUpdate=!0},setOffset:function(e){this._dx=e[0],this._dy=e[1],this._needsUpdate=!0},getZoom:function(){return this._zoom},getOffset:function(){return[this._dx,this._dy]},_update:function(){if(this._target&&this._needsUpdate){var e=this._target,t=this._zoom;e.position.x=this._dx,e.position.y=this._dy,e.scale.set(t,t,t),this.zr.refresh(),this._needsUpdate=!1,this.trigger("update")}},_mouseDownHandler:function(e){if(!e.target){var t=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(t,n)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var r=this._convertPos(t,n);this._x=r.x,this._y=r.y}}},_convertPos:function(e,t){var n=this.viewGL.camera,r=this.viewGL.viewport;return{x:(e-r.x)/r.width*(n.right-n.left)+n.left,y:(t-r.y)/r.height*(n.bottom-n.top)+n.top}},_mouseMoveHandler:function(e){var t=this._convertPos(e.offsetX,e.offsetY);this._dx+=t.x-this._x,this._dy+=t.y-this._y,this._x=t.x,this._y=t.y,this._needsUpdate=!0},_mouseUpHandler:function(e){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_mouseWheelHandler:function(e){var t=(e=e.event).wheelDelta||-e.detail;if(0!==t){var n=e.offsetX,r=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(n,r)){var i=t>0?1.1:.9,o=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=o/this._zoom;var a=this._convertPos(n,r),s=(a.x-this._dx)*(i-1),l=(a.y-this._dy)*(i-1);this._dx-=s,this._dy-=l,this._zoom=o,this._needsUpdate=!0}}},dispose:function(){var e=this.zr;e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("globalout",this._mouseUpHandler),e.animation.off("frame",this._update)}}),s5=sQ.vec2;zJ.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");var l5=1,u5=Kg.extend({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this.viewGL=new N0("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new f3(!0,t),this._forceEdgesMesh=new zJ.Mesh({material:new zJ.Material({shader:zJ.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new zJ.Geometry({attributes:{node:new zJ.Geometry.Attribute("node","float",2),color:new zJ.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:zJ.Mesh.LINES}),this._edgesMesh=new zJ.Mesh({material:new zJ.Material({shader:zJ.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new e5({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new a5({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,n){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=n,this._initLayout(e,t,n),this._pointsBuilder.update(e,t,n),this._forceLayoutInstance instanceof n5||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,n),this._control.off("update"),this._control.on("update",(function(){n.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)}),this),this._control.setZoom(vJ(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var r=this._pointsBuilder.getPointsMesh();if(r.off("mousemove",this._mousemoveHandler),r.off("mouseout",this._mouseOutHandler,this),n.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?n.getZr().on("click",this._clickHandler):"mouseover"===i?(r.on("mousemove",this._mousemoveHandler,this),r.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1):"production"!==process.env.NODE_ENV&&console.warn("Unkown focusNodeAdjacencyOn value s"+i)}this._lastMouseOverDataIndex=-1},_clickHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?t!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._mouseOutHandler(e),this._lastMouseOverDataIndex=t}},_mouseOutHandler:function(e){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(e,t){var n=this._forceEdgesMesh.geometry,r=t.getEdgeData(),i=0,o=this._forceLayoutInstance,a=2*r.count();n.attributes.node.init(a),n.attributes.color.init(a),r.each((function(t){var a=e[t];n.attributes.node.set(i,o.getNodeUV(a.node1)),n.attributes.node.set(i+1,o.getNodeUV(a.node2));var s=D1(r,a.dataIndex),l=zJ.parseColor(s);l[3]*=vJ(A1(r,a.dataIndex),1),n.attributes.color.set(i,l),n.attributes.color.set(i+1,l),i+=2})),n.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,n=(e=this._model.getEdgeData(),this._model.getData().getLayout("points"));t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var r=[],i=[],o=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each((function(a){var s=e.graph.getEdgeByIndex(a),l=2*s.node1.dataIndex,u=2*s.node2.dataIndex;r[0]=n[l],r[1]=n[l+1],i[0]=n[u],i[1]=n[u+1];var c=D1(e,s.dataIndex),h=zJ.parseColor(c);h[3]*=vJ(A1(e,s.dataIndex),1);var d=e.getItemModel(s.dataIndex),p=vJ(d.get(o),1)*this._api.getDevicePixelRatio();t.addLine(r,i,h,p);for(var f=0;f<4;f++)this._originalEdgeColors[4*s.dataIndex+f]=h[f];this._edgeIndicesMap[s.dataIndex]=a}),this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),n=[],r=0;r<e.count();r++)this._forceLayoutInstance.getNodeUV(r,n),t.geometry.attributes.position.set(r,n);t.geometry.dirty("position")},_initLayout:function(e,t,n){var r=e.get("layout"),i=e.getGraph(),o=Wd(e.getBoxLayoutParams(),{width:n.getWidth(),height:n.getHeight()});"force"===r&&("production"!==process.env.NODE_ENV&&console.warn("Currently only forceAtlas2 layout supported."),r="forceAtlas2"),this.stopLayout(e,t,n,{beforeLayout:!0});var a=e.getData(),s=e.getData();if("forceAtlas2"===r){var l=e.getModel("forceAtlas2"),u=this._forceLayoutInstance,c=[],h=[],d=a.getDataExtent("value"),p=s.getDataExtent("value"),f=vJ(l.get("edgeWeight"),1),g=vJ(l.get("nodeWeight"),1);"number"==typeof f&&(f=[f,f]),"number"==typeof g&&(g=[g,g]);var m=0,v={},y=new Float32Array(2*a.count());if(i.eachNode((function(e){var t,n,r=e.dataIndex,i=a.get("value",r);if(a.hasItemOption){var s=a.getItemModel(r);t=s.get("x"),n=s.get("y")}null==t&&(t=o.x+Math.random()*o.width,n=o.y+Math.random()*o.height),y[2*m]=t,y[2*m+1]=n,v[e.id]=m++;var l=eo(i,d,g);isNaN(l)&&(l=isNaN(g[0])?1:g[0]),c.push({x:t,y:n,mass:l,size:a.getItemVisual(r,"symbolSize")})})),a.setLayout("points",y),i.eachEdge((function(e){var t=e.dataIndex,n=eo(a.get("value",t),p,f);isNaN(n)&&(n=isNaN(f[0])?1:f[0]),h.push({node1:v[e.node1.id],node2:v[e.node2.id],weight:n,dataIndex:t})})),!u){var _=l.get("GPU");this._forceLayoutInstance&&((!_||this._forceLayoutInstance instanceof n5)&&(_||this._forceLayoutInstance instanceof o5)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),u=this._forceLayoutInstance=_?new n5:new o5}u.initData(c,h),u.updateOption(l.option),this._updateForceEdgesGeometry(u.getEdges(),e),this._updatePositionTexture(),n.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else{y=new Float32Array(2*a.count()),m=0;i.eachNode((function(e){var t,n,r=e.dataIndex;if(a.hasItemOption){var i=a.getItemModel(r);t=i.get("x"),n=i.get("y")}y[m++]=t,y[m++]=n})),a.setLayout("points",y),this._updateAfterLayout(e,t,n)}},_updatePositionTexture:function(){var e=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(e),this._forceEdgesMesh.material.set("positionTex",e)},startLayout:function(e,t,n,r){if(!r||null==r.from||r.from===this.uid){var i=this.viewGL,o=(n=this._api,this._forceLayoutInstance),a=this._model.getData(),s=this._model.getModel("forceAtlas2");if(o){if(this.groupGL.remove(this._edgesMesh),this.groupGL.add(this._forceEdgesMesh),this._forceLayoutInstance){this._updateForceNodesGeometry(e.getData()),this._pointsBuilder.hideLabels();var l=this,u=this._layoutId=l5++,c=s.getShallow("maxSteps"),h=s.getShallow("steps"),d=0,p=Math.max(2*h,20),f=function(t){if(t===l._layoutId)return o.isFinished(c)?(n.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void n.dispatchAction({type:"graphGLFinishLayout",points:a.getLayout("points"),from:l.uid})):void o.update(i.layer.renderer,h,(function(){l._updatePositionTexture(),(d+=h)>=p&&(l._syncNodePosition(e),d=0),n.getZr().refresh(),dn((function(){f(t)}))}))};dn((function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(i.layer.renderer),l._forceLayoutInstanceToDispose=null),f(u)})),this._layouting=!0}}else"production"!==process.env.NODE_ENV&&console.error("None layout don't have startLayout action")}},stopLayout:function(e,t,n,r){r&&null!=r.from&&r.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(r&&r.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,n)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(e){var t=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);e.getData().setLayout("points",t),e.setNodePosition(t)},_updateAfterLayout:function(e,t,n){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,n),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,n,r){var i=this._model.getData();this._downplayAll();var o=r.dataIndex,a=i.graph,s=[],l=a.getNodeByIndex(o);s.push(l),l.edges.forEach((function(e){e.dataIndex<0||(e.node1!==l&&s.push(e.node1),e.node2!==l&&s.push(e.node2))}),this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach((function(e){this._pointsBuilder.highlight(i,e.dataIndex)}),this),this._pointsBuilder.updateLabels(s.map((function(e){return e.dataIndex})));var u=[];l.edges.forEach((function(e){e.dataIndex>=0&&(this._highlightEdge(e.dataIndex),u.push(e))}),this),this._focusNodes=s,this._focusEdges=u},unfocusNodeAdjacency:function(e,t,n,r){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),n=zJ.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),r=vJ(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);n[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],n)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach((function(e){this._pointsBuilder.downplay(this._model.getData(),e.dataIndex)}),this),this._focusEdges&&this._focusEdges.forEach((function(e){this._downplayEdge(e.dataIndex)}),this)},_downplayEdge:function(e){var t=this._getColor(e,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],t)},_setEdgeFade:function(){var e=[];return function(t,n){this._getColor(t,e),e[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var n=0;n<4;n++)t[n]=this._originalEdgeColors[4*e+n];return t},_fadeOutEdgesAll:function(e){this._model.getData().graph.eachEdge((function(t){this._setEdgeFade(t.dataIndex,e)}),this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(e,t){this.viewGL.setViewport(0,0,t.getWidth(),t.getHeight(),t.getDevicePixelRatio());for(var n=this.viewGL.camera,r=e.getData().getLayout("points"),i=s5.create(1/0,1/0),o=s5.create(-1/0,-1/0),a=[],s=0;s<r.length;)a[0]=r[s++],a[1]=r[s++],s5.min(i,i,a),s5.max(o,o,a);var l=(o[1]+i[1])/2,u=(o[0]+i[0])/2;if(!(u>n.left&&u<n.right&&l<n.bottom&&l>n.top)){var c=Math.max(o[0]-i[0],10),h=c/t.getWidth()*t.getHeight();c*=1.4,h*=1.4,i[0]-=.2*c,n.left=i[0],n.top=l-h/2,n.bottom=l+h/2,n.right=c+i[0],n.near=0,n.far=100}},dispose:function(){var e=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(e),this.groupGL.removeAll(),this._layoutId=-1,this._pointsBuilder.dispose()},remove:function(){this.groupGL.removeAll(),this._control.dispose()}});function c5(e){return e instanceof Array||(e=[e,e]),e}i_((function(e){function t(){}e.registerChartView(u5),e.registerSeriesModel($3),e.registerVisual((function(e){const t={};e.eachSeriesByType("graphGL",(function(e){var n=e.getCategoriesData(),r=e.getData(),i={};n.each((function(r){var o=n.getName(r);i["ec-"+o]=r;var a=n.getItemModel(r),s=a.getModel("itemStyle").getItemStyle();s.fill||(s.fill=e.getColorFromPalette(o,t)),n.setItemVisual(r,"style",s);var l=["symbol","symbolSize","symbolKeepAspect"];for(let e=0;e<l.length;e++){var u=a.getShallow(l[e],!0);null!=u&&n.setItemVisual(r,l[e],u)}})),n.count()&&r.each((function(e){let t=r.getItemModel(e).getShallow("category");if(null!=t){"string"==typeof t&&(t=i["ec-"+t]);var o=n.getItemVisual(t,"style");z(r.ensureUniqueItemVisual(e,"style"),o);var a=["symbol","symbolSize","symbolKeepAspect"];for(let i=0;i<a.length;i++)r.setItemVisual(e,a[i],n.getItemVisual(t,a[i]))}}))}))})),e.registerVisual((function(e){e.eachSeriesByType("graphGL",(function(e){var t=e.getGraph(),n=e.getEdgeData(),r=c5(e.get("edgeSymbol")),i=c5(e.get("edgeSymbolSize"));n.setVisual("drawType","stroke"),n.setVisual("fromSymbol",r&&r[0]),n.setVisual("toSymbol",r&&r[1]),n.setVisual("fromSymbolSize",i&&i[0]),n.setVisual("toSymbolSize",i&&i[1]),n.setVisual("style",e.getModel("lineStyle").getLineStyle()),n.each((function(e){var r=n.getItemModel(e),i=t.getEdgeByIndex(e),o=c5(r.getShallow("symbol",!0)),a=c5(r.getShallow("symbolSize",!0)),s=r.getModel("lineStyle").getLineStyle(),l=n.ensureUniqueItemVisual(e,"style");switch(z(l,s),l.stroke){case"source":var u=i.node1.getVisual("style");l.stroke=u&&u.fill;break;case"target":u=i.node2.getVisual("style");l.stroke=u&&u.fill}o[0]&&i.setVisual("fromSymbol",o[0]),o[1]&&i.setVisual("toSymbol",o[1]),a[0]&&i.setVisual("fromSymbolSize",a[0]),a[1]&&i.setVisual("toSymbolSize",a[1])}))}))})),e.registerAction({type:"graphGLRoam",event:"graphglroam",update:"series.graphGL:roam"},(function(e,t){t.eachComponent({mainType:"series",query:e},(function(t){t.setView(e)}))})),e.registerAction({type:"graphGLStartLayout",event:"graphgllayoutstarted",update:"series.graphGL:startLayout"},t),e.registerAction({type:"graphGLStopLayout",event:"graphgllayoutstopped",update:"series.graphGL:stopLayout"},t),e.registerAction({type:"graphGLFocusNodeAdjacency",event:"graphGLFocusNodeAdjacency",update:"series.graphGL:focusNodeAdjacency"},t),e.registerAction({type:"graphGLUnfocusNodeAdjacency",event:"graphGLUnfocusNodeAdjacency",update:"series.graphGL:unfocusNodeAdjacency"},t)}));var h5=Vg.extend({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(e,t){var n=this.get("coordinateSystem"),r="geo"===n?["lng","lat"]:Yy(n)||["x","y"];if("production"!==process.env.NODE_ENV&&r.length>2)throw new Error("flowGL can only be used on 2d coordinate systems.");r.push("vx","vy");var i=N_(this.getSource(),{coordDimensions:r,encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),o=new L_(i,this);return o.initData(this.getSource()),o},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}}),d5=WK.extend((function(){return{dynamic:!0,attributes:{position:new WK.Attribute("position","float",3,"POSITION")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(e){var t=this.attributes,n=4*e,r=2*e;this.vertexCount!==n&&t.position.init(n),this.triangleCount!==r&&(this.indices=0===r?null:this.vertexCount>65535?new Uint32Array(3*r):new Uint16Array(3*r))},addLine:function(e){var t=this._vertexOffset;this.attributes.position.set(t,[e[0],e[1],1]),this.attributes.position.set(t+1,[e[0],e[1],-1]),this.attributes.position.set(t+2,[e[0],e[1],2]),this.attributes.position.set(t+3,[e[0],e[1],-2]),this.setTriangleIndices(this._faceOffset++,[t,t+1,t+2]),this.setTriangleIndices(this._faceOffset++,[t+1,t+2,t+3]),this._vertexOffset+=4}});bq.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");var p5=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new PK({type:AK.FLOAT,flipY:!1}),this.particleLife=[5,20],this._particleType="point",this._particleSize=1,this.particleColor=[1,1,1,1],this.particleSpeedScaling=1,this._thisFrameTexture=null,this._particlePass=null,this._spawnTexture=null,this._particleTexture0=null,this._particleTexture1=null,this._particlePointsMesh=null,this._surfaceFrameBuffer=null,this._elapsedTime=0,this._scene=null,this._camera=null,this._lastFrameTexture=null,this._supersampling=1,this._downsampleTextures=[],this._width=512,this._height=512,this.init()};p5.prototype={constructor:p5,init:function(){var e={type:AK.FLOAT,minFilter:AK.NEAREST,magFilter:AK.NEAREST,useMipmap:!1};this._spawnTexture=new PK(e),this._particleTexture0=new PK(e),this._particleTexture1=new PK(e),this._frameBuffer=new k$({depthBuffer:!1}),this._particlePass=new lJ({fragment:bq.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new lJ({fragment:bq.source("clay.compositor.downsample")});var t=new IK({renderOrder:10,material:new WZ({shader:new bq(bq.source("ecgl.vfParticle.renderPoints.vertex"),bq.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:IK.POINTS,geometry:new WK({dynamic:!0,mainAttribute:"texcoord0"})}),n=new IK({renderOrder:10,material:new WZ({shader:new bq(bq.source("ecgl.vfParticle.renderLines.vertex"),bq.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new d5,culling:!1}),r=new IK({material:new WZ({shader:new bq(bq.source("ecgl.color.vertex"),bq.source("ecgl.color.fragment"))}),geometry:new B$});r.material.enableTexture("diffuseMap"),this._particlePointsMesh=t,this._particleLinesMesh=n,this._lastFrameFullQuadMesh=r,this._camera=new iJ,this._thisFrameTexture=new PK,this._lastFrameTexture=new PK},setParticleDensity:function(e,t){for(var n=new Float32Array(4*(e*t)),r=0,i=this.particleLife,o=0;o<e;o++)for(var a=0;a<t;a++,r++){n[4*r]=Math.random(),n[4*r+1]=Math.random(),n[4*r+2]=Math.random();var s=(i[1]-i[0])*Math.random()+i[0];n[4*r+3]=s}"line"===this._particleType?this._setLineGeometry(e,t):this._setPointsGeometry(e,t),this._spawnTexture.width=e,this._spawnTexture.height=t,this._spawnTexture.pixels=n,this._particleTexture0.width=this._particleTexture1.width=e,this._particleTexture0.height=this._particleTexture1.height=t,this._particlePass.setUniform("textureSize",[e,t])},_setPointsGeometry:function(e,t){var n=e*t,r=this._particlePointsMesh.geometry,i=r.attributes;i.texcoord0.init(n);for(var o=0,a=0;a<e;a++)for(var s=0;s<t;s++,o++)i.texcoord0.value[2*o]=a/e,i.texcoord0.value[2*o+1]=s/t;r.dirty()},_setLineGeometry:function(e,t){var n=e*t,r=this._getParticleMesh().geometry;r.setLineCount(n),r.resetOffset();for(var i=0;i<e;i++)for(var o=0;o<t;o++)r.addLine([i/e,o/t]);r.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(e,t,n,r){var i=this._getParticleMesh(),o=this._frameBuffer,a=this._particlePass;r&&this._updateDownsampleTextures(e,t),i.material.set("size",this._particleSize*this._supersampling),i.material.set("color",this.particleColor),a.setUniform("speedScaling",this.particleSpeedScaling),o.attach(this._particleTexture1),a.setUniform("firstFrameTime",r?(this.particleLife[1]+this.particleLife[0])/2:0),a.setUniform("particleTexture",this._particleTexture0),a.setUniform("deltaTime",n),a.setUniform("elapsedTime",this._elapsedTime),a.render(e,o),i.material.set("particleTexture",this._particleTexture1),i.material.set("prevParticleTexture",this._particleTexture0),o.attach(this._thisFrameTexture),o.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT);var s=this._lastFrameFullQuadMesh;s.material.set("diffuseMap",this._lastFrameTexture),s.material.set("color",[1,1,1,this.motionBlurFactor]),this._camera.update(!0),e.renderPass([s,i],this._camera),o.unbind(e),this._downsample(e),this._swapTexture(),this._elapsedTime+=n},_downsample:function(e){var t=this._downsampleTextures;if(0!==t.length)for(var n=0,r=this._thisFrameTexture,i=t[n];i;)this._frameBuffer.attach(i),this._downsamplePass.setUniform("texture",r),this._downsamplePass.setUniform("textureSize",[r.width,r.height]),this._downsamplePass.render(e,this._frameBuffer),r=i,i=t[++n]},getSurfaceTexture:function(){var e=this._downsampleTextures;return e.length>0?e[e.length-1]:this._lastFrameTexture},setRegion:function(e){this._particlePass.setUniform("region",e)},resize:function(e,t){this._lastFrameTexture.width=e*this._supersampling,this._lastFrameTexture.height=t*this._supersampling,this._thisFrameTexture.width=e*this._supersampling,this._thisFrameTexture.height=t*this._supersampling,this._width=e,this._height=t},setParticleSize:function(e){var t=this._getParticleMesh();if(e<=2)return t.material.disableTexture("spriteTexture"),void(t.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new PK),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=function(e){var t=document.createElement("canvas");t.width=t.height=e;var n=t.getContext("2d");return n.fillStyle="#fff",n.arc(e/2,e/2,e/2,0,2*Math.PI),n.fill(),t}(e),this._spriteTexture.dirty()),t.material.transparent=!0,t.material.enableTexture("spriteTexture"),t.material.set("spriteTexture",this._spriteTexture),this._particleSize=e},setGradientTexture:function(e){var t=this._getParticleMesh().material;t[e?"enableTexture":"disableTexture"]("gradientTexture"),t.setUniform("gradientTexture",e)},setColorTextureImage:function(e,t){this._getParticleMesh().material.setTextureImage("colorTexture",e,t,{flipY:!0})},setParticleType:function(e){this._particleType=e},clearFrame:function(e){var t=this._frameBuffer;t.attach(this._lastFrameTexture),t.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),t.unbind(e)},setSupersampling:function(e){this._supersampling=e,this.resize(this._width,this._height)},_updateDownsampleTextures:function(e,t){for(var n=this._downsampleTextures,r=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,o=this._width*this._supersampling,a=this._height*this._supersampling,s=0;s<r;s++)n[s]=n[s]||new PK,n[s].width=o/i,n[s].height=a/i,i*=2;for(;s<n.length;s++)n[s].dispose(e);n.length=r},_swapTexture:function(){var e=this._particleTexture0;this._particleTexture0=this._particleTexture1,this._particleTexture1=e;e=this._thisFrameTexture;this._thisFrameTexture=this._lastFrameTexture,this._lastFrameTexture=e},dispose:function(e){e.disposeFrameBuffer(this._frameBuffer),e.disposeTexture(this.vectorFieldTexture),e.disposeTexture(this._spawnTexture),e.disposeTexture(this._particleTexture0),e.disposeTexture(this._particleTexture1),e.disposeTexture(this._thisFrameTexture),e.disposeTexture(this._lastFrameTexture),e.disposeGeometry(this._particleLinesMesh.geometry),e.disposeGeometry(this._particlePointsMesh.geometry),e.disposeGeometry(this._lastFrameFullQuadMesh.geometry),this._spriteTexture&&e.disposeTexture(this._spriteTexture),this._particlePass.dispose(e),this._downsamplePass.dispose(e),this._downsampleTextures.forEach((function(t){t.dispose(e)}))}};var f5=Kg.extend({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new N0("orthographic"),this.groupGL=new zJ.Node,this.viewGL.add(this.groupGL),this._particleSurface=new p5;var n=new zJ.Mesh({geometry:new zJ.PlaneGeometry,material:new zJ.Material({shader:new zJ.Shader({vertex:zJ.Shader.source("ecgl.color.vertex"),fragment:zJ.Shader.source("ecgl.color.fragment")}),transparent:!0})});n.material.enableTexture("diffuseMap"),this.groupGL.add(n),this._planeMesh=n},render:function(e,t,n){var r=this._particleSurface;r.setParticleType(e.get("particleType")),r.setSupersampling(e.get("supersampling")),this._updateData(e,n),this._updateCamera(n.getWidth(),n.getHeight(),n.getDevicePixelRatio());var i=vJ(e.get("particleDensity"),128);r.setParticleDensity(i,i);var o=this._planeMesh,a=+new Date,s=this,l=!0;o.__percent=0,o.stopAnimation(),o.animate("",{loop:!0}).when(1e5,{__percent:1}).during((function(){var e=+new Date,t=Math.min(e-a,20);a+=t,s._renderer&&(r.update(s._renderer,n,t/1e3,l),o.material.set("diffuseMap",r.getSurfaceTexture())),l=!1})).start();var u=e.getModel("itemStyle"),c=zJ.parseColor(u.get("color"));c[3]*=vJ(u.get("opacity"),1),o.material.set("color",c),r.setColorTextureImage(e.get("colorTexture"),n),r.setParticleSize(e.get("particleSize")),r.particleSpeedScaling=e.get("particleSpeed"),r.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,n){this._updateData(e,n)},afterRender:function(e,t,n,r){var i=r.renderer;this._renderer=i},_updateData:function(e,t){var n=e.coordinateSystem,r=n.dimensions.map((function(t){return e.coordDimToDataDim(t)[0]})),i=e.getData(),o=i.getDataExtent(r[0]),a=i.getDataExtent(r[1]),s=e.get("gridWidth"),l=e.get("gridHeight");if(null==s||"auto"===s){var u=(o[1]-o[0])/(a[1]-a[0]);s=Math.round(Math.sqrt(u*i.count()))}null!=l&&"auto"!==l||(l=Math.ceil(i.count()/s));var c=this._particleSurface.vectorFieldTexture,h=c.pixels;if(h&&h.length===l*s*4)for(var d=0;d<h.length;d++)h[d]=0;else h=c.pixels=new Float32Array(s*l*4);var p=0,f=1/0,g=new Float32Array(2*i.count()),m=0,v=[[1/0,1/0],[-1/0,-1/0]];i.each([r[0],r[1],"vx","vy"],(function(e,t,r,i){var o=n.dataToPoint([e,t]);g[m++]=o[0],g[m++]=o[1],v[0][0]=Math.min(o[0],v[0][0]),v[0][1]=Math.min(o[1],v[0][1]),v[1][0]=Math.max(o[0],v[1][0]),v[1][1]=Math.max(o[1],v[1][1]);var a=Math.sqrt(r*r+i*i);p=Math.max(p,a),f=Math.min(f,a)})),i.each(["vx","vy"],(function(e,t,n){var r=Math.round((g[2*n]-v[0][0])/(v[1][0]-v[0][0])*(s-1)),i=4*((l-1-Math.round((g[2*n+1]-v[0][1])/(v[1][1]-v[0][1])*(l-1)))*s+r);h[i]=e/p*.5+.5,h[i+1]=t/p*.5+.5,h[i+3]=1})),c.width=s,c.height=l,"bmap"===e.get("coordinateSystem")&&this._fillEmptyPixels(c),c.dirty(),this._updatePlanePosition(v[0],v[1],e,t),this._updateGradientTexture(i.getVisual("visualMeta"),[f,p])},_fillEmptyPixels:function(e){var t=e.pixels,n=e.width,r=e.height;function i(e,i,o){e=Math.max(Math.min(e,n-1),0);var a=4*((i=Math.max(Math.min(i,r-1),0))*(n-1)+e);return 0!==t[a+3]&&(o[0]=t[a],o[1]=t[a+1],!0)}function o(e,t,n){n[0]=e[0]+t[0],n[1]=e[1]+t[1]}for(var a=[],s=[],l=[],u=[],c=[],h=0,d=0;d<r;d++)for(var p=0;p<n;p++){var f=4*(d*(n-1)+p);0===t[f+3]&&(h=a[0]=a[1]=0,i(p-1,d,s)&&(h++,o(s,a,a)),i(p+1,d,l)&&(h++,o(l,a,a)),i(p,d-1,u)&&(h++,o(u,a,a)),i(p,d+1,c)&&(h++,o(c,a,a)),a[0]/=h,a[1]/=h,t[f]=a[0],t[f+1]=a[1]),t[f+3]=1}},_updateGradientTexture:function(e,t){if(e&&e.length){this._gradientTexture=this._gradientTexture||new zJ.Texture2D({image:document.createElement("canvas")});var n=this._gradientTexture,r=n.image;r.width=200,r.height=1;var i=r.getContext("2d"),o=i.createLinearGradient(0,.5,r.width,.5);e[0].stops.forEach((function(e){var n;t[1]===t[0]?n=0:(n=e.value/t[1],n=Math.min(Math.max(n,0),1)),o.addColorStop(n,e.color)})),i.fillStyle=o,i.fillRect(0,0,r.width,r.height),n.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(e,t,n,r){var i=this._limitInViewportAndFullFill(e,t,n,r);e=i.leftTop,t=i.rightBottom,this._particleSurface.setRegion(i.region),this._planeMesh.position.set((e[0]+t[0])/2,r.getHeight()-(e[1]+t[1])/2,0);var o=t[0]-e[0],a=t[1]-e[1];this._planeMesh.scale.set(o/2,a/2,1),this._particleSurface.resize(Math.max(Math.min(o,2048),1),Math.max(Math.min(a,2048),1)),this._renderer&&this._particleSurface.clearFrame(this._renderer)},_limitInViewportAndFullFill:function(e,t,n,r){var i=[Math.max(e[0],0),Math.max(e[1],0)],o=[Math.min(t[0],r.getWidth()),Math.min(t[1],r.getHeight())];if("bmap"===n.get("coordinateSystem")){var a=n.getData().getDataExtent(n.coordDimToDataDim("lng")[0]);Math.floor(a[1]-a[0])>=359&&(i[0]>0&&(i[0]=0),o[0]<r.getWidth()&&(o[0]=r.getWidth()))}var s=t[0]-e[0],l=t[1]-e[1],u=o[0]-i[0],c=o[1]-i[1];return{leftTop:i,rightBottom:o,region:[(i[0]-e[0])/s,1-c/l-(i[1]-e[1])/l,u/s,c/l]}},_updateCamera:function(e,t,n){this.viewGL.setViewport(0,0,e,t,n);var r=this.viewGL.camera;r.left=r.bottom=0,r.top=t,r.right=e,r.near=0,r.far=100,r.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}});i_((function(e){e.registerChartView(f5),e.registerSeriesModel(h5)}));var g5=Vg.extend({type:"series.linesGL",dependencies:["grid","geo"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",streamEnabled:!0,init:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),g5.superApply(this,"init",arguments)},mergeOption:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),g5.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=Me(this._flatCoords,t.flatCoords),this._flatCoordsOffset=Me(this._flatCoordsOffset,t.flatCoordsOffset)):(this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset),e.data=new Float32Array(t.count)),this.getRawData().appendData(e.data)},_getCoordsFromItemModel:function(e){var t=this.getData().getItemModel(e),n=t.option instanceof Array?t.option:t.getShallow("coords");if("production"!==process.env.NODE_ENV&&!(n instanceof Array&&n.length>0&&n[0]instanceof Array))throw new Error("Invalid coords "+JSON.stringify(n)+". Lines must have 2d coords array in data item.");return n},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var n=this._flatCoordsOffset[2*e],r=this._flatCoordsOffset[2*e+1],i=0;i<r;i++)t[i]=t[i]||[],t[i][0]=this._flatCoords[n+2*i],t[i][1]=this._flatCoords[n+2*i+1];return r}var o=this._getCoordsFromItemModel(e);for(i=0;i<o.length;i++)t[i]=t[i]||[],t[i][0]=o[i][0],t[i][1]=o[i][1];return o.length},_processFlatCoordsArray:function(e){var t=0;if(this._flatCoords&&(t=this._flatCoords.length),"number"==typeof e[0]){for(var n=e.length,r=new Uint32Array(n),i=new Float64Array(n),o=0,a=0,s=0,l=0;l<n;){s++;var u=e[l++];r[a++]=o+t,r[a++]=u;for(var c=0;c<u;c++){var h=e[l++],d=e[l++];if(i[o++]=h,i[o++]=d,l>n&&"production"!==process.env.NODE_ENV)throw new Error("Invalid data format.")}}return{flatCoordsOffset:new Uint32Array(r.buffer,0,a),flatCoords:i,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:e.length}},getInitialData:function(e,t){var n=new L_(["value"],this);return n.hasItemOption=!1,n.initData(e.data,[],(function(e,t,r,i){if(e instanceof Array)return NaN;n.hasItemOption=!0;var o=e.value;return null!=o?o instanceof Array?o[i]:o:void 0})),n},defaultOption:{coordinateSystem:"geo",zlevel:10,progressive:1e4,progressiveThreshold:5e4,blendMode:"source-over",lineStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}}),m5=Kg.extend({type:"linesGL",__ecgl__:!0,init:function(e,t){this.groupGL=new zJ.Node,this.viewGL=new N0("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new q3(this.viewGL),this._nativeLinesShader=zJ.createShader("ecgl.lines3D"),this._meshLinesShader=zJ.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n);var r=this._linesMeshes[0];r||(r=this._linesMeshes[0]=this._createLinesMesh(e)),this._linesMeshes.length=1,this.groupGL.add(r),this._updateLinesMesh(e,r,0,e.getData().count()),this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalPrepareRender:function(e,t,n){this.groupGL.removeAll(),this._glViewHelper.reset(e,n),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),n)},incrementalRender:function(e,t,n,r){var i=this._linesMeshes[this._currentStep];i||(i=this._createLinesMesh(t),this._linesMeshes[this._currentStep]=i),this._updateLinesMesh(t,i,e.start,e.end),this.groupGL.add(i),r.getZr().refresh(),this._currentStep++},updateTransform:function(e,t,n){e.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(e,n)},_createLinesMesh:function(e){return new zJ.Mesh({$ignorePicking:!0,material:new zJ.Material({shader:zJ.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new e5({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:zJ.Mesh.LINES,culling:!1})},_updateLinesMesh:function(e,t,n,r){var i=e.getData();t.material.blend="lighter"===e.get("blendMode")?zJ.additiveBlend:null;var o=e.get("lineStyle.curveness")||0,a=e.get("polyline"),s=t.geometry,l=e.coordinateSystem,u=vJ(e.get("lineStyle.width"),1);u>1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=zJ.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=zJ.Mesh.LINES),n=n||0,r=r||i.count(),s.resetOffset();var c=0,h=0,d=[],p=[],f=[],g=[],m=[],v=.3,y=.7;function _(){p[0]=d[0]*y+g[0]*v-(d[1]-g[1])*o,p[1]=d[1]*y+g[1]*v-(g[0]-d[0])*o,f[0]=d[0]*v+g[0]*y-(d[1]-g[1])*o,f[1]=d[1]*v+g[1]*y-(g[0]-d[0])*o}if(a||0!==o)for(var x=n;x<r;x++)if(a){var b=e.getLineCoordsCount(x);c+=s.getPolylineVertexCount(b),h+=s.getPolylineTriangleCount(b)}else e.getLineCoords(x,m),this._glViewHelper.dataToPoint(l,m[0],d),this._glViewHelper.dataToPoint(l,m[1],g),_(),c+=s.getCubicCurveVertexCount(d,p,f,g),h+=s.getCubicCurveTriangleCount(d,p,f,g);else{var w=r-n;c+=w*s.getLineVertexCount(),h+=w*s.getLineVertexCount()}s.setVertexCount(c),s.setTriangleCount(h);var S=n,T=[];for(x=n;x<r;x++){zJ.parseColor(D1(i,S),T);var M=vJ(A1(i,S),1);T[3]*=M;b=e.getLineCoords(x,m);for(var C=0;C<b;C++)this._glViewHelper.dataToPoint(l,m[C],m[C]);a?s.addPolyline(m,T,u,0,b):0!==o?(d=m[0],g=m[1],_(),s.addCubicCurve(d,p,f,g,T,u)):s.addPolyline(m,T,u,0,2),S++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});i_((function(e){e.registerChartView(m5),e.registerSeriesModel(g5)}));const v5=({className:e="",style:n={},extraOption:r={},lineStyles:i={},pointsStyles:s={},pointsData:l=[],linesData:u=[],globeOption:c={}})=>{const h=t(null),[d,p]=o();return a((()=>{const e=Ry(h.current);p(e);const t=KX(e.resize,500),n=()=>{t()};return globalThis.addEventListener("resize",n),()=>{globalThis.removeEventListener("resize",n)}}),[]),a((()=>{if(d){const e=[];e.push(Object.assign({type:"lines3D",name:"lines3D",effect:{show:!0,trailWidth:2,trailLength:.15,trailOpacity:1,trailColor:"rgb(30, 30, 60)"},lineStyle:{width:5,color:"rgb(50, 50, 150)",opacity:.3},blendMode:"lighter",data:u},i)),e.push(Object.assign({type:"scatter3D",coordinateSystem:"globe",zlevel:3,rippleEffect:{brushType:"stroke"},label:{fontSize:8,show:!0,position:"right",formatter:"{b}"},itemStyle:{normal:{color:"#f5f802"}},data:l},s)),d.setOption(Object.assign({backgroundColor:"#000",baseColor:"#000",shading:"realistic",globe:Object.assign({environment:"https://img.alicdn.com/imgextra/i2/O1CN017x8UE61p6wqej1Y0c_!!6000000005312-0-tps-2048-1024.jpg",heightTexture:"https://img.alicdn.com/imgextra/i2/O1CN01BB16kM1ILFttfdYZg_!!6000000000876-0-tps-4096-2048.jpg",baseTexture:"https://img.alicdn.com/imgextra/i4/O1CN01fs70Dq25ElSd8mU6C_!!6000000007495-0-tps-5400-2700.jpg",shading:"lambert",light:{ambient:{intensity:1},main:{intensity:.1}},viewControl:{autoRotate:!0,distance:2e3}},c),series:e},r));const t=setTimeout((()=>{d.resize()}),500);return()=>{clearTimeout(t)}}}),[d,r,c,i,u,l,s]),vU.jsx(iX,{ref:h,className:e,style:n})};export{v5 as EarthChart,dY as WinChart,oX as WinChartType,dY as default,cU as echarts};