File: /www/server/panel/BTPanel/static/js/page-legacy2.js
!function(){function e(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=c(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.toStringTag||"@@toStringTag";function s(r,i,a,o){var s=i&&i.prototype instanceof u?i:u,h=Object.create(s.prototype);return n(h,"_invoke",function(r,n,i){var a,o,s,u=0,h=i||[],c=!1,d={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return a=t,o=0,s=e,d.n=r,l}};function f(r,n){for(o=r,s=n,t=0;!c&&u&&!i&&t<h.length;t++){var i,a=h[t],f=d.p,p=a[2];r>3?(i=p===n)&&(s=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=e):a[0]<=f&&((i=r<2&&f<a[1])?(o=0,d.v=n,d.n=a[1]):f<p&&(i=r<3||a[0]>n||n>p)&&(a[4]=r,a[5]=n,d.n=p,o=0))}if(i||r>1)return l;throw c=!0,n}return function(i,h,p){if(u>1)throw TypeError("Generator is already running");for(c&&1===h&&f(h,p),o=h,s=p;(t=o<2?e:s)||!c;){a||(o?o<3?(o>1&&(d.n=-1),f(o,s)):d.n=s:d.v=s);try{if(u=2,a){if(o||(i="next"),t=a[i]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,o<2&&(o=0)}else 1===o&&(t=a.return)&&t.call(a),o<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),o=1);a=e}else if((t=(c=d.n<0)?s:r.call(n,d))!==l)break}catch(t){a=e,o=1,s=t}finally{u=1}}return{value:t,done:c}}}(r,a,o),!0),h}var l={};function u(){}function h(){}function c(){}t=Object.getPrototypeOf;var d=[][a]?t(t([][a]())):(n(t={},a,function(){return this}),t),f=c.prototype=u.prototype=Object.create(d);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,n(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return h.prototype=c,n(f,"constructor",c),n(c,"constructor",h),h.displayName="GeneratorFunction",n(c,o,"GeneratorFunction"),n(f),n(f,o,"Generator"),n(f,a,function(){return this}),n(f,"toString",function(){return"[object Generator]"}),(r=function(){return{w:s,m:p}})()}function n(e,t,r,i){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}n=function(e,t,r,i){function o(t,r){n(e,t,function(e){return this._invoke(t,r,e)})}t?a?a(e,t,{value:r,enumerable:!i,configurable:!i,writable:!i}):e[t]=r:(o("next",0),o("throw",1),o("return",2))},n(e,t,r,i)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t,r,n,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,i)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){a(o,n,i,s,l,"next",e)}function l(e){a(o,n,i,s,l,"throw",e)}s(void 0)})}}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e,r,n){return(r=function(e){var r=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,r||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==t(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return d(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}System.register(["./base-lib-legacy.js?v=1777008528","./utils-lib-legacy.js?v=1777008528","./index-legacy431.js?v=1777008528","./map-legacy.js?v=1777008528","./hooks-legacy2.js?v=1777008528","./use-log-detail-legacy.js?v=1777008528","./index-legacy432.js?v=1777008528","./view-model-legacy.js?v=1777008528","./column-legacy.js?v=1777008528","./__commonjsHelpers__-legacy.js?v=1777008528","./constants-legacy.js?v=1777008528","./index-legacy110.js?v=1777008528"],function(n,a){"use strict";var s,u,c,d,f,p,m,g,v,_,y,x,b,w,T,S,M,A,E,C,D,L,P,O,N,R,I,B,z,F,k,U,G,H,V,W,j,X,q,Z,Y,K,Q,J,$,ee,te,re,ne,ie,ae,oe,se,le,ue,he,ce,de,fe,pe,me,ge,ve,_e,ye,xe,be,we,Te,Se,Me,Ae,Ee,Ce,De,Le,Pe,Oe,Ne,Re,Ie,Be,ze,Fe,ke,Ue,Ge,He,Ve,We,je,Xe,qe,Ze,Ye,Ke,Qe,Je,$e,et,tt,rt,nt,it,at,ot,st,lt,ut,ht,ct,dt,ft,pt,mt,gt,vt,_t,yt,xt,bt,wt,Tt,St,Mt,At,Et,Ct,Dt;return{setters:[function(e){s=e.r,u=e.c,c=e.x,d=e.y,f=e.A,p=e.N,m=e.B,g=e.G,v=e.M,_=e.g,y=e.e,x=e.z,b=e.D,w=e.O,T=e.P,S=e.w,M=e.n,A=e.a7,E=e.v,C=e.aG,D=e.C,L=e.R,P=e.J,O=e.K,N=e.al,R=e.aj,I=e.F,B=e.aT,z=e.ay,F=e.H,k=e.a$,U=e.aV,G=e.ap},function(e){H=e._,V=e.an,W=e.cW,j=e.cX,X=e.dJ,q=e.dL,Z=e.i8,Y=e.i9,K=e.ia,Q=e.ib,J=e.ic,$=e.id,ee=e.ie,te=e.ig,re=e.ih,ne=e.ii,ie=e.dY,ae=e.dZ,oe=e.dW,se=e.ij,le=e.en,ue=e.ik,he=e.il,ce=e.im,de=e.eB,fe=e.ez,pe=e.io,me=e.ip,ge=e.eo,ve=e.iq,_e=e.ir,ye=e.is,xe=e.eA,be=e.it,we=e.iu,Te=e.iv,Se=e.iw,Me=e.ix,Ae=e.iy,Ee=e.e7,Ce=e.iz,De=e.em,Le=e.iA,Pe=e.iB,Oe=e.iC,Ne=e.ex,Re=e.iD,Ie=e.iE,Be=e.iF,ze=e.iG,Fe=e.iH,ke=e.iI,Ue=e.iJ,Ge=e.iK,He=e.iL,Ve=e.e1,We=e.ep,je=e.eq,Xe=e.iM,qe=e.iN,Ze=e.iO,Ye=e.iP,Ke=e.iQ,Qe=e.iR,Je=e.iS,$e=e.iT,et=e.iU,tt=e.iV,rt=e.iW,nt=e.iX,it=e.cV,at=e.iY,ot=e.t,st=e.J,lt=e.f,ut=e.A,ht=e.bO,ct=e.iZ,dt=e.Z,ft=e.aJ,pt=e.w,mt=e.b4,gt=e.j},function(e){vt=e.D},function(e){_t=e.u,yt=e.a},function(e){xt=e.u},function(e){bt=e.h},function(e){wt=e.g,Tt=e.s,St=e.a,Mt=e.b,At=e.c,Et=e.d},function(e){Ct=e.h},function(e){Dt=e.u},null,null,null],execute:function(){var Lt=s(!0),Pt=s(1),Ot=s(""),Nt=s(null),Rt=s(4),It=s(100),Bt=s(3),zt=s([]),Ft=s([]),kt=s([]),Ut=s("2d"),Gt=s("world"),Ht=s(null),Vt=s("request"),Wt=Object.freeze(Object.defineProperty({__proto__:null,activeTimeIndex:Pt,countdownDisplaySec:Bt,countdownPercentage:It,countdownTotal:Rt,customTimeRange:Ot,latencyHistory:kt,mapApiData:Ht,mapMode:Ut,mapRegion:Gt,overviewData:Nt,qpsHistory:zt,sourceRankMode:Vt,trafficHistory:Ft,wafSwitchStatus:Lt},Symbol.toStringTag,{value:"Module"})),jt={key:0,class:"flex items-center justify-between px-[1.5rem] py-[1.6rem] border-b border-solid border-[var(--el-border-color-lighter)]"},Xt={class:"flex items-center gap-2 text-[14px] font-bold text-secondary"},qt={class:"flex items-center"},Zt={class:"flex-1 relative p-4 flex flex-col"},Yt=u({__name:"dashboard-card",props:{title:{default:""},isEmpty:{type:Boolean,default:!1},height:{}},setup:function(e){return function(t,r){return c(),d("div",{class:"border border-solid border-[var(--el-border-color-lighter)] flex flex-col transition-shadow dashboard-card",style:v({height:e.height})},[e.title||t.$slots.icon||t.$slots.extra?(c(),d("div",jt,[f("div",Xt,[p(t.$slots,"icon",{},void 0,!0),f("span",null,m(e.title),1)]),f("div",qt,[p(t.$slots,"extra",{},void 0,!0)])])):g("",!0),f("div",Zt,[p(t.$slots,"default",{},void 0,!0)])],4)}}}),Kt=H(Yt,[["__scopeId","data-v-4fd1d80a"]]),Qt={class:"flex items-center justify-between"},Jt={class:"flex items-center gap-2"},$t={class:"countdown-ring",viewBox:"0 0 36 36"},er=["stroke-dashoffset"],tr={class:"ring-text"},rr=H(u({__name:"time-filter",props:{percentage:{default:100},displaySec:{default:30}},emits:["change","refresh","customChange"],setup:function(e,t){var r=t.emit,n=e,i=r,a=2*Math.PI*16,o=_(function(){var e=(100-n.percentage)/100;return a*e}),s=[{label:"昨天",getValue:function(){return null}},{label:"今天",getValue:function(){return null}}];function l(e,t){t<s.length?i("change",t):e&&i("customChange",e)}function u(){i("refresh")}return function(t,r){return c(),d("div",Qt,[y(vt,{buttons:s,type:"date","default-index":1,onChange:l}),f("div",Jt,[f("div",{class:"ring-countdown",onClick:u},[(c(),d("svg",$t,[r[0]||(r[0]=f("circle",{class:"countdown-ring-bg",cx:"18",cy:"18",r:"16",fill:"none",stroke:"rgba(103, 194, 58, 0.2)","stroke-width":"2"},null,-1)),f("circle",{class:"countdown-ring-progress",cx:"18",cy:"18",r:"16",fill:"none",stroke:"var(--el-color-primary)","stroke-width":"2","stroke-linecap":"round","stroke-dasharray":a,"stroke-dashoffset":x(o),transform:"rotate(0 18 18)"},null,8,er)])),f("span",tr,m(e.displaySec),1)])])])}}}),[["__scopeId","data-v-45e92735"]]),nr=""+new URL("../images/btwaf/today-new.svg",a.meta.url).href,ir=""+new URL("../images/btwaf/malicious-new.svg",a.meta.url).href,ar={class:"flex gap-4 h-full"},or={class:"text-[28px] mt-[1.6rem] leading-tight font-bold text-[var(--el-text-color-primary)]"},sr={class:"today_request_trend text-[12px] text-[--el-color-primary] py-2"},lr={class:"text-[12px] text-[--el-color-text-secondary] mt-1"},ur={class:"text-[28px] mt-[1.6rem] leading-tight font-bold text-[var(--el-text-color-primary)]"},hr={class:"malicious_request_trend text-[12px] text-[#ff6b6b] py-2"},cr={class:"text-[12px] text-[--el-color-text-secondary] mt-1"},dr=H(u({__name:"request-stats",props:{todayRequest:{},maliciousRequest:{},yesterdayTotal:{},yesterdayMaliciousRequest:{},activeTimeIndex:{}},emits:["clickRequest","clickMalicious"],setup:function(e){var t=e,r=_(function(){return 1===t.activeTimeIndex?"此时:":"总数:"}),n=_(function(){var e=100*(t.todayRequest/(t.yesterdayTotal||1)-1);return{value:e,text:"".concat(Math.abs(e).toFixed(2),"%"),up:e>0}}),i=_(function(){var e=100*(t.maliciousRequest/(t.yesterdayMaliciousRequest||1)-1);return{value:e,text:"".concat(Math.abs(e).toFixed(2),"%"),up:e>0}});function a(e){return e.toLocaleString()}return function(t,o){return c(),d("div",ar,[f("div",{class:"flex-1 border border-solid border-[var(--el-border-color-lighter)] p-[2rem] flex flex-col hover:shadow-sm transition-shadow relative overflow-hidden request-card",onClick:o[0]||(o[0]=function(e){return t.$emit("clickRequest")})},[o[2]||(o[2]=f("div",{class:"text-[14px] mb-2 flex items-center"},[f("span",{class:"w-[0.4rem] h-[1.4rem] block rounded mr-4 bg-[--el-color-primary]"}),f("span",null,"请求数")],-1)),f("div",or,m(a(e.todayRequest)),1),f("div",sr,m(x(n).up?"↑":"↓")+" "+m(x(n).text),1),f("div",lr," 昨日"+m(x(r))+m(a(e.yesterdayTotal)),1),o[3]||(o[3]=f("img",{src:nr,class:"absolute right-0 bottom-[5px] w-[9rem] h-[10rem]"},null,-1))]),f("div",{class:"flex-1 border border-solid border-[var(--el-border-color-lighter)] p-[2rem] flex flex-col hover:shadow-sm transition-shadow relative overflow-hidden request-card",onClick:o[1]||(o[1]=function(e){return t.$emit("clickMalicious")})},[o[4]||(o[4]=f("div",{class:"text-[14px] mb-2 flex items-center"},[f("span",{class:"w-[0.4rem] h-[1.4rem] block rounded mr-4 bg-[#ff6b6b]"}),b("恶意请求")],-1)),f("div",ur,m(a(e.maliciousRequest)),1),f("div",hr,m(x(i).up?"↑":"↓")+" "+m(x(i).text),1),f("div",cr," 昨日总数:"+m(e.yesterdayMaliciousRequest),1),o[5]||(o[5]=f("img",{src:ir,class:"absolute right-0 bottom-[5px] w-[9rem] h-[10rem]"},null,-1))])])}}}),[["__scopeId","data-v-bbf9f20e"]]),fr=u({__name:"traffic-filter-chart",props:{chart:{}},setup:function(e){return function(t,r){return c(),w(T(e.chart),{style:{height:"154px",width:"100%"}})}}}),pr={class:"flex flex-col h-full"},mr={class:"flex-1"},gr=u({__name:"realtime-qps",props:{chart:{}},setup:function(e){return function(t,r){return c(),d("div",pr,[f("div",mr,[(c(),w(T(e.chart),{style:{height:"100%",width:"100%"}}))])])}}}),vr={class:"flex flex-col h-full"},_r={class:"flex-1"},yr=u({__name:"realtime-traffic",props:{chart:{}},setup:function(e){return function(t,r){return c(),d("div",vr,[f("div",_r,[(c(),w(T(e.chart),{style:{height:"100%",width:"100%"}}))])])}}}),xr={class:"flex flex-col h-full"},br={class:"flex-1"},wr=u({__name:"realtime-latency",props:{chart:{}},setup:function(e){return function(t,r){return c(),d("div",xr,[f("div",br,[(c(),w(T(e.chart),{style:{height:"100%",width:"100%"}}))])])}}}),Tr={"阿富汗":[67.709953,33.93911],"安哥拉":[17.873887,-11.202692],"阿尔巴尼亚":[20.168331,41.153332],"阿联酋":[53.847818,23.424076],"阿根廷":[-63.616672,-38.416097],"亚美尼亚":[45.038189,40.069099],"法属南半球和南极领地":[69.348557,-49.280366],"澳大利亚":[133.775136,-25.274398],"奥地利":[14.550072,47.516231],"阿塞拜疆":[47.576927,40.143105],"布隆迪":[29.918886,-3.373056],"比利时":[4.469936,50.503887],"贝宁":[2.315834,9.30769],"布基纳法索":[-1.561593,12.238333],"孟加拉国":[90.356331,23.684994],"保加利亚":[25.48583,42.733883],"巴哈马":[-77.39628,25.03428],"波斯尼亚和黑塞哥维那":[17.679076,43.915886],"白俄罗斯":[27.953389,53.709807],"伯利兹":[-88.49765,17.189877],"百慕大":[-64.7505,32.3078],"玻利维亚":[-63.588653,-16.290154],"巴西":[-51.92528,-14.235004],"文莱":[114.727669,4.535277],"不丹":[90.433601,27.514162],"博茨瓦纳":[24.684866,-22.328474],"中非共和国":[20.939444,6.611111],"加拿大":[-106.346771,56.130366],"瑞士":[8.227512,46.818188],"智利":[-71.542969,-35.675147],"中国":[104.195397,35.86166],"象牙海岸":[-5.54708,7.539989],"喀麦隆":[12.354722,7.369722],"刚果民主共和国":[21.758664,-4.038333],"刚果共和国":[15.827659,-.228021],"哥伦比亚":[-74.297333,4.570868],"哥斯达黎加":[-83.753428,9.748917],"古巴":[-77.781167,21.521757],"北塞浦路斯":[33.429859,35.126413],"塞浦路斯":[33.429859,35.126413],"捷克共和国":[15.472962,49.817492],"德国":[10.451526,51.165691],"吉布提":[42.590275,11.825138],"丹麦":[9.501785,56.26392],"多明尼加共和国":[-70.162651,18.735693],"阿尔及利亚":[1.659626,28.033886],"厄瓜多尔":[-78.183406,-1.831239],"埃及":[30.802498,26.820553],"厄立特里亚":[39.782334,15.179384],"西班牙":[-3.74922,40.463667],"爱沙尼亚":[25.013607,58.595272],"埃塞俄比亚":[40.489673,9.145],"斐":[178.065032,-17.713371],"福克兰群岛":[-59.523613,-51.796253],"法国":[2.213749,46.227638],"加蓬":[11.609444,-.803689],"英国":[-3.435973,55.378051],"格鲁吉亚":[-82.900075,32.165622],"加纳":[-1.023194,7.946527],"几内亚":[-9.696645,9.945587],"冈比亚":[-15.310139,13.443182],"几内亚比绍":[-15.180413,11.803749],"赤道几内亚":[10.267895,1.650801],"希腊":[21.824312,39.074208],"格陵兰":[-42.604303,71.706936],"危地马拉":[-90.230759,15.783471],"法属圭亚那":[-53.125782,3.933889],"圭亚那":[-58.93018,4.860416],"洪都拉斯":[-86.241905,15.2],"克罗地亚":[15.2,45.1],"海地":[-72.285215,18.971187],"匈牙利":[19.503304,47.162494],"印尼":[113.921327,-.789275],"爱尔兰":[-8.24389,53.41291],"伊朗":[53.688046,32.427908],"伊拉克":[43.679291,33.223191],"冰岛":[-19.020835,64.963051],"以色列":[34.851612,31.046051],"意大利":[12.56738,41.87194],"牙买加":[-77.297508,18.109581],"约旦":[36.238414,30.585164],"日本":[138.252924,36.204824],"哈萨克斯坦":[66.923684,48.019573],"肯尼亚":[37.906193,-.023559],"吉尔吉斯斯坦":[74.766098,41.20438],"柬埔寨":[104.990963,12.565679],"韩国":[127.766922,35.907757],"科索沃":[20.902977,42.602636],"科威特":[47.481766,29.31166],"老挝":[102.495496,19.85627],"黎巴嫩":[35.862285,33.854721],"利比里亚":[-9.429499,6.428055],"利比亚":[17.228331,26.3351],"斯里兰卡":[80.771797,7.873054],"莱索托":[28.233608,-29.609988],"立陶宛":[23.881275,55.169438],"卢森堡":[6.129583,49.815273],"拉脱维亚":[24.603189,56.879635],"摩洛哥":[-7.09262,31.791702],"摩尔多瓦":[28.369885,47.411631],"马达加斯加":[46.869107,-18.766947],"墨西哥":[-102.552784,23.634501],"马其顿":[21.745275,41.608635],"马里":[-3.996166,17.570692],"缅甸":[95.956223,21.913965],"黑山":[19.37439,42.708678],"蒙古":[103.846656,46.862496],"莫桑比克":[35.529562,-18.665695],"毛里塔尼亚":[-10.940835,21.00789],"马拉维":[34.301525,-13.254308],"马来西亚":[101.975766,4.210484],"纳米比亚":[18.49041,-22.95764],"新喀里多尼亚":[165.618042,-20.904305],"尼日尔":[8.081666,17.607789],"尼日利亚":[8.675277,9.081999],"尼加拉瓜":[-85.207229,12.865416],"荷兰":[5.291266,52.132633],"挪威":[8.468946,60.472024],"尼泊尔":[84.124008,28.394857],"新西兰":[174.885971,-40.900557],"阿曼":[55.923255,21.512583],"巴基斯坦":[69.345116,30.375321],"巴拿马":[-80.782127,8.537981],"秘鲁":[-75.015152,-9.189967],"菲律宾":[121.774017,12.879721],"巴布亚新几内亚":[143.95555,-6.314993],"波兰":[19.145136,51.919438],"波多黎各":[-66.590149,18.220833],"北朝鲜":[127.510093,40.339852],"葡萄牙":[-8.224454,39.399872],"巴拉圭":[-58.443832,-23.442503],"卡塔尔":[51.183884,25.354826],"罗马尼亚":[24.96676,45.943161],"俄罗斯":[105.318756,61.52401],"卢旺达":[29.873888,-1.940278],"西撒哈拉":[-12.885834,24.215527],"沙特阿拉伯":[45.079162,23.885942],"苏丹":[30.217636,12.862807],"南苏丹":[31.306979,6.876992],"塞内加尔":[-14.452362,14.497401],"所罗门群岛":[160.156194,-9.64571],"塞拉利昂":[-11.779889,8.460555],"萨尔瓦多":[-88.89653,13.794185],"索马里兰":[46.825284,9.411743],"索马里":[46.199616,5.152149],"塞尔维亚共和国":[21.005859,44.016521],"苏里南":[-56.027783,3.919305],"斯洛伐克":[19.699024,48.669026],"斯洛文尼亚":[14.995463,46.151241],"瑞典":[18.643501,60.128161],"斯威士兰":[31.465866,-26.522503],"叙利亚":[38.996815,34.802075],"乍得":[18.732207,15.454166],"多哥":[.824782,8.619543],"泰国":[100.992541,15.870032],"塔吉克斯坦":[71.276093,38.861034],"土库曼斯坦":[59.556278,38.969719],"东帝汶":[125.727539,-8.874217],"特里尼达和多巴哥":[-61.222503,10.691803],"突尼斯":[9.537499,33.886917],"土耳其":[35.243322,38.963745],"坦桑尼亚联合共和国":[34.888822,-6.369028],"乌干达":[32.290275,1.373333],"乌克兰":[31.16558,48.379433],"乌拉圭":[-55.765835,-32.522779],"美国":[-95.712891,37.09024],"乌兹别克斯坦":[64.585262,41.377491],"委内瑞拉":[-66.58973,6.42375],"越南":[108.277199,14.058324],"瓦努阿图":[166.959158,-15.376706],"西岸":[35.302723,31.94657],"也门":[48.516388,15.552727],"南非":[22.937506,-30.559482],"赞比亚":[27.849332,-13.133897],"津巴布韦":[29.154857,-19.015438],"科摩罗":[43.872219,-11.875001],"印度尼西亚":[106.515414,-6.10304],"印度":[78.96288,20.593684]},Sr=u({__name:"attack-map-2d",props:{mapData:{},mapRegion:{}},setup:function(e){var t=e,n=V({options:{}}),a=["北京","天津","上海","重庆"],s=["内蒙古","广西","西藏","宁夏","新疆"],u=["香港","澳门"];function d(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];t?_t():yt();var n=t?r.map(function(e){return l(l({},e),{},{name:(t=e.name,"宁夏"===t?"宁夏回族自治区":"新疆"===t?"新疆维吾尔自治区":"广西"===t?"广西壮族自治区":a.includes(t)?"".concat(t,"市"):s.includes(t)?"".concat(t,"自治区"):u.includes(t)?"".concat(t,"特别行政区"):"省"!==t[t.length-1]?"".concat(t,"省"):t)});var t}):r,i=t||!r.length?[]:function(e){return h(e).sort(function(e,t){return t.value-e.value}).slice(0,5).reduce(function(e,t){var r=Tr[t.name];return r&&e.push({name:t.name,coord:r,value:t.value}),e},[])}(r);e.setOption({tooltip:{trigger:"item",formatter:function(e){var t,r=String(null!==(t=e.value)&&void 0!==t?t:"").split(".")[0];return"NaN"===r?e.name:"".concat(e.name,"<br/>攻击次数:").concat(r)}},visualMap:{min:0,max:100,left:-200,range:null,inRange:{color:["rgba(62,183,82,0.13)","rgba(62,183,82,0.5)","#3eb752"]}},series:[{type:"map",map:t?"china":"world",layoutCenter:["50%","50%"],layoutSize:t?"110%":"150%",roam:!1,label:{show:!1},itemStyle:{emphasis:{borderColor:"#fff",areaColor:"#20a53a"},normal:{borderColor:"#fff",areaColor:"#E6E6E6"}},data:n,markPoint:{show:!t&&i.length>0,symbol:"pin",symbolSize:50,label:{show:!0,formatter:function(e){return e.data.value}},itemStyle:{color:"#4e5c6b",borderColor:"#6956ff",borderWidth:4},data:i}}]})}return S(function(){return[t.mapData,t.mapRegion]},function(){var e=o(r().m(function e(t){var a,o,s,l,u;return r().w(function(e){for(;;)switch(e.n){case 0:return a=i(t,2),o=a[0],s=a[1],l="china"===s,e.n=1,n.getEChart();case 1:if(u=e.v){e.n=2;break}return e.a(2);case 2:return d(u,l,null!=o?o:[]),e.n=3,M();case 3:u.resize();case 4:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),{immediate:!0}),function(e,t){return c(),w(T(x(n).BtECharts),{style:{height:"100%",width:"100%"}})}}});function Mr(e,r,n){"object"==t(r)&&(n=r,r=null);var i,a=this;if(!(e instanceof Function))for(var o in i=[],e)e.hasOwnProperty(o)&&i.push(o);var s=function(t){if(a.apply(this,arguments),e instanceof Function?Ar(this,e.call(this,t)):function(e,t,r){for(var n=0;n<r.length;n++){var i=r[n];e[i]=t[i]}}(this,e,i),this.constructor===s)for(var r=s.__initializers__,n=0;n<r.length;n++)r[n].apply(this,arguments)};s.__super__=a,a.__initializers__?s.__initializers__=a.__initializers__.slice():s.__initializers__=[],r&&s.__initializers__.push(r);var l=function(){};return l.prototype=a.prototype,s.prototype=new l,s.prototype.constructor=s,Ar(s.prototype,n),s.extend=a.extend,s.derive=a.extend,s}function Ar(e,t){if(t)for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])}W([j,X]),W(q);var Er={extend:Mr,derive:Mr};function Cr(e,t){this.action=e,this.context=t}var Dr={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],r=t.length,n=-1,i=arguments;switch(i.length){case 1:for(;++n<r;)t[n].action.call(t[n].context);return;case 2:for(;++n<r;)t[n].action.call(t[n].context,i[1]);return;case 3:for(;++n<r;)t[n].action.call(t[n].context,i[1],i[2]);return;case 4:for(;++n<r;)t[n].action.call(t[n].context,i[1],i[2],i[3]);return;case 5:for(;++n<r;)t[n].action.call(t[n].context,i[1],i[2],i[3],i[4]);return;default:for(;++n<r;)t[n].action.apply(t[n].context,Array.prototype.slice.call(i,1));return}}},on:function(e,t,r){if(e&&t){var n=this.__handlers__||(this.__handlers__={});if(n[e]){if(this.has(e,t))return}else n[e]=[];var i=new Cr(t,r||this);return n[e].push(i),this}},once:function(e,t,r){if(e&&t){var n=this;return this.on(e,function r(){n.off(e,r),t.apply(this,arguments)},r)}},before:function(e,t,r){if(e&&t)return e="before"+e,this.on(e,t,r)},after:function(e,t,r){if(e&&t)return e="after"+e,this.on(e,t,r)},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 r=this.__handlers__||(this.__handlers__={});if(t){if(r[e]){for(var n=r[e],i=[],a=0;a<n.length;a++)t&&n[a].action!==t&&i.push(n[a]);r[e]=i}return this}r[e]=[]},has:function(e,t){var r=this.__handlers__;if(!r||!r[e])return!1;for(var n=r[e],i=0;i<n.length;i++)if(n[i].action===t)return!0}},Lr=0,Pr=Array.prototype.forEach,Or={genGUID:function(){return++Lr},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;for(var r=e.split("/"),n=t.split("/"),i=r[0];"."===i||".."===i;)".."===i&&n.pop(),r.shift(),i=r[0];return n.join("/")+"/"+r.join("/")},extend:function(e,t){if(t)for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},defaults:function(e,t){if(t)for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e},extendWithPropList:function(e,t,r){if(t)for(var n=0;n<r.length;n++){var i=r[n];e[i]=t[i]}return e},defaultsWithPropList:function(e,t,r){if(t)for(var n=0;n<r.length;n++){var i=r[n];null==e[i]&&(e[i]=t[i])}return e},each:function(e,t,r){if(e&&t)if(e.forEach&&e.forEach===Pr)e.forEach(t,r);else if(e.length===+e.length)for(var n=0,i=e.length;n<i;n++)t.call(r,e[n],n,e);else for(var a in e)e.hasOwnProperty(a)&&t.call(r,e[a],a,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(Or.isObject(e)){if(Or.isArray(e))return e.slice();if(Or.isArrayLike(e)){for(var t=new e.constructor(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}return Or.extend({},e)}return e}},Nr=function(){this.__uid__=Or.genGUID()};Nr.__initializers__=[function(e){Or.extend(this,e)}],Or.extend(Nr,Er),Or.extend(Nr.prototype,Dr);var Rr=["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"],Ir=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];function Br(e){for(var t={},r={},n=0;n<Rr.length;n++){a(Rr[n])}for(n=0;n<Ir.length;n++){var i=Ir[n];r[i]=e.getParameter(e[i])}function a(r){if(e.getExtension){var n=e.getExtension(r);n||(n=e.getExtension("MOZ_"+r)),n||(n=e.getExtension("WEBKIT_"+r)),t[r]=n}}this.getExtension=function(e){return e in t||a(e),t[e]},this.getParameter=function(e){return r[e]}}var zr=256,Fr=1024,kr=16384,Ur=0,Gr=1,Hr=2,Vr=3,Wr=4,jr=5,Xr=6,qr=35040,Zr=35044,Yr=35048,Kr=1028,Qr=1029,Jr=1032,$r=2304,en=2305,tn=5120,rn=5121,nn=5122,an=5123,on=5124,sn=5125,ln=5126,un=6402,hn=6406,cn=6407,dn=6408,fn=6409,pn=6410,mn=9728,gn=9729,vn=9984,_n=9985,yn=9986,xn=9987,bn=3553,wn=34067,Tn=10497,Sn=33071,Mn=33648,An=36160,En=36161,Cn=34041,Dn=36064,Ln=36096,Pn=36128,On=33306;var Nn,Rn={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 r=t.loaded/t.total;e.onprogress(r,t.loaded,t.total)}else e.onprogress(null)}),t.onload=function(r){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}},In={supportWebGL:function(){if(null==Nn)try{var e=document.createElement("canvas");if(!(e.getContext("webgl")||e.getContext("experimental-webgl")))throw new Error}catch(Sc){Nn=!1}return Nn}};In.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,In.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,In.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,In.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,In.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,In.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,In.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var Bn={};"undefined"!=typeof window?Bn=window:"undefined"!=typeof global&&(Bn=global),In.requestAnimationFrame=Bn.requestAnimationFrame||Bn.msRequestAnimationFrame||Bn.mozRequestAnimationFrame||Bn.webkitRequestAnimationFrame||function(e){setTimeout(e,16)},In.createCanvas=function(){return document.createElement("canvas")},In.createImage=function(){return new Bn.Image},In.request={get:Rn.get},In.addEventListener=function(e,t,r,n){e.addEventListener(t,r,n)},In.removeEventListener=function(e,t,r){e.removeEventListener(t,r)};var zn=function(){this.head=null,this.tail=null,this._length=0};zn.prototype.insert=function(e){var t=new zn.Entry(e);return this.insertEntry(t),t},zn.prototype.insertAt=function(e,t){if(!(e<0)){for(var r=this.head,n=0;r&&n!=e;)r=r.next,n++;if(r){var i=new zn.Entry(t),a=r.prev;a?(a.next=i,i.prev=a):this.head=i,i.next=r,r.prev=i}else this.insert(t)}},zn.prototype.insertBeforeEntry=function(e,t){var r=new zn.Entry(e),n=t.prev;n?(n.next=r,r.prev=n):this.head=r,r.next=t,t.prev=r,this._length++},zn.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},zn.prototype.remove=function(e){var t=e.prev,r=e.next;t?t.next=r:this.head=r,r?r.prev=t:this.tail=t,e.next=e.prev=null,this._length--},zn.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t?(this.remove(t),t.value):void 0}},zn.prototype.getHead=function(){if(this.head)return this.head.value},zn.prototype.getTail=function(){if(this.tail)return this.tail.value},zn.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t.value}},zn.prototype.indexOf=function(e){for(var t=this.head,r=0;t;){if(t.value===e)return r;t=t.next,r++}},zn.prototype.length=function(){return this._length},zn.prototype.isEmpty=function(){return 0===this._length},zn.prototype.forEach=function(e,t){for(var r=this.head,n=0,i=void 0!==t;r;)i?e.call(t,r.value,n):e(r.value,n),r=r.next,n++},zn.prototype.clear=function(){this.tail=this.head=null,this._length=0},zn.Entry=function(e){this.value=e,this.next=null,this.prev=null};var Fn=function(e){this._list=new zn,this._map={},this._maxSize=e||10};Fn.prototype.setMaxSize=function(e){this._maxSize=e},Fn.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){var r=this._list.length();if(r>=this._maxSize&&r>0){var n=this._list.head;this._list.remove(n),delete this._map[n.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},Fn.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},Fn.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},Fn.prototype.clear=function(){this._list.clear(),this._map={}};var kn={},Un={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 Gn(e){return(e=Math.round(e))<0?0:e>255?255:e}function Hn(e){return e<0?0:e>1?1:e}function Vn(e){return e.length&&"%"===e.charAt(e.length-1)?Gn(parseFloat(e)/100*255):Gn(parseInt(e,10))}function Wn(e){return e.length&&"%"===e.charAt(e.length-1)?Hn(parseFloat(e)/100):Hn(parseFloat(e))}function jn(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}function Xn(e,t,r){return e+(t-e)*r}function qn(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function Zn(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var Yn=new Fn(20),Kn=null;function Qn(e,t){Kn&&Zn(Kn,t),Kn=Yn.put(e,Kn||t.slice())}function Jn(e,t){var r=(parseFloat(e[0])%360+360)%360/360,n=Wn(e[1]),i=Wn(e[2]),a=i<=.5?i*(n+1):i+n-i*n,o=2*i-a;return qn(t=t||[],Gn(255*jn(o,a,r+1/3)),Gn(255*jn(o,a,r)),Gn(255*jn(o,a,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}kn.parse=function(e,t){if(e){t=t||[];var r=Yn.get(e);if(r)return Zn(t,r);var n,i=(e+="").replace(/ /g,"").toLowerCase();if(i in Un)return Zn(t,Un[i]),Qn(e,t),t;if("#"===i.charAt(0))return 4===i.length?(n=parseInt(i.substr(1),16))>=0&&n<=4095?(qn(t,(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,1),Qn(e,t),t):void qn(t,0,0,0,1):7===i.length?(n=parseInt(i.substr(1),16))>=0&&n<=16777215?(qn(t,(16711680&n)>>16,(65280&n)>>8,255&n,1),Qn(e,t),t):void qn(t,0,0,0,1):void 0;var a=i.indexOf("("),o=i.indexOf(")");if(-1!==a&&o+1===i.length){var s=i.substr(0,a),l=i.substr(a+1,o-(a+1)).split(","),u=1;switch(s){case"rgba":if(4!==l.length)return void qn(t,0,0,0,1);u=Wn(l.pop());case"rgb":return 3!==l.length?void qn(t,0,0,0,1):(qn(t,Vn(l[0]),Vn(l[1]),Vn(l[2]),u),Qn(e,t),t);case"hsla":return 4!==l.length?void qn(t,0,0,0,1):(l[3]=Wn(l[3]),Jn(l,t),Qn(e,t),t);case"hsl":return 3!==l.length?void qn(t,0,0,0,1):(Jn(l,t),Qn(e,t),t);default:return}}qn(t,0,0,0,1)}},kn.parseToFloat=function(e,t){if(t=kn.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},kn.lift=function(e,t){var r=kn.parse(e);if(r){for(var n=0;n<3;n++)r[n]=t<0?r[n]*(1-t)|0:(255-r[n])*t+r[n]|0;return kn.stringify(r,4===r.length?"rgba":"rgb")}},kn.toHex=function(e){var t=kn.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},kn.fastLerp=function(e,t,r){if(t&&t.length&&e>=0&&e<=1){r=r||[];var n=e*(t.length-1),i=Math.floor(n),a=Math.ceil(n),o=t[i],s=t[a],l=n-i;return r[0]=Gn(Xn(o[0],s[0],l)),r[1]=Gn(Xn(o[1],s[1],l)),r[2]=Gn(Xn(o[2],s[2],l)),r[3]=Hn(Xn(o[3],s[3],l)),r}},kn.fastMapToColor=kn.fastLerp,kn.lerp=function(e,t,r){if(t&&t.length&&e>=0&&e<=1){var n=e*(t.length-1),i=Math.floor(n),a=Math.ceil(n),o=kn.parse(t[i]),s=kn.parse(t[a]),l=n-i,u=kn.stringify([Gn(Xn(o[0],s[0],l)),Gn(Xn(o[1],s[1],l)),Gn(Xn(o[2],s[2],l)),Hn(Xn(o[3],s[3],l))],"rgba");return r?{color:u,leftIndex:i,rightIndex:a,value:n}:u}},kn.mapToColor=kn.lerp,kn.modifyHSL=function(e,t,r,n){if(e=kn.parse(e))return e=function(e){if(e){var t,r,n=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),l=s-o,u=(s+o)/2;if(0===l)t=0,r=0;else{r=u<.5?l/(s+o):l/(2-s-o);var h=((s-n)/6+l/2)/l,c=((s-i)/6+l/2)/l,d=((s-a)/6+l/2)/l;n===s?t=d-c:i===s?t=1/3+h-d:a===s&&(t=2/3+c-h),t<0&&(t+=1),t>1&&(t-=1)}var f=[360*t,r,u];return null!=e[3]&&f.push(e[3]),f}}(e),null!=t&&(e[0]=(i=t,(i=Math.round(i))<0?0:i>360?360:i)),null!=r&&(e[1]=Wn(r)),null!=n&&(e[2]=Wn(n)),kn.stringify(Jn(e),"rgba");var i},kn.modifyAlpha=function(e,t){if((e=kn.parse(e))&&null!=t)return e[3]=Hn(t),kn.stringify(e,"rgba")},kn.stringify=function(e,t){if(e&&e.length){var r=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(r+=","+e[3]),t+"("+r+")"}};var $n=kn.parseToFloat,ei={};function ti(e){var t=Object.keys(e);t.sort();for(var r=[],n=0;n<t.length;n++){var i=t[n],a=e[i];null===a?r.push(i):r.push(i+" "+a.toString())}return r.join("\n")}var ri,ni=Nr.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 r=this.uniforms[e];r&&("string"==typeof t&&(t=$n(t)||t),r.value=t,this.autoUpdateTextureStatus&&"t"===r.type&&(t?this.enableTexture(e):this.disableTexture(e)))},setUniforms:function(e){for(var t in e){var r=e[t];this.setUniform(t,r)}},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,r){if("object"===t(e))for(var n in e){var i=e[n];this.setUniform(n,i)}else this.setUniform(e,r)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var r=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var n=this.uniforms;this._enabledUniforms=Object.keys(n),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,a=this.fragmentDefines;if(this.vertexDefines=Or.clone(e.vertexDefines),this.fragmentDefines=Or.clone(e.fragmentDefines),t){for(var o in r)n[o]&&(n[o].value=r[o].value);Or.defaults(this.vertexDefines,i),Or.defaults(this.fragmentDefines,a)}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=Or.clone(this.vertexDefines),e.fragmentDefines=Or.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,r){var n=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(r=t,t=e,e="both"),r=null!=r?r:null,"vertex"!==e&&"both"!==e||n[t]!==r&&(n[t]=r,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==r&&(i[t]=r,"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 r=this._textureStatus[e];if(r)r.enabled||(r.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 r=this._textureStatus[e];if(r)!r.enabled||(r.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 r in t)t[r].enabled&&e.push(r);return e},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(e,t,r){r.sort();for(var n=[],i=0;i<r.length;i++){var a=r[i];n.push(a)}var o=ti(e)+"\n"+ti(t)+"\n"+n.join("\n");if(ei[o])return ei[o];var s=Or.genGUID();return ei[o]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),ii=1e-6,ai=Array,oi=Math.random,si={};si.create=function(){var e=new ai(2);return e[0]=0,e[1]=0,e},si.clone=function(e){var t=new ai(2);return t[0]=e[0],t[1]=e[1],t},si.fromValues=function(e,t){var r=new ai(2);return r[0]=e,r[1]=t,r},si.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},si.set=function(e,t,r){return e[0]=t,e[1]=r,e},si.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},si.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e},si.sub=si.subtract,si.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e},si.mul=si.multiply,si.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e},si.div=si.divide,si.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},si.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},si.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},si.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},si.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)},si.dist=si.distance,si.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n},si.sqrDist=si.squaredDistance,si.length=function(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)},si.len=si.length,si.squaredLength=function(e){var t=e[0],r=e[1];return t*t+r*r},si.sqrLen=si.squaredLength,si.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},si.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},si.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},si.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},si.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},si.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},si.random=function(e,t){t=t||1;var r=2*GLMAT_RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},si.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},si.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},si.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},si.transformMat4=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},si.forEach=(ri=si.create(),function(e,t,r,n,i,a){var o,s;for(t||(t=2),r||(r=0),s=n?Math.min(n*t+r,e.length):e.length,o=r;o<s;o+=t)ri[0]=e[o],ri[1]=e[o+1],i(ri,ri,a),e[o]=ri[0],e[o+1]=ri[1];return e});var li=function(e,t){e=e||0,t=t||0,this.array=si.fromValues(e,t),this._dirty=!0};if(li.prototype={constructor:li,add:function(e){return si.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 li(this.x,this.y)},copy:function(e){return si.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return si.cross(e.array,this.array,t.array),e._dirty=!0,this},dist:function(e){return si.dist(this.array,e.array)},distance:function(e){return si.distance(this.array,e.array)},div:function(e){return si.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return si.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return si.dot(this.array,e.array)},len:function(){return si.len(this.array)},length:function(){return si.length(this.array)},lerp:function(e,t,r){return si.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return si.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return si.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return si.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return si.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return si.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return si.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return si.random(this.array,e),this._dirty=!0,this},scale:function(e){return si.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return si.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return si.sqrDist(this.array,e.array)},squaredDistance:function(e){return si.squaredDistance(this.array,e.array)},sqrLen:function(){return si.sqrLen(this.array)},squaredLength:function(){return si.squaredLength(this.array)},sub:function(e){return si.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return si.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat2:function(e){return si.transformMat2(this.array,this.array,e.array),this._dirty=!0,this},transformMat2d:function(e){return si.transformMat2d(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return si.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return si.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 ui=li.prototype;Object.defineProperty(ui,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Object.defineProperty(ui,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}})}li.add=function(e,t,r){return si.add(e.array,t.array,r.array),e._dirty=!0,e},li.set=function(e,t,r){return si.set(e.array,t,r),e._dirty=!0,e},li.copy=function(e,t){return si.copy(e.array,t.array),e._dirty=!0,e},li.cross=function(e,t,r){return si.cross(e.array,t.array,r.array),e._dirty=!0,e},li.distance=li.dist=function(e,t){return si.distance(e.array,t.array)},li.divide=li.div=function(e,t,r){return si.divide(e.array,t.array,r.array),e._dirty=!0,e},li.dot=function(e,t){return si.dot(e.array,t.array)},li.len=function(e){return si.length(e.array)},li.lerp=function(e,t,r,n){return si.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},li.min=function(e,t,r){return si.min(e.array,t.array,r.array),e._dirty=!0,e},li.max=function(e,t,r){return si.max(e.array,t.array,r.array),e._dirty=!0,e},li.multiply=li.mul=function(e,t,r){return si.multiply(e.array,t.array,r.array),e._dirty=!0,e},li.negate=function(e,t){return si.negate(e.array,t.array),e._dirty=!0,e},li.normalize=function(e,t){return si.normalize(e.array,t.array),e._dirty=!0,e},li.random=function(e,t){return si.random(e.array,t),e._dirty=!0,e},li.scale=function(e,t,r){return si.scale(e.array,t.array,r),e._dirty=!0,e},li.scaleAndAdd=function(e,t,r,n){return si.scaleAndAdd(e.array,t.array,r.array,n),e._dirty=!0,e},li.squaredDistance=li.sqrDist=function(e,t){return si.sqrDist(e.array,t.array)},li.squaredLength=li.sqrLen=function(e){return si.sqrLen(e.array)},li.subtract=li.sub=function(e,t,r){return si.subtract(e.array,t.array,r.array),e._dirty=!0,e},li.transformMat2=function(e,t,r){return si.transformMat2(e.array,t.array,r.array),e._dirty=!0,e},li.transformMat2d=function(e,t,r){return si.transformMat2d(e.array,t.array,r.array),e._dirty=!0,e},li.transformMat3=function(e,t,r){return si.transformMat3(e.array,t.array,r.array),e._dirty=!0,e},li.transformMat4=function(e,t,r){return si.transformMat4(e.array,t.array,r.array),e._dirty=!0,e};var hi={};function ci(e){for(var t=e.split("\n"),r=0,n=t.length;r<n;r++)t[r]=r+1+": "+t[r];return t.join("\n")}function di(e,t,r){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),ci(r)].join("\n")}var fi=new In.Float32Array(16),pi=Nr.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,r){t&&(e.gl.activeTexture(e.gl.TEXTURE0+r),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 r=this._textureSlot;return this.useTextureSlot(e,t,r),this._textureSlot++,r},setUniform:function(e,t,r,n){var i=this._locations[r];if(null==i)return!1;switch(t){case"m4":if(!(n instanceof Float32Array)){for(var a=0;a<n.length;a++)fi[a]=n[a];n=fi}e.uniformMatrix4fv(i,!1,n);break;case"2i":e.uniform2i(i,n[0],n[1]);break;case"2f":e.uniform2f(i,n[0],n[1]);break;case"3i":e.uniform3i(i,n[0],n[1],n[2]);break;case"3f":e.uniform3f(i,n[0],n[1],n[2]);break;case"4i":e.uniform4i(i,n[0],n[1],n[2],n[3]);break;case"4f":e.uniform4f(i,n[0],n[1],n[2],n[3]);break;case"1i":e.uniform1i(i,n);break;case"1f":e.uniform1f(i,n);break;case"1fv":e.uniform1fv(i,n);break;case"1iv":e.uniform1iv(i,n);break;case"2iv":e.uniform2iv(i,n);break;case"2fv":e.uniform2fv(i,n);break;case"3iv":e.uniform3iv(i,n);break;case"3fv":e.uniform3fv(i,n);break;case"4iv":e.uniform4iv(i,n);break;case"4fv":e.uniform4fv(i,n);break;case"m2":case"m2v":e.uniformMatrix2fv(i,!1,n);break;case"m3":case"m3v":e.uniformMatrix3fv(i,!1,n);break;case"m4v":if(Array.isArray(n)&&Array.isArray(n[0])){var o=new In.Float32Array(16*n.length),s=0;for(a=0;a<n.length;a++)for(var l=n[a],u=0;u<16;u++)o[s++]=l[u];e.uniformMatrix4fv(i,!1,o)}else e.uniformMatrix4fv(i,!1,n)}return!0},setUniformOfSemantic:function(e,t,r){var n=this.uniformSemantics[t];return!!n&&this.setUniform(e,n.type,n.symbol,r)},enableAttributes:function(e,t,r){var n,i=e.gl,a=this._program,o=this._locations;(n=r?r.__enabledAttributeList:hi[e.__uid__])||(n=r?r.__enabledAttributeList=[]:hi[e.__uid__]=[]);for(var s=[],l=0;l<t.length;l++){var u=t[l];if(this.attributes[u]){var h=o[u];if(null==h){if(-1===(h=i.getAttribLocation(a,u))){s[l]=-1;continue}o[u]=h}s[l]=h,n[h]?n[h]=2:n[h]=1}else s[l]=-1}for(l=0;l<n.length;l++)switch(n[l]){case 1:i.enableVertexAttribArray(l),n[l]=3;break;case 2:n[l]=3;break;case 3:i.disableVertexAttribArray(l),n[l]=0}return s},getAttribLocation:function(e,t){var r=this._locations,n=r[t];return null==n&&(n=e.getAttribLocation(this._program,t),r[t]=n),n},buildProgram:function(e,t,r,n){var i=e.createShader(e.VERTEX_SHADER),a=e.createProgram();e.shaderSource(i,r),e.compileShader(i);var o=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(o,n),e.compileShader(o);var s=di(e,i,r);if(s)return s;if(s=di(e,o,n))return s;if(e.attachShader(a,i),e.attachShader(a,o),t.attributeSemantics.POSITION)e.bindAttribLocation(a,0,t.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);e.bindAttribLocation(a,0,l[0])}if(e.linkProgram(a),e.deleteShader(i),e.deleteShader(o),this._program=a,this.vertexCode=r,this.fragmentCode=n,!e.getProgramParameter(a,e.LINK_STATUS))return"Could not link program\n"+e.getProgramInfoLog(a);for(var u=0;u<t.uniforms.length;u++){var h=t.uniforms[u];this._locations[h]=e.getUniformLocation(a,h)}}}),mi=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function gi(e,t,r){var n={};for(var i in r)n[i+"_COUNT"]=r[i];return e.replace(mi,function(e,r,i,a){var o="";isNaN(r)&&(r=r in t?t[r]:n[r]),isNaN(i)&&(i=i in t?t[i]:n[i]);for(var s=parseInt(r);s<parseInt(i);s++)o+="{"+a.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return o})}function vi(e,t,r){var n=[];if(t)for(var i in t){var a=t[i];a>0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;o<r.length;o++){var s=r[o];n.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in e){var l=e[s];null===l?n.push("#define "+s):n.push("#define "+s+" "+l.toString())}return n.join("\n")}function _i(e){this._renderer=e,this._cache={}}_i.prototype.getProgram=function(e,t,r){var n=this._cache,i=e.isSkinnedMesh&&e.isSkinnedMesh(),a=e.isInstancedMesh&&e.isInstancedMesh(),o="s"+t.shader.shaderID+"m"+t.getProgramKey();if(r&&(o+="se"+r.getProgramKey(e.lightGroup)),i&&(o+=",sk"+e.joints.length),a&&(o+=",is"),_=n[o])return _;var s=r?r.getLightsNumbers(e.lightGroup):{},l=this._renderer,u=l.gl,h=t.getEnabledTextures(),c="";if(i){var d={SKINNING:null,JOINT_COUNT:e.joints.length};e.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),c+="\n"+vi(d)+"\n"}a&&(c+="\n#define INSTANCING\n");var f=c+vi(t.vertexDefines,s,h),p=c+vi(t.fragmentDefines,s,h),m=f+"\n"+t.shader.vertex,g=["OES_standard_derivatives","EXT_shader_texture_lod"].filter(function(e){return null!=l.getGLExtension(e)});g.indexOf("EXT_shader_texture_lod")>=0&&(p+="\n#define SUPPORT_TEXTURE_LOD"),g.indexOf("OES_standard_derivatives")>=0&&(p+="\n#define SUPPORT_STANDARD_DERIVATIVES");var v,_,y=function(e){for(var t=[],r=0;r<e.length;r++)t.push("#extension GL_"+e[r]+" : enable");return t.join("\n")}(g)+"\n"+(["precision",v=t.precision,"float"].join(" ")+";\n"+["precision",v,"int"].join(" ")+";\n"+["precision",v,"sampler2D"].join(" ")+";\n\n")+p+"\n"+t.shader.fragment,x=gi(m,t.vertexDefines,s),b=gi(y,t.fragmentDefines,s);(_=new pi).uniformSemantics=t.shader.uniformSemantics,_.attributes=t.shader.attributes;var w=_.buildProgram(u,t.shader,x,b);return _.__error=w,n[o]=_,_};var yi=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,xi=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,bi=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,wi={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 Ti(e){for(var t=[],r=0;r<e;r++)t[r]=0;return t}var Si={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return Ti(2)},vec3:function(){return Ti(3)},vec4:function(){return Ti(4)},ivec2:function(){return Ti(2)},ivec3:function(){return Ti(3)},ivec4:function(){return Ti(4)},mat2:function(){return Ti(4)},mat3:function(){return Ti(9)},mat4:function(){return Ti(16)},array:function(){return[]}},Mi=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],Ai=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],Ei=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],Ci={vec4:4,vec3:3,vec2:2,float:1},Di={},Li={};function Pi(e){return e.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function Oi(){console.error("Wrong uniform/attributes syntax")}function Ni(e,t){for(var r=/[,=\(\):]/,n=t.replace(/:\s*\[\s*(.*)\s*\]/g,"="+e+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),i=[],a=0;a<n.length;a++)n[a].match(r)?i.push(n[a].charAt(0),n[a].slice(1)):i.push(n[a]);var o,s=0,l={},u=null;function h(e){e||Oi();var t=e.match(/\[(.*?)\]/);o=e.replace(/\[(.*?)\]/,""),l[o]={},t&&(l[o].isArray=!0,l[o].arraySize=t[1])}h((n=i)[0]);for(a=1;a<n.length;a++){var c=n[a];if(c)if("="!==c)if(":"!==c)if(","!==c)if(")"!==c)if("("!==c)if(c.indexOf("vec")>=0){if(1!==s&&4!==s){Oi();break}s=2,u=[]}else if(1!==s)if(4!==s)h(c),s=0;else{var d=c;Mi.indexOf(d)>=0||Ai.indexOf(d)>=0||Ei.indexOf(d)>=0?l[o].semantic=d:"ignore"===d||"unconfigurable"===d?l[o].ignore=!0:l[o].value="bool"===e?"true"===d:parseFloat(d)}else l[o].value="bool"===e?"true"===c:parseFloat(c),u=null;else{if(2!==s){Oi();break}if(!(u instanceof Array)){Oi();break}u.push(+n[++a])}else l[o].value=new In.Float32Array(u),u=null,s=5;else if(2===s){if(!(u instanceof Array)){Oi();break}u.push(+n[++a])}else s=5;else s=4;else{if(0!==s&&3!==s){Oi();break}s=1}}return l}function Ri(e,r){"object"===t(e)&&(r=e.fragment,e=e.vertex),e=Pi(e),r=Pi(r),this._shaderID=function(e,t){var r="vertex:"+e+"fragment:"+t;if(Di[r])return Di[r];var n=Or.genGUID();return Di[r]=n,Li[n]={vertex:e,fragment:t},n}(e,r),this._vertexCode=Ri.parseImport(e),this._fragmentCode=Ri.parseImport(r),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}Ri.prototype={constructor:Ri,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var r=this.uniformTemplates[t];e[t]={type:r.type,value:r.value()}}return e},_parseImport:function(){this._vertexCode=Ri.parseImport(this.vertex),this._fragmentCode=Ri.parseImport(this.fragment)},_addSemanticUniform:function(e,t,r){if(Mi.indexOf(r)>=0)this.attributeSemantics[r]={symbol:e,type:t};else if(Ei.indexOf(r)>=0){var n=!1,i=r;r.match(/TRANSPOSE$/)&&(n=!0,i=r.slice(0,-9)),this.matrixSemantics[r]={symbol:e,type:t,isTranspose:n,semanticNoTranspose:i}}else Ai.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:e,type:t})},_addMaterialUniform:function(e,t,r,n,i,a){a[e]={type:r,value:i?Si.array:n||Si[t],semantic:null}},_parseUniforms:function(){var e={},t=this,r="vertex";function n(e){return null!=e?function(){return e}:null}function i(i,a,o){var s=Ni(a,o),l=[];for(var u in s){var h=s[u],c=h.semantic,d=u,f=wi[a],p=n(s[u].value);s[u].isArray&&(d+="["+s[u].arraySize+"]",f+="v"),l.push(d),t._uniformList.push(u),h.ignore||("sampler2D"!==a&&"samplerCube"!==a||(t.textures[u]={shaderType:r,type:a}),c?t._addSemanticUniform(u,f,c):t._addMaterialUniform(u,a,f,p,s[u].isArray,e))}return l.length>0?"uniform "+a+" "+l.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(yi,i),r="fragment",this._fragmentCode=this._fragmentCode.replace(yi,i),t.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(xi,function(r,n,i){var a=Ni(n,i),o=Ci[n]||1,s=[];for(var l in a){var u=a[l].semantic;if(e[l]={type:"float",size:o,semantic:u||null},u){if(Mi.indexOf(u)<0)throw new Error('Unkown semantic "'+u+'"');t.attributeSemantics[u]={symbol:l,type:n}}s.push(l)}return"attribute "+n+" "+s.join(",")+";\n"}),this.attributes=e},_parseDefines:function(){var e=this,t="vertex";function r(r,n,i){var a="vertex"===t?e.vertexDefines:e.fragmentDefines;return a[n]||(a[n]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(bi,r),t="fragment",this._fragmentCode=this._fragmentCode.replace(bi,r)},clone:function(){var e=Li[this._shaderID];return new Ri(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(Ri.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(Ri.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(Ri.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(Ri.prototype,"uniforms",{get:function(){return this._uniformList}}));var Ii=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;Ri.parseImport=function(e){return e=e.replace(Ii,function(e,t,r){return(e=Ri.source(r))?Ri.parseImport(e):(console.error('Shader chunk "'+r+'" not existed in library'),"")})};var Bi=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;Ri.import=function(e){e.replace(Bi,function(e,t,r,n){if(n=n.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var i,a=r.split("."),o=Ri.codes,s=0;s<a.length-1;)o[i=a[s++]]||(o[i]={}),o=o[i];o[i=a[s]]=n}return n})},Ri.codes={},Ri.source=function(e){for(var t=e.split("."),r=Ri.codes,n=0;r&&n<t.length;){r=r[t[n++]]}return"string"!=typeof r?(console.error('Shader "'+e+'" not existed in library'),""):r};var zi="@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",Fi={create:function(){var e=new ai(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 ai(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 r=t[1],n=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,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 r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],v=t[15],_=r*s-n*o,y=r*l-i*o,x=r*u-a*o,b=n*l-i*s,w=n*u-a*s,T=i*u-a*l,S=h*m-c*p,M=h*g-d*p,A=h*v-f*p,E=c*g-d*m,C=c*v-f*m,D=d*v-f*g,L=_*D-y*C+x*E+b*A-w*M+T*S;return L?(L=1/L,e[0]=(s*D-l*C+u*E)*L,e[1]=(i*C-n*D-a*E)*L,e[2]=(m*T-g*w+v*b)*L,e[3]=(d*w-c*T-f*b)*L,e[4]=(l*A-o*D-u*M)*L,e[5]=(r*D-i*A+a*M)*L,e[6]=(g*x-p*T-v*y)*L,e[7]=(h*T-d*x+f*y)*L,e[8]=(o*C-s*A+u*S)*L,e[9]=(n*A-r*C-a*S)*L,e[10]=(p*w-m*x+v*_)*L,e[11]=(c*x-h*w-f*_)*L,e[12]=(s*M-o*E-l*S)*L,e[13]=(r*E-n*M+i*S)*L,e[14]=(m*y-p*b-g*_)*L,e[15]=(h*b-c*y+d*_)*L,e):null},adjoint:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],v=t[15];return e[0]=s*(d*v-f*g)-c*(l*v-u*g)+m*(l*f-u*d),e[1]=-(n*(d*v-f*g)-c*(i*v-a*g)+m*(i*f-a*d)),e[2]=n*(l*v-u*g)-s*(i*v-a*g)+m*(i*u-a*l),e[3]=-(n*(l*f-u*d)-s*(i*f-a*d)+c*(i*u-a*l)),e[4]=-(o*(d*v-f*g)-h*(l*v-u*g)+p*(l*f-u*d)),e[5]=r*(d*v-f*g)-h*(i*v-a*g)+p*(i*f-a*d),e[6]=-(r*(l*v-u*g)-o*(i*v-a*g)+p*(i*u-a*l)),e[7]=r*(l*f-u*d)-o*(i*f-a*d)+h*(i*u-a*l),e[8]=o*(c*v-f*m)-h*(s*v-u*m)+p*(s*f-u*c),e[9]=-(r*(c*v-f*m)-h*(n*v-a*m)+p*(n*f-a*c)),e[10]=r*(s*v-u*m)-o*(n*v-a*m)+p*(n*u-a*s),e[11]=-(r*(s*f-u*c)-o*(n*f-a*c)+h*(n*u-a*s)),e[12]=-(o*(c*g-d*m)-h*(s*g-l*m)+p*(s*d-l*c)),e[13]=r*(c*g-d*m)-h*(n*g-i*m)+p*(n*d-i*c),e[14]=-(r*(s*g-l*m)-o*(n*g-i*m)+p*(n*l-i*s)),e[15]=r*(s*d-l*c)-o*(n*d-i*c)+h*(n*l-i*s),e},determinant:function(e){var t=e[0],r=e[1],n=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],h=e[9],c=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15];return(t*o-r*a)*(c*g-d*m)-(t*s-n*a)*(h*g-d*p)+(t*l-i*a)*(h*m-c*p)+(r*s-n*o)*(u*g-d*f)-(r*l-i*o)*(u*m-c*f)+(n*l-i*s)*(u*p-h*f)},multiply:function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],v=t[14],_=t[15],y=r[0],x=r[1],b=r[2],w=r[3];return e[0]=y*n+x*s+b*c+w*m,e[1]=y*i+x*l+b*d+w*g,e[2]=y*a+x*u+b*f+w*v,e[3]=y*o+x*h+b*p+w*_,y=r[4],x=r[5],b=r[6],w=r[7],e[4]=y*n+x*s+b*c+w*m,e[5]=y*i+x*l+b*d+w*g,e[6]=y*a+x*u+b*f+w*v,e[7]=y*o+x*h+b*p+w*_,y=r[8],x=r[9],b=r[10],w=r[11],e[8]=y*n+x*s+b*c+w*m,e[9]=y*i+x*l+b*d+w*g,e[10]=y*a+x*u+b*f+w*v,e[11]=y*o+x*h+b*p+w*_,y=r[12],x=r[13],b=r[14],w=r[15],e[12]=y*n+x*s+b*c+w*m,e[13]=y*i+x*l+b*d+w*g,e[14]=y*a+x*u+b*f+w*v,e[15]=y*o+x*h+b*p+w*_,e},multiplyAffine:function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[4],s=t[5],l=t[6],u=t[8],h=t[9],c=t[10],d=t[12],f=t[13],p=t[14],m=r[0],g=r[1],v=r[2];return e[0]=m*n+g*o+v*u,e[1]=m*i+g*s+v*h,e[2]=m*a+g*l+v*c,m=r[4],g=r[5],v=r[6],e[4]=m*n+g*o+v*u,e[5]=m*i+g*s+v*h,e[6]=m*a+g*l+v*c,m=r[8],g=r[9],v=r[10],e[8]=m*n+g*o+v*u,e[9]=m*i+g*s+v*h,e[10]=m*a+g*l+v*c,m=r[12],g=r[13],v=r[14],e[12]=m*n+g*o+v*u+d,e[13]=m*i+g*s+v*h+f,e[14]=m*a+g*l+v*c+p,e}};Fi.mul=Fi.multiply,Fi.mulAffine=Fi.multiplyAffine,Fi.translate=function(e,t,r){var n,i,a,o,s,l,u,h,c,d,f,p,m=r[0],g=r[1],v=r[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*v+t[12],e[13]=t[1]*m+t[5]*g+t[9]*v+t[13],e[14]=t[2]*m+t[6]*g+t[10]*v+t[14],e[15]=t[3]*m+t[7]*g+t[11]*v+t[15]):(n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],f=t[10],p=t[11],e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=u,e[7]=h,e[8]=c,e[9]=d,e[10]=f,e[11]=p,e[12]=n*m+s*g+c*v+t[12],e[13]=i*m+l*g+d*v+t[13],e[14]=a*m+u*g+f*v+t[14],e[15]=o*m+h*g+p*v+t[15]),e},Fi.scale=function(e,t,r){var n=r[0],i=r[1],a=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Fi.rotate=function(e,t,r,n){var i,a,o,s,l,u,h,c,d,f,p,m,g,v,_,y,x,b,w,T,S,M,A,E,C=n[0],D=n[1],L=n[2],P=Math.sqrt(C*C+D*D+L*L);return Math.abs(P)<ii?null:(C*=P=1/P,D*=P,L*=P,i=Math.sin(r),o=1-(a=Math.cos(r)),s=t[0],l=t[1],u=t[2],h=t[3],c=t[4],d=t[5],f=t[6],p=t[7],m=t[8],g=t[9],v=t[10],_=t[11],y=C*C*o+a,x=D*C*o+L*i,b=L*C*o-D*i,w=C*D*o-L*i,T=D*D*o+a,S=L*D*o+C*i,M=C*L*o+D*i,A=D*L*o-C*i,E=L*L*o+a,e[0]=s*y+c*x+m*b,e[1]=l*y+d*x+g*b,e[2]=u*y+f*x+v*b,e[3]=h*y+p*x+_*b,e[4]=s*w+c*T+m*S,e[5]=l*w+d*T+g*S,e[6]=u*w+f*T+v*S,e[7]=h*w+p*T+_*S,e[8]=s*M+c*A+m*E,e[9]=l*M+d*A+g*E,e[10]=u*M+f*A+v*E,e[11]=h*M+p*A+_*E,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},Fi.rotateX=function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[4],o=t[5],s=t[6],l=t[7],u=t[8],h=t[9],c=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]=a*i+u*n,e[5]=o*i+h*n,e[6]=s*i+c*n,e[7]=l*i+d*n,e[8]=u*i-a*n,e[9]=h*i-o*n,e[10]=c*i-s*n,e[11]=d*i-l*n,e},Fi.rotateY=function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[0],o=t[1],s=t[2],l=t[3],u=t[8],h=t[9],c=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]=a*i-u*n,e[1]=o*i-h*n,e[2]=s*i-c*n,e[3]=l*i-d*n,e[8]=a*n+u*i,e[9]=o*n+h*i,e[10]=s*n+c*i,e[11]=l*n+d*i,e},Fi.rotateZ=function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[0],o=t[1],s=t[2],l=t[3],u=t[4],h=t[5],c=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]=a*i+u*n,e[1]=o*i+h*n,e[2]=s*i+c*n,e[3]=l*i+d*n,e[4]=u*i-a*n,e[5]=h*i-o*n,e[6]=c*i-s*n,e[7]=d*i-l*n,e},Fi.fromRotationTranslation=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=n+n,l=i+i,u=a+a,h=n*s,c=n*l,d=n*u,f=i*l,p=i*u,m=a*u,g=o*s,v=o*l,_=o*u;return e[0]=1-(f+m),e[1]=c+_,e[2]=d-v,e[3]=0,e[4]=c-_,e[5]=1-(h+m),e[6]=p+g,e[7]=0,e[8]=d+v,e[9]=p-g,e[10]=1-(h+f),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},Fi.fromQuat=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,l=i+i,u=r*o,h=n*o,c=n*s,d=i*o,f=i*s,p=i*l,m=a*o,g=a*s,v=a*l;return e[0]=1-c-p,e[1]=h+v,e[2]=d-g,e[3]=0,e[4]=h-v,e[5]=1-u-p,e[6]=f+m,e[7]=0,e[8]=d+g,e[9]=f-m,e[10]=1-u-c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Fi.frustum=function(e,t,r,n,i,a,o){var s=1/(r-t),l=1/(i-n),u=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*l,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*l,e[10]=(o+a)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*u,e[15]=0,e},Fi.perspective=function(e,t,r,n,i){var a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},Fi.ortho=function(e,t,r,n,i,a,o){var s=1/(t-r),l=1/(n-i),u=1/(a-o);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+r)*s,e[13]=(i+n)*l,e[14]=(o+a)*u,e[15]=1,e},Fi.lookAt=function(e,t,r,n){var i,a,o,s,l,u,h,c,d,f,p=t[0],m=t[1],g=t[2],v=n[0],_=n[1],y=n[2],x=r[0],b=r[1],w=r[2];return Math.abs(p-x)<ii&&Math.abs(m-b)<ii&&Math.abs(g-w)<ii?Fi.identity(e):(h=p-x,c=m-b,d=g-w,i=_*(d*=f=1/Math.sqrt(h*h+c*c+d*d))-y*(c*=f),a=y*(h*=f)-v*d,o=v*c-_*h,(f=Math.sqrt(i*i+a*a+o*o))?(i*=f=1/f,a*=f,o*=f):(i=0,a=0,o=0),s=c*o-d*a,l=d*i-h*o,u=h*a-c*i,(f=Math.sqrt(s*s+l*l+u*u))?(s*=f=1/f,l*=f,u*=f):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=h,e[3]=0,e[4]=a,e[5]=l,e[6]=c,e[7]=0,e[8]=o,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*p+a*m+o*g),e[13]=-(s*p+l*m+u*g),e[14]=-(h*p+c*m+d*g),e[15]=1,e)},Fi.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 ki={create:function(){var e=new ai(3);return e[0]=0,e[1]=0,e[2]=0,e},clone:function(e){var t=new ai(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},fromValues:function(e,t,r){var n=new ai(3);return n[0]=e,n[1]=t,n[2]=r,n},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set:function(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e},add:function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e},subtract:function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}};ki.sub=ki.subtract,ki.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e},ki.mul=ki.multiply,ki.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e},ki.div=ki.divide,ki.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e},ki.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e},ki.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e},ki.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e},ki.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)},ki.dist=ki.distance,ki.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i},ki.sqrDist=ki.squaredDistance,ki.length=function(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)},ki.len=ki.length,ki.squaredLength=function(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n},ki.sqrLen=ki.squaredLength,ki.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},ki.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},ki.normalize=function(e,t){var r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e},ki.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},ki.cross=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],l=r[2];return e[0]=i*l-a*s,e[1]=a*o-n*l,e[2]=n*s-i*o,e},ki.lerp=function(e,t,r,n){var i=t[0],a=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e},ki.random=function(e,t){t=t||1;var r=2*oi()*Math.PI,n=2*oi()-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e},ki.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e},ki.transformMat3=function(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=n*r[0]+i*r[3]+a*r[6],e[1]=n*r[1]+i*r[4]+a*r[7],e[2]=n*r[2]+i*r[5]+a*r[8],e},ki.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],l=r[2],u=r[3],h=u*n+s*a-l*i,c=u*i+l*n-o*a,d=u*a+o*i-s*n,f=-o*n-s*i-l*a;return e[0]=h*u+f*-o+c*-l-d*-s,e[1]=c*u+f*-s+d*-o-h*-l,e[2]=d*u+f*-l+h*-s-c*-o,e},ki.rotateX=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},ki.rotateY=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},ki.rotateZ=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},ki.forEach=function(){var e=ki.create();return function(t,r,n,i,a,o){var s,l;for(r||(r=3),n||(n=0),l=i?Math.min(i*r+n,t.length):t.length,s=n;s<l;s+=r)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}(),ki.angle=function(e,t){var r=ki.fromValues(e[0],e[1],e[2]),n=ki.fromValues(t[0],t[1],t[2]);ki.normalize(r,r),ki.normalize(n,n);var i=ki.dot(r,n);return i>1?0:Math.acos(i)},Ri.import(zi);var Ui=Fi.create,Gi={};function Hi(e){return e.material}function Vi(e,t,r){return t.uniforms[r].value}function Wi(e,t,r,n){return r!==n}function ji(e){return!0}function Xi(){}var qi={float:ln,byte:tn,ubyte:rn,short:nn,ushort:an};function Zi(e,t,r){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=r,this.vao=null}function Yi(e){var t,r;this.bind=function(e){t||((t=In.createCanvas()).width=t.height=1,t.getContext("2d"));var n=e.gl,i=!r;i&&(r=n.createTexture()),n.bindTexture(n.TEXTURE_2D,r),i&&n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)},this.unbind=function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var Ki=Nr.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=In.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 Br(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(Sc){throw"Error creating WebGL Context "+Sc}this._programMgr=new _i(this),this._placeholderTexture=new Yi},{resize:function(e,t){var r=this.canvas,n=this.devicePixelRatio;null!=e?(r.style&&(r.style.width=e+"px",r.style.height=t+"px"),r.width=e*n,r.height=t*n,this._width=e,this._height=t):(this._width=r.width/n,this._height=r.height/n),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,r,n,i,a){if("object"===t(e)){var o=e;e=o.x,r=o.y,n=o.width,i=o.height,a=o.devicePixelRatio}a=a||this.devicePixelRatio,this.gl.viewport(e*a,r*a,n*a,i*a),this.viewport={x:e,y:r,width:n,height:i,devicePixelRatio:a}},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,r,n){var i=this.gl,a=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,l=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||l&&l!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*l,o.y*l,o.width*l,o.height*l)),i.clearColor(a[0],a[1],a[2],a[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(r||e.update(!1),e.updateLights(),t=t||e.getMainCamera()){t.update();var u=e.updateRenderList(t,!0);this._sceneRendering=e;var h=u.opaque,c=u.transparent,d=e.material;e.trigger("beforerender",this,e,t,u),n?(this.renderPreZ(h,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var f=Ui(),p=ki.create(),m=0;m<c.length;m++){var g=c[m];Fi.multiplyAffine(f,t.viewMatrix.array,g.worldTransform.array),ki.transformMat4(p,g.position.array,f),g.__depth=p[2]}this.renderPass(h,t,{getMaterial:function(e){return d||e.material},sortCompare:this.opaqueSortCompare}),this.renderPass(c,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,r){return t=t||e.material,this._programMgr.getProgram(e,t,r)},validateProgram:function(e){if(e.__error){var t=e.__error;if(Gi[e.__uid__])return;if(Gi[e.__uid__]=!0,this.throwError)throw new Error(t);this.trigger("error",t)}},updatePrograms:function(e,t,r){var n=r&&r.getMaterial||Hi;t=t||null;for(var i=0;i<e.length;i++){var a=e[i],o=n.call(this,a);if(i>0){var s=e[i-1],l=s.joints?s.joints.length:0;if((a.joints?a.joints.length:0)===l&&a.material===s.material&&a.lightGroup===s.lightGroup){a.__program=s.__program;continue}}var u=this._programMgr.getProgram(a,o,t);this.validateProgram(u),a.__program=u}},renderPass:function(e,t,r){this.trigger("beforerenderpass",this,e,t,r),(r=r||{}).getMaterial=r.getMaterial||Hi,r.getUniform=r.getUniform||Vi,r.isMaterialChanged=r.isMaterialChanged||Wi,r.beforeRender=r.beforeRender||Xi,r.afterRender=r.afterRender||Xi;var n=r.ifRender||ji;this.updatePrograms(e,this._sceneRendering,r),r.sortCompare&&e.sort(r.sortCompare);var i=this.viewport,a=i.devicePixelRatio,o=[i.x*a,i.y*a,i.width*a,i.height*a],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],u=[o[2],o[3]],h=Date.now();t?(Fi.copy(Qi.VIEW,t.viewMatrix.array),Fi.copy(Qi.PROJECTION,t.projectionMatrix.array),Fi.copy(Qi.VIEWINVERSE,t.worldTransform.array)):(Fi.identity(Qi.VIEW),Fi.identity(Qi.PROJECTION),Fi.identity(Qi.VIEWINVERSE)),Fi.multiply(Qi.VIEWPROJECTION,Qi.PROJECTION,Qi.VIEW),Fi.invert(Qi.PROJECTIONINVERSE,Qi.PROJECTION),Fi.invert(Qi.VIEWPROJECTIONINVERSE,Qi.VIEWPROJECTION);for(var c,d,f,p,m,g,v,_,y,x,b,w,T=this.gl,S=this._sceneRendering,M=null,A=0;A<e.length;A++){var E,C=e[A],D=null!=C.worldTransform;if(n(C)){D&&(E=C.isSkinnedMesh&&C.isSkinnedMesh()?C.offsetMatrix?C.offsetMatrix.array:Qi.IDENTITY:C.worldTransform.array);var L=C.geometry,P=r.getMaterial.call(this,C),O=C.__program,N=P.shader,R=L.__uid__+"-"+O.__uid__,I=R!==x;x=R,D&&(Fi.copy(Qi.WORLD,E),Fi.multiply(Qi.WORLDVIEWPROJECTION,Qi.VIEWPROJECTION,E),Fi.multiplyAffine(Qi.WORLDVIEW,Qi.VIEW,E),(N.matrixSemantics.WORLDINVERSE||N.matrixSemantics.WORLDINVERSETRANSPOSE)&&Fi.invert(Qi.WORLDINVERSE,E),(N.matrixSemantics.WORLDVIEWINVERSE||N.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Fi.invert(Qi.WORLDVIEWINVERSE,Qi.WORLDVIEW),(N.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||N.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Fi.invert(Qi.WORLDVIEWPROJECTIONINVERSE,Qi.WORLDVIEWPROJECTION)),C.beforeRender&&C.beforeRender(this),r.beforeRender.call(this,C,P,c);var B=O!==d;B?(O.bind(this),O.setUniformOfSemantic(T,"VIEWPORT",o),O.setUniformOfSemantic(T,"WINDOW_SIZE",l),t&&(O.setUniformOfSemantic(T,"NEAR",t.near),O.setUniformOfSemantic(T,"FAR",t.far)),O.setUniformOfSemantic(T,"DEVICEPIXELRATIO",a),O.setUniformOfSemantic(T,"TIME",h),O.setUniformOfSemantic(T,"VIEWPORT_SIZE",u),S&&S.setLightUniforms(O,C.lightGroup,this)):O=d,(B||r.isMaterialChanged(C,f,P,c))&&(P.depthTest!==p&&(P.depthTest?T.enable(T.DEPTH_TEST):T.disable(T.DEPTH_TEST),p=P.depthTest),P.depthMask!==m&&(T.depthMask(P.depthMask),m=P.depthMask),P.transparent!==y&&(P.transparent?T.enable(T.BLEND):T.disable(T.BLEND),y=P.transparent),P.transparent&&(P.blend?P.blend(T):(T.blendEquationSeparate(T.FUNC_ADD,T.FUNC_ADD),T.blendFuncSeparate(T.SRC_ALPHA,T.ONE_MINUS_SRC_ALPHA,T.ONE,T.ONE_MINUS_SRC_ALPHA))),w=this._bindMaterial(C,P,O,f||null,c||null,d||null,r.getUniform),c=P);var z=N.matrixSemanticKeys;if(D)for(var F=0;F<z.length;F++){var k=z[F],U=N.matrixSemantics[k],G=Qi[k];if(U.isTranspose){var H=Qi[U.semanticNoTranspose];Fi.transpose(G,H)}O.setUniform(T,U.type,U.symbol,G)}C.cullFace!==v&&(v=C.cullFace,T.cullFace(v)),C.frontFace!==_&&(_=C.frontFace,T.frontFace(_)),C.culling!==g&&((g=C.culling)?T.enable(T.CULL_FACE):T.disable(T.CULL_FACE)),this._updateSkeleton(C,O,w),I&&(b=this._bindVAO(M,N,L,O)),this._renderObject(C,b,O),r.afterRender(this,C),C.afterRender&&C.afterRender(this),d=O,f=C}}this.trigger("afterrenderpass",this,e,t,r)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(e,t,r){var n=this.gl,i=e.skeleton;if(i)if(i.update(),e.joints.length>this.getMaxJointNumber()){var a=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,a,r),t.setUniform(n,"1i","skinMatricesTexture",r),t.setUniform(n,"1f","skinMatricesTextureSize",a.width)}else{var o=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(n,"SKIN_MATRIX",o)}},_renderObject:function(e,t,r){var n=this.gl,i=e.geometry,a=e.mode;null==a&&(a=4);var o=null,s=e.isInstancedMesh&&e.isInstancedMesh();if(!s||(o=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(e,r,o)),t.indicesBuffer){var u=this.getGLExtension("OES_element_index_uint")&&i.indices instanceof Uint32Array?n.UNSIGNED_INT:n.UNSIGNED_SHORT;s?o.drawElementsInstancedANGLE(a,t.indicesBuffer.count,u,0,e.getInstanceCount()):n.drawElements(a,t.indicesBuffer.count,u,0)}else s?o.drawArraysInstancedANGLE(a,0,i.vertexCount,e.getInstanceCount()):n.drawArrays(a,0,i.vertexCount);if(s)for(var h=0;h<l.length;h++)n.disableVertexAttribArray(l[h])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(e,t,r){for(var n=this.gl,i=e.getInstancedAttributesBuffers(this),a=[],o=0;o<i.length;o++){var s=i[o],l=t.getAttribLocation(n,s.symbol);if(!(l<0)){var u=qi[s.type]||n.FLOAT;n.enableVertexAttribArray(l),n.bindBuffer(n.ARRAY_BUFFER,s.buffer),n.vertexAttribPointer(l,s.size,u,!1,0,0),r.vertexAttribDivisorANGLE(l,s.divisor),a.push(l)}}return a},_bindMaterial:function(e,t,r,n,i,a,o){for(var s=this.gl,l=a===r,u=r.currentTextureSlot(),h=t.getEnabledUniforms(),c=t.getTextureUniforms(),d=this._placeholderTexture,f=0;f<c.length;f++){var p=o(e,t,v=c[f]);if("t"===(g=t.uniforms[v].type)&&p)p.__slot=-1;else if("tv"===g)for(var m=0;m<p.length;m++)p[m]&&(p[m].__slot=-1)}d.__slot=-1;for(f=0;f<h.length;f++){var g,v=h[f],_=t.uniforms[v],y=(p=o(e,t,v),"t"===(g=_.type));if(y&&(p&&p.isRenderable()||(p=d)),i&&l){var x=o(n,i,v);if(y&&(x&&x.isRenderable()||(x=d)),x===p){if(y)r.takeCurrentTextureSlot(this,null);else if("tv"===g&&p)for(m=0;m<p.length;m++)r.takeCurrentTextureSlot(this,null);continue}}if(null!=p)if(y)if(p.__slot<0){var b=r.currentTextureSlot();r.setUniform(s,"1i",v,b)&&(r.takeCurrentTextureSlot(this,p),p.__slot=b)}else r.setUniform(s,"1i",v,p.__slot);else if(Array.isArray(p)){if(0===p.length)continue;if("tv"===g){if(!r.hasUniform(v))continue;var w=[];for(m=0;m<p.length;m++){var T=p[m];if(T.__slot<0){b=r.currentTextureSlot();w.push(b),r.takeCurrentTextureSlot(this,T),T.__slot=b}else w.push(T.__slot)}r.setUniform(s,"1iv",v,w)}else r.setUniform(s,_.type,v,p)}else r.setUniform(s,_.type,v,p)}var S=r.currentTextureSlot();return r.resetTextureSlot(u),S},_bindVAO:function(e,t,r,n){var i=!r.dynamic,a=this.gl,o=this.__uid__+"-"+n.__uid__,s=r.__vaoCache[o];if(!s){var l=r.getBufferChunks(this);if(!l||!l.length)return;for(var u=l[0],h=u.attributeBuffers,c=u.indicesBuffer,d=[],f=[],p=0;p<h.length;p++){var m,g=(w=h[p]).name,v=w.semantic;if(v){var _=t.attributeSemantics[v];m=_&&_.symbol}else m=g;m&&n.attributes[m]&&(d.push(w),f.push(m))}s=new Zi(d,f,c),i&&(r.__vaoCache[o]=s)}var y=!0;e&&i&&(null==s.vao?s.vao=e.createVertexArrayOES():y=!1,e.bindVertexArrayOES(s.vao));d=s.availableAttributes,c=s.indicesBuffer;if(y){var x=n.enableAttributes(this,s.availableAttributeSymbols,e&&i&&s);for(p=0;p<d.length;p++){var b=x[p];if(-1!==b){var w,T=(w=d[p]).buffer,S=w.size,M=qi[w.type]||a.FLOAT;a.bindBuffer(a.ARRAY_BUFFER,T),a.vertexAttribPointer(b,S,M,!1,0,0)}}r.isUseIndices()&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,c.buffer)}return s},renderPreZ:function(e,t,r){var n=this.gl,i=this._prezMaterial||new ni({shader:new Ri(Ri.source("clay.prez.vertex"),Ri.source("clay.prez.fragment"))});this._prezMaterial=i,n.colorMask(!1,!1,!1,!1),n.depthMask(!0),this.renderPass(e,r,{ifRender:function(e){return!e.ignorePreZ},isMaterialChanged:function(e,t){var r=e.material,n=t.material;return r.get("diffuseMap")!==n.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(n.get("alphaCutoff")||0)},getUniform:function(e,t,r){return"alphaMap"===r?e.material.get("diffuseMap"):"alphaCutoff"===r?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===r?e.material.get("uvRepeat"):"uvOffset"===r?e.material.get("uvOffset"):t.get(r)},getMaterial:function(){return i},sort:this.opaqueSortCompare}),n.colorMask(!0,!0,!0,!0),n.depthMask(!0)},disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,r){e.getParent()&&e.getParent().remove(e);var n={};e.traverse(function(e){var i=e.material;if(e.geometry&&t&&e.geometry.dispose(this),r&&i&&!n[i.__uid__]){for(var a=i.getTextureUniforms(),o=0;o<a.length;o++){var s=a[o],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 h=0;h<l.length;h++)l[h]&&l[h].dispose&&l[h].dispose(this)}n[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,r){r||(r=new li),t=this._height-t;var n=this.viewport,i=r.array;return i[0]=(e-n.x)/n.width,i[0]=2*i[0]-1,i[1]=(t-n.y)/n.height,i[1]=2*i[1]-1,r}});Ki.opaqueSortCompare=Ki.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},Ki.transparentSortCompare=Ki.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 Qi={IDENTITY:Ui(),WORLD:Ui(),VIEW:Ui(),PROJECTION:Ui(),WORLDVIEW:Ui(),VIEWPROJECTION:Ui(),WORLDVIEWPROJECTION:Ui(),WORLDINVERSE:Ui(),VIEWINVERSE:Ui(),PROJECTIONINVERSE:Ui(),WORLDVIEWINVERSE:Ui(),VIEWPROJECTIONINVERSE:Ui(),WORLDVIEWPROJECTIONINVERSE:Ui(),WORLDTRANSPOSE:Ui(),VIEWTRANSPOSE:Ui(),PROJECTIONTRANSPOSE:Ui(),WORLDVIEWTRANSPOSE:Ui(),VIEWPROJECTIONTRANSPOSE:Ui(),WORLDVIEWPROJECTIONTRANSPOSE:Ui(),WORLDINVERSETRANSPOSE:Ui(),VIEWINVERSETRANSPOSE:Ui(),PROJECTIONINVERSETRANSPOSE:Ui(),WORLDVIEWINVERSETRANSPOSE:Ui(),VIEWPROJECTIONINVERSETRANSPOSE:Ui(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Ui()};Ki.COLOR_BUFFER_BIT=kr,Ki.DEPTH_BUFFER_BIT=zr,Ki.STENCIL_BUFFER_BIT=Fr;var Ji=function(e,t,r){e=e||0,t=t||0,r=r||0,this.array=ki.fromValues(e,t,r),this._dirty=!0};Ji.prototype={constructor:Ji,add:function(e){return ki.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,r){return this.array[0]=e,this.array[1]=t,this.array[2]=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._dirty=!0,this},clone:function(){return new Ji(this.x,this.y,this.z)},copy:function(e){return ki.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return ki.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return ki.dist(this.array,e.array)},distance:function(e){return ki.distance(this.array,e.array)},div:function(e){return ki.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return ki.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return ki.dot(this.array,e.array)},len:function(){return ki.len(this.array)},length:function(){return ki.length(this.array)},lerp:function(e,t,r){return ki.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return ki.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return ki.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return ki.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return ki.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return ki.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return ki.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return ki.random(this.array,e),this._dirty=!0,this},scale:function(e){return ki.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return ki.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return ki.sqrDist(this.array,e.array)},squaredDistance:function(e){return ki.squaredDistance(this.array,e.array)},sqrLen:function(){return ki.sqrLen(this.array)},squaredLength:function(){return ki.squaredLength(this.array)},sub:function(e){return ki.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return ki.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return ki.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return ki.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return ki.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 r=-1/t[2];t[0]=e[0]*t[0]*r,t[1]=e[5]*t[1]*r,t[2]=(e[10]*t[2]+e[14])*r}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){Ji.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){Ji.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var $i=Object.defineProperty;if($i){var ea=Ji.prototype;$i(ea,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),$i(ea,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),$i(ea,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}function ta(e,t,r){return e<t?t:e>r?r:e}Ji.add=function(e,t,r){return ki.add(e.array,t.array,r.array),e._dirty=!0,e},Ji.set=function(e,t,r,n){ki.set(e.array,t,r,n),e._dirty=!0},Ji.copy=function(e,t){return ki.copy(e.array,t.array),e._dirty=!0,e},Ji.cross=function(e,t,r){return ki.cross(e.array,t.array,r.array),e._dirty=!0,e},Ji.distance=Ji.dist=function(e,t){return ki.distance(e.array,t.array)},Ji.divide=Ji.div=function(e,t,r){return ki.divide(e.array,t.array,r.array),e._dirty=!0,e},Ji.dot=function(e,t){return ki.dot(e.array,t.array)},Ji.len=function(e){return ki.length(e.array)},Ji.lerp=function(e,t,r,n){return ki.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},Ji.min=function(e,t,r){return ki.min(e.array,t.array,r.array),e._dirty=!0,e},Ji.max=function(e,t,r){return ki.max(e.array,t.array,r.array),e._dirty=!0,e},Ji.multiply=Ji.mul=function(e,t,r){return ki.multiply(e.array,t.array,r.array),e._dirty=!0,e},Ji.negate=function(e,t){return ki.negate(e.array,t.array),e._dirty=!0,e},Ji.normalize=function(e,t){return ki.normalize(e.array,t.array),e._dirty=!0,e},Ji.random=function(e,t){return ki.random(e.array,t),e._dirty=!0,e},Ji.scale=function(e,t,r){return ki.scale(e.array,t.array,r),e._dirty=!0,e},Ji.scaleAndAdd=function(e,t,r,n){return ki.scaleAndAdd(e.array,t.array,r.array,n),e._dirty=!0,e},Ji.squaredDistance=Ji.sqrDist=function(e,t){return ki.sqrDist(e.array,t.array)},Ji.squaredLength=Ji.sqrLen=function(e){return ki.sqrLen(e.array)},Ji.subtract=Ji.sub=function(e,t,r){return ki.subtract(e.array,t.array,r.array),e._dirty=!0,e},Ji.transformMat3=function(e,t,r){return ki.transformMat3(e.array,t.array,r.array),e._dirty=!0,e},Ji.transformMat4=function(e,t,r){return ki.transformMat4(e.array,t.array,r.array),e._dirty=!0,e},Ji.transformQuat=function(e,t,r){return ki.transformQuat(e.array,t.array,r.array),e._dirty=!0,e};var ra=Math.atan2,na=Math.asin,ia=Math.abs;Ji.eulerFromQuat=function(e,t,r){e._dirty=!0,t=t.array;var n=e.array,i=t[0],a=t[1],o=t[2],s=t[3],l=i*i,u=a*a,h=o*o,c=s*s;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":n[0]=ra(2*(i*s-a*o),c-l-u+h),n[1]=na(ta(2*(i*o+a*s),-1,1)),n[2]=ra(2*(o*s-i*a),c+l-u-h);break;case"YXZ":n[0]=na(ta(2*(i*s-a*o),-1,1)),n[1]=ra(2*(i*o+a*s),c-l-u+h),n[2]=ra(2*(i*a+o*s),c-l+u-h);break;case"ZXY":n[0]=na(ta(2*(i*s+a*o),-1,1)),n[1]=ra(2*(a*s-o*i),c-l-u+h),n[2]=ra(2*(o*s-i*a),c-l+u-h);break;case"ZYX":n[0]=ra(2*(i*s+o*a),c-l-u+h),n[1]=na(ta(2*(a*s-i*o),-1,1)),n[2]=ra(2*(i*a+o*s),c+l-u-h);break;case"YZX":n[0]=ra(2*(i*s-o*a),c-l+u-h),n[1]=ra(2*(a*s-i*o),c+l-u-h),n[2]=na(ta(2*(i*a+o*s),-1,1));break;case"XZY":n[0]=ra(2*(i*s+a*o),c-l+u-h),n[1]=ra(2*(i*o+a*s),c+l-u-h),n[2]=na(ta(2*(o*s-i*a),-1,1));break;default:console.warn("Unkown order: "+r)}return e},Ji.eulerFromMat3=function(e,t,r){var n=t.array,i=n[0],a=n[3],o=n[6],s=n[1],l=n[4],u=n[7],h=n[2],c=n[5],d=n[8],f=e.array;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":f[1]=na(ta(o,-1,1)),ia(o)<.99999?(f[0]=ra(-u,d),f[2]=ra(-a,i)):(f[0]=ra(c,l),f[2]=0);break;case"YXZ":f[0]=na(-ta(u,-1,1)),ia(u)<.99999?(f[1]=ra(o,d),f[2]=ra(s,l)):(f[1]=ra(-h,i),f[2]=0);break;case"ZXY":f[0]=na(ta(c,-1,1)),ia(c)<.99999?(f[1]=ra(-h,d),f[2]=ra(-a,l)):(f[1]=0,f[2]=ra(s,i));break;case"ZYX":f[1]=na(-ta(h,-1,1)),ia(h)<.99999?(f[0]=ra(c,d),f[2]=ra(s,i)):(f[0]=0,f[2]=ra(-a,l));break;case"YZX":f[2]=na(ta(s,-1,1)),ia(s)<.99999?(f[0]=ra(-u,l),f[1]=ra(-h,i)):(f[0]=0,f[1]=ra(o,d));break;case"XZY":f[2]=na(-ta(a,-1,1)),ia(a)<.99999?(f[0]=ra(c,l),f[1]=ra(o,i)):(f[0]=ra(-u,d),f[1]=0);break;default:console.warn("Unkown order: "+r)}return e._dirty=!0,e},Object.defineProperties(Ji,{POSITIVE_X:{get:function(){return new Ji(1,0,0)}},NEGATIVE_X:{get:function(){return new Ji(-1,0,0)}},POSITIVE_Y:{get:function(){return new Ji(0,1,0)}},NEGATIVE_Y:{get:function(){return new Ji(0,-1,0)}},POSITIVE_Z:{get:function(){return new Ji(0,0,1)}},NEGATIVE_Z:{get:function(){return new Ji(0,0,-1)}},UP:{get:function(){return new Ji(0,1,0)}},ZERO:{get:function(){return new Ji}}});var aa,oa,sa,la,ua,ha=1e-5,ca=function(e,t){this.origin=e||new Ji,this.direction=t||new Ji};ca.prototype={constructor:ca,intersectPlane:function(e,t){var r=e.normal.array,n=e.distance,i=this.origin.array,a=this.direction.array,o=ki.dot(r,a);if(0===o)return null;t||(t=new Ji);var s=(ki.dot(r,i)-n)/o;return ki.scaleAndAdd(t.array,i,a,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=ki.dot(e.normal.array,this.direction.array);ki.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,2*-t),this.direction._dirty=!0},distanceToPoint:(ua=ki.create(),function(e){ki.sub(ua,e,this.origin.array);var t=ki.dot(ua,this.direction.array);if(t<0)return ki.distance(this.origin.array,e);var r=ki.lenSquared(ua);return Math.sqrt(r-t*t)}),intersectSphere:function(){var e=ki.create();return function(t,r,n){var i=this.origin.array,a=this.direction.array;t=t.array,ki.sub(e,t,i);var o=ki.dot(e,a),s=ki.squaredLength(e)-o*o,l=r*r;if(!(s>l)){var u=Math.sqrt(l-s),h=o-u,c=o+u;return n||(n=new Ji),h<0?c<0?null:(ki.scaleAndAdd(n.array,i,a,c),n):(ki.scaleAndAdd(n.array,i,a,h),n)}}}(),intersectBoundingBox:function(e,t){var r,n,i,a,o,s,l=this.direction.array,u=this.origin.array,h=e.min.array,c=e.max.array,d=1/l[0],f=1/l[1],p=1/l[2];if(d>=0?(r=(h[0]-u[0])*d,n=(c[0]-u[0])*d):(n=(h[0]-u[0])*d,r=(c[0]-u[0])*d),f>=0?(i=(h[1]-u[1])*f,a=(c[1]-u[1])*f):(a=(h[1]-u[1])*f,i=(c[1]-u[1])*f),r>a||i>n)return null;if((i>r||r!=r)&&(r=i),(a<n||n!=n)&&(n=a),p>=0?(o=(h[2]-u[2])*p,s=(c[2]-u[2])*p):(s=(h[2]-u[2])*p,o=(c[2]-u[2])*p),r>s||o>n)return null;if((o>r||r!=r)&&(r=o),(s<n||n!=n)&&(n=s),n<0)return null;var m=r>=0?r:n;return t||(t=new Ji),ki.scaleAndAdd(t.array,u,l,m),t},intersectTriangle:(aa=ki.create(),oa=ki.create(),sa=ki.create(),la=ki.create(),function(e,t,r,n,i,a){var o=this.direction.array,s=this.origin.array;e=e.array,t=t.array,r=r.array,ki.sub(aa,t,e),ki.sub(oa,r,e),ki.cross(la,oa,o);var l=ki.dot(aa,la);if(n){if(l>-1e-5)return null}else if(l>-1e-5&&l<ha)return null;ki.sub(sa,s,e);var u=ki.dot(la,sa)/l;if(u<0||u>1)return null;ki.cross(la,aa,sa);var h=ki.dot(o,la)/l;if(h<0||h>1||u+h>1)return null;ki.cross(la,aa,oa);var c=-ki.dot(sa,la)/l;return c<0?null:(i||(i=new Ji),a&&Ji.set(a,1-u-h,u,h),ki.scaleAndAdd(i.array,s,o,c),i)}),applyTransform:function(e){Ji.add(this.direction,this.direction,this.origin),Ji.transformMat4(this.origin,this.origin,e),Ji.transformMat4(this.direction,this.direction,e),Ji.sub(this.direction,this.direction,this.origin),Ji.normalize(this.direction,this.direction)},copy:function(e){Ji.copy(this.origin,e.origin),Ji.copy(this.direction,e.direction)},clone:function(){var e=new ca;return e.copy(this),e}};var da={create:function(){var e=new ai(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},clone:function(e){var t=new ai(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues:function(e,t,r,n){var i=new ai(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,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,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e},add:function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e},subtract:function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}};da.sub=da.subtract,da.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e},da.mul=da.multiply,da.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e},da.div=da.divide,da.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e},da.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},da.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e},da.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e},da.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(r*r+n*n+i*i+a*a)},da.dist=da.distance,da.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return r*r+n*n+i*i+a*a},da.sqrDist=da.squaredDistance,da.length=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)},da.len=da.length,da.squaredLength=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i},da.sqrLen=da.squaredLength,da.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},da.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},da.normalize=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*o),e},da.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},da.lerp=function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e[3]=s+n*(r[3]-s),e},da.random=function(e,t){return t=t||1,e[0]=oi(),e[1]=oi(),e[2]=oi(),e[3]=oi(),da.normalize(e,e),da.scale(e,e,t),e},da.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,e},da.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],l=r[2],u=r[3],h=u*n+s*a-l*i,c=u*i+l*n-o*a,d=u*a+o*i-s*n,f=-o*n-s*i-l*a;return e[0]=h*u+f*-o+c*-l-d*-s,e[1]=c*u+f*-s+d*-o-h*-l,e[2]=d*u+f*-l+h*-s-c*-o,e},da.forEach=function(){var e=da.create();return function(t,r,n,i,a,o){var s,l;for(r||(r=4),n||(n=0),l=i?Math.min(i*r+n,t.length):t.length,s=n;s<l;s+=r)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}();var fa={create:function(){var e=new ai(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 ai(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 r=t[1],n=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=n,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 r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=h*o-s*u,d=-h*a+s*l,f=u*a-o*l,p=r*c+n*d+i*f;return p?(p=1/p,e[0]=c*p,e[1]=(-h*n+i*u)*p,e[2]=(s*n-i*o)*p,e[3]=d*p,e[4]=(h*r-i*l)*p,e[5]=(-s*r+i*a)*p,e[6]=f*p,e[7]=(-u*r+n*l)*p,e[8]=(o*r-n*a)*p,e):null},adjoint:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8];return e[0]=o*h-s*u,e[1]=i*u-n*h,e[2]=n*s-i*o,e[3]=s*l-a*h,e[4]=r*h-i*l,e[5]=i*a-r*s,e[6]=a*u-o*l,e[7]=n*l-r*u,e[8]=r*o-n*a,e},determinant:function(e){var t=e[0],r=e[1],n=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8];return t*(u*a-o*l)+r*(-u*i+o*s)+n*(l*i-a*s)},multiply:function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=r[0],f=r[1],p=r[2],m=r[3],g=r[4],v=r[5],_=r[6],y=r[7],x=r[8];return e[0]=d*n+f*o+p*u,e[1]=d*i+f*s+p*h,e[2]=d*a+f*l+p*c,e[3]=m*n+g*o+v*u,e[4]=m*i+g*s+v*h,e[5]=m*a+g*l+v*c,e[6]=_*n+y*o+x*u,e[7]=_*i+y*s+x*h,e[8]=_*a+y*l+x*c,e}};fa.mul=fa.multiply,fa.translate=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=r[0],f=r[1];return e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=d*n+f*o+u,e[7]=d*i+f*s+h,e[8]=d*a+f*l+c,e},fa.rotate=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=Math.sin(r),f=Math.cos(r);return e[0]=f*n+d*o,e[1]=f*i+d*s,e[2]=f*a+d*l,e[3]=f*o-d*n,e[4]=f*s-d*i,e[5]=f*l-d*a,e[6]=u,e[7]=h,e[8]=c,e},fa.scale=function(e,t,r){var n=r[0],i=r[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*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},fa.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},fa.fromQuat=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,l=i+i,u=r*o,h=n*o,c=n*s,d=i*o,f=i*s,p=i*l,m=a*o,g=a*s,v=a*l;return e[0]=1-c-p,e[3]=h-v,e[6]=d+g,e[1]=h+v,e[4]=1-u-p,e[7]=f-m,e[2]=d-g,e[5]=f+m,e[8]=1-u-c,e},fa.normalFromMat4=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],v=t[15],_=r*s-n*o,y=r*l-i*o,x=r*u-a*o,b=n*l-i*s,w=n*u-a*s,T=i*u-a*l,S=h*m-c*p,M=h*g-d*p,A=h*v-f*p,E=c*g-d*m,C=c*v-f*m,D=d*v-f*g,L=_*D-y*C+x*E+b*A-w*M+T*S;return L?(L=1/L,e[0]=(s*D-l*C+u*E)*L,e[1]=(l*A-o*D-u*M)*L,e[2]=(o*C-s*A+u*S)*L,e[3]=(i*C-n*D-a*E)*L,e[4]=(r*D-i*A+a*M)*L,e[5]=(n*A-r*C-a*S)*L,e[6]=(m*T-g*w+v*b)*L,e[7]=(g*x-p*T-v*y)*L,e[8]=(p*w-m*x+v*_)*L,e):null},fa.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 pa,ma,ga,va,_a={};_a.create=function(){var e=new ai(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},_a.rotationTo=(pa=ki.create(),ma=ki.fromValues(1,0,0),ga=ki.fromValues(0,1,0),function(e,t,r){var n=ki.dot(t,r);return n<-.999999?(ki.cross(pa,ma,t),ki.length(pa)<1e-6&&ki.cross(pa,ga,t),ki.normalize(pa,pa),_a.setAxisAngle(e,pa,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(ki.cross(pa,t,r),e[0]=pa[0],e[1]=pa[1],e[2]=pa[2],e[3]=1+n,_a.normalize(e,e))}),_a.setAxes=(va=fa.create(),function(e,t,r,n){return va[0]=r[0],va[3]=r[1],va[6]=r[2],va[1]=n[0],va[4]=n[1],va[7]=n[2],va[2]=-t[0],va[5]=-t[1],va[8]=-t[2],_a.normalize(e,_a.fromMat3(e,va))}),_a.clone=da.clone,_a.fromValues=da.fromValues,_a.copy=da.copy,_a.set=da.set,_a.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},_a.setAxisAngle=function(e,t,r){r*=.5;var n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e},_a.add=da.add,_a.multiply=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],h=r[3];return e[0]=n*h+o*s+i*u-a*l,e[1]=i*h+o*l+a*s-n*u,e[2]=a*h+o*u+n*l-i*s,e[3]=o*h-n*s-i*l-a*u,e},_a.mul=_a.multiply,_a.scale=da.scale,_a.rotateX=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=n*l+o*s,e[1]=i*l+a*s,e[2]=a*l-i*s,e[3]=o*l-n*s,e},_a.rotateY=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=n*l-a*s,e[1]=i*l+o*s,e[2]=a*l+n*s,e[3]=o*l-i*s,e},_a.rotateZ=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*s,e[1]=i*l-n*s,e[2]=a*l+o*s,e[3]=o*l-a*s,e},_a.calculateW=function(e,t){var r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},_a.dot=da.dot,_a.lerp=da.lerp,_a.slerp=function(e,t,r,n){var i,a,o,s,l,u=t[0],h=t[1],c=t[2],d=t[3],f=r[0],p=r[1],m=r[2],g=r[3];return(a=u*f+h*p+c*m+d*g)<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),e[0]=s*u+l*f,e[1]=s*h+l*p,e[2]=s*c+l*m,e[3]=s*d+l*g,e},_a.invert=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},_a.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},_a.length=da.length,_a.len=_a.length,_a.squaredLength=da.squaredLength,_a.sqrLen=_a.squaredLength,_a.normalize=da.normalize,_a.fromMat3=function(e,t){var r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*a+a]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+i]+t[3*i+a])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e};var ya,xa,ba,wa,Ta=function(){this._axisX=new Ji,this._axisY=new Ji,this._axisZ=new Ji,this.array=Fi.create(),this._dirty=!0};Ta.prototype={constructor:Ta,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 Fi.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new Ta).copy(this)},copy:function(e){return Fi.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return Fi.determinant(this.array)},fromQuat:function(e){return Fi.fromQuat(this.array,e.array),this._dirty=!0,this},fromRotationTranslation:function(e,t){return Fi.fromRotationTranslation(this.array,e.array,t.array),this._dirty=!0,this},fromMat2d:function(e){return Ta.fromMat2d(this,e),this},frustum:function(e,t,r,n,i,a){return Fi.frustum(this.array,e,t,r,n,i,a),this._dirty=!0,this},identity:function(){return Fi.identity(this.array),this._dirty=!0,this},invert:function(){return Fi.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(e,t,r){return Fi.lookAt(this.array,e.array,t.array,r.array),this._dirty=!0,this},mul:function(e){return Fi.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return Fi.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return Fi.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return Fi.multiply(this.array,e.array,this.array),this._dirty=!0,this},ortho:function(e,t,r,n,i,a){return Fi.ortho(this.array,e,t,r,n,i,a),this._dirty=!0,this},perspective:function(e,t,r,n){return Fi.perspective(this.array,e,t,r,n),this._dirty=!0,this},rotate:function(e,t){return Fi.rotate(this.array,this.array,e,t.array),this._dirty=!0,this},rotateX:function(e){return Fi.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return Fi.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return Fi.rotateZ(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return Fi.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return Fi.translate(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return Fi.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:(ya=ki.create(),xa=ki.create(),ba=ki.create(),wa=fa.create(),function(e,t,r){var n=this.array;ki.set(ya,n[0],n[1],n[2]),ki.set(xa,n[4],n[5],n[6]),ki.set(ba,n[8],n[9],n[10]);var i=ki.length(ya),a=ki.length(xa),o=ki.length(ba);this.determinant()<0&&(i=-i),e&&e.set(i,a,o),r.set(n[12],n[13],n[14]),fa.fromMat4(wa,n),wa[0]/=i,wa[1]/=i,wa[2]/=i,wa[3]/=a,wa[4]/=a,wa[5]/=a,wa[6]/=o,wa[7]/=o,wa[8]/=o,_a.fromMat3(t.array,wa),_a.normalize(t.array,t.array),t._dirty=!0,r._dirty=!0}),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Sa=Object.defineProperty;if(Sa){var Ma=Ta.prototype;Sa(Ma,"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}}),Sa(Ma,"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}}),Sa(Ma,"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}})}Ta.adjoint=function(e,t){return Fi.adjoint(e.array,t.array),e._dirty=!0,e},Ta.copy=function(e,t){return Fi.copy(e.array,t.array),e._dirty=!0,e},Ta.determinant=function(e){return Fi.determinant(e.array)},Ta.identity=function(e){return Fi.identity(e.array),e._dirty=!0,e},Ta.ortho=function(e,t,r,n,i,a,o){return Fi.ortho(e.array,t,r,n,i,a,o),e._dirty=!0,e},Ta.perspective=function(e,t,r,n,i){return Fi.perspective(e.array,t,r,n,i),e._dirty=!0,e},Ta.lookAt=function(e,t,r,n){return Fi.lookAt(e.array,t.array,r.array,n.array),e._dirty=!0,e},Ta.invert=function(e,t){return Fi.invert(e.array,t.array),e._dirty=!0,e},Ta.multiply=Ta.mul=function(e,t,r){return Fi.mul(e.array,t.array,r.array),e._dirty=!0,e},Ta.fromQuat=function(e,t){return Fi.fromQuat(e.array,t.array),e._dirty=!0,e},Ta.fromRotationTranslation=function(e,t,r){return Fi.fromRotationTranslation(e.array,t.array,r.array),e._dirty=!0,e},Ta.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},Ta.rotate=function(e,t,r,n){return Fi.rotate(e.array,t.array,r,n.array),e._dirty=!0,e},Ta.rotateX=function(e,t,r){return Fi.rotateX(e.array,t.array,r),e._dirty=!0,e},Ta.rotateY=function(e,t,r){return Fi.rotateY(e.array,t.array,r),e._dirty=!0,e},Ta.rotateZ=function(e,t,r){return Fi.rotateZ(e.array,t.array,r),e._dirty=!0,e},Ta.scale=function(e,t,r){return Fi.scale(e.array,t.array,r.array),e._dirty=!0,e},Ta.transpose=function(e,t){return Fi.transpose(e.array,t.array),e._dirty=!0,e},Ta.translate=function(e,t,r){return Fi.translate(e.array,t.array,r.array),e._dirty=!0,e};var Aa=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=void 0===n?1:n,this.array=_a.fromValues(e,t,r,n),this._dirty=!0};Aa.prototype={constructor:Aa,add:function(e){return _a.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return _a.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,r,n){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this.array[3]=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.array[3]=e[3],this._dirty=!0,this},clone:function(){return new Aa(this.x,this.y,this.z,this.w)},conjugate:function(){return _a.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return _a.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return _a.dot(this.array,e.array)},fromMat3:function(e){return _a.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:function(){var e=fa.create();return function(t){return fa.fromMat4(e,t.array),fa.transpose(e,e),_a.fromMat3(this.array,e),this._dirty=!0,this}}(),identity:function(){return _a.identity(this.array),this._dirty=!0,this},invert:function(){return _a.invert(this.array,this.array),this._dirty=!0,this},len:function(){return _a.len(this.array)},length:function(){return _a.length(this.array)},lerp:function(e,t,r){return _a.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},mul:function(e){return _a.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return _a.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return _a.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return _a.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return _a.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return _a.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return _a.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return _a.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return _a.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,r){return _a.setAxes(this.array,e.array,t.array,r.array),this._dirty=!0,this},setAxisAngle:function(e,t){return _a.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,r){return _a.slerp(this.array,e.array,t.array,r),this._dirty=!0,this},sqrLen:function(){return _a.sqrLen(this.array)},squaredLength:function(){return _a.squaredLength(this.array)},fromEuler:function(e,t){return Aa.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Ea=Object.defineProperty;if(Ea){var Ca=Aa.prototype;Ea(Ca,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Ea(Ca,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Ea(Ca,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),Ea(Ca,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}Aa.add=function(e,t,r){return _a.add(e.array,t.array,r.array),e._dirty=!0,e},Aa.set=function(e,t,r,n,i){_a.set(e.array,t,r,n,i),e._dirty=!0},Aa.copy=function(e,t){return _a.copy(e.array,t.array),e._dirty=!0,e},Aa.calculateW=function(e,t){return _a.calculateW(e.array,t.array),e._dirty=!0,e},Aa.conjugate=function(e,t){return _a.conjugate(e.array,t.array),e._dirty=!0,e},Aa.identity=function(e){return _a.identity(e.array),e._dirty=!0,e},Aa.invert=function(e,t){return _a.invert(e.array,t.array),e._dirty=!0,e},Aa.dot=function(e,t){return _a.dot(e.array,t.array)},Aa.len=function(e){return _a.length(e.array)},Aa.lerp=function(e,t,r,n){return _a.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},Aa.slerp=function(e,t,r,n){return _a.slerp(e.array,t.array,r.array,n),e._dirty=!0,e},Aa.multiply=Aa.mul=function(e,t,r){return _a.multiply(e.array,t.array,r.array),e._dirty=!0,e},Aa.rotateX=function(e,t,r){return _a.rotateX(e.array,t.array,r),e._dirty=!0,e},Aa.rotateY=function(e,t,r){return _a.rotateY(e.array,t.array,r),e._dirty=!0,e},Aa.rotateZ=function(e,t,r){return _a.rotateZ(e.array,t.array,r),e._dirty=!0,e},Aa.setAxisAngle=function(e,t,r){return _a.setAxisAngle(e.array,t.array,r),e._dirty=!0,e},Aa.normalize=function(e,t){return _a.normalize(e.array,t.array),e._dirty=!0,e},Aa.squaredLength=Aa.sqrLen=function(e){return _a.sqrLen(e.array)},Aa.fromMat3=function(e,t){return _a.fromMat3(e.array,t.array),e._dirty=!0,e},Aa.setAxes=function(e,t,r,n){return _a.setAxes(e.array,t.array,r.array,n.array),e._dirty=!0,e},Aa.rotationTo=function(e,t,r){return _a.rotationTo(e.array,t.array,r.array),e._dirty=!0,e},Aa.fromEuler=function(e,t,r){e._dirty=!0,t=t.array;var n=e.array,i=Math.cos(t[0]/2),a=Math.cos(t[1]/2),o=Math.cos(t[2]/2),s=Math.sin(t[0]/2),l=Math.sin(t[1]/2),u=Math.sin(t[2]/2);switch(r=(r||"XYZ").toUpperCase()){case"XYZ":n[0]=s*a*o+i*l*u,n[1]=i*l*o-s*a*u,n[2]=i*a*u+s*l*o,n[3]=i*a*o-s*l*u;break;case"YXZ":n[0]=s*a*o+i*l*u,n[1]=i*l*o-s*a*u,n[2]=i*a*u-s*l*o,n[3]=i*a*o+s*l*u;break;case"ZXY":n[0]=s*a*o-i*l*u,n[1]=i*l*o+s*a*u,n[2]=i*a*u+s*l*o,n[3]=i*a*o-s*l*u;break;case"ZYX":n[0]=s*a*o-i*l*u,n[1]=i*l*o+s*a*u,n[2]=i*a*u-s*l*o,n[3]=i*a*o+s*l*u;break;case"YZX":n[0]=s*a*o+i*l*u,n[1]=i*l*o+s*a*u,n[2]=i*a*u-s*l*o,n[3]=i*a*o-s*l*u;break;case"XZY":n[0]=s*a*o-i*l*u,n[1]=i*l*o-s*a*u,n[2]=i*a*u+s*l*o,n[3]=i*a*o+s*l*u}};var Da,La,Pa,Oa,Na,Ra,Ia=ki.set,Ba=ki.copy,za=function(e,t){this.min=e||new Ji(1/0,1/0,1/0),this.max=t||new Ji(-1/0,-1/0,-1/0),this.vertices=null};za.prototype={constructor:za,updateFromVertices:function(e){if(e.length>0){var t=this.min,r=this.max,n=t.array,i=r.array;Ba(n,e[0]),Ba(i,e[0]);for(var a=1;a<e.length;a++){var o=e[a];o[0]<n[0]&&(n[0]=o[0]),o[1]<n[1]&&(n[1]=o[1]),o[2]<n[2]&&(n[2]=o[2]),o[0]>i[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}t._dirty=!0,r._dirty=!0}},union:function(e){var t=this.min,r=this.max;return ki.min(t.array,t.array,e.min.array),ki.max(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersection:function(e){var t=this.min,r=this.max;return ki.max(t.array,t.array,e.min.array),ki.min(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,r=this.max.array,n=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||r[0]<n[0]||r[1]<n[1]||r[2]<n[2])},containBoundingBox:function(e){var t=this.min.array,r=this.max.array,n=e.min.array,i=e.max.array;return t[0]<=n[0]&&t[1]<=n[1]&&t[2]<=n[2]&&r[0]>=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},containPoint:function(e){var t=this.min.array,r=this.max.array,n=e.array;return t[0]<=n[0]&&t[1]<=n[1]&&t[2]<=n[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},isFinite:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(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:(Da=ki.create(),La=ki.create(),Pa=ki.create(),Oa=ki.create(),Na=ki.create(),Ra=ki.create(),function(e,t){var r=e.min.array,n=e.max.array,i=t.array;return Da[0]=i[0]*r[0],Da[1]=i[1]*r[0],Da[2]=i[2]*r[0],La[0]=i[0]*n[0],La[1]=i[1]*n[0],La[2]=i[2]*n[0],Pa[0]=i[4]*r[1],Pa[1]=i[5]*r[1],Pa[2]=i[6]*r[1],Oa[0]=i[4]*n[1],Oa[1]=i[5]*n[1],Oa[2]=i[6]*n[1],Na[0]=i[8]*r[2],Na[1]=i[9]*r[2],Na[2]=i[10]*r[2],Ra[0]=i[8]*n[2],Ra[1]=i[9]*n[2],Ra[2]=i[10]*n[2],r=this.min.array,n=this.max.array,r[0]=Math.min(Da[0],La[0])+Math.min(Pa[0],Oa[0])+Math.min(Na[0],Ra[0])+i[12],r[1]=Math.min(Da[1],La[1])+Math.min(Pa[1],Oa[1])+Math.min(Na[1],Ra[1])+i[13],r[2]=Math.min(Da[2],La[2])+Math.min(Pa[2],Oa[2])+Math.min(Na[2],Ra[2])+i[14],n[0]=Math.max(Da[0],La[0])+Math.max(Pa[0],Oa[0])+Math.max(Na[0],Ra[0])+i[12],n[1]=Math.max(Da[1],La[1])+Math.max(Pa[1],Oa[1])+Math.max(Na[1],Ra[1])+i[13],n[2]=Math.max(Da[2],La[2])+Math.max(Pa[2],Oa[2])+Math.max(Na[2],Ra[2])+i[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(e){var t=this.min.array,r=this.max.array,n=e.array,i=t[0],a=t[1],o=t[2],s=r[0],l=r[1],u=t[2],h=r[0],c=r[1],d=r[2];if(1===n[15])t[0]=n[0]*i+n[12],t[1]=n[5]*a+n[13],r[2]=n[10]*o+n[14],r[0]=n[0]*h+n[12],r[1]=n[5]*c+n[13],t[2]=n[10]*d+n[14];else{var f=-1/o;t[0]=n[0]*i*f,t[1]=n[5]*a*f,r[2]=(n[10]*o+n[14])*f,f=-1/u,r[0]=n[0]*s*f,r[1]=n[5]*l*f,f=-1/d,t[2]=(n[10]*d+n[14])*f}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]=ki.fromValues(0,0,0);this.vertices=e}var r=this.min.array,n=this.max.array;return Ia(e[0],r[0],r[1],r[2]),Ia(e[1],r[0],n[1],r[2]),Ia(e[2],n[0],r[1],r[2]),Ia(e[3],n[0],n[1],r[2]),Ia(e[4],r[0],r[1],n[2]),Ia(e[5],r[0],n[1],n[2]),Ia(e[6],n[0],r[1],n[2]),Ia(e[7],n[0],n[1],n[2]),this},copy:function(e){var t=this.min,r=this.max;return Ba(t.array,e.min.array),Ba(r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new za;return e.copy(this),e}};var Fa,ka,Ua,Ga=0,Ha=Nr.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")+"_"+Ga++),this.position||(this.position=new Ji),this.rotation||(this.rotation=new Aa),this.scale||(this.scale=new Ji(1,1,1)),this.worldTransform=new Ta,this.localTransform=new Ta,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var r=t._nodeRepository;delete r[this.name],r[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 r=this._scene;r&&r!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){var t=this._children,r=t.indexOf(e);r<0||(t.splice(r,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,r=0;r<t.length;r++)if(t[r].name===e)return t[r]},getDescendantByName:function(e){for(var t=this._children,r=0;r<t.length;r++){var n=t[r];if(n.name===e)return n;var i=n.getDescendantByName(e);if(i)return i}},queryNode:function(e){if(e){for(var t=e.split("/"),r=this,n=0;n<t.length;n++){var i=t[n];if(i){for(var a=!1,o=r._children,s=0;s<o.length;s++){var l=o[s];if(l.name===i){r=l,a=!0;break}}if(!a)return}}return r}},getPath:function(e){if(!this._parent)return"/";for(var t=this._parent,r=this.name;t._parent&&(r=t.name+"/"+r,t._parent!=e);)t=t._parent;return!t._parent&&e?null:r},traverse:function(e,t){e.call(t,this);for(var r=this._children,n=0,i=r.length;n<i;n++)r[n].traverse(e,t)},eachChild:function(e,t){for(var r=this._children,n=0,i=r.length;n<i;n++){var a=r[n];e.call(t,a,n)}},setLocalTransform:function(e){Fi.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){Fi.copy(this.worldTransform.array,e.array),this.decomposeWorldTransform()},decomposeWorldTransform:(ka=Fi.create(),function(e){var t=this.localTransform,r=this.worldTransform;this._parent?(Fi.invert(ka,this._parent.worldTransform.array),Fi.multiply(t.array,ka,r.array)):Fi.copy(t.array,r.array);var n=e?null:this.scale;t.decomposeMatrix(n,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,r=this.scale;if(this.transformNeedsUpdate()){var n=this.localTransform.array;Fi.fromRotationTranslation(n,t.array,e.array),Fi.scale(n,n,r.array),t._dirty=!1,r._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var e=this.localTransform.array,t=this.worldTransform.array;this._parent?Fi.multiplyAffine(t,this._parent.worldTransform.array,e):Fi.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,r=0,n=t.length;r<n;r++)t[r].update(e)},getBoundingBox:function(){function e(e){return!e.invisible&&e.geometry}var t=new za,r=new Ta,n=new Ta;return function(i,a){return a=a||new za,this._parent?Ta.invert(n,this._parent.worldTransform):Ta.identity(n),this.traverse(function(e){e.geometry&&e.geometry.boundingBox&&(t.copy(e.geometry.boundingBox),Ta.multiply(r,n,e.worldTransform),t.applyTransform(r),a.union(t))},this,e),a}}(),getWorldPosition:function(e){this.transformNeedsUpdate()&&this.updateWorldTransform();var t=this.worldTransform.array;if(e){var r=e.array;return r[0]=t[12],r[1]=t[13],r[2]=t[14],e}return new Ji(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 r=0;r<t.length;r++)e.add(t[r].clone());return e},rotateAround:function(){var e=new Ji,t=new Ta;return function(r,n,i){e.copy(this.position).subtract(r);var a=this.localTransform;a.identity(),a.translate(r),a.rotate(i,n),t.fromRotationTranslation(this.rotation,e),a.multiply(t),a.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:(Fa=new Ta,function(e,t){Fa.lookAt(this.position,e,t||this.localTransform.y).invert(),this.setLocalTransform(Fa),this.target=e})}),Va=Ha.extend({material:null,geometry:null,mode:Wr,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:Qr,frontFace:en,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=Ha.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:(Ua=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var e=Ha.prototype.clone.call(this);e.geometry=this.geometry,e.material=this.material;for(var t=0;t<Ua.length;t++){var r=Ua[t];e[r]!==this[r]&&(e[r]=this[r])}return e})});Va.POINTS=Ur,Va.LINES=Gr,Va.LINE_LOOP=Hr,Va.LINE_STRIP=Vr,Va.TRIANGLES=Wr,Va.TRIANGLE_STRIP=jr,Va.TRIANGLE_FAN=Xr,Va.BACK=Qr,Va.FRONT=Kr,Va.FRONT_AND_BACK=Jr,Va.CW=$r,Va.CCW=en;var Wa,ja,Xa,qa,Za,Ya=Nr.extend({scene:null,camera:null,renderer:null},function(){this._ray=new ca,this._ndc=new li},{pick:function(e,t,r){return this.pickAll(e,t,[],r)[0]||null},pickAll:function(e,t,r,n){return this.renderer.screenToNDC(e,t,this._ndc),this.camera.castRay(this._ndc,this._ray),r=r||[],this._intersectNode(this.scene,r,n||!1),r.sort(this._intersectionCompareFunc),r},_intersectNode:function(e,t,r){e instanceof Va&&e.isRenderable()&&(e.ignorePicking&&!r||!(e.mode===Wr&&e.geometry.isUseIndices()||e.geometry.pickByRay||e.geometry.pick)||this._intersectRenderable(e,t));for(var n=0;n<e._children.length;n++)this._intersectNode(e._children[n],t,r)},_intersectRenderable:(Wa=new Ji,ja=new Ji,Xa=new Ji,qa=new ca,Za=new Ta,function(e,t){var r=e.isSkinnedMesh();qa.copy(this._ray),Ta.invert(Za,e.worldTransform),r||qa.applyTransform(Za);var n=e.geometry,i=r?e.skeleton.boundingBox:n.boundingBox;if(!i||qa.intersectBoundingBox(i))if(n.pick)n.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,e,t);else if(n.pickByRay)n.pickByRay(qa,e,t);else{var a,o,s=e.cullFace===Qr&&e.frontFace===en||e.cullFace===Kr&&e.frontFace===$r,l=n.indices,u=n.attributes.position,h=n.attributes.weight,c=n.attributes.joint,d=[];if(u&&u.value&&l){if(r){o=e.skeleton.getSubSkinMatrices(e.__uid__,e.joints);for(var f=0;f<e.joints.length;f++){d[f]=d[f]||[];for(var p=0;p<16;p++)d[f][p]=o[16*f+p]}var m=[],g=[],v=[],_=[],y=[],x=n.attributes.skinnedPosition;for(x&&x.value||(n.createAttribute("skinnedPosition","f",3),(x=n.attributes.skinnedPosition).init(n.vertexCount)),f=0;f<n.vertexCount;f++){for(u.get(f,m),h.get(f,g),c.get(f,v),g[3]=1-g[0]-g[1]-g[2],ki.set(_,0,0,0),p=0;p<4;p++)v[p]>=0&&g[p]>1e-4&&(ki.transformMat4(y,m,d[v[p]]),ki.scaleAndAdd(_,_,y,g[p]));x.set(f,_)}}for(f=0;f<l.length;f+=3){var b=l[f],w=l[f+1],T=l[f+2],S=r?n.attributes.skinnedPosition:u;if(S.get(b,Wa.array),S.get(w,ja.array),S.get(T,Xa.array),a=s?qa.intersectTriangle(Wa,ja,Xa,e.culling):qa.intersectTriangle(Wa,Xa,ja,e.culling)){var M=new Ji;r?Ji.copy(M,a):Ji.transformMat4(M,a,e.worldTransform),t.push(new Ya.Intersection(a,M,e,[b,w,T],f/3,Ji.dist(M,this._ray.origin)))}}}}}),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});Ya.Intersection=function(e,t,r,n,i,a){this.point=e,this.pointWorld=t,this.target=r,this.triangle=n,this.triangleIndex=i,this.distance=a};var Ka="__dt__",Qa=function(){this._contextId=0,this._caches=[],this._context={}};(Qa.prototype={use:function(e,t){var r=this._caches;r[e]||(r[e]={},t&&(r[e]=t())),this._contextId=e,this._context=r[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){var t=Ka+(e=e||"");this.put(t,!0)},dirtyAll:function(e){for(var t=Ka+(e=e||""),r=this._caches,n=0;n<r.length;n++)r[n]&&(r[n][t]=!0)},fresh:function(e){var t=Ka+(e=e||"");this.put(t,!1)},freshAll:function(e){for(var t=Ka+(e=e||""),r=this._caches,n=0;n<r.length;n++)r[n]&&(r[n][t]=!1)},isDirty:function(e){var t=Ka+(e=e||""),r=this._context;return!r.hasOwnProperty(t)||!0===r[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(r){e&&e.call(t,r)})},miss:function(e){return!this._context.hasOwnProperty(e)}}).constructor=Qa;var Ja=Nr.extend({width:512,height:512,type:rn,format:dn,wrapS:Tn,wrapT:Tn,minFilter:xn,magFilter:gn,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},function(){this._cache=new Qa},{getWebGLTexture:function(e){var t=e.gl,r=this._cache;return r.use(e.__uid__),r.miss("webgl_texture")&&r.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):r.isDirty()&&(this.update(e),r.fresh()),r.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===un&&(this.useMipmap=!1);var r=e.getGLExtension("EXT_sRGB");this.format!==Ja.SRGB||r||(this.format=Ja.RGB),this.format!==Ja.SRGB_ALPHA||r||(this.format=Ja.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?Sn:this.wrapS},getAvailableWrapT:function(){return this.NPOT?Sn:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===vn||e===yn?mn:e===xn||e===_n?gn: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 r=t.get("webgl_texture");r&&e.gl.deleteTexture(r),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(Ja.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(Ja.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),Ja.BYTE=tn,Ja.UNSIGNED_BYTE=rn,Ja.SHORT=nn,Ja.UNSIGNED_SHORT=an,Ja.INT=on,Ja.UNSIGNED_INT=sn,Ja.FLOAT=ln,Ja.HALF_FLOAT=36193,Ja.UNSIGNED_INT_24_8_WEBGL=34042,Ja.DEPTH_COMPONENT=un,Ja.DEPTH_STENCIL=Cn,Ja.ALPHA=hn,Ja.RGB=cn,Ja.RGBA=dn,Ja.LUMINANCE=fn,Ja.LUMINANCE_ALPHA=pn,Ja.SRGB=35904,Ja.SRGB_ALPHA=35906,Ja.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,Ja.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,Ja.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,Ja.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,Ja.NEAREST=mn,Ja.LINEAR=gn,Ja.NEAREST_MIPMAP_NEAREST=vn,Ja.LINEAR_MIPMAP_NEAREST=_n,Ja.NEAREST_MIPMAP_LINEAR=yn,Ja.LINEAR_MIPMAP_LINEAR=xn,Ja.REPEAT=Tn,Ja.CLAMP_TO_EDGE=Sn,Ja.MIRRORED_REPEAT=Mn;var $a=Va.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=Va.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});$a.POINTS=Ur,$a.LINES=Gr,$a.LINE_LOOP=Hr,$a.LINE_STRIP=Vr,$a.TRIANGLES=Wr,$a.TRIANGLE_STRIP=jr,$a.TRIANGLE_FAN=Xr,$a.BACK=Qr,$a.FRONT=Kr,$a.FRONT_AND_BACK=Jr,$a.CW=$r,$a.CCW=en;var eo={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))}},to=eo.isPowerOfTwo;function ro(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}var no=Ja.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 r=this.format,n=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==Ja.REPEAT&&this.wrapT!==Ja.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 a=e.getGLExtension("EXT_texture_filter_anisotropic");(a&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,a.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n)&&(e.getGLExtension("OES_texture_half_float")||(n=ln));if(this.mipmaps.length)for(var o=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var u=this.mipmaps[l];this._updateTextureData(t,u,l,o,s,r,n,!1),o/=2,s/=2}else this._updateTextureData(t,this,0,this.width,this.height,r,n,i),!this.useMipmap||this.NPOT&&!i||t.generateMipmap(t.TEXTURE_2D);t.bindTexture(t.TEXTURE_2D,null)},_updateTextureData:function(e,t,r,n,i,a,o,s){if(t.image){var l=t.image;s&&(this._potCanvas=function(e,t){var r=ro(e.width),n=ro(e.height);return(t=t||document.createElement("canvas")).width=r,t.height=n,t.getContext("2d").drawImage(e.image,0,0,r,n),t}(this,this._potCanvas),l=this._potCanvas),e.texImage2D(e.TEXTURE_2D,r,a,a,o,l)}else a<=Ja.COMPRESSED_RGBA_S3TC_DXT5_EXT&&a>=Ja.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,a,n,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,a,n,i,0,a,o,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 to(this.width)&&to(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 r=In.createImage();t&&(r.crossOrigin=t);var n=this;return r.onload=function(){n.dirty(),n.trigger("success",n)},r.onerror=function(){n.trigger("error",n)},r.src=e,this.image=r,this}});function io(e){return{byte:In.Int8Array,ubyte:In.Uint8Array,short:In.Int16Array,ushort:In.Uint16Array}[e]||In.Float32Array}function ao(e){return"attr_"+e}function oo(e,t,r,n){switch(this.name=e,this.type=t,this.size=r,this.semantic=n||"",this.value=null,r){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 r=this.value;return t[0]=r[2*e],t[1]=r[2*e+1],t},this.set=function(e,t){var r=this.value;r[2*e]=t[0],r[2*e+1]=t[1]},this.copy=function(e,t){var r=this.value;t*=2,r[e*=2]=r[t],r[e+1]=r[t+1]};break;case 3:this.get=function(e,t){var r=3*e,n=this.value;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t},this.set=function(e,t){var r=3*e,n=this.value;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2]},this.copy=function(e,t){var r=this.value;t*=3,r[e*=3]=r[t],r[e+1]=r[t+1],r[e+2]=r[t+2]};break;case 4:this.get=function(e,t){var r=this.value,n=4*e;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t[3]=r[n+3],t},this.set=function(e,t){var r=this.value,n=4*e;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2],r[n+3]=t[3]},this.copy=function(e,t){var r=this.value;t*=4,r[e*=4]=r[t],r[e+1]=r[t+1],r[e+2]=r[t+2],r[e+3]=r[t+3]}}}function so(e,t,r,n,i){this.name=e,this.type=t,this.buffer=r,this.size=n,this.semantic=i,this.symbol="",this.needsRemove=!1}function lo(e){this.buffer=e,this.count=0}Object.defineProperty(no.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(no.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)}}),oo.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=io(this.type);this.value=new t(e*this.size)}},oo.prototype.fromArray=function(e){var t,r=io(this.type);if(e[0]&&e[0].length){var n=0,i=this.size;t=new r(e.length*i);for(var a=0;a<e.length;a++)for(var o=0;o<i;o++)t[n++]=e[a][o]}else t=new r(e);this.value=t},oo.prototype.clone=function(e){var t=new oo(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t};var uo=Nr.extend(function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}},function(){this._cache=new Qa,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(ao(e)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(e,t){if(e<this.triangleCount&&e>=0){t||(t=[]);var r=this.indices;return t[0]=r[3*e],t[1]=r[3*e+1],t[2]=r[3*e+2],t}},setTriangleIndices:function(e,t){var r=this.indices;r[3*e]=t[0],r[3*e+1]=t[1],r[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,r=this.vertexCount>65535?In.Uint32Array:In.Uint16Array;if(e[0]&&e[0].length){var n=0;t=new r(3*e.length);for(var i=0;i<e.length;i++)for(var a=0;a<3;a++)t[n++]=e[i][a]}else t=new r(e);this.indices=t},createAttribute:function(e,t,r,n){var i=new oo(e,t,r,n);return this.attributes[e]&&this.removeAttribute(e),this.attributes[e]=i,this._attributeList.push(e),i},removeAttribute:function(e){var t=this._attributeList,r=t.indexOf(e);return r>=0&&(t.splice(r,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 r=[],n=this.vertexCount,i=0;i<t.length;i++){var a=t[i],o=this.attributes[a];o.value&&o.value.length===n*o.size&&r.push(a)}return this._enabledAttributes=r,r},getBufferChunks:function(e){var t=this._cache;t.use(e.__uid__);var r=t.isDirty("attributes"),n=t.isDirty("indices");if(r||n){this._updateBuffer(e.gl,r,n);for(var i=this.getEnabledAttributes(),a=0;a<i.length;a++)t.fresh(ao(i[a]));t.fresh("attributes"),t.fresh("indices")}return t.fresh("any"),t.get("chunks")},_updateBuffer:function(e,t,r){var n=this._cache,i=n.get("chunks"),a=!1;i||((i=[])[0]={attributeBuffers:[],indicesBuffer:null},n.put("chunks",i),a=!0);var o=i[0],s=o.attributeBuffers,l=o.indicesBuffer;if(t||a){var u=this.getEnabledAttributes(),h={};if(!a)for(var c=0;c<s.length;c++)h[s[c].name]=s[c];for(var d=0;d<u.length;d++){var f,p,m=u[d],g=this.attributes[m];a||(f=h[m]),p=f?f.buffer:e.createBuffer(),n.isDirty(ao(m))&&(e.bindBuffer(e.ARRAY_BUFFER,p),e.bufferData(e.ARRAY_BUFFER,g.value,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW)),s[d]=new so(m,g.type,p,g.size,g.semantic)}for(c=d;c<s.length;c++)e.deleteBuffer(s[c].buffer);s.length=d}this.isUseIndices()&&(r||a)&&(l||(l=new lo(e.createBuffer()),o.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 r=t.get("chunks");if(r)for(var n=0;n<r.length;n++){for(var i=r[n],a=0;a<i.attributeBuffers.length;a++){var o=i.attributeBuffers[a];e.gl.deleteBuffer(o.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(uo.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(uo.prototype,"triangleCount",{enumerable:!1,get:function(){var e=this.indices;return e?e.length/3:0}})),uo.STATIC_DRAW=Zr,uo.DYNAMIC_DRAW=Yr,uo.STREAM_DRAW=qr,uo.AttributeBuffer=so,uo.IndicesBuffer=lo,uo.Attribute=oo;var ho=ki.create,co=ki.add,fo=ki.set,po=uo.Attribute,mo=uo.extend(function(){return{attributes:{position:new po("position","float",3,"POSITION"),texcoord0:new po("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new po("texcoord1","float",2,"TEXCOORD_1"),normal:new po("normal","float",3,"NORMAL"),tangent:new po("tangent","float",4,"TANGENT"),color:new po("color","float",4,"COLOR"),weight:new po("weight","float",3,"WEIGHT"),joint:new po("joint","float",4,"JOINT"),barycentric:new po("barycentric","float",3,null)},boundingBox:null}},{mainAttribute:"position",updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new za);var t=this.attributes.position.value;if(t&&t.length){var r=e.min,n=e.max,i=r.array,a=n.array;ki.set(i,t[0],t[1],t[2]),ki.set(a,t[0],t[1],t[2]);for(var o=3;o<t.length;){var s=t[o++],l=t[o++],u=t[o++];s<i[0]&&(i[0]=s),l<i[1]&&(i[1]=l),u<i[2]&&(i[2]=u),s>a[0]&&(a[0]=s),l>a[1]&&(a[1]=l),u>a[2]&&(a[2]=u)}r._dirty=!0,n._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,r=t.position.value,n=t.normal.value;if(n&&n.length===r.length)for(var i=0;i<n.length;i++)n[i]=0;else n=t.normal.value=new In.Float32Array(r.length);for(var a,o,s,l=ho(),u=ho(),h=ho(),c=ho(),d=ho(),f=ho(),p=e?e.length:this.vertexCount,m=0;m<p;){e?(a=e[m++],o=e[m++],s=e[m++]):(a=m++,o=m++,s=m++),fo(l,r[3*a],r[3*a+1],r[3*a+2]),fo(u,r[3*o],r[3*o+1],r[3*o+2]),fo(h,r[3*s],r[3*s+1],r[3*s+2]),ki.sub(c,l,u),ki.sub(d,u,h),ki.cross(f,c,d);for(i=0;i<3;i++)n[3*a+i]=n[3*a+i]+f[i],n[3*o+i]=n[3*o+i]+f[i],n[3*s+i]=n[3*s+i]+f[i]}for(i=0;i<n.length;)fo(f,n[i],n[i+1],n[i+2]),ki.normalize(f,f),n[i++]=f[0],n[i++]=f[1],n[i++]=f[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.indices,t=this.attributes,r=t.position.value,n=t.normal.value,i=ho(),a=ho(),o=ho(),s=ho(),l=ho(),u=ho();n||(n=t.normal.value=new Float32Array(r.length));for(var h,c,d,f=e?e.length:this.vertexCount,p=0;p<f;){e?(h=e[p++],c=e[p++],d=e[p++]):(h=p++,c=p++,d=p++),fo(i,r[3*h],r[3*h+1],r[3*h+2]),fo(a,r[3*c],r[3*c+1],r[3*c+2]),fo(o,r[3*d],r[3*d+1],r[3*d+2]),ki.sub(s,i,a),ki.sub(l,a,o),ki.cross(u,s,l),ki.normalize(u,u);for(var m=0;m<3;m++)n[3*h+m]=u[m],n[3*c+m]=u[m],n[3*d+m]=u[m]}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 r=t.texcoord0.value,n=t.position.value,i=t.tangent.value,a=t.normal.value;if(r){for(var o=[],s=[],l=0;l<e;l++)o[l]=[0,0,0],s[l]=[0,0,0];var u,h,c,d=[0,0,0],f=[0,0,0],p=this.indices,m=p?p.length:this.vertexCount;for(l=0;l<m;){p?(u=p[l++],h=p[l++],c=p[l++]):(u=l++,h=l++,c=l++);var g=r[2*u],v=r[2*h],_=r[2*c],y=r[2*u+1],x=r[2*h+1],b=r[2*c+1],w=n[3*u],T=n[3*h],S=n[3*c],M=n[3*u+1],A=n[3*h+1],E=n[3*c+1],C=n[3*u+2],D=T-w,L=S-w,P=A-M,O=E-M,N=n[3*h+2]-C,R=n[3*c+2]-C,I=v-g,B=_-g,z=x-y,F=b-y,k=1/(I*F-z*B);d[0]=(F*D-z*L)*k,d[1]=(F*P-z*O)*k,d[2]=(F*N-z*R)*k,f[0]=(I*L-B*D)*k,f[1]=(I*O-B*P)*k,f[2]=(I*R-B*N)*k,co(o[u],o[u],d),co(o[h],o[h],d),co(o[c],o[c],d),co(s[u],s[u],f),co(s[h],s[h],f),co(s[c],s[c],f)}var U=ho(),G=ho(),H=ho();for(l=0;l<e;l++){H[0]=a[3*l],H[1]=a[3*l+1],H[2]=a[3*l+2];var V=o[l];ki.scale(U,H,ki.dot(H,V)),ki.sub(U,V,U),ki.normalize(U,U),ki.cross(G,H,V),i[4*l]=U[0],i[4*l+1]=U[1],i[4*l+2]=U[2],i[4*l+3]=ki.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 In.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),n={},i=0;i<r.length;i++){n[l=r[i]]=e[l].value,e[l].init(this.indices.length)}for(var a=0,o=0;o<t.length;o++){var s=t[o];for(i=0;i<r.length;i++)for(var l,u=e[l=r[i]].value,h=e[l].size,c=0;c<h;c++)u[a*h+c]=n[l][s*h+c];t[o]=a,a++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.attributes,t=e.barycentric.value,r=this.indices;if(!t||t.length!==3*r.length){t=e.barycentric.value=new Float32Array(3*r.length);for(var n=0;n<(r?r.length:this.vertexCount/3);)for(var i=0;i<3;i++){t[3*(r?r[n++]:3*n+i)+i]=1}this.dirty()}}},applyTransform:function(e){var t=this.attributes,r=t.position.value,n=t.normal.value,i=t.tangent.value;e=e.array;var a=Fi.create();Fi.invert(a,e),Fi.transpose(a,a);var o=ki.transformMat4,s=ki.forEach;s(r,3,0,null,o,e),n&&s(n,3,0,null,o,a),i&&s(i,4,0,null,o,a),this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__uid__);var r=t.get("chunks");if(r)for(var n=0;n<r.length;n++){for(var i=r[n],a=0;a<i.attributeBuffers.length;a++){var o=i.attributeBuffers[a];e.gl.deleteBuffer(o.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__)}});mo.STATIC_DRAW=uo.STATIC_DRAW,mo.DYNAMIC_DRAW=uo.DYNAMIC_DRAW,mo.STREAM_DRAW=uo.STREAM_DRAW,mo.AttributeBuffer=uo.AttributeBuffer,mo.IndicesBuffer=uo.IndicesBuffer,mo.Attribute=po;var go="uniform vec3 ",vo="uniform float ",_o="@export clay.header.",yo="@end",xo=":unconfigurable;",bo=[_o+"directional_light",go+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+xo,go+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+xo,yo,_o+"ambient_light",go+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+xo,yo,_o+"ambient_sh_light",go+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+xo,go+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+xo,"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}",yo,_o+"ambient_cubemap_light",go+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+xo,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+xo,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+xo,yo,_o+"point_light",go+"pointLightPosition[POINT_LIGHT_COUNT]"+xo,vo+"pointLightRange[POINT_LIGHT_COUNT]"+xo,go+"pointLightColor[POINT_LIGHT_COUNT]"+xo,yo,_o+"spot_light",go+"spotLightPosition[SPOT_LIGHT_COUNT]"+xo,go+"spotLightDirection[SPOT_LIGHT_COUNT]"+xo,vo+"spotLightRange[SPOT_LIGHT_COUNT]"+xo,vo+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+xo,vo+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+xo,vo+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+xo,go+"spotLightColor[SPOT_LIGHT_COUNT]"+xo,yo].join("\n");Ri.import(bo);var wo,To,So,Mo,Ao=Ha.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var e=Ha.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}}),Eo=function(e,t){this.normal=e||new Ji(0,1,0),this.distance=t||0};Eo.prototype={constructor:Eo,distanceToPoint:function(e){return ki.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new Ji);var r=this.distanceToPoint(e);return ki.scaleAndAdd(t.array,e.array,this.normal.array,-r),t._dirty=!0,t},normalize:function(){var e=1/ki.len(this.normal.array);ki.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,r=this.normal.array,n=ki.dot(t[0].array,r)>this.distance,i=1;i<8;i++)if(ki.dot(t[i].array,r)>this.distance!=n)return!0},intersectLine:(Mo=ki.create(),function(e,t,r){var n=this.distanceToPoint(e),i=this.distanceToPoint(t);if(n>0&&i>0||n<0&&i<0)return null;var a=this.normal.array,o=this.distance,s=e.array;ki.sub(Mo,t.array,e.array),ki.normalize(Mo,Mo);var l=ki.dot(a,Mo);if(0===l)return null;r||(r=new Ji);var u=(ki.dot(a,s)-o)/l;return ki.scaleAndAdd(r.array,s,Mo,-u),r._dirty=!0,r}),applyTransform:(wo=Fi.create(),To=da.create(),So=da.create(),So[3]=1,function(e){e=e.array,ki.scale(So,this.normal.array,this.distance),da.transformMat4(So,So,e),this.distance=ki.dot(So,this.normal.array),Fi.invert(wo,e),Fi.transpose(wo,wo),To[3]=0,ki.copy(To,this.normal.array),da.transformMat4(To,To,wo),ki.copy(this.normal.array,To)}),copy:function(e){ki.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new Eo;return e.copy(this),e}};var Co,Do=ki.set,Lo=ki.copy,Po=ki.transformMat4,Oo=Math.min,No=Math.max,Ro=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new Eo);this.boundingBox=new za,this.vertices=[];for(e=0;e<8;e++)this.vertices[e]=ki.fromValues(0,0,0)};Ro.prototype={setFromProjection:function(e){var t=this.planes,r=e.array,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],u=r[6],h=r[7],c=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],_=r[15];Do(t[0].normal.array,o-n,h-s,p-c),t[0].distance=-(_-m),t[0].normalize(),Do(t[1].normal.array,o+n,h+s,p+c),t[1].distance=-(_+m),t[1].normalize(),Do(t[2].normal.array,o+i,h+l,p+d),t[2].distance=-(_+g),t[2].normalize(),Do(t[3].normal.array,o-i,h-l,p-d),t[3].distance=-(_-g),t[3].normalize(),Do(t[4].normal.array,o-a,h-u,p-f),t[4].distance=-(_-v),t[4].normalize(),Do(t[5].normal.array,o+a,h+u,p+f),t[5].distance=-(_+v),t[5].normalize();var y=this.boundingBox,x=this.vertices;if(0===_){var b=l/n,w=-v/(f-1),T=-v/(f+1),S=-T/l,M=-w/l;y.min.set(-S*b,-S,T),y.max.set(S*b,S,w),Do(x[0],-S*b,-S,T),Do(x[1],-S*b,S,T),Do(x[2],S*b,-S,T),Do(x[3],S*b,S,T),Do(x[4],-M*b,-M,w),Do(x[5],-M*b,M,w),Do(x[6],M*b,-M,w),Do(x[7],M*b,M,w)}else{var A=(-1-m)/n,E=(1-m)/n,C=(1-g)/l,D=(-1-g)/l,L=(-1-v)/f,P=(1-v)/f;y.min.set(Math.min(A,E),Math.min(D,C),Math.min(P,L)),y.max.set(Math.max(E,A),Math.max(C,D),Math.max(L,P));var O=y.min.array,N=y.max.array;Do(x[0],O[0],O[1],O[2]),Do(x[1],O[0],N[1],O[2]),Do(x[2],N[0],O[1],O[2]),Do(x[3],N[0],N[1],O[2]),Do(x[4],O[0],O[1],N[2]),Do(x[5],O[0],N[1],N[2]),Do(x[6],N[0],O[1],N[2]),Do(x[7],N[0],N[1],N[2])}},getTransformedBoundingBox:(Co=ki.create(),function(e,t){var r=this.vertices,n=t.array,i=e.min,a=e.max,o=i.array,s=a.array,l=r[0];Po(Co,l,n),Lo(o,Co),Lo(s,Co);for(var u=1;u<8;u++)l=r[u],Po(Co,l,n),o[0]=Oo(Co[0],o[0]),o[1]=Oo(Co[1],o[1]),o[2]=Oo(Co[2],o[2]),s[0]=No(Co[0],s[0]),s[1]=No(Co[1],s[1]),s[2]=No(Co[2],s[2]);return i._dirty=!0,a._dirty=!0,e})};var Io,Bo=Ha.extend(function(){return{projectionMatrix:new Ta,invProjectionMatrix:new Ta,viewMatrix:new Ta,frustum:new Ro}},function(){this.update(!0)},{update:function(e){Ha.prototype.update.call(this,e),Ta.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),Ta.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){Ta.copy(this.viewMatrix,e),Ta.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){Ta.copy(this.projectionMatrix,e),Ta.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(Io=da.create(),function(e,t){var r=void 0!==t?t:new ca,n=e.array[0],i=e.array[1];return da.set(Io,n,i,-1,1),da.transformMat4(Io,Io,this.invProjectionMatrix.array),da.transformMat4(Io,Io,this.worldTransform.array),ki.scale(r.origin.array,Io,1/Io[3]),da.set(Io,n,i,1,1),da.transformMat4(Io,Io,this.invProjectionMatrix.array),da.transformMat4(Io,Io,this.worldTransform.array),ki.scale(Io,Io,1/Io[3]),ki.sub(r.direction.array,Io,r.origin.array),ki.normalize(r.direction.array,r.direction.array),r.direction._dirty=!0,r.origin._dirty=!0,r})}),zo=Fi.create(),Fo=Fi.create(),ko={};function Uo(e){var t=[],r=Object.keys(e);r.sort();for(var n=0;n<r.length;n++){var i=r[n];t.push(i+" "+e[i])}var a=t.join("\n");if(ko[a])return ko[a];var o=Or.genGUID();return ko[a]=o,o}function Go(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}Go.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},Go.prototype.add=function(e,t){t?this.transparent[this._transparentCount++]=e:this.opaque[this._opaqueCount++]=e},Go.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var Ho,Vo,Wo=Ha.extend(function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new za,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new Fn(20)}},function(){this._scene=this},{addToScene:function(e){e instanceof Bo?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof Ao&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof Bo?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof Ao&&(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={},r=0;r<e.length;r++){var n=e[r];if(!n.invisible){var i=n.group;t[i]||(t[i]={}),t[i][n.type]=t[i][n.type]||0,t[i][n.type]++}}for(var a in this._lightNumber=t,t)this._lightProgramKeys[a]=Uo(t[a]);this._updateLightUniforms()},cloneNode:function(e){var t=e.clone(),r={};return function e(t,n){r[t.__uid__]=n;for(var i=0;i<t._children.length;i++){e(t._children[i],n._children[i])}}(e,t),t.traverse(function(e){e.skeleton&&(e.skeleton=e.skeleton.clone(r)),e.material&&(e.material=e.material.clone())}),t},updateRenderList:function(e,t){var r=e.__uid__,n=this._renderLists.get(r);n||(n=new Go,this._renderLists.put(r,n)),n.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,n,t),n.endCount(),n},getRenderList:function(e){return this._renderLists.get(e.__uid__)},_doUpdateRenderList:function(e,t,r,n,i){if(!e.invisible)for(var a=0;a<e._children.length;a++){var o=e._children[a];if(o.isRenderable()){var s=o.isSkinnedMesh()?zo:o.worldTransform.array,l=o.geometry;Fi.multiplyAffine(Fo,t.viewMatrix.array,s),(i&&!l.boundingBox||!this.isFrustumCulled(o,t,Fo))&&n.add(o,o.material.transparent||r)}o._children.length>0&&this._doUpdateRenderList(o,t,r,n,i)}},isFrustumCulled:(Ho=new za,Vo=new Ta,function(e,t,r){var n=e.boundingBox;if(n||(n=e.skeleton&&e.skeleton.boundingBox?e.skeleton.boundingBox:e.geometry.boundingBox),!n)return!1;if(Vo.array=r,Ho.transformFrom(n,Vo),e.castShadow&&this.viewBoundingBoxLastFrame.union(Ho),e.frustumCulling){if(!Ho.intersectBoundingBox(t.frustum.boundingBox))return!0;Vo.array=t.projectionMatrix.array,Ho.max.array[2]>0&&Ho.min.array[2]<0&&(Ho.max.array[2]=-1e-20),Ho.applyProjection(Vo);var i=Ho.min.array,a=Ho.max.array;if(a[0]<-1||i[0]>1||a[1]<-1||i[1]>1||a[2]<-1||i[2]>1)return!0}return!1}),_updateLightUniforms:function(){var e=this.lights;e.sort(jo);var t=this._lightUniforms;for(var r in t)for(var n in t[r])t[r][n].value.length=0;for(var i=0;i<e.length;i++){var a=e[i];if(!a.invisible){r=a.group;for(var n in a.uniformTemplates){var o=a.uniformTemplates[n],s=o.value(a);if(null!=s){t[r]||(t[r]={}),t[r][n]||(t[r][n]={type:"",value:[]});var l=t[r][n];switch(l.type=o.type+"v",o.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 "+o.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,r=this._lightNumber;for(var n in r[e]){if(!t[e])return!0;if(r[e][n]!==t[e][n])return!0}for(var n in t[e]){if(!r[e])return!0;if(r[e][n]!==t[e][n])return!0}return!1},getLightsNumbers:function(e){return this._lightNumber[e]},getProgramKey:function(e){return this._lightProgramKeys[e]},setLightUniforms:function(){function e(e,t,r){for(var n in e){var i=e[n];if("tv"===i.type){if(!t.hasUniform(n))continue;for(var a=[],o=0;o<i.value.length;o++){var s=i.value[o],l=t.takeCurrentTextureSlot(r,s);a.push(l)}t.setUniform(r.gl,"1iv",n,a)}else t.setUniform(r.gl,i.type,n,i.value)}}return function(t,r,n){e(this._lightUniforms[r],t,n),e(this.shadowUniforms,t,n)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});function jo(e,t){if(t.castShadow&&!e.castShadow)return!0}var Xo=eo.isPowerOfTwo,qo=["px","nx","py","ny","pz","nz"],Zo=Ja.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 r=this.format,n=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===n)&&(e.getGLExtension("OES_texture_half_float")||(n=ln));if(this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(t,l,s,a,o,r,n),a/=2,o/=2}else this._updateTextureData(t,this,0,this.width,this.height,r,n),!this.NPOT&&this.useMipmap&&t.generateMipmap(t.TEXTURE_CUBE_MAP);t.bindTexture(t.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(e,t,r,n,i,a,o){for(var s=0;s<6;s++){var l=qo[s],u=t.image&&t.image[l];u?e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,r,a,a,o,u):e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,r,a,n,i,0,a,o,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?Xo(this.image.px.width)&&Xo(this.image.px.height):Xo(this.width)&&Xo(this.height)},isRenderable:function(){return this.image.px?Yo(this.image.px)&&Yo(this.image.nx)&&Yo(this.image.py)&&Yo(this.image.ny)&&Yo(this.image.pz)&&Yo(this.image.nz):!(!this.width||!this.height)},load:function(e,t){var r=0,n=this;return Or.each(e,function(e,i){var a=In.createImage();t&&(a.crossOrigin=t),a.onload=function(){0===--r&&(n.dirty(),n.trigger("success",n))},a.onerror=function(){r--},r++,a.src=e,n.image[i]=a}),this}});function Yo(e){return e.width>0&&e.height>0}Object.defineProperty(Zo.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(Zo.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 Ko=Bo.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=Bo.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),Qo="framebuffer",Jo="renderbuffer",$o=Jo+"_width",es=Jo+"_height",ts=Jo+"_attached",rs="depthtexture_attached",ns=An,is=En,as=Ln,os=Dn,ss=Nr.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},function(){this._cache=new Qa,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(ns,this._getFrameBufferGL(e)),this._boundRenderer=e;var r=this._cache;r.put("viewport",e.viewport);var n,i,a=!1;for(var o in this._textures){a=!0;var s=this._textures[o];s&&(n=s.texture.width,i=s.texture.height,this._doAttach(e,s.texture,o,s.target))}this._width=n,this._height=i,!a&&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,n,i,1);var l=r.get("attached_textures");if(l)for(var o in l)if(!this._textures[o]){var u=l[o];this._doDetach(t,o,u)}if(!r.get(rs)&&this.depthBuffer){r.miss(Jo)&&r.put(Jo,t.createRenderbuffer());var h=r.get(Jo);n===r.get($o)&&i===r.get(es)||(t.bindRenderbuffer(is,h),t.renderbufferStorage(is,t.DEPTH_COMPONENT16,n,i),r.put($o,n),r.put(es,i),t.bindRenderbuffer(is,null)),r.get(ts)||(t.framebufferRenderbuffer(ns,as,is,h),r.put(ts,!0))}},unbind:function(e){e.__currentFrameBuffer=null,e.gl.bindFramebuffer(ns,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 r in this._textures){var n=this._textures[r];if(n){var i=n.texture;if(!i.NPOT&&i.useMipmap&&i.minFilter===Ja.LINEAR_MIPMAP_LINEAR){var a="textureCube"===i.textureType?wn:bn;t.bindTexture(a,i.getWebGLTexture(e)),t.generateMipmap(a),t.bindTexture(a,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(ns)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(Qo)&&t.put(Qo,e.gl.createFramebuffer()),t.get(Qo)},attach:function(e,t,r){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||os,r=r||bn;var n,i=this._boundRenderer;if(i&&i.gl){var a=this._cache;a.use(i.__uid__),n=a.get("attached_textures")}var o=this._textures[t];if(!o||o.target!==r||o.texture!==e||!n||null==n[t]){var s=!0;i&&(s=this._doAttach(i,e,t,r),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=r)}},_doAttach:function(e,t,r,n){var i=e.gl,a=t.getWebGLTexture(e),o=this._cache.get("attached_textures");if(o&&o[r]){var s=o[r];if(s.texture===t&&s.target===n)return}var l=!0;if(((r=+r)===as||r===On)&&(e.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==un&&t.format!==Cn&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var u=this._cache.get(Jo);u&&(i.framebufferRenderbuffer(ns,as,is,null),i.deleteRenderbuffer(u),this._cache.put(Jo,!1)),this._cache.put(ts,!1),this._cache.put(rs,!0)}return i.framebufferTexture2D(ns,r,n,a,0),o||(o={},this._cache.put("attached_textures",o)),o[r]=o[r]||{},o[r].texture=t,o[r].target=n,l},_doDetach:function(e,t,r){e.framebufferTexture2D(ns,t,r,null,0);var n=this._cache.get("attached_textures");n&&n[t]&&(n[t]=null),t!==as&&t!==On||this._cache.put(rs,!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,r=this._cache;r.use(e.__uid__);var n=r.get(Jo);n&&t.deleteRenderbuffer(n);var i=r.get(Qo);i&&t.deleteFramebuffer(i),r.deleteContext(e.__uid__),this._textures={}}});ss.DEPTH_ATTACHMENT=as,ss.COLOR_ATTACHMENT0=os,ss.STENCIL_ATTACHMENT=Pn,ss.DEPTH_STENCIL_ATTACHMENT=On;var ls=["px","nx","py","ny","pz","nz"],us=Nr.extend(function(){var e={position:new Ji,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new Ko({fov:90}),nx:new Ko({fov:90}),py:new Ko({fov:90}),ny:new Ko({fov:90}),pz:new Ko({fov:90}),nz:new Ko({fov:90})};return t.px.lookAt(Ji.POSITIVE_X,Ji.NEGATIVE_Y),t.nx.lookAt(Ji.NEGATIVE_X,Ji.NEGATIVE_Y),t.py.lookAt(Ji.POSITIVE_Y,Ji.POSITIVE_Z),t.ny.lookAt(Ji.NEGATIVE_Y,Ji.NEGATIVE_Z),t.pz.lookAt(Ji.POSITIVE_Z,Ji.NEGATIVE_Y),t.nz.lookAt(Ji.NEGATIVE_Z,Ji.NEGATIVE_Y),e._frameBuffer=new ss,e},{getCamera:function(e){return this._cameras[e]},render:function(e,t,r){var n=e.gl;r||t.update();for(var i=this.texture.width,a=2*Math.atan(i/(i-.5))/Math.PI*180,o=0;o<6;o++){var s=ls[o],l=this._cameras[s];if(Ji.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=a,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,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._frameBuffer.bind(e),e.render(t,l,!0),this._frameBuffer.unbind(e)}},dispose:function(e){this._frameBuffer.dispose(e)}}),hs=mo.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,r=this.attributes,n=[],i=[],a=[],o=[],s=0;s<=e;s++)for(var l=s/e,u=0;u<=t;u++){var h=u/t;if(n.push([2*h-1,2*l-1,0]),i&&i.push([h,l]),a&&a.push([0,0,1]),u<t&&s<e){var c=u+s*(t+1);o.push([c,c+1,c+t+1]),o.push([c+t+1,c+1,c+t+2])}}r.position.fromArray(n),r.texcoord0.fromArray(i),r.normal.fromArray(a),this.initIndicesFromArray(o),this.boundingBox=new za,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),cs=new Ta,ds=mo.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},function(){this.build()},{build:function(){var e={px:fs("px",this.depthSegments,this.heightSegments),nx:fs("nx",this.depthSegments,this.heightSegments),py:fs("py",this.widthSegments,this.depthSegments),ny:fs("ny",this.widthSegments,this.depthSegments),pz:fs("pz",this.widthSegments,this.heightSegments),nz:fs("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],r=0,n=0;for(var i in e)r+=e[i].vertexCount,n+=e[i].indices.length;for(var a=0;a<t.length;a++)this.attributes[t[a]].init(r);this.indices=new In.Uint16Array(n);var o=0,s=0;for(var i in e){var l=e[i];for(a=0;a<t.length;a++)for(var u=t[a],h=l.attributes[u].value,c=l.attributes[u].size,d="normal"===u,f=0;f<h.length;f++){var p=h[f];this.inside&&d&&(p=-p),this.attributes[u].value[f+c*s]=p}var m=l.indices.length;for(f=0;f<l.indices.length;f++)this.indices[f+o]=s+l.indices[this.inside?m-f-1:f];o+=l.indices.length,s+=l.vertexCount}this.boundingBox=new za,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});function fs(e,t,r){cs.identity();var n=new hs({widthSegments:t,heightSegments:r});switch(e){case"px":Ta.translate(cs,cs,Ji.POSITIVE_X),Ta.rotateY(cs,cs,Math.PI/2);break;case"nx":Ta.translate(cs,cs,Ji.NEGATIVE_X),Ta.rotateY(cs,cs,-Math.PI/2);break;case"py":Ta.translate(cs,cs,Ji.POSITIVE_Y),Ta.rotateX(cs,cs,-Math.PI/2);break;case"ny":Ta.translate(cs,cs,Ji.NEGATIVE_Y),Ta.rotateX(cs,cs,Math.PI/2);break;case"pz":Ta.translate(cs,cs,Ji.POSITIVE_Z);break;case"nz":Ta.translate(cs,cs,Ji.NEGATIVE_Z),Ta.rotateY(cs,cs,Math.PI)}return n.applyTransform(cs),n}Ri.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 ps=$a.extend(function(){var e=new Ri({vertex:Ri.source("clay.skybox.vertex"),fragment:Ri.source("clay.skybox.fragment")}),t=new ni({shader:e,depthMask:!1});return{scene:null,geometry:new ds,material:t,environmentMap:null,culling:!1,_dummyCamera:new Ko}},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=Ja.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,r){this.renderSkybox(e,r)},renderSkybox:function(e,t){var r=this._dummyCamera;r.aspect=e.getViewportAspect(),r.fov=t.fov||50,r.updateProjectionMatrix(),Ta.invert(r.invProjectionMatrix,r.projectionMatrix),r.worldTransform.copy(t.worldTransform),r.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],r)}});function ms(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var gs=ms("DXT1"),vs=ms("DXT3"),_s=ms("DXT5"),ys=function(e,t){var r=new Int32Array(e,0,31);if(542327876!==r[0])return null;if(4&!r(20))return null;var n,i,a=r(21),o=r[4],s=r[3],l=512&r[28],u=131072&r[2];switch(a){case gs:n=8,i=Ja.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case vs:n=16,i=Ja.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case _s:n=16,i=Ja.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var h=r[1]+4,c=l?6:1,d=1;u&&(d=Math.max(1,r[7]));for(var f=[],p=0;p<c;p++){var m=o,g=s;f[p]=new no({width:m,height:g,format:i});for(var v=[],_=0;_<d;_++){var y=Math.max(4,m)/4*Math.max(4,g)/4*n,x=new Uint8Array(e,h,y);h+=y,m*=.5,g*=.5,v[_]=x}f[p].pixels=v[0],u&&(f[p].mipmaps=v)}if(!t)return f[0];t.width=f[0].width,t.height=f[0].height,t.format=f[0].format,t.pixels=f[0].pixels,t.mipmaps=f[0].mipmaps},xs=String.fromCharCode;function bs(e,t,r,n){if(e[3]>0){var i=Math.pow(2,e[3]-128-8+n);t[r+0]=e[0]*i,t[r+1]=e[1]*i,t[r+2]=e[2]*i}else t[r+0]=0,t[r+1]=0,t[r+2]=0;return t[r+3]=1,t}function ws(e,t){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3]}function Ts(e,t,r,n){for(var i=0,a=0,o=n;o>0;)if(e[a][0]=t[r++],e[a][1]=t[r++],e[a][2]=t[r++],e[a][3]=t[r++],1===e[a][0]&&1===e[a][1]&&1===e[a][2]){for(var s=e[a][3]<<i>>>0;s>0;s--)ws(e[a-1],e[a]),a++,o--;i+=8}else a++,o--,i=0;return r}function Ss(e,t,r,n){if(n<8|n>32767)return Ts(e,t,r,n);if(2!=(i=t[r++]))return Ts(e,t,r-1,n);if(e[0][1]=t[r++],e[0][2]=t[r++],i=t[r++],(e[0][2]<<8>>>0|i)>>>0!==n)return null;for(var i=0;i<4;i++)for(var a=0;a<n;){var o=t[r++];if(o>128){o=(127&o)>>>0;for(var s=t[r++];o--;)e[a++][i]=s}else for(;o--;)e[a++][i]=t[r++]}return r}var Ms=function(e,t,r){null==r&&(r=0);var n=new Uint8Array(e),i=n.length;if("#?"===function(e,t,r){for(var n="",i=t;i<r;i++)n+=xs(e[i]);return n}(n,0,2)){for(var a=2;a<i&&("\n"!==xs(n[a])||"\n"!==xs(n[a+1]));a++);if(!(a>=i)){a+=2;for(var o="";a<i;a++){var s=xs(n[a]);if("\n"===s)break;o+=s}var l=o.split(" "),u=parseInt(l[1]),h=parseInt(l[3]);if(h&&u){for(var c=a+1,d=[],f=0;f<h;f++){d[f]=[];for(var p=0;p<4;p++)d[f][p]=0}for(var m=new Float32Array(h*u*4),g=0,v=0;v<u;v++){if(!(c=Ss(d,n,c,h)))return null;for(f=0;f<h;f++)bs(d[f],m,g,r),g+=4}return t||(t=new no),t.width=h,t.height=u,t.pixels=m,t.type=Ja.FLOAT,t}}}},As={loadTexture:function(e,r,n,i){var a;if("function"==typeof r?(i=n=r,r={}):r=r||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===r.fileType)return a=new no({width:0,height:0,sRGB:!1}),As._fetchTexture(e,function(e){Ms(e,a,r.exposure),a.dirty(),n&&n(a)},i),a;e.match(/.dds$/)||"dds"===r.fileType?(a=new no({width:0,height:0}),As._fetchTexture(e,function(e){ys(e,a),a.dirty(),n&&n(a)},i)):((a=new no).load(e),a.success(n),a.error(i))}else"object"===t(e)&&void 0!==e.px&&((a=new Zo).load(e),a.success(n),a.error(i));return a},loadPanorama:function(e,t,r,n,i,a){var o=this;"function"==typeof n?(a=i=n,n={}):n=n||{},As.loadTexture(t,n,function(t){t.flipY=n.flipY||!1,o.panoramaToCubeMap(e,t,r,n),t.dispose(e),i&&i(r)},a)},panoramaToCubeMap:function(e,t,r,n){var i=new us,a=new ps({scene:new Wo});return a.setEnvironmentMap(t),(n=n||{}).encodeRGBM&&a.material.define("fragment","RGBM_ENCODE"),r.sRGB=t.sRGB,i.texture=r,i.render(e,a.scene),i.texture=null,i.dispose(e),r},heightToNormal:function(e,t){var r=document.createElement("canvas"),n=r.width=e.width,i=r.height=e.height,a=r.getContext("2d");a.drawImage(e,0,0,n,i),t=t||!1;for(var o=a.getImageData(0,0,n,i),s=a.createImageData(n,i),l=0;l<o.data.length;l+=4){if(t){var u=o.data[l],h=o.data[l+1],c=o.data[l+2];if(Math.abs(u-h)+Math.abs(h-c)>20)return console.warn("Given image is not a height map"),e}var d,f,p,m;l%(4*n)==0?(d=o.data[l],p=o.data[l+4]):l%(4*n)==4*(n-1)?(d=o.data[l-4],p=o.data[l]):(d=o.data[l-4],p=o.data[l+4]),l<4*n?(f=o.data[l],m=o.data[l+4*n]):l>n*(i-1)*4?(f=o.data[l-4*n],m=o.data[l]):(f=o.data[l-4*n],m=o.data[l+4*n]),s.data[l]=d-p+127,s.data[l+1]=f-m+127,s.data[l+2]=255,s.data[l+3]=255}return a.putImageData(s,0,0),r},isHeightImage:function(e,t,r){if(!e||!e.width||!e.height)return!1;var n=document.createElement("canvas"),i=n.getContext("2d"),a=t||32;r=r||20,n.width=n.height=a,i.drawImage(e,0,0,a,a);for(var o=i.getImageData(0,0,a,a),s=0;s<o.data.length;s+=4){var l=o.data[s],u=o.data[s+1],h=o.data[s+2];if(Math.abs(l-u)+Math.abs(u-h)>r)return!1}return!0},_fetchTexture:function(e,t,r){In.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,n){e=e||512,t=t||64,r=r||"black",n=n||"white";var i=Math.ceil(e/t),a=document.createElement("canvas");a.width=e,a.height=e;var o=a.getContext("2d");o.fillStyle=n,o.fillRect(0,0,e,e),o.fillStyle=r;for(var s=0;s<i;s++)for(var l=0;l<i;l++){(l%2?s%2:s%2-1)&&o.fillRect(s*t,l*t,t,t)}return new no({image:a,anisotropic:8})},createBlank:function(e){var t=document.createElement("canvas");t.width=1,t.height=1;var r=t.getContext("2d");return r.fillStyle=e,r.fillRect(0,0,1,1),new no({image:t})}},Es=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function Cs(e){return"_on"+e}var Ds=function(e){var t=this;this._texture=new no({anisotropic:32,flipY:!1,surface:this,dispose:function(e){t.dispose(),no.prototype.dispose.call(this,e)}}),Es.forEach(function(e){this[Cs(e)]=function(t){t.triangle&&this._meshes.forEach(function(r){this.dispatchEvent(e,r,t.triangle,t.point)},this)}},this),this._meshes=[],e&&this.setECharts(e),this.onupdate=null};Ds.prototype={constructor:Ds,getTexture:function(){return this._texture},setECharts:function(e){this._chart=e;var t=e.getDom();if(t instanceof HTMLCanvasElement){var r=this,n=e.getZr(),i=n.__oldRefreshImmediately||n.refreshImmediately;n.refreshImmediately=function(){i.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},n.__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 Ji,t=new Ji,r=new Ji,n=new li,i=new li,a=new li,o=new li,s=new Ji;return function(l,u,h,c){var d=u.geometry,f=d.attributes.position,p=d.attributes.texcoord0,m=Ji.dot,g=Ji.cross;f.get(h[0],e.array),f.get(h[1],t.array),f.get(h[2],r.array),p.get(h[0],n.array),p.get(h[1],i.array),p.get(h[2],a.array),g(s,t,r);var v=m(e,s),_=m(c,s)/v;g(s,r,e);var y=m(c,s)/v;g(s,e,t);var x=m(c,s)/v;li.scale(o,n,_),li.scaleAndAdd(o,o,i,y),li.scaleAndAdd(o,o,a,x);var b=o.x*this._chart.getWidth(),w=o.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:b,zrY:w})}}(),attachToMesh:function(e){this._meshes.indexOf(e)>=0||(Es.forEach(function(t){e.on(t,this[Cs(t)],this)},this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),Es.forEach(function(t){e.off(t,this[Cs(t)])},this)},dispose:function(){this._meshes.forEach(function(e){this.detachFromMesh(e)},this)}};var Ls=Bo.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=Bo.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}});Ri.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 Ps=new hs,Os=new $a({geometry:Ps,frustumCulling:!1}),Ns=new Ls,Rs=Nr.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var e=new Ri(Ri.source("clay.compositor.vertex"),this.fragment),t=new ni({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||Dn,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 r in this.outputs){var n=this.outputs[r];n&&t.attach(n,r)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var r=e.gl;if(t){this.bind(e,t);var n=e.getGLExtension("EXT_draw_buffers");if(n&&this.outputs){var i=[];for(var a in this.outputs)(a=+a)>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&i.push(a);n.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){Os.material=this.material,e.renderPass([Os],Ns)},dispose:function(e){}}),Is={},Bs=["px","nx","py","ny","pz","nz"];Is.prefilterEnvironmentMap=function(e,t,r,n,i){i&&n||(n=Is.generateNormalDistribution(),i=Is.integrateBRDF(e,n));var a=(r=r||{}).width||64,o=r.height||64,s=r.type||t.type,l=new Zo({width:a,height:o,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var u=Math.min(a,o),h=Math.log(u)/Math.log(2)+1,c=new ni({shader:new Ri({vertex:Ri.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"})});c.set("normalDistribution",n),r.encodeRGBM&&c.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&c.define("fragment","RGBM_DECODE");var d,f=new Wo;if("texture2D"===t.textureType){var p=new Zo({width:a,height:o,type:s===Ja.FLOAT?Ja.HALF_FLOAT:s});As.panoramaToCubeMap(e,t,p,{encodeRGBM:r.decodeRGBM}),t=p}(d=new ps({scene:f,material:c})).material.set("environmentMap",t);var m=new us({texture:l});r.encodeRGBM&&(s=l.type=Ja.UNSIGNED_BYTE);for(var g=new no({width:a,height:o,type:s}),v=new ss({depthBuffer:!1}),_=In[s===Ja.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],y=0;y<h;y++){l.mipmaps[y]={pixels:{}},d.material.set("roughness",y/(h-1));for(var x=g.width,b=2*Math.atan(x/(x-.5))/Math.PI*180,w=0;w<Bs.length;w++){var T=new _(g.width*g.height*4);v.attach(g),v.bind(e);var S=m.getCamera(Bs[w]);S.fov=b,e.render(f,S),e.gl.readPixels(0,0,g.width,g.height,Ja.RGBA,s,T),v.unbind(e),l.mipmaps[y].pixels[Bs[w]]=T}g.width/=2,g.height/=2,g.dirty()}return v.dispose(e),g.dispose(e),d.dispose(e),n.dispose(e),{environmentMap:l,brdfLookup:i,normalDistribution:n,maxMipmapLevel:h}},Is.integrateBRDF=function(e,t){t=t||Is.generateNormalDistribution();var r=new ss({depthBuffer:!1}),n=new Rs({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 no({width:512,height:256,type:Ja.HALF_FLOAT,wrapS:Ja.CLAMP_TO_EDGE,wrapT:Ja.CLAMP_TO_EDGE,minFilter:Ja.NEAREST,magFilter:Ja.NEAREST,useMipmap:!1});return n.setUniform("normalDistribution",t),n.setUniform("viewportSize",[512,256]),n.attachOutput(i),n.render(e,r),r.dispose(e),i},Is.generateNormalDistribution=function(e,t){for(var r=new no({width:e=e||256,height:t=t||1024,type:Ja.FLOAT,minFilter:Ja.NEAREST,magFilter:Ja.NEAREST,wrapS:Ja.CLAMP_TO_EDGE,wrapT:Ja.CLAMP_TO_EDGE,useMipmap:!1}),n=new Float32Array(t*e*4),i=[],a=0;a<e;a++){for(var o=a/e,s=o*o,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 h=Math.sqrt((1-u)/(1+(s*s-1)*u));i[l]=h}for(l=0;l<t;l++){var c=4*(l*e+a),d=(h=i[l],Math.sqrt(1-h*h)),f=l/t,p=2*Math.PI*f;n[c]=d*Math.cos(p),n[c+1]=h,n[c+2]=d*Math.sin(p),n[c+3]=1}}return r.pixels=n,r};var zs=Ao.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=Is.generateNormalDistribution(),this._brdfLookup=Is.integrateBRDF(e,this._normalDistribution));var r=this.cubemap;if(!r.__prefiltered){var n=Is.prefilterEnvironmentMap(e,r,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=n.environmentMap,this.cubemap.__prefiltered=!0,r.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,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}}),Fs=Ao.extend({castShadow:!1,coefficients:[]},function(){this._coefficientsTmpArr=new In.Float32Array(27)},{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,r=0;r<e.coefficients.length;r++)t[r]=e.coefficients[r];return t}}}}),ks={},Us=["px","nx","py","ny","pz","nz"];function Gs(e,t){var r=e[0],n=e[1],i=e[2];return 0===t?1:1===t?r:2===t?n:3===t?i:4===t?r*i:5===t?n*i:6===t?r*n:7===t?3*i*i-1:r*r-n*n}var Hs={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]};ks.projectEnvironmentMap=function(e,t,r){var n;(r=r||{}).lod=r.lod||0;var i=new Wo,a=64;"texture2D"===t.textureType||(a=t.image&&t.image.px?t.image.px.width:t.width),n=new ps({scene:i,environmentMap:t});var o=Math.ceil(a/Math.pow(2,r.lod)),s=Math.ceil(a/Math.pow(2,r.lod)),l=new no({width:o,height:s}),u=new ss;n.material.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&n.material.define("fragment","RGBM_DECODE"),n.material.set("lod",r.lod);for(var h=new us({texture:l}),c={},d=0;d<Us.length;d++){c[Us[d]]=new Uint8Array(o*s*4);var f=h.getCamera(Us[d]);f.fov=90,u.attach(l),u.bind(e),e.render(i,f),e.gl.readPixels(0,0,o,s,Ja.RGBA,Ja.UNSIGNED_BYTE,c[Us[d]]),u.unbind(e)}return n.dispose(e),u.dispose(e),l.dispose(e),function(e,t,r,n){for(var i=new In.Float32Array(27),a=ki.create(),o=ki.create(),s=ki.create(),l=0;l<9;l++){for(var u=ki.create(),h=0;h<Us.length;h++){for(var c=t[Us[h]],d=ki.create(),f=0,p=0,m=Hs[Us[h]],g=0;g<n;g++)for(var v=0;v<r;v++){a[0]=v/(r-1)*2-1,a[1]=g/(n-1)*2-1,a[2]=-1,ki.normalize(a,a),s[0]=a[m[0]]*m[3],s[1]=a[m[1]]*m[4],s[2]=a[m[2]]*m[5],o[0]=c[p++]/255,o[1]=c[p++]/255,o[2]=c[p++]/255;var _=c[p++]/255*8.12;o[0]*=_,o[1]*=_,o[2]*=_,ki.scaleAndAdd(d,d,o,Gs(s,l)*-a[2]),f+=-a[2]}ki.scaleAndAdd(u,u,d,1/f)}i[3*l]=u[0]/6,i[3*l+1]=u[1]/6,i[3*l+2]=u[2]/6}return i}(0,c,o,s)};var Vs=function(){for(var e=0,t=arguments.length;e<t;e++)if(null!=arguments[e])return arguments[e]},Ws=function(e,t){return null!=t.dataIndexInside?t.dataIndexInside:null!=t.dataIndex?Z(t.dataIndex)?Y(t.dataIndex,function(t){return e.indexOfRawIndex(t)}):e.indexOfRawIndex(t.dataIndex):null!=t.name?Z(t.name)?Y(t.name,function(t){return e.indexOfName(t)}):e.indexOfName(t.name):void 0},js=mo.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,r=this.attributes.position,n=this.attributes.texcoord0,i=this.attributes.normal,a=(t+1)*(e+1);r.init(a),n.init(a),i.init(a);var o,s,l,u,h,c,d,f,p,m,g,v=a>65535?Uint32Array:Uint16Array,_=this.indices=new v(t*e*6),y=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,T=this.thetaLength,S=[],M=[],A=0,E=1/(y=this.radius);for(d=0;d<=e;d++)for(c=0;c<=t;c++)u=c/t,h=d/e,o=-y*Math.cos(x+u*b)*Math.sin(w+h*T),s=y*Math.cos(w+h*T),l=y*Math.sin(x+u*b)*Math.sin(w+h*T),S[0]=o,S[1]=s,S[2]=l,M[0]=u,M[1]=h,r.set(A,S),n.set(A,M),S[0]*=E,S[1]*=E,S[2]*=E,i.set(A,S),A++;var C=t+1,D=0;for(d=0;d<e;d++)for(c=0;c<t;c++)p=d*C+c,f=d*C+c+1,g=(d+1)*C+c+1,m=(d+1)*C+c,_[D++]=f,_[D++]=p,_[D++]=g,_[D++]=p,_[D++]=m,_[D++]=g;this.boundingBox=new za,this.boundingBox.max.set(y,y,y),this.boundingBox.min.set(-y,-y,-y)}}),Xs=Ao.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}}}),qs=Ao.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 Ji,e.__dir.copy(e.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}},clone:function(){var e=Ao.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),Zs=Ao.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,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}},clone:function(){var e=Ao.prototype.clone.call(this);return e.range=this.range,e}}),Ys=Ao.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 Ji,e.__dir.copy(e.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}},clone:function(){var e=Ao.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}}),Ks=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=n||0,this.array=da.fromValues(e,t,r,n),this._dirty=!0};Ks.prototype={constructor:Ks,add:function(e){return da.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,r,n){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this.array[3]=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.array[3]=e[3],this._dirty=!0,this},clone:function(){return new Ks(this.x,this.y,this.z,this.w)},copy:function(e){return da.copy(this.array,e.array),this._dirty=!0,this},dist:function(e){return da.dist(this.array,e.array)},distance:function(e){return da.distance(this.array,e.array)},div:function(e){return da.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return da.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return da.dot(this.array,e.array)},len:function(){return da.len(this.array)},length:function(){return da.length(this.array)},lerp:function(e,t,r){return da.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return da.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return da.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return da.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return da.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return da.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return da.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return da.random(this.array,e),this._dirty=!0,this},scale:function(e){return da.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return da.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return da.sqrDist(this.array,e.array)},squaredDistance:function(e){return da.squaredDistance(this.array,e.array)},sqrLen:function(){return da.sqrLen(this.array)},squaredLength:function(){return da.squaredLength(this.array)},sub:function(e){return da.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return da.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return da.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return da.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 Qs=Object.defineProperty;if(Qs){var Js=Ks.prototype;Qs(Js,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Qs(Js,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Qs(Js,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),Qs(Js,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}Ks.add=function(e,t,r){return da.add(e.array,t.array,r.array),e._dirty=!0,e},Ks.set=function(e,t,r,n,i){da.set(e.array,t,r,n,i),e._dirty=!0},Ks.copy=function(e,t){return da.copy(e.array,t.array),e._dirty=!0,e},Ks.distance=Ks.dist=function(e,t){return da.distance(e.array,t.array)},Ks.divide=Ks.div=function(e,t,r){return da.divide(e.array,t.array,r.array),e._dirty=!0,e},Ks.dot=function(e,t){return da.dot(e.array,t.array)},Ks.len=function(e){return da.length(e.array)},Ks.lerp=function(e,t,r,n){return da.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},Ks.min=function(e,t,r){return da.min(e.array,t.array,r.array),e._dirty=!0,e},Ks.max=function(e,t,r){return da.max(e.array,t.array,r.array),e._dirty=!0,e},Ks.multiply=Ks.mul=function(e,t,r){return da.multiply(e.array,t.array,r.array),e._dirty=!0,e},Ks.negate=function(e,t){return da.negate(e.array,t.array),e._dirty=!0,e},Ks.normalize=function(e,t){return da.normalize(e.array,t.array),e._dirty=!0,e},Ks.random=function(e,t){return da.random(e.array,t),e._dirty=!0,e},Ks.scale=function(e,t,r){return da.scale(e.array,t.array,r),e._dirty=!0,e},Ks.scaleAndAdd=function(e,t,r,n){return da.scaleAndAdd(e.array,t.array,r.array,n),e._dirty=!0,e},Ks.squaredDistance=Ks.sqrDist=function(e,t){return da.sqrDist(e.array,t.array)},Ks.squaredLength=Ks.sqrLen=function(e){return da.sqrLen(e.array)},Ks.subtract=Ks.sub=function(e,t,r){return da.subtract(e.array,t.array,r.array),e._dirty=!0,e},Ks.transformMat4=function(e,t,r){return da.transformMat4(e.array,t.array,r.array),e._dirty=!0,e},Ks.transformQuat=function(e,t,r){return da.transformQuat(e.array,t.array,r.array),e._dirty=!0,e};var $s={create:function(){var e=new ai(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},clone:function(e){var t=new ai(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 r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},invert:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*a-i*n;return o?(o=1/o,e[0]=a*o,e[1]=-n*o,e[2]=-i*o,e[3]=r*o,e):null},adjoint:function(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e},determinant:function(e){return e[0]*e[3]-e[2]*e[1]},multiply:function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],h=r[3];return e[0]=n*s+a*l,e[1]=i*s+o*l,e[2]=n*u+a*h,e[3]=i*u+o*h,e}};$s.mul=$s.multiply,$s.rotate=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=n*l+a*s,e[1]=i*l+o*s,e[2]=n*-s+a*l,e[3]=i*-s+o*l,e},$s.scale=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],l=r[1];return e[0]=n*s,e[1]=i*s,e[2]=a*l,e[3]=o*l,e},$s.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))},$s.LDU=function(e,t,r,n){return e[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-e[2]*r[1],[e,t,r]};var el=function(){this.array=$s.create(),this._dirty=!0};el.prototype={constructor:el,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 el).copy(this)},copy:function(e){return $s.copy(this.array,e.array),this._dirty=!0,this},adjoint:function(){return $s.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return $s.determinant(this.array)},identity:function(){return $s.identity(this.array),this._dirty=!0,this},invert:function(){return $s.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return $s.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return $s.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return $s.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return $s.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return $s.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return $s.scale(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return $s.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)}},el.adjoint=function(e,t){return $s.adjoint(e.array,t.array),e._dirty=!0,e},el.copy=function(e,t){return $s.copy(e.array,t.array),e._dirty=!0,e},el.determinant=function(e){return $s.determinant(e.array)},el.identity=function(e){return $s.identity(e.array),e._dirty=!0,e},el.invert=function(e,t){return $s.invert(e.array,t.array),e._dirty=!0,e},el.multiply=el.mul=function(e,t,r){return $s.mul(e.array,t.array,r.array),e._dirty=!0,e},el.rotate=function(e,t,r){return $s.rotate(e.array,t.array,r),e._dirty=!0,e},el.scale=function(e,t,r){return $s.scale(e.array,t.array,r.array),e._dirty=!0,e},el.transpose=function(e,t){return $s.transpose(e.array,t.array),e._dirty=!0,e};var tl={create:function(){var e=new ai(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 ai(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 r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=r*a-n*i;return l?(l=1/l,e[0]=a*l,e[1]=-n*l,e[2]=-i*l,e[3]=r*l,e[4]=(i*s-a*o)*l,e[5]=(n*o-r*s)*l,e):null},determinant:function(e){return e[0]*e[3]-e[1]*e[2]},multiply:function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],h=r[1],c=r[2],d=r[3],f=r[4],p=r[5];return e[0]=n*u+a*h,e[1]=i*u+o*h,e[2]=n*c+a*d,e[3]=i*c+o*d,e[4]=n*f+a*p+s,e[5]=i*f+o*p+l,e}};tl.mul=tl.multiply,tl.rotate=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=Math.sin(r),h=Math.cos(r);return e[0]=n*h+a*u,e[1]=i*h+o*u,e[2]=n*-u+a*h,e[3]=i*-u+o*h,e[4]=s,e[5]=l,e},tl.scale=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],h=r[1];return e[0]=n*u,e[1]=i*u,e[2]=a*h,e[3]=o*h,e[4]=s,e[5]=l,e},tl.translate=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],h=r[1];return e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=n*u+a*h+s,e[5]=i*u+o*h+l,e},tl.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 rl=function(){this.array=tl.create(),this._dirty=!0};rl.prototype={constructor:rl,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 rl).copy(this)},copy:function(e){return tl.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return tl.determinant(this.array)},identity:function(){return tl.identity(this.array),this._dirty=!0,this},invert:function(){return tl.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return tl.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return tl.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return tl.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return tl.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return tl.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return tl.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return tl.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)}},rl.copy=function(e,t){return tl.copy(e.array,t.array),e._dirty=!0,e},rl.determinant=function(e){return tl.determinant(e.array)},rl.identity=function(e){return tl.identity(e.array),e._dirty=!0,e},rl.invert=function(e,t){return tl.invert(e.array,t.array),e._dirty=!0,e},rl.multiply=rl.mul=function(e,t,r){return tl.mul(e.array,t.array,r.array),e._dirty=!0,e},rl.rotate=function(e,t,r){return tl.rotate(e.array,t.array,r),e._dirty=!0,e},rl.scale=function(e,t,r){return tl.scale(e.array,t.array,r.array),e._dirty=!0,e},rl.translate=function(e,t,r){return tl.translate(e.array,t.array,r.array),e._dirty=!0,e};var nl=function(){this.array=fa.create(),this._dirty=!0};nl.prototype={constructor:nl,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 fa.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new nl).copy(this)},copy:function(e){return fa.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return fa.determinant(this.array)},fromMat2d:function(e){return fa.fromMat2d(this.array,e.array),this._dirty=!0,this},fromMat4:function(e){return fa.fromMat4(this.array,e.array),this._dirty=!0,this},fromQuat:function(e){return fa.fromQuat(this.array,e.array),this._dirty=!0,this},identity:function(){return fa.identity(this.array),this._dirty=!0,this},invert:function(){return fa.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return fa.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return fa.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return fa.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return fa.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return fa.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return fa.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return fa.translate(this.array,this.array,e.array),this._dirty=!0,this},normalFromMat4:function(e){return fa.normalFromMat4(this.array,e.array),this._dirty=!0,this},transpose:function(){return fa.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)}},nl.adjoint=function(e,t){return fa.adjoint(e.array,t.array),e._dirty=!0,e},nl.copy=function(e,t){return fa.copy(e.array,t.array),e._dirty=!0,e},nl.determinant=function(e){return fa.determinant(e.array)},nl.identity=function(e){return fa.identity(e.array),e._dirty=!0,e},nl.invert=function(e,t){return fa.invert(e.array,t.array),e},nl.multiply=nl.mul=function(e,t,r){return fa.mul(e.array,t.array,r.array),e._dirty=!0,e},nl.fromMat2d=function(e,t){return fa.fromMat2d(e.array,t.array),e._dirty=!0,e},nl.fromMat4=function(e,t){return fa.fromMat4(e.array,t.array),e._dirty=!0,e},nl.fromQuat=function(e,t){return fa.fromQuat(e.array,t.array),e._dirty=!0,e},nl.normalFromMat4=function(e,t){return fa.normalFromMat4(e.array,t.array),e._dirty=!0,e},nl.rotate=function(e,t,r){return fa.rotate(e.array,t.array,r),e._dirty=!0,e},nl.scale=function(e,t,r){return fa.scale(e.array,t.array,r.array),e._dirty=!0,e},nl.transpose=function(e,t){return fa.transpose(e.array,t.array),e._dirty=!0,e},nl.translate=function(e,t,r){return fa.translate(e.array,t.array,r.array),e._dirty=!0,e};var il={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(e,t){this._animators=this._animators||[];var r;if(e){for(var n=e.split("."),i=this,a=0,o=n.length;a<o;a++)i&&(i=i[n[a]]);i&&(r=i)}else r=this;if(null==r)throw new Error("Target "+e+" not exists");var s=this._animators,l=new K(r,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,r=t.length,n=0;n<r;n++)t[n].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])}},al="\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 ol(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}Object.assign(Ha.prototype,il),Ri.import(al),Ri.import(zi),Ri.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"),Ri.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"),Ri.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"),Ri.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"),Ri.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"),Ri.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 sl=Wo.prototype.addToScene,ll=Wo.prototype.removeFromScene;Wo.prototype.addToScene=function(e){if(sl.call(this,e),this.__zr){var t=this.__zr;e.traverse(function(e){e.__zr=t,e.addAnimatorsToZr&&e.addAnimatorsToZr(t)})}},Wo.prototype.removeFromScene=function(e){ll.call(this,e),e.traverse(function(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)})},ni.prototype.setTextureImage=function(e,t,r,n){if(this.shader){var i,a,o=r.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(e),(a=t)&&"none"!==a&&(i=ul.loadTexture(t,r,n,function(t){s.enableTexture(e),o&&o.refresh()}),s.set(e,i)),i}};var ul={};ul.Renderer=Ki,ul.Node=Ha,ul.Mesh=$a,ul.Shader=Ri,ul.Material=ni,ul.Texture=Ja,ul.Texture2D=no,ul.Geometry=mo,ul.SphereGeometry=js,ul.PlaneGeometry=hs,ul.CubeGeometry=ds,ul.AmbientLight=Xs,ul.DirectionalLight=qs,ul.PointLight=Zs,ul.SpotLight=Ys,ul.PerspectiveCamera=Ko,ul.OrthographicCamera=Ls,ul.Vector2=li,ul.Vector3=Ji,ul.Vector4=Ks,ul.Quaternion=Aa,ul.Matrix2=el,ul.Matrix2d=rl,ul.Matrix3=nl,ul.Matrix4=Ta,ul.Plane=Eo,ul.Ray=ca,ul.BoundingBox=za,ul.Frustum=Ro;var hl=null;function cl(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function dl(e){if((e.wrapS===Ja.REPEAT||e.wrapT===Ja.REPEAT)&&e.image){var t=cl(e.width),r=cl(e.height);if(t!==e.width||r!==e.height){var n=document.createElement("canvas");n.width=t,n.height=r,n.getContext("2d").drawImage(e.image,0,0,t,r),e.image=n}}}ul.loadTexture=function(e,t,r,n){"function"==typeof r&&(n=r,r={}),r=r||{};for(var i=Object.keys(r).sort(),a="",o=0;o<i.length;o++)a+=i[o]+"_"+r[i[o]]+"_";var s,l=t.__textureCache=t.__textureCache||new Q(20);if((s=e).getZr&&s.setOption){var u=e.__textureid__;if(c=l.get(a+u))c.texture.surface.setECharts(e),n&&n(c.texture);else{var h=new Ds(e);h.onupdate=function(){t.getZr().refresh()},c={texture:h.getTexture()};for(o=0;o<i.length;o++)c.texture[i[o]]=r[i[o]];u=e.__textureid__||"__ecgl_ec__"+c.texture.__uid__,e.__textureid__=u,l.put(a+u,c),n&&n(c.texture)}return c.texture}if(ol(e)){var c;u=e.__textureid__;if(!(c=l.get(a+u))){c={texture:new ul.Texture2D({image:e})};for(o=0;o<i.length;o++)c.texture[i[o]]=r[i[o]];u=e.__textureid__||"__ecgl_image__"+c.texture.__uid__,e.__textureid__=u,l.put(a+u,c),dl(c.texture),n&&n(c.texture)}return c.texture}if(c=l.get(a+e))c.callbacks?c.callbacks.push(n):n&&n(c.texture);else if(e.match(/.hdr$|^data:application\/octet-stream/)){c={callbacks:[n]};var d=As.loadTexture(e,{exposure:r.exposure,fileType:"hdr"},function(){d.dirty(),c.callbacks.forEach(function(e){e&&e(d)}),c.callbacks=null});c.texture=d,l.put(a+e,c)}else{for(d=new ul.Texture2D({image:new Image}),o=0;o<i.length;o++)d[i[o]]=r[i[o]];c={texture:d,callbacks:[n]};var f=d.image;f.onload=function(){d.image=f,dl(d),d.dirty(),c.callbacks.forEach(function(e){e&&e(d)}),c.callbacks=null},f.crossOrigin="Anonymous",f.src=e,d.image=null!==hl?hl:hl=As.createBlank("rgba(255,255,255,0)").image,l.put(a+e,c)}return c.texture},ul.createAmbientCubemap=function(e,t,r,n){var i=(e=e||{}).texture,a=Vs(e.exposure,1),o=new zs({intensity:Vs(e.specularIntensity,1)}),s=new Fs({intensity:Vs(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 o.cubemap=ul.loadTexture(i,r,{exposure:a},function(){o.cubemap.flipY=!1,o.prefilter(t,32),s.coefficients=ks.projectEnvironmentMap(t,o.cubemap,{lod:1}),n&&n()}),{specular:o,diffuse:s}},ul.createBlankTexture=As.createBlank,ul.isImage=ol,ul.additiveBlend=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)},ul.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=J(e||"#000",t)||[0,0,0,0])[0]/=255,t[1]/=255,t[2]/=255,t)},ul.directionFromAlphaBeta=function(e,t){var r=e/180*Math.PI+Math.PI/2,n=-t/180*Math.PI+Math.PI/2,i=[],a=Math.sin(r);return i[0]=a*Math.cos(n),i[1]=-Math.cos(r),i[2]=a*Math.sin(n),i},ul.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},ul.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],ul.createShader=function(e){"ecgl.shadow"===e&&(e="ecgl.displayShadow");var t=Ri.source(e+".vertex"),r=Ri.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),r||console.error("Fragment shader of '%s' not exits",e);var n=new Ri(t,r);return n.name=e,n},ul.createMaterial=function(e,t){t instanceof Array||(t=[t]);var r=ul.createShader(e),n=new ni({shader:r});return t.forEach(function(e){"string"==typeof e&&n.define(e)}),n},ul.setMaterialFromModel=function(e,t,r,n){t.autoUpdateTextureStatus=!1;var i=r.getModel(e+"Material"),a=i.get("detailTexture"),o=Vs(i.get("textureTiling"),1),s=Vs(i.get("textureOffset"),0);"number"==typeof o&&(o=[o,o]),"number"==typeof s&&(s=[s,s]);var l=o[0]>1||o[1]>1?ul.Texture.REPEAT:ul.Texture.CLAMP_TO_EDGE,u={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===e){var h=i.get("roughness"),c=i.get("metalness");null!=c?isNaN(c)&&(t.setTextureImage("metalnessMap",c,n,u),c=Vs(i.get("metalnessAdjust"),.5)):c=0,null!=h?isNaN(h)&&(t.setTextureImage("roughnessMap",h,n,u),h=Vs(i.get("roughnessAdjust"),.5)):h=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",a,n,u),t.setTextureImage("normalMap",d,n,u),t.set({roughness:h,metalness:c,detailUvRepeat:o,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",a,n,u),t.set({detailUvRepeat:o,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",a,n,u),t.set({detailUvRepeat:o,detailUvOffset:s});else if("hatching"===e){var f=i.get("hatchingTextures")||[];f.length;for(var p=0;p<6;p++)t.setTextureImage("hatch"+(p+1),f[p],n,{anisotropic:8,wrapS:ul.Texture.REPEAT,wrapT:ul.Texture.REPEAT});t.set({detailUvRepeat:o,detailUvOffset:s})}},ul.updateVertexAnimation=function(e,t,r,n){var i=n.get("animation"),a=n.get("animationDurationUpdate"),o=n.get("animationEasingUpdate"),s=r.shadowDepthMaterial;if(i&&t&&a>0&&t.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<e.length;l++)r.geometry.attributes[e[l][0]].value=t.geometry.attributes[e[l][1]].value;r.geometry.dirty(),r.__percent=0,r.material.set("percent",0),r.stopAnimation(),r.animate().when(a,{__percent:1}).during(function(){r.material.set("percent",r.__percent),s&&s.set("percent",r.__percent)}).done(function(){r.ignorePreZ=!1,r.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")}).start(o)}else r.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")};var fl=function(e,t){this.id=e,this.zr=t;try{this.renderer=new Ki({clearBit:0,devicePixelRatio:t.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(t.painter.getWidth(),t.painter.getHeight())}catch(Sc){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(Sc)}this.onglobalout=this.onglobalout.bind(this),t.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var r=this.dom.style;r.position="absolute",r.left="0",r.top="0",this.views=[],this._picking=new Ya({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new $({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null,this._disposed=!1};function pl(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}fl.prototype.setUnpainted=function(){},fl.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 r=this.zr;e.scene.traverse(function(e){e.__zr=r,e.addAnimatorsToZr&&e.addAnimatorsToZr(r)})}},fl.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(pl,this),e.layer=null,this._viewsToDispose.push(e))}},fl.prototype.removeViewsAll=function(){this.views.forEach(function(e){e.scene.traverse(pl,this),e.layer=null,this._viewsToDispose.push(e)},this),this.views.length=0},fl.prototype.resize=function(e,t){this.renderer.resize(e,t)},fl.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)},fl.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},fl.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},fl.prototype.needsRefresh=function(){this.zr.refresh()},fl.prototype.refresh=function(e){this._backgroundColor=e?ul.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()},fl.prototype.renderToCanvas=function(e){this._startAccumulating(!0),e.drawImage(this.dom,0,0,e.canvas.width,e.canvas.height)},fl.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()},fl.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var ml=1;function gl(e){for(var t=0;t<e.length;t++)e[t].__used__=0}function vl(e,t){for(var r=0;r<t.length;r++)t[r].__used__||t[r].dispose(e)}function _l(e,t){e.__used__=e.__used__||0,e.__used__++,1===e.__used__&&t.push(e)}function yl(e,t,r){var n,i;e.traverse(function(e){if(e.isRenderable()){var a=e.geometry,o=e.material;if(o!==n)for(var s=o.getTextureUniforms(),l=0;l<s.length;l++){var u=s[l],h=o.uniforms[u].value;if(h)if(h instanceof Ja)_l(h,t);else if(h instanceof Array)for(var c=0;c<h.length;c++)h[c]instanceof Ja&&_l(h[c],t)}a!==i&&_l(a,r),n=o,i=a}});for(var a=0;a<e.lights.length;a++)e.lights[a].cubemap&&_l(e.lights[a].cubemap,t)}fl.prototype._startAccumulating=function(e){var t=this;this._stopAccumulating();for(var r=!1,n=0;n<this.views.length;n++)r=this.views[n].needsAccumulate()||r;function i(n){if(t._accumulatingId&&n===t._accumulatingId){for(var a=!0,o=0;o<t.views.length;o++)a=t.views[o].isAccumulateFinished()&&r;a||(t._doRender(!0),e?i(n):te(function(){i(n)}))}}r&&(this._accumulatingId=ml++,e?i(t._accumulatingId):this._accumulatingTimeout=setTimeout(function(){i(t._accumulatingId)},50))},fl.prototype._trackAndClean=function(){var e=[],t=[];this._textureList&&(gl(this._textureList),gl(this._geometriesList));for(var r=0;r<this.views.length;r++)yl(this.views[r].scene,e,t);this._textureList&&(vl(this.renderer,this._textureList),vl(this.renderer,this._geometriesList)),this._textureList=e,this._geometriesList=t},fl.prototype.dispose=function(){this._disposed||(this._stopAccumulating(),this._textureList&&(gl(this._textureList),gl(this._geometriesList),vl(this.renderer,this._textureList),vl(this.renderer,this._geometriesList)),this.zr.off("globalout",this.onglobalout),this._disposed=!0)},fl.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}},fl.prototype.onmousemove=function(e){if(!e.target||!e.target.__isGLToZRProxy){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY),r=t&&t.target,n=this._hovered;this._hovered=t,n&&r!==n.target&&(n.relatedTarget=r,this._dispatchEvent("mouseout",e,n),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",e,t),t&&(this.zr.setCursorStyle("pointer"),n&&r===n.target||this._dispatchEvent("mouseover",e,t)),this._dispatchDataEvent("mousemove",e,t)}},fl.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}},fl.prototype.onclick=fl.prototype.dblclick=function(e){if(!e.target||!e.target.__isGLToZRProxy){var t=this._upX-this._downX,r=this._upY-this._downY;if(!(Math.sqrt(t*t+r*r)>20)){e=e.event;var n=this.pickObject(e.offsetX,e.offsetY);n&&(this._dispatchEvent(e.type,e,n),this._dispatchDataEvent(e.type,e,n));var i=this._clickToSetFocusPoint(e);if(i)i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}},fl.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,r=t.viewport,n=this.views.length-1;n>=0;n--){var i=this.views[n];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var a=this._picking.pick(e.offsetX,e.offsetY,!0);if(a)return a.view=i,a}}t.viewport=r},fl.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},fl.prototype.pickObject=function(e,t){for(var r=[],n=this.renderer,i=n.viewport,a=0;a<this.views.length;a++){var o=this.views[a];o.containPoint(e,t)&&(this._picking.scene=o.scene,this._picking.camera=o.camera,n.viewport=o.viewport,this._picking.pickAll(e,t,r))}return n.viewport=i,r.sort(function(e,t){return e.distance-t.distance}),r[0]},fl.prototype._dispatchEvent=function(e,t,r){r||(r={});var n=r.target;for(r.cancelBubble=!1,r.event=t,r.type=e,r.offsetX=t.offsetX,r.offsetY=t.offsetY;n&&(n.trigger(e,r),n=n.getParent(),!r.cancelBubble););this._dispatchToView(e,r)},fl.prototype._dispatchDataEvent=function(e,t,r){var n=r&&r.target,i=n&&n.dataIndex,a=n&&n.seriesIndex,o=n&&n.eventData,s=!1,l=this._zrEventProxy;l.x=t.offsetX,l.y=t.offsetY,l.update();var u={target:l},h=ee(l);"mousemove"===e&&(null!=i?i!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(h.dataIndex=this._lastDataIndex,h.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0):null!=o&&o!==this._lastEventData&&(null!=this._lastEventData&&(h.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",t)),s=!0),this._lastEventData=o,this._lastDataIndex=i,this._lastSeriesIndex=a),h.eventData=o,h.dataIndex=i,h.seriesIndex=a,(null!=o||parseInt(i,10)>=0&&parseInt(a,10)>=0)&&(this.zr.handler.dispatchToElement(u,e,t),s&&this.zr.handler.dispatchToElement(u,"mouseover",t))},fl.prototype._dispatchToView=function(e,t){for(var r=0;r<this.views.length;r++)this.views[r].containPoint(t.offsetX,t.offsetY)&&this.views[r].trigger(e,t)},Object.assign(fl.prototype,Dr);var xl=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function bl(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var r=e[t].normal,n=e[t].emphasis;r&&(e[t]=r),n&&(e.emphasis=e.emphasis||{},e.emphasis[t]=n)}}function wl(e){e&&(e instanceof Array||(e=[e]),re(e,function(e){if(e.axisLabel){var t=e.axisLabel;Object.assign(t,t.textStyle),t.textStyle=null}}))}function Tl(e){this._layers={},this._zr=e}Tl.prototype.update=function(e,t){var r=this,n=t.getZr();if(n.getWidth()&&n.getHeight()){for(var i in this._layers)this._layers[i].removeViewsAll();e.eachComponent(function(r,n){if("series"!==r){var i=t.getViewOfComponentModel(n),s=n.coordinateSystem;if(i.__ecgl__){if(s){if(!s.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+n.id);l=s.viewGL}else{if(!n.viewGL)return void console.error("Can't find viewGL of component "+n.id);l=s.viewGL}var l=s.viewGL,u=a(n);u.addView(l),i.afterRender&&i.afterRender(n,e,t,u),o(i.groupGL,n.get("silent"))}}}),e.eachSeries(function(r){var n=t.getViewOfSeriesModel(r),i=r.coordinateSystem;if(n.__ecgl__){if(i&&!i.viewGL&&!n.viewGL)return void console.error("Can't find viewGL of series "+n.id);var s=i&&i.viewGL||n.viewGL,l=a(r);l.addView(s),n.afterRender&&n.afterRender(r,e,t,l),o(n.groupGL,r.get("silent"))}})}else console.warn("Dom has no width or height");function a(e){var t;n.setSleepAfterStill(0),t=(e.coordinateSystem&&e.coordinateSystem.model,e.get("zlevel"));var i=r._layers,a=i[t];if(!a){if(a=i[t]=new fl("gl-"+t,n),n.painter.isSingleCanvas()){a.virtual=!0;var o=new se({z:1e4,style:{image:a.renderer.canvas},silent:!0});a.__hostImage=o,n.add(o)}n.painter.insertLayer(t,a)}return a.__hostImage&&a.__hostImage.setStyle({width:a.renderer.getWidth(),height:a.renderer.getHeight()}),a}function o(e,t){e&&e.traverse(function(e){e.isRenderable&&e.isRenderable()&&(e.ignorePicking=null!=e.$ignorePicking?e.$ignorePicking:t)})}},ie(function(e){var t=e.getZr(),r=t.painter.dispose;t.painter.dispose=function(){"function"==typeof this.eachOtherLayer&&this.eachOtherLayer(function(e){e instanceof fl&&e.dispose()}),r.call(this)},t.painter.getRenderedCanvas=function(e){if(e=e||{},this._singleCanvas)return this._layers[0].dom;var t=document.createElement("canvas"),r=e.pixelRatio||this.dpr;t.width=this.getWidth()*r,t.height=this.getHeight()*r;var n=t.getContext("2d");n.dpr=r,n.clearRect(0,0,t.width,t.height),e.backgroundColor&&(n.fillStyle=e.backgroundColor,n.fillRect(0,0,t.width,t.height));var i,a=this.storage.getDisplayList(!0),o={},s=this;function l(e,t){var r,i=s._zlevelList;null==e&&(e=-1/0);for(var a=0;a<i.length;a++){var o=i[a],l=s._layers[o];if(!l.__builtin__&&o>e&&o<t){r=l;break}}r&&r.renderToCanvas&&(n.save(),r.renderToCanvas(n),n.restore())}for(var u={ctx:n},h=0;h<a.length;h++){var c=a[h];c.zlevel!==i&&(l(i,c.zlevel),i=c.zlevel),this._doPaintEl(c,u,!0,null,o)}return l(i,1/0),t}}),ae(function(e,t){var r=t.getZr();(r.__egl=r.__egl||new Tl(r)).update(e,t)}),oe(function(e){re(e.series,function(t){ne(xl,t.type)>=0&&(!function(e){bl(e,"itemStyle"),bl(e,"lineStyle"),bl(e,"areaStyle"),bl(e,"label")}(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))}),wl(e.xAxis3D),wl(e.yAxis3D),wl(e.zAxis3D),wl(e.grid3D),bl(e.geo3D)});var Sl={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)}},Ml={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"}}},Al={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}}}},El=le.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}}});ue(El.prototype,Sl),ue(El.prototype,Ml),ue(El.prototype,Al);var Cl=Vs,Dl={left:0,middle:1,right:2};function Ll(e){return e instanceof Array||(e=[e,e]),e}var Pl=Nr.extend(function(){return{zr:null,viewGL:null,_center:new Ji,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 li,_panVelocity:new li,_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 r=(t=t||{}).baseDistance||0,n=t.baseOrthoSize||1,i=e.get("projection");"perspective"!==i&&"orthographic"!==i&&"isometric"!==i&&(i="perspective"),this._projection=i,this.viewGL.setProjection(i);var a=e.get("distance")+r,o=e.get("orthographicSize")+n;[["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]]=Cl(e.get(t[0]),t[1])},this),this.minDistance+=r,this.maxDistance+=r,this.minOrthographicSize+=n,this.maxOrthographicSize+=n;var s=e.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach(function(t){l[t]=Cl(e.get(t),s&&s.get(t))});var u=Cl(t.alpha,e.get("alpha"))||0,h=Cl(t.beta,e.get("beta"))||0,c=Cl(t.center,e.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:u,beta:h,center:c,distance:a,orthographicSize:o,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(u),this.setBeta(h),this.setCenter(c),this.setOrthographicSize(o)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(e){var t=this.zr,r=this,n={},i={};return null!=e.distance&&(n.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(n.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(n.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(n).when(e.duration||1e3,i).during(function(){null!=n.alpha&&r.setAlpha(n.alpha),null!=n.beta&&r.setBeta(n.beta),null!=n.distance&&r.setDistance(n.distance),null!=n.center&&r.setCenter(n.center),null!=n.orthographicSize&&r.setOrthographicSize(n.orthographicSize),r._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(),r=this._orthoSize,n=r/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-n/2,t.right=n/2,t.top=r/2,t.bottom=-r/2},_updatePan:function(e){var t=this._panVelocity,r=this._distance,n=this.getCamera(),i=n.worldTransform.y,a=n.worldTransform.x;this._center.scaleAndAdd(a,-t.x*r/200).scaleAndAdd(i,-t.y*r/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new Ji,r=this._theta+Math.PI/2,n=this._phi+Math.PI/2,i=Math.sin(r);t.x=i*Math.cos(n),t.y=-Math.cos(r),t.z=i*Math.sin(n),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 r=e.len();(r*=t)<1e-4&&(r=0),e.normalize().scale(r)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),r=Math.atan2(e.x,e.z);this._theta=t,this._phi=-r,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,r=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,r)||(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===Dl[this.rotateMouseButton]?this._mode="rotate":e.event.button===Dl[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=Ll(this.panSensitivity),r=Ll(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*r[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*r[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 r,n=e.offsetX,i=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(n,i))r="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)*r*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 r=t.indexOf(e);r>=0&&t.splice(r,1)}),e}});Object.defineProperty(Pl.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});var Ol={convertToDynamicArray:function(e){e&&this.resetOffset();var t=this.attributes;for(var r in t)e||!t[r].value?t[r].value=[]:t[r].value=Array.prototype.slice.call(t[r].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()}},Nl={vec2:si,vec3:ki,vec4:da,mat2:$s,mat2d:tl,mat3:fa,mat4:Fi,quat:_a},Rl=Nl.vec3,Il=[[0,0],[1,1]],Bl=mo.extend(function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new mo.Attribute("position","float",3,"POSITION"),positionPrev:new mo.Attribute("positionPrev","float",3),positionNext:new mo.Attribute("positionNext","float",3),prevPositionPrev:new mo.Attribute("prevPositionPrev","float",3),prevPosition:new mo.Attribute("prevPosition","float",3),prevPositionNext:new mo.Attribute("prevPositionNext","float",3),offset:new mo.Attribute("offset","float",1),color:new mo.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,r,n){return 1/(Rl.dist(e,t)+Rl.dist(r,t)+Rl.dist(n,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(Il)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Il)},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,r,n,i,a){null==a&&(a=1);var o=e[0],s=e[1],l=e[2],u=t[0],h=t[1],c=t[2],d=r[0],f=r[1],p=r[2],m=n[0],g=n[1],v=n[2],_=this._getCubicCurveApproxStep(e,t,r,n),y=_*_,x=y*_,b=3*_,w=3*y,T=6*y,S=6*x,M=o-2*u+d,A=s-2*h+f,E=l-2*c+p,C=3*(u-d)-o+m,D=3*(h-f)-s+g,L=3*(c-p)-l+v,P=o,O=s,N=l,R=(u-o)*b+M*w+C*x,I=(h-s)*b+A*w+D*x,B=(c-l)*b+E*w+L*x,z=M*T+C*S,F=A*T+D*S,k=E*T+L*S,U=C*S,G=D*S,H=L*S,V=0,W=0,j=Math.ceil(1/_),X=new Float32Array(3*(j+1)),q=(X=[],0);for(W=0;W<j+1;W++)X[q++]=P,X[q++]=O,X[q++]=N,P+=R,O+=I,N+=B,R+=z,I+=F,B+=k,z+=U,F+=G,k+=H,(V+=_)>1&&(P=R>0?Math.min(P,m):Math.max(P,m),O=I>0?Math.min(O,g):Math.max(O,g),N=B>0?Math.min(N,v):Math.max(N,v));return this.addPolyline(X,i,a)},addLine:function(e,t,r,n){return this.addPolyline([e,t],r,n)},addPolyline:function(e,t,r,n,i){if(e.length){var a="number"!=typeof e[0];if(null==i&&(i=a?e.length:e.length/3),!(i<2)){null==n&&(n=0),null==r&&(r=1),this._itemVertexOffsets.push(this._vertexOffset);var o,s,l=(a="number"!=typeof e[0])?"number"!=typeof t[0]:t.length/4===i,u=this.attributes.position,h=this.attributes.positionPrev,c=this.attributes.positionNext,d=this.attributes.color,f=this.attributes.offset,p=this.indices,m=this._vertexOffset;r=Math.max(r,.01);for(var g=n;g<i;g++){if(a)o=e[g],s=l?t[g]:t;else{var v=3*g;if((o=o||[])[0]=e[v],o[1]=e[v+1],o[2]=e[v+2],l){var _=4*g;(s=s||[])[0]=t[_],s[1]=t[_+1],s[2]=t[_+2],s[3]=t[_+3]}else s=t}if(this.useNativeLine?g>1&&(u.copy(m,m-1),d.copy(m,m-1),m++):(g<i-1&&(h.set(m+2,o),h.set(m+3,o)),g>0&&(c.set(m-2,o),c.set(m-1,o)),u.set(m,o),u.set(m+1,o),d.set(m,s),d.set(m+1,s),f.set(m,r/2),f.set(m+1,-r/2),m+=2),this.useNativeLine)d.set(m,s),u.set(m,o),m++;else if(g>0){var y=3*this._triangleOffset;(p=this.indices)[y]=m-4,p[y+1]=m-3,p[y+2]=m-2,p[y+3]=m-3,p[y+4]=m-1,p[y+5]=m-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*i;h.copy(x,x+2),h.copy(x+1,x+3),c.copy(b-1,b-3),c.copy(b-2,b-4)}return this._vertexOffset=m,this._vertexOffset}}},setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=r;i<n;i++)this.attributes.color.set(i,t);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});function zl(e,t,r,n,i,a,o){this._zr=e,this._x=0,this._y=0,this._rowHeight=0,this.width=n,this.height=i,this.offsetX=t,this.offsetY=r,this.dpr=o,this.gap=a}function Fl(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 no({image:t,flipY:!1});var r=this;this._zr=ce(t);var n=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){n.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new zl(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}function kl(){}he(Bl.prototype,Ol),zl.prototype={constructor:zl,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(e,t,r){var n=e.getBoundingRect();null==t&&(t=n.width),null==r&&(r=n.height),t*=this.dpr,r*=this.dpr,this._fitElement(e,t,r);var i=this._x,a=this._y,o=this.width*this.dpr,s=this.height*this.dpr,l=this.gap;if(i+t+l>o&&(i=this._x=0,a+=this._rowHeight+l,this._y=a,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,r),a+r+l>s)return null;e.x+=this.offsetX*this.dpr+i,e.y+=this.offsetY*this.dpr+a,this._zr.add(e);var u=[this.offsetX/this.width,this.offsetY/this.height];return[[i/o+u[0],a/s+u[1]],[(i+t)/o+u[0],(a+r)/s+u[1]]]},_fitElement:function(e,t,r){var n=e.getBoundingRect(),i=t/n.width,a=r/n.height;e.x=-n.x*i,e.y=-n.y*a,e.scaleX=i,e.scaleY=a,e.update()}},Fl.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,r=t*this._nodeWidth%e,n=Math.floor(t*this._nodeWidth/e)*this._nodeHeight;if(!(n>=e)){var i=(r+this._nodeWidth)*this._dpr,a=(n+this._nodeHeight)*this._dpr;try{this._zr.resize({width:i,height:a})}catch(Sc){this._canvas.width=i,this._canvas.height=a}var o=new zl(this._zr,r,n,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(o),o}},add:function(e,t,r){if(this._coords[e.id])return this._coords[e.id];var n=this._getCurrentNode().add(e,t,r);if(!n){var i=this._expand();if(!i)return;n=i.add(e,t,r)}return this._coords[e.id]=n,n},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()}},kl.prototype={constructor:kl,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new ul.DirectionalLight({shadowBias:.005}),this.ambientLight=new ul.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,r=this.ambientLight,n=e.getModel("light"),i=n.getModel("main"),a=n.getModel("ambient");t.intensity=i.get("intensity"),r.intensity=a.get("intensity"),t.color=ul.parseColor(i.get("color")).slice(0,3),r.color=ul.parseColor(a.get("color")).slice(0,3);var o=i.get("alpha")||0,s=i.get("beta")||0;t.position.setArray(ul.directionFromAlphaBeta(o,s)),t.lookAt(ul.Vector3.ZERO),t.castShadow=i.get("shadow"),t.shadowResolution=ul.getShadowResolution(i.get("shadowQuality"))},updateAmbientCubemap:function(e,t,r){var n=t.getModel("light.ambientCubemap"),i=n.get("texture");if(i){this._cubemapLightsCache=this._cubemapLightsCache||{};var a=this._cubemapLightsCache[i];if(!a){var o=this;a=this._cubemapLightsCache[i]=ul.createAmbientCubemap(n.option,e,r,function(){o._isSkyboxFromAmbientCubemap&&o._skybox.setEnvironmentMap(a.specular.cubemap),r.getZr().refresh()})}this._lightRoot.add(a.diffuse),this._lightRoot.add(a.specular),this._currentCubemapLights=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(e,r,n){var i=r.get("environment"),a=this;var o=(a._skybox=a._skybox||new ps,a._skybox);if(i&&"none"!==i)if("auto"===i)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var s=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(s),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"===t(i)&&i.colorStops||"string"==typeof i&&J(i)){this._isSkyboxFromAmbientCubemap=!1;var l=new ul.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(l);var u=l.image=document.createElement("canvas");u.width=u.height=16;var h=u.getContext("2d"),c=new $({shape:{x:0,y:0,width:16,height:16},style:{fill:i}});de(h,c),o.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;l=ul.loadTexture(i,n,{anisotropic:8,flipY:!1});o.setEnvironmentMap(l),o.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var d=r.coordinateSystem;if(this._skybox)if(!d||!d.viewGL||"auto"===i||i.match&&i.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var f=d.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[f]("fragment","SRGB_DECODE")}}};var Ul=Nl.vec3,Gl=mo.extend(function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new mo.Attribute("position","float",3,"POSITION"),normal:new mo.Attribute("normal","float",3,"NORMAL"),color:new mo.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,r=this.getQuadVertexCount()*e,n=this.getQuadTriangleCount()*e;this.vertexCount!==r&&(t.position.init(r),t.normal.init(r),t.color.init(r)),this.triangleCount!==n&&(this.indices=r>65535?new Uint32Array(3*n):new Uint16Array(3*n))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=Ul.create(),t=Ul.create(),r=Ul.create(),n=[0,3,1,3,2,1];return function(i,a){var o=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;Ul.sub(e,i[1],i[0]),Ul.sub(t,i[2],i[1]),Ul.cross(r,e,t),Ul.normalize(r,r);for(var u=0;u<4;u++)o.set(this._vertexOffset+u,i[u]),l.set(this._vertexOffset+u,a),s.set(this._vertexOffset+u,r);var h=3*this._faceOffset;for(u=0;u<6;u++)this.indices[h+u]=n[u]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});he(Gl.prototype,Ol);var Hl=Vs,Vl={x:0,y:2,z:1};function Wl(e,t,r){this.rootNode=new ul.Node;var n=new ul.Mesh({geometry:new Bl({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new ul.Mesh({geometry:new Gl,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(n),this.faceInfo=e,this.plane=new ul.Plane,this.linesMesh=n,this.quadsMesh=i}Wl.prototype.update=function(e,t,r){var n=e.coordinateSystem,i=[n.getAxis(this.faceInfo[0]),n.getAxis(this.faceInfo[1])],a=this.linesMesh.geometry,o=this.quadsMesh.geometry;a.convertToDynamicArray(!0),o.convertToDynamicArray(!0),this._updateSplitLines(a,i,e,r),this._udpateSplitAreas(o,i,e,r),a.convertToTypedArray(),o.convertToTypedArray();var s=n.getAxis(this.faceInfo[2]);!function(e,t,r,n){var i=[0,0,0],a=n<0?r.getExtentMin():r.getExtentMax();i[Vl[r.dim]]=a,e.position.setArray(i),e.rotation.identity(),t.distance=-Math.abs(a),t.normal.set(0,0,0),"x"===r.dim?(e.rotation.rotateY(n*Math.PI/2),t.normal.x=-n):"z"===r.dim?(e.rotation.rotateX(-n*Math.PI/2),t.normal.y=-n):(n>0&&e.rotation.rotateY(Math.PI),t.normal.z=-n)}(this.rootNode,this.plane,s,this.faceInfo[3])},Wl.prototype._updateSplitLines=function(e,t,r,n){var i=n.getDevicePixelRatio();t.forEach(function(n,a){var o=n.model,s=t[1-a].getExtent();if(!n.scale.isBlank()){var l=o.getModel("splitLine",r.getModel("splitLine"));if(l.get("show")){var u=l.getModel("lineStyle"),h=u.get("color"),c=Hl(u.get("opacity"),1),d=Hl(u.get("width"),1);h=Z(h)?h:[h];for(var f=n.getTicksCoords({tickModel:l}),p=0,m=0;m<f.length;m++){var g=f[m].coord,v=ul.parseColor(h[p%h.length]);v[3]*=c;var _=[0,0,0],y=[0,0,0];_[a]=y[a]=g,_[1-a]=s[0],y[1-a]=s[1],e.addLine(_,y,v,d*i),p++}}}})},Wl.prototype._udpateSplitAreas=function(e,t,r,n){t.forEach(function(n,i){var a=n.model,o=t[1-i].getExtent();if(!n.scale.isBlank()){var s=a.getModel("splitArea",r.getModel("splitArea"));if(s.get("show")){var l=s.getModel("areaStyle"),u=l.get("color"),h=Hl(l.get("opacity"),1);u=Z(u)?u:[u];for(var c=n.getTicksCoords({tickModel:s,clamp:!0}),d=0,f=[0,0,0],p=[0,0,0],m=0;m<c.length;m++){var g=c[m].coord,v=[0,0,0],_=[0,0,0];if(v[i]=_[i]=g,v[1-i]=o[0],_[1-i]=o[1],0!==m){var y=ul.parseColor(u[d%u.length]);y[3]*=h,e.addQuad([f,v,_,p],y),f=v,p=_,d++}else f=v,p=_}}}})};var jl=[0,1,2,0,2,3],Xl=mo.extend(function(){return{attributes:{position:new mo.Attribute("position","float",3,"POSITION"),texcoord:new mo.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new mo.Attribute("offset","float",2),color:new mo.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(e){this._spriteCount=e;var t=4*e,r=2*e;this.vertexCount!==t&&(this.attributes.position.init(t),this.attributes.offset.init(t),this.attributes.color.init(t)),this.triangleCount!==r&&(this.indices=t>65535?new Uint32Array(3*r):new Uint16Array(3*r))},setSpriteAlign:function(e,t,r,n,i){var a,o,s,l;switch(null==r&&(r="left"),null==n&&(n="top"),i=i||0,r){case"left":a=i,s=t[0]+i;break;case"center":case"middle":a=-t[0]/2,s=t[0]/2;break;case"right":a=-t[0]-i,s=-i}switch(n){case"bottom":o=i,l=t[1]+i;break;case"middle":o=-t[1]/2,l=t[1]/2;break;case"top":o=-t[1]-i,l=-i}var u=4*e,h=this.attributes.offset;h.set(u,[a,l]),h.set(u+1,[s,l]),h.set(u+2,[s,o]),h.set(u+3,[a,o])},addSprite:function(e,t,r,n,i,a){var o=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,r,n,i,a);for(var s=0;s<jl.length;s++)this.indices[3*this._faceOffset+s]=jl[s]+o;return this._faceOffset+=2,this._vertexOffset+=4,o/4},setSprite:function(e,t,r,n,i,a,o){for(var s=4*e,l=this.attributes,u=0;u<4;u++)l.position.set(s+u,t);var h=l.texcoord;h.set(s,[n[0][0],n[0][1]]),h.set(s+1,[n[1][0],n[0][1]]),h.set(s+2,[n[1][0],n[1][1]]),h.set(s+3,[n[0][0],n[1][1]]),this.setSpriteAlign(e,r,i,a,o)}});he(Xl.prototype,Ol);ul.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 ql=ul.Mesh.extend(function(){return{geometry:new Xl({dynamic:!0}),material:new ul.Material({shader:ul.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}}),Zl=Vs,Yl={x:0,y:2,z:1};function Kl(e,t){var r=new ul.Mesh({geometry:new Bl({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),n=new ql;n.material.depthMask=!1;var i=new ul.Node;i.add(r),i.add(n),this.rootNode=i,this.dim=e,this.linesMesh=r,this.labelsMesh=n,this.axisLineCoords=null,this.labelElements=[]}var Ql={x:"y",y:"x",z:"y"};Kl.prototype.update=function(e,t,r){var n=e.coordinateSystem.getAxis(this.dim),i=this.linesMesh.geometry,a=this.labelsMesh.geometry;i.convertToDynamicArray(!0),a.convertToDynamicArray(!0);var o=n.model,s=n.getExtent(),l=r.getDevicePixelRatio(),u=o.getModel("axisLine",e.getModel("axisLine")),h=o.getModel("axisTick",e.getModel("axisTick")),c=o.getModel("axisLabel",e.getModel("axisLabel")),d=u.get("lineStyle.color");if(u.get("show")){var f=u.getModel("lineStyle"),p=[0,0,0];(S=[0,0,0])[M=Yl[n.dim]]=s[0],p[M]=s[1],this.axisLineCoords=[S,p];var m=ul.parseColor(d),g=Zl(f.get("width"),1),v=Zl(f.get("opacity"),1);m[3]*=v,i.addLine(S,p,m,g*l)}if(h.get("show")){var _=h.getModel("lineStyle"),y=ul.parseColor(Zl(_.get("color"),d));g=Zl(_.get("width"),1);y[3]*=Zl(_.get("opacity"),1);for(var x=n.getTicksCoords(),b=h.get("length"),w=0;w<x.length;w++){var T=x[w].coord,S=[0,0,0],M=(p=[0,0,0],Yl[n.dim]),A=Yl[Ql[n.dim]];S[M]=p[M]=T,p[A]=b,i.addLine(S,p,y,g*l)}}this.labelElements=[];l=r.getDevicePixelRatio();if(c.get("show")){x=n.getTicksCoords();var E=o.get("data"),C=c.get("margin"),D=n.getViewLabels();for(w=0;w<D.length;w++){var L=D[w].tickValue,P=D[w].formattedLabel,O=D[w].rawLabel,N=(T=n.dataToCoord(L),[0,0,0]);M=Yl[n.dim],A=Yl[Ql[n.dim]];N[M]=N[M]=T,N[A]=C;var R=c;E&&E[L]&&E[L].textStyle&&(R=new fe(E[L].textStyle,c,o.ecModel));var I=Zl(R.get("color"),d),B=new pe({style:me(R,{text:P,fill:"function"==typeof I?I("category"===n.type?O:"value"===n.type?L+"":L,w):I,verticalAlign:"top",align:"left"})}),z=t.add(B),F=B.getBoundingRect();a.addSprite(N,[F.width*l,F.height*l],z),this.labelElements.push(B)}}if(o.get("name")){var k=o.getModel("nameTextStyle"),U=(N=[0,0,0],M=Yl[n.dim],A=Yl[Ql[n.dim]],Zl(k.get("color"),d)),G=k.get("borderColor");g=k.get("borderWidth");N[M]=N[M]=(s[0]+s[1])/2,N[A]=o.get("nameGap");B=new pe({style:me(k,{text:o.get("name"),fill:U,stroke:G,lineWidth:g})}),z=t.add(B),F=B.getBoundingRect();a.addSprite(N,[F.width*l,F.height*l],z),B.__idx=this.labelElements.length,this.nameLabelElement=B}this.labelsMesh.material.set("textureAtlas",t.getTexture()),this.labelsMesh.material.set("uvScale",t.getCoordsScale()),i.convertToTypedArray(),a.convertToTypedArray()},Kl.prototype.setSpriteAlign=function(e,t,r){for(var n=r.getDevicePixelRatio(),i=this.labelsMesh.geometry,a=0;a<this.labelElements.length;a++){var o=this.labelElements[a].getBoundingRect();i.setSpriteAlign(a,[o.width*n,o.height*n],e,t)}var s=this.nameLabelElement;if(s){o=s.getBoundingRect();i.setSpriteAlign(s.__idx,[o.width*n,o.height*n],e,t),i.dirty()}this.textAlign=e,this.textVerticalAlign=t};var Jl="@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",$l=Vs;ul.Shader.import(Jl);var eu={x:0,y:2,z:1},tu=ge.extend({type:"grid3D",__ecgl__:!0,init:function(e,t){var r=new ul.Material({shader:ul.createShader("ecgl.color"),depthMask:!1,transparent:!0}),n=new ul.Material({shader:ul.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});r.define("fragment","DOUBLE_SIDED"),r.define("both","VERTEX_COLOR"),this.groupGL=new ul.Node,this._control=new Pl({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 Wl(e,n,r);return this.groupGL.add(t.rootNode),t},this),this._axes=["x","y","z"].map(function(e){var t=new Kl(e,n);return this.groupGL.add(t.rootNode),t},this);var i=t.getDevicePixelRatio();this._axisLabelSurface=new Fl({width:256,height:256,devicePixelRatio:i}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new ul.Mesh({geometry:new Bl({useNativeLine:!1}),material:n,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new Fl({width:128,height:128,devicePixelRatio:i}),this._axisPointerLabelsMesh=new ql({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new ul.Node,this._sceneHelper=new kl,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,r){this._model=e,this._api=r;var n=e.coordinateSystem;n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(n.viewGL);var a=e.getModel("viewControl");i.setFromViewControlModel(a,0),this._axisLabelSurface.clear(),i.off("update"),e.get("show")&&(this._faces.forEach(function(n){n.update(e,t,r)},this),this._axes.forEach(function(t){t.update(e,this._axisLabelSurface,r)},this)),i.on("update",this._onCameraChange.bind(this,e,r),this),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},showAxisPointer:function(e,t,r,n){this._doShowAxisPointer(),this._updateAxisPointer(n.value)},hideAxisPointer:function(e,t,r,n){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,r=this._model.coordinateSystem,n=r.viewGL,i=n.castRay(e.offsetX,e.offsetY,new ul.Ray),a=0;a<this._faces.length;a++){var o=this._faces[a];if(!o.rootNode.invisible){o.plane.normal.dot(n.camera.worldTransform.z)<0&&o.plane.normal.negate();var s=i.intersectPlane(o.plane);if(s){var l=r.getAxis(o.faceInfo[0]),u=r.getAxis(o.faceInfo[1]),h=eu[o.faceInfo[0]],c=eu[o.faceInfo[1]];l.contain(s.array[h])&&u.contain(s.array[c])&&(t=s)}}}if(t){var d=r.pointToData(t.array,[],!0);this._updateAxisPointer(d),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(e,t){e.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var r=this._control;t.dispatchAction({type:"grid3DChangeCamera",alpha:r.getAlpha(),beta:r.getBeta(),distance:r.getDistance(),center:r.getCenter(),from:this.uid,grid3DId:e.id})},_updateFaceVisibility:function(){var e=this._control.getCamera(),t=new ul.Vector3;e.update();for(var r=0;r<this._faces.length/2;r++){for(var n=[],i=0;i<2;i++){this._faces[2*r+i].rootNode.getWorldPosition(t),t.transformMat4(e.viewMatrix),n[i]=t.z}var a=n[0]>n[1]?0:1,o=this._faces[2*r+a],s=this._faces[2*r+1-a];o.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),r=e.getAxis("y"),n=e.getAxis("z"),i=n.getExtentMax(),a=n.getExtentMin(),o=t.getExtentMin(),s=t.getExtentMax(),l=r.getExtentMax(),u=r.getExtentMin(),h=this._axes[0].rootNode,c=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,p=f[4].rootNode.invisible?u:l,m=f[2].rootNode.invisible?i:a,g=f[0].rootNode.invisible?o:s,v=f[2].rootNode.invisible?i:a,_=f[0].rootNode.invisible?s:o,y=f[4].rootNode.invisible?u:l;h.rotation.identity(),c.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,h.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,c.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),h.position.set(0,m,p),c.position.set(g,v,0),d.position.set(_,0,y),h.update(),c.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new ul.Vector4,new ul.Vector4],r=new ul.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach(function(n){var i=n.axisLineCoords;n.labelsMesh.geometry;for(var a=0;a<t.length;a++)t[a].setArray(i[a]),t[a].w=1,t[a].transformMat4(n.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),t[a].x/=t[a].w,t[a].y/=t[a].w;var o,s,l=t[1].x-t[0].x,u=t[1].y-t[0].y,h=(t[1].x+t[0].x)/2,c=(t[1].y+t[0].y)/2;Math.abs(u/l)<.5?(o="center",s=c>r.y?"bottom":"top"):(s="middle",o=h>r.x?"left":"right"),n.setSpriteAlign(o,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,r=t.dataToPoint(e),n=this._axisPointerLineMesh.geometry,i=this._model.getModel("axisPointer"),a=this._api.getDevicePixelRatio();function o(e){return Vs(e.model.get("axisPointer.show"),i.get("show"))}function s(e){var t=e.model.getModel("axisPointer",i).getModel("lineStyle"),r=ul.parseColor(t.get("color")),n=$l(t.get("width"),1),a=$l(t.get("opacity"),1);return r[3]*=a,{color:r,lineWidth:n}}n.convertToDynamicArray(!0);for(var l=0;l<this._faces.length;l++){var u=this._faces[l];if(!u.rootNode.invisible){for(var h=u.faceInfo,c=h[3]<0?t.getAxis(h[2]).getExtentMin():t.getAxis(h[2]).getExtentMax(),d=eu[h[2]],f=0;f<2;f++){var p=h[f],m=h[1-f],g=t.getAxis(p),v=t.getAxis(m);if(o(g)){var _=eu[p],y=eu[m];(w=[0,0,0])[_]=(b=[0,0,0])[_]=r[_],w[d]=b[d]=c,w[y]=v.getExtentMin(),b[y]=v.getExtentMax();var x=s(g);n.addLine(w,b,x.color,x.lineWidth*a)}}if(o(t.getAxis(h[2]))){var b,w=r.slice();(b=r.slice())[d]=c;x=s(t.getAxis(h[2]));n.addLine(w,b,x.color,x.lineWidth*a)}}}n.convertToTypedArray(),this._updateAxisPointerLabelsMesh(e),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(e){var t=this._model,r=this._axisPointerLabelsMesh,n=this._axisPointerLabelsSurface,i=t.coordinateSystem,a=t.getModel("axisPointer");r.geometry.convertToDynamicArray(!0),n.clear();var o={x:"y",y:"x",z:"y"};this._axes.forEach(function(t,s){var l=i.getAxis(t.dim),u=l.model.getModel("axisPointer",a),h=u.getModel("label"),c=u.get("lineStyle.color");if(h.get("show")&&u.get("show")){var d=e[s],f=h.get("formatter"),p=l.scale.getLabel({value:d});if(null!=f)p=f(p,e);else if("interval"===l.scale.type||"log"===l.scale.type){var m=ve(l.scale.getTicks()[0]);p=d.toFixed(m+2)}var g=h.get("color"),v=new pe({style:me(h,{text:p,fill:g||c,align:"left",verticalAlign:"top"})}),_=n.add(v),y=v.getBoundingRect(),x=this._api.getDevicePixelRatio(),b=t.rootNode.position.toArray();b[eu[o[t.dim]]]+=(t.flipped?-1:1)*h.get("margin"),b[eu[t.dim]]=l.dataToCoord(e[s]),r.geometry.addSprite(b,[y.width*x,y.height*x],_,t.textAlign,t.textVerticalAlign)}},this),n.getZr().refreshImmediately(),r.material.set("uvScale",n.getCoordsScale()),r.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._axisLabelSurface.dispose(),this._axisPointerLabelsSurface.dispose()}});function ru(e){_e.call(this,e),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}function nu(e,t,r){xe.call(this,e,t,r)}ru.prototype={constructor:ru,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,r){return(t=t||[])[0]=this.getAxis("x").dataToCoord(e[0],r),t[2]=this.getAxis("y").dataToCoord(e[1],r),t[1]=this.getAxis("z").dataToCoord(e[2],r),t},pointToData:function(e,t,r){return(t=t||[])[0]=this.getAxis("x").coordToData(e[0],r),t[1]=this.getAxis("y").coordToData(e[2],r),t[2]=this.getAxis("z").coordToData(e[1],r),t}},ye(ru,_e),nu.prototype={constructor:nu,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)}},ye(nu,xe);var iu=function(){this._pool={},this._allocatedTextures=[]};iu.prototype={constructor:iu,get:function(e){var t=su(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var r=this._pool[t];if(!r.length){var n=new no(e);return this._allocatedTextures.push(n),n}return r.pop()},put:function(e){var t=su(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 au={width:512,height:512,type:rn,format:dn,wrapS:Sn,wrapT:Sn,minFilter:xn,magFilter:gn,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},ou=Object.keys(au);function su(e){Or.defaultsWithPropList(e,au,ou),function(e){var t=(r=e.width,n=e.height,!(r&r-1||n&n-1));var r,n;e.format===un&&(e.useMipmap=!1);t&&e.useMipmap||(e.minFilter==vn||e.minFilter==yn?e.minFilter=mn:e.minFilter!=xn&&e.minFilter!=_n||(e.minFilter=gn));t||(e.wrapS=Sn,e.wrapT=Sn)}(e);for(var t="",r=0;r<ou.length;r++){t+=e[ou[r]].toString()}return t}var lu=["px","nx","py","ny","pz","nz"];function uu(e,t,r){return"alphaMap"===r?e.material.get("diffuseMap"):"alphaCutoff"===r?e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")&&e.material.get("alphaCutoff")||0:"uvRepeat"===r?e.material.get("uvRepeat"):"uvOffset"===r?e.material.get("uvOffset"):t.get(r)}function hu(e,t){var r=e.material,n=t.material;return r.get("diffuseMap")!==n.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(n.get("alphaCutoff")||0)}Ri.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 cu,du,fu,pu,mu,gu,vu,_u=Nr.extend(function(){return{softShadow:_u.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 ss,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new iu}},function(){this._gaussianPassH=new Rs({fragment:Ri.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new Rs({fragment:Ri.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 Rs({fragment:Ri.source("clay.sm.debug_depth")})},{render:function(e,t,r,n){r||(r=t.getMainCamera()),this.trigger("beforerender",this,e,t,r),this._renderShadowPass(e,t,r,n),this.trigger("afterrender",this,e,t,r)},renderDebug:function(e,t){e.saveClear();var r=e.viewport,n=0,i=t||r.width/4,a=i;for(var o in this.softShadow===_u.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[o];e.setViewport(n,0,i*s.width/s.height,a),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),n+=i*s.width/s.height}e.setViewport(r),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===_u.VSM)t.material.define("fragment","USE_VSM"),t.material.undefine("fragment","PCF_KERNEL_SIZE");else{t.material.undefine("fragment","USE_VSM");var r=this.kernelPCF;r&&r.length?t.material.define("fragment","PCF_KERNEL_SIZE",r.length/2):t.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(e,t){var r=this;t.traverse(function(t){t.isRenderable()&&r._updateReceivers(e,t)});for(var n=0;n<t.lights.length;n++){var i=t.lights[n];i.castShadow&&!i.invisible&&this._lightsCastShadow.push(i)}},_renderShadowPass:function(e,t,r,n){for(var i in this._shadowMapNumber)this._shadowMapNumber[i]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var a=e.gl;if(n||t.update(),r&&r.update(),t.updateLights(),this._update(e,t),this._lightsCastShadow.length||!this._lastRenderNotCastShadow){this._lastRenderNotCastShadow=0===this._lightsCastShadow,a.enable(a.DEPTH_TEST),a.depthMask(!0),a.disable(a.BLEND),a.clearColor(1,1,1,1);for(var o,s=[],l=[],u=[],h=[],c=[],d=[],f=0;f<this._lightsCastShadow.length;f++){var p=this._lightsCastShadow[f];if("DIRECTIONAL_LIGHT"===p.type){if(o){console.warn("Only one direectional light supported with shadow cascade");continue}if(p.shadowCascade>4){console.warn("Support at most 4 cascade");continue}p.shadowCascade>1&&(o=p),this.renderDirectionalLightShadow(e,t,r,p,c,h,u)}else"SPOT_LIGHT"===p.type?this.renderSpotLightShadow(e,t,p,l,s):"POINT_LIGHT"===p.type&&this.renderPointLightShadow(e,t,p,d);this._shadowMapNumber[p.type]++}for(var m in this._shadowMapNumber){var g=this._shadowMapNumber[m],v=m+"_SHADOWMAP_COUNT";for(f=0;f<this._receivers.length;f++){(_=this._receivers[f].material).fragmentDefines[v]!==g&&(g>0?_.define("fragment",v,g):_.isDefined("fragment",v)&&_.undefine("fragment",v))}}for(f=0;f<this._receivers.length;f++){var _=this._receivers[f].material;o?_.define("fragment","SHADOW_CASCADE",o.shadowCascade):_.undefine("fragment","SHADOW_CASCADE")}var y=t.shadowUniforms;if(u.length>0){var x=u.map(S);if(y.directionalLightShadowMaps={value:u,type:"tv"},y.directionalLightMatrices={value:h,type:"m4v"},y.directionalLightShadowMapSizes={value:x,type:"1fv"},o){var b=c.slice(),w=c.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),h.reverse(),y.shadowCascadeClipsNear={value:b,type:"1fv"},y.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var T=s.map(S);(y=t.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},y.spotLightMatrices={value:l,type:"m4v"},y.spotLightShadowMapSizes={value:T,type:"1fv"}}d.length>0&&(y.pointLightShadowMaps={value:d,type:"tv"})}function S(e){return e.height}},renderDirectionalLightShadow:(cu=new Ro,du=new Ta,fu=new za,pu=new Ta,mu=new Ta,gu=new Ta,vu=new Ta,function(e,t,r,n,i,a,o){var s=this._getDepthMaterial(n),l={getMaterial:function(e){return e.shadowDepthMaterial||s},isMaterialChanged:hu,getUniform:uu,ifRender:function(e){return e.castShadow},sortCompare:Ki.opaqueSortCompare};if(!t.viewBoundingBoxLastFrame.isFinite()){var u=t.getBoundingBox();t.viewBoundingBoxLastFrame.copy(u).applyTransform(r.viewMatrix)}var h=Math.min(-t.viewBoundingBoxLastFrame.min.z,r.far),c=Math.max(-t.viewBoundingBoxLastFrame.max.z,r.near),d=this._getDirectionalLightCamera(n,t,r),f=gu.array;vu.copy(d.projectionMatrix),Fi.invert(mu.array,d.worldTransform.array),Fi.multiply(mu.array,mu.array,r.worldTransform.array),Fi.multiply(f,vu.array,mu.array);for(var p=[],m=r instanceof Ko,g=(r.near+r.far)/(r.near-r.far),v=2*r.near*r.far/(r.near-r.far),_=0;_<=n.shadowCascade;_++){var y=c*Math.pow(h/c,_/n.shadowCascade),x=c+(h-c)*_/n.shadowCascade,b=y*n.cascadeSplitLogFactor+x*(1-n.cascadeSplitLogFactor);p.push(b),i.push(-(-b*g+v)/-b)}var w=this._getTexture(n,n.shadowCascade);o.push(w);var T=e.viewport,S=e.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(e),S.clear(S.COLOR_BUFFER_BIT|S.DEPTH_BUFFER_BIT),_=0;_<n.shadowCascade;_++){var M=p[_],A=p[_+1];m?Fi.perspective(du.array,r.fov/180*Math.PI,r.aspect,M,A):Fi.ortho(du.array,r.left,r.right,r.bottom,r.top,M,A),cu.setFromProjection(du),cu.getTransformedBoundingBox(fu,mu),fu.applyProjection(vu);var E=fu.min.array,C=fu.max.array;E[0]=Math.max(E[0],-1),E[1]=Math.max(E[1],-1),C[0]=Math.min(C[0],1),C[1]=Math.min(C[1],1),pu.ortho(E[0],C[0],E[1],C[1],1,-1),d.projectionMatrix.multiplyLeft(pu);var D=n.shadowResolution||512;e.setViewport((n.shadowCascade-_-1)*D,0,D,D,1);var L=t.updateRenderList(d);e.renderPass(L.opaque,d,l),this.softShadow===_u.VSM&&this._gaussianFilter(e,w,w.width);var P=new Ta;P.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),a.push(P.array),d.projectionMatrix.copy(vu)}this._frameBuffer.unbind(e),e.setViewport(T)}),renderSpotLightShadow:function(e,t,r,n,i){var a=this._getTexture(r),o=this._getSpotLightCamera(r),s=e.gl;this._frameBuffer.attach(a),this._frameBuffer.bind(e),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(r),u={getMaterial:function(e){return e.shadowDepthMaterial||l},isMaterialChanged:hu,getUniform:uu,ifRender:function(e){return e.castShadow},sortCompare:Ki.opaqueSortCompare},h=t.updateRenderList(o);e.renderPass(h.opaque,o,u),this._frameBuffer.unbind(e),this.softShadow===_u.VSM&&this._gaussianFilter(e,a,a.width);var c=new Ta;c.copy(o.worldTransform).invert().multiplyLeft(o.projectionMatrix),i.push(a),n.push(c.array)},renderPointLightShadow:function(e,t,r,n){var i=this._getTexture(r),a=e.gl;n.push(i);var o=this._getDepthMaterial(r),s={getMaterial:function(e){return e.shadowDepthMaterial||o},getUniform:uu,sortCompare:Ki.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},u=new za,h=r.getWorldPosition().array,c=new za,d=r.range;c.min.setArray(h),c.max.setArray(h);var f=new Ji(d,d,d);c.max.add(f),c.min.sub(f);var p={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 r=0;r<lu.length;r++)l[lu[r]].push(e);return}if(u.transformFrom(t.boundingBox,e.worldTransform),!u.intersectBoundingBox(c))return;u.updateVertices();for(r=0;r<lu.length;r++)p[lu[r]]=!1;for(r=0;r<8;r++){var n=u.vertices[r],i=n[0]-h[0],a=n[1]-h[1],o=n[2]-h[2],s=Math.abs(i),d=Math.abs(a),f=Math.abs(o);s>d?s>f?p[i>0?"px":"nx"]=!0:p[o>0?"pz":"nz"]=!0:d>f?p[a>0?"py":"ny"]=!0:p[o>0?"pz":"nz"]=!0}for(r=0;r<lu.length;r++)p[lu[r]]&&l[lu[r]].push(e)}});for(var m=0;m<6;m++){var g=lu[m],v=this._getPointLightCamera(r,g);this._frameBuffer.attach(i,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m),this._frameBuffer.bind(e),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),e.renderPass(l[g],v,s)}this._frameBuffer.unbind(e)},_getDepthMaterial:function(e){var t=this._lightMaterials[e.__uid__],r="POINT_LIGHT"===e.type;if(!t){var n=r?"clay.sm.distance.":"clay.sm.depth.";t=new ni({precision:this.precision,shader:new Ri(Ri.source(n+"vertex"),Ri.source(n+"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===_u.VSM?t.define("fragment","USE_VSM"):t.undefine("fragment","USE_VSM"),r&&(t.set("lightPosition",e.getWorldPosition().array),t.set("range",e.range)),t},_gaussianFilter:function(e,t,r){var n={width:r,height:r,type:Ja.FLOAT},i=this._texturePool.get(n);this._frameBuffer.attach(i),this._frameBuffer.bind(e),this._gaussianPassH.setUniform("texture",t),this._gaussianPassH.setUniform("textureWidth",r),this._gaussianPassH.render(e),this._frameBuffer.attach(t),this._gaussianPassV.setUniform("texture",i),this._gaussianPassV.setUniform("textureHeight",r),this._gaussianPassV.render(e),this._frameBuffer.unbind(e),this._texturePool.put(i)},_getTexture:function(e,t){var r=e.__uid__,n=this._textures[r],i=e.shadowResolution||512;return t=t||1,n||((n="POINT_LIGHT"===e.type?new Zo:new no).width=i*t,n.height=i,this.softShadow===_u.VSM?(n.type=Ja.FLOAT,n.anisotropic=4):(n.minFilter=mn,n.magFilter=mn,n.useMipmap=!1),this._textures[r]=n),n},_getPointLightCamera:function(e,t){this._lightCameras.point||(this._lightCameras.point={px:new Ko,nx:new Ko,py:new Ko,ny:new Ko,pz:new Ko,nz:new Ko});var r=this._lightCameras.point[t];switch(r.far=e.range,r.fov=90,r.position.set(0,0,0),t){case"px":r.lookAt(Ji.POSITIVE_X,Ji.NEGATIVE_Y);break;case"nx":r.lookAt(Ji.NEGATIVE_X,Ji.NEGATIVE_Y);break;case"py":r.lookAt(Ji.POSITIVE_Y,Ji.POSITIVE_Z);break;case"ny":r.lookAt(Ji.NEGATIVE_Y,Ji.NEGATIVE_Z);break;case"pz":r.lookAt(Ji.POSITIVE_Z,Ji.NEGATIVE_Y);break;case"nz":r.lookAt(Ji.NEGATIVE_Z,Ji.NEGATIVE_Y)}return e.getWorldPosition(r.position),r.update(),r},_getDirectionalLightCamera:function(){var e=new Ta,t=new za,r=new za;return function(n,i,a){this._lightCameras.directional||(this._lightCameras.directional=new Ls);var o=this._lightCameras.directional;t.copy(i.viewBoundingBoxLastFrame),t.intersection(a.frustum.boundingBox),o.position.copy(t.min).add(t.max).scale(.5).transformMat4(a.worldTransform),o.rotation.copy(n.rotation),o.scale.copy(n.scale),o.updateWorldTransform(),Ta.invert(e,o.worldTransform),Ta.multiply(e,e,a.worldTransform),r.copy(t).applyTransform(e);var s=r.min.array,l=r.max.array;return o.position.set((s[0]+l[0])/2,(s[1]+l[1])/2,l[2]).transformMat4(o.worldTransform),o.near=0,o.far=-s[2]+l[2],isNaN(this.lightFrustumBias)?o.far*=4:o.far+=this.lightFrustumBias,o.left=s[0],o.right=l[0],o.top=l[1],o.bottom=s[1],o.update(!0),o}}(),_getSpotLightCamera:function(e){this._lightCameras.spot||(this._lightCameras.spot=new Ko);var t=this._lightCameras.spot;return t.fov=2*e.penumbraAngle,t.far=e.range,t.worldTransform.copy(e.worldTransform),t.updateProjectionMatrix(),Fi.invert(t.viewMatrix.array,t.worldTransform.array),t},dispose:function(e){var t=e.gl||e;for(var r in this._frameBuffer&&this._frameBuffer.dispose(t),this._textures)this._textures[r].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 n=0;n<this._receivers.length;n++){var i=this._receivers[n];if(i.material){var a=i.material;a.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),a.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),a.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),a.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});_u.VSM=1,_u.PCF=2;var yu=Nr.extend(function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},{updateParameter:function(e,t){var r,n,i=this.outputs[e],a=i.parameters,o=i._parametersCopy;if(o||(o=i._parametersCopy={}),a)for(var s in a)"width"!==s&&"height"!==s&&(o[s]=a[s]);return r=a.width instanceof Function?a.width.call(this,t):a.width,n=a.height instanceof Function?a.height.call(this,t):a.height,o.width===r&&o.height===n||this._outputTextures[e]&&this._outputTextures[e].dispose(t.gl),o.width=r,o.height=n,o},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 r=this.outputs[t];return r?this._rendered?r.outputLastFrame?this._prevOutputTextures[t]:this._outputTextures[t]:this._rendering?(this._prevOutputTextures[t]||(this._prevOutputTextures[t]=this._compositor.allocateTexture(r.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,r){this.inputLinks[e]={node:t,pin:r},t.outputLinks[r]||(t.outputLinks[r]=[]),t.outputLinks[r].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 r=this.inputLinks[t];r.node.updateReference(r.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])}}}),xu=Nr.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 r in t.inputs)if(t.inputs[r])if(!t.pass||t.pass.material.isUniformEnabled(r)){var n=t.inputs[r],i=this.findPin(n);i?t.link(r,i.node,i.pin):"string"==typeof n?console.warn("Node "+n+" not exist"):console.warn("Pin of "+n.node+"."+n.pin+" not exist")}else console.warn("Pin "+t.name+"."+r+" not used.")}},findPin:function(e){var t;if(("string"==typeof e||e instanceof yu)&&(e={node:e}),"string"==typeof e.node)for(var r=0;r<this.nodes.length;r++){var n=this.nodes[r];n.name===e.node&&(t=n)}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}}}}),bu=xu.extend(function(){return{_outputs:[],_texturePool:new iu,_frameBuffer:new ss({depthBuffer:!1})}},{addNode:function(e){xu.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 r=0;r<this.nodes.length;r++)this.nodes[r].outputs||this._outputs.push(this.nodes[r])}for(r=0;r<this.nodes.length;r++)this.nodes[r].beforeFrame();for(r=0;r<this._outputs.length;r++)this._outputs[r].updateReference();for(r=0;r<this._outputs.length;r++)this._outputs[r].render(e,t);for(r=0;r<this.nodes.length;r++)this.nodes[r].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)}}),wu=yu.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},function(){this.frameBuffer=new ss},{render:function(e){this._rendering=!0;var t,r=e.gl;if(this.trigger("beforerender"),this.outputs){var n=this.frameBuffer;for(var i in this.outputs){var a=this.updateParameter(i,e),o=this.outputs[i],s=this._compositor.allocateTexture(a);this._outputTextures[i]=s,"string"==typeof(h=o.attachment||r.COLOR_ATTACHMENT0)&&(h=r[h]),n.attach(s,h)}n.bind(e);var l=e.getGLExtension("EXT_draw_buffers");if(l){var u=[];for(var h in this.outputs)(h=parseInt(h))>=r.COLOR_ATTACHMENT0&&h<=r.COLOR_ATTACHMENT0+8&&u.push(h);l.drawBuffersEXT(u)}e.saveClear(),e.clearBit=zr|kr,t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),n.unbind(e)}else t=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",t),this._rendering=!1,this._rendered=!0}}),Tu=yu.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),Su=yu.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 Rs({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var r=e.gl;for(var n in this.inputLinks){var i=(c=this.inputLinks[n]).node.getOutput(e,c.pin);this.pass.setUniform(n,i)}if(this.outputs){this.pass.outputs={};var a={};for(var o in this.outputs){var s=this.updateParameter(o,e);isNaN(s.width)&&this.updateParameter(o,e);var l=this.outputs[o],u=this._compositor.allocateTexture(s);this._outputTextures[o]=u,"string"==typeof(h=l.attachment||r.COLOR_ATTACHMENT0)&&(h=r[h]),a[h]=u}for(var h in this._compositor.getFrameBuffer().bind(e),a)this._compositor.getFrameBuffer().attach(a[h],h);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 n in this.inputLinks){var c;(c=this.inputLinks[n]).node.removeReference(c.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var r,n,i=this.outputs[e],a=i.parameters,o=i._parametersCopy;if(o||(o=i._parametersCopy={}),a)for(var s in a)"width"!==s&&"height"!==s&&(o[s]=a[s]);return r="function"==typeof a.width?a.width.call(this,t):a.width,n="function"==typeof a.height?a.height.call(this,t):a.height,r=Math.ceil(r),n=Math.ceil(n),o.width===r&&o.height===n||this._outputTextures[e]&&this._outputTextures[e].dispose(t),o.width=r,o.height=n,o},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(){yu.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),Mu="@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",Au="\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",Eu="@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",Cu="@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",Du="@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",Lu="\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",Pu="@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",Ou="@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",Nu="@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(Mu),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(Au),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(Eu),e.import(Cu),e.import(Du),e.import(Lu),e.import(Pu),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(Ou),e.import(Nu)}(Ri);var Ru=/^#source\((.*?)\)/;function Iu(e,t){var r=new bu;t=t||{};var n={textures:{},parameters:{}};for(var i in e.parameters){var a=e.parameters[i];n.parameters[i]=ku(a)}return function(e,t,r,n){if(!e.textures)return void n({});var i={},a=0,o=!1,s=r.textureRootPath;Or.each(e.textures,function(e,t){var r,l=e.path,u=ku(e.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map(function(e){return Or.relative2absolute(e,s)})),r=new Zo(u);else{if("string"!=typeof l)return;s&&(l=Or.relative2absolute(l,s)),r=new no(u)}r.load(l),a++,r.once("success",function(){i[t]=r,0===--a&&(n(i),o=!0)})}),0!==a||o||n(i)}(e,0,t,function(i){n.textures=i,function(){for(var i=0;i<e.nodes.length;i++){var a=Bu(e.nodes[i],n,t);a&&r.addNode(a)}}()}),r}function Bu(e,t,r){var n,i,a,o,s=e.type||"filter";if("filter"===s){var l=e.shader.trim(),u=Ru.exec(l);if(u?n=Ri.source(u[1].trim()):"#"===l.charAt(0)&&(n=t.shaders[l.substr(1)]),n||(n=l),!n)return}if(e.inputs)for(var h in i={},e.inputs)"string"==typeof e.inputs[h]?i[h]=e.inputs[h]:i[h]={node:e.inputs[h].node,pin:e.inputs[h].pin};if(e.outputs)for(var h in a={},e.outputs){var c=e.outputs[h];a[h]={},null!=c.attachment&&(a[h].attachment=c.attachment),null!=c.keepLastFrame&&(a[h].keepLastFrame=c.keepLastFrame),null!=c.outputLastFrame&&(a[h].outputLastFrame=c.outputLastFrame),c.parameters&&(a[h].parameters=ku(c.parameters))}if(o="scene"===s?new wu({name:e.name,scene:r.scene,camera:r.camera,outputs:a}):"texture"===s?new Tu({name:e.name,outputs:a}):new Su({name:e.name,shader:n,inputs:i,outputs:a})){if(e.parameters)for(var h in e.parameters){"string"==typeof(d=e.parameters[h])?"#"===(d=d.trim()).charAt(0)?d=t.textures[d.substr(1)]:o.on("beforerender",Uu(h,Gu(d))):"function"==typeof d&&o.on("beforerender",d),o.setParameter(h,d)}if(e.defines&&o.pass)for(var h in e.defines){var d=e.defines[h];o.pass.material.define("fragment",h,d)}}return o}function zu(e,t){return e}function Fu(e,t){return t}function ku(e){var t={};if(!e)return t;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach(function(r){var n=e[r];null!=n&&("string"==typeof n&&(n=Ja[n]),t[r]=n)});var r=e.scale||1;return["width","height"].forEach(function(n){if(null!=e[n]){var i=e[n];"string"==typeof i?(i=i.trim(),t[n]=(a=Gu(i),o=(o=r)||1,function(e){var t=e.getDevicePixelRatio(),r=e.getWidth()*o,n=e.getHeight()*o;return a(r,n,t)})):t[n]=i}var a,o}),t.width||(t.width=zu),t.height||(t.height=Fu),null!=e.useMipmap&&(t.useMipmap=e.useMipmap),t}function Uu(e,t){return function(r){var n=r.getDevicePixelRatio(),i=r.getWidth(),a=r.getHeight(),o=t(i,a,n);this.setParameter(e,o)}}function Gu(e){var t=/^expr\((.*)\)$/.exec(e);if(t)try{var r=new Function("width","height","dpr","return "+t[1]);return r(1,1),r}catch(Sc){throw new Error("Invalid expression.")}}function Hu(e,t){for(var r=0,n=1/t,i=e;i>0;)r+=n*(i%t),i=Math.floor(i/t),n/=t;return r}function Vu(e){for(var t=new Uint8Array(e*e*4),r=0,n=new Ji,i=0;i<e;i++)for(var a=0;a<e;a++)n.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),t[r++]=255*(.5*n.x+.5),t[r++]=255*(.5*n.y+.5),t[r++]=0,t[r++]=255;return t}function Wu(e){return new no({pixels:Vu(e),wrapS:Ja.REPEAT,wrapT:Ja.REPEAT,width:e,height:e})}function ju(e,t,r){var n=new Float32Array(3*e);t=t||0;for(var i=0;i<e;i++){var a=Hu(i+t,2)*(r?1:2)*Math.PI,o=Hu(i+t,3)*Math.PI,s=Math.random(),l=Math.cos(a)*Math.sin(o)*s,u=Math.cos(o)*s,h=Math.sin(a)*Math.sin(o)*s;n[3*i]=l,n[3*i+1]=u,n[3*i+2]=h}return n}function Xu(e){e=e||{},this._ssaoPass=new Rs({fragment:Ri.source("ecgl.ssao.estimate")}),this._blurPass=new Rs({fragment:Ri.source("ecgl.ssao.blur")}),this._framebuffer=new ss({depthBuffer:!1}),this._ssaoTexture=new no,this._blurTexture=new no,this._blurTexture2=new no,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)}Ri.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"),Xu.prototype.setDepthTexture=function(e){this._depthTex=e},Xu.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},Xu.prototype.update=function(e,t,r){var n=e.getWidth(),i=e.getHeight(),a=this._ssaoPass,o=this._blurPass;a.setUniform("kernel",this._kernels[r%this._kernels.length]),a.setUniform("depthTex",this._depthTex),null!=this._normalTex&&a.setUniform("normalTex",this._normalTex),a.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new Ta;Ta.transpose(s,t.worldTransform),a.setUniform("projection",t.projectionMatrix.array),a.setUniform("projectionInv",t.invProjectionMatrix.array),a.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,u=this._blurTexture,h=this._blurTexture2;l.width=n/2,l.height=i/2,u.width=n,u.height=i,h.width=n,h.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),a.render(e),o.setUniform("textureSize",[n/2,i/2]),o.setUniform("projection",t.projectionMatrix.array),this._framebuffer.attach(u),o.setUniform("direction",0),o.setUniform("ssaoTexture",l),o.render(e),this._framebuffer.attach(h),o.setUniform("textureSize",[n,i]),o.setUniform("direction",1),o.setUniform("ssaoTexture",u),o.render(e),this._framebuffer.unbind(e);var c=e.clearColor;e.gl.clearColor(c[0],c[1],c[2],c[3])},Xu.prototype.getTargetTexture=function(){return this._blurTexture2},Xu.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)},Xu.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]=ju(e,t*e,!!this._normalTex)},Xu.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=Vu(e),t.width=t.height=e,t.dirty()):(t=Wu(e),this._ssaoPass.setUniform("noiseTex",Wu(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},Xu.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e),this._blurTexture2.dispose(e)};function qu(e){e=e||{},this._ssrPass=new Rs({fragment:Ri.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new Rs({fragment:Ri.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new Rs({fragment:Ri.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new Rs({fragment:Ri.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 no({type:Ja.HALF_FLOAT}),this._texture2=new no({type:Ja.HALF_FLOAT}),this._texture3=new no({type:Ja.HALF_FLOAT}),this._prevTexture=new no({type:Ja.HALF_FLOAT}),this._currentTexture=new no({type:Ja.HALF_FLOAT}),this._frameBuffer=new ss({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}Ri.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"),qu.prototype.setAmbientCubemap=function(e,t){this._ssrPass.material.set("specularCubemap",e),this._ssrPass.material.set("specularIntensity",t);var r=e&&t;this._ssrPass.material[r?"enableTexture":"disableTexture"]("specularCubemap")},qu.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),o=this._ssrTexture,s=this._texture2,l=this._texture3;o.width=this._prevTexture.width=this._currentTexture.width=i/this._downScale,o.height=this._prevTexture.height=this._currentTexture.height=a/this._downScale,s.width=l.width=i,s.height=l.height=a;var u=this._frameBuffer,h=this._ssrPass,c=this._blurPass1,d=this._blurPass2,f=this._blendPass,p=new Ta,m=new Ta;Ta.transpose(p,t.worldTransform),Ta.transpose(m,t.viewMatrix),h.setUniform("sourceTexture",r),h.setUniform("projection",t.projectionMatrix.array),h.setUniform("projectionInv",t.invProjectionMatrix.array),h.setUniform("toViewSpace",p.array),h.setUniform("toWorldSpace",m.array),h.setUniform("nearZ",t.near);var g=n/this._totalSamples*this._samplePerFrame;if(h.setUniform("jitterOffset",g),h.setUniform("sampleOffset",n*this._samplePerFrame),c.setUniform("textureSize",[o.width,o.height]),d.setUniform("textureSize",[i,a]),d.setUniform("sourceTexture",r),c.setUniform("projection",t.projectionMatrix.array),d.setUniform("projection",t.projectionMatrix.array),u.attach(o),u.bind(e),h.render(e),this._physicallyCorrect&&(u.attach(this._currentTexture),f.setUniform("texture1",this._prevTexture),f.setUniform("texture2",o),f.material.set({weight1:n>=1?.95:0,weight2:n>=1?.05:1}),f.render(e)),u.attach(s),c.setUniform("texture",this._physicallyCorrect?this._currentTexture:o),c.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}},qu.prototype.getTargetTexture=function(){return this._texture3},qu.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},qu.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=Is.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},qu.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},qu.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},qu.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 Zu=[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 Yu(e,t,r,n,i){var a=e.gl;t.setUniform(a,"1i",r,i),a.activeTexture(a.TEXTURE0+i),n.isRenderable()?n.bind(e):n.unbind(e)}function Ku(e,t,r,n,i){var a,o,s,l,u=e.gl;return function(i,h,c){if(!l||l.material!==i.material){var d=i.material,f=i.__program,p=d.get("roughness");null==p&&(p=1);var m=d.get("normalMap")||t,g=d.get("roughnessMap"),v=d.get("bumpMap"),_=d.get("uvRepeat"),y=d.get("uvOffset"),x=d.get("detailUvRepeat"),b=d.get("detailUvOffset"),w=!!v&&d.isTextureEnabled("bumpMap"),T=!!g&&d.isTextureEnabled("roughnessMap"),S=d.isDefined("fragment","DOUBLE_SIDED");v=v||r,g=g||n,c!==h?(h.set("normalMap",m),h.set("bumpMap",v),h.set("roughnessMap",g),h.set("useBumpMap",w),h.set("useRoughnessMap",T),h.set("doubleSide",S),null!=_&&h.set("uvRepeat",_),null!=y&&h.set("uvOffset",y),null!=x&&h.set("detailUvRepeat",x),null!=b&&h.set("detailUvOffset",b),h.set("roughness",p)):(f.setUniform(u,"1f","roughness",p),a!==m&&Yu(e,f,"normalMap",m,0),o!==v&&v&&Yu(e,f,"bumpMap",v,1),s!==g&&g&&Yu(e,f,"roughnessMap",g,2),null!=_&&f.setUniform(u,"2f","uvRepeat",_),null!=y&&f.setUniform(u,"2f","uvOffset",y),null!=x&&f.setUniform(u,"2f","detailUvRepeat",x),null!=b&&f.setUniform(u,"2f","detailUvOffset",b),f.setUniform(u,"1i","useBumpMap",+w),f.setUniform(u,"1i","useRoughnessMap",+T),f.setUniform(u,"1i","doubleSide",+S)),a=m,o=v,s=g,l=i}}}function Qu(e){this._depthTex=new no({format:Ja.DEPTH_COMPONENT,type:Ja.UNSIGNED_INT}),this._normalTex=new no({type:Ja.HALF_FLOAT}),this._framebuffer=new ss,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,ss.DEPTH_ATTACHMENT),this._normalMaterial=new ni({shader:new Ri(Ri.source("ecgl.normal.vertex"),Ri.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=As.createBlank("#000"),this._defaultBumpMap=As.createBlank("#000"),this._defaultRoughessMap=As.createBlank("#000"),this._debugPass=new Rs({fragment:Ri.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}function Ju(e){e=e||{},this._edgePass=new Rs({fragment:Ri.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new no({type:Ja.HALF_FLOAT}),this._frameBuffer=new ss,this._frameBuffer.attach(this._targetTexture)}Ri.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"),Qu.prototype.getDepthTexture=function(){return this._depthTex},Qu.prototype.getNormalTexture=function(){return this._normalTex},Qu.prototype.update=function(e,t,r){var n=e.getWidth(),i=e.getHeight(),a=this._depthTex,o=this._normalTex,s=this._normalMaterial;a.width=n,a.height=i,o.width=n,o.height=i;var l=t.getRenderList(r).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,r,{getMaterial:function(){return s},ifRender:function(e){return e.renderNormal},beforeRender:Ku(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},Qu.prototype.renderDebug=function(e){this._debugPass.render(e)},Qu.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},Ju.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),o=this._targetTexture;o.width=i,o.height=a;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(e),s.unbind(e)},Ju.prototype.getTargetTexture=function(){return this._targetTexture},Ju.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},Ju.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};var $u={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 eh(e,t){return{color:{parameters:{width:e,height:t}}}}Ri.import(Mu),Ri.import(Au),Ri.import(Eu),Ri.import(Cu),Ri.import(Du),Ri.import(Lu),Ri.import(Pu),Ri.import(Ou),Ri.import(Nu),Ri.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"),Ri.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 th=["composite","FXAA"];function rh(){this._width,this._height,this._dpr,this._sourceTexture=new no({type:Ja.HALF_FLOAT}),this._depthTexture=new no({format:Ja.DEPTH_COMPONENT,type:Ja.UNSIGNED_INT}),this._framebuffer=new ss,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,ss.DEPTH_ATTACHMENT),this._normalPass=new Qu,this._compositor=Iu($u);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=th.map(function(e){return this._compositor.getNodeByName(e)},this);var r={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new Xu(r),this._ssrPass=new qu(r),this._edgePass=new Ju(r)}function nh(e){for(var t=[],r=0;r<30;r++)t.push([Hu(r,2),Hu(r,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new no,this._sourceFb=new ss,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new no,this._outputTex=new no;var n=this._blendPass=new Rs({fragment:Ri.source("clay.compositor.blend")});n.material.disableTexturesAll(),n.material.enableTexture(["texture1","texture2"]),this._blendFb=new ss({depthBuffer:!1}),this._outputPass=new Rs({fragment:Ri.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 ih(e){e=e||"perspective",this.layer=null,this.scene=new Wo,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new rh,this._temporalSS=new nh,this._shadowMapPass=new _u;for(var t=[],r=0,n=0;n<30;n++){for(var i=[],a=0;a<6;a++)i.push(4*Hu(r,2)-2),i.push(4*Hu(r,3)-2),r++;t.push(i)}this._pcfKernels=t,this.scene.on("beforerender",function(e,t,r){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,r)},this)}rh.prototype.resize=function(e,t,r){e*=r=r||1,t*=r;var n=this._sourceTexture,i=this._depthTexture;n.width=e,n.height=t,i.width=e,i.height=t;var a={getWidth:function(){return e},getHeight:function(){return t},getDevicePixelRatio:function(){return r}};function o(e,t){if("function"==typeof e[t]){var r=e[t].__original||e[t];e[t]=function(e){return r.call(this,a)},e[t].__original=r}}this._compositor.nodes.forEach(function(e){for(var t in e.outputs){var r=e.outputs[t].parameters;r&&(o(r,"width"),o(r,"height"))}for(var n in e.parameters)o(e.parameters,n)}),this._width=e,this._height=t,this._dpr=r},rh.prototype.getWidth=function(){return this._width},rh.prototype.getHeight=function(){return this._height},rh.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},rh.prototype._getPrevNode=function(e){for(var t=th.indexOf(e.name)-1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t-=1,r=this._finalNodesChain[t];return r},rh.prototype._getNextNode=function(e){for(var t=th.indexOf(e.name)+1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t+=1,r=this._finalNodesChain[t];return r},rh.prototype._addChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(e.inputs.texture=t.name,r?(e.outputs=eh(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},rh.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(r?(t.outputs=eh(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},rh.prototype.updateNormal=function(e,t,r,n){this._ifRenderNormalPass()&&this._normalPass.update(e,t,r)},rh.prototype.updateSSAO=function(e,t,r,n){this._ssaoPass.update(e,r,n)},rh.prototype.enableSSAO=function(){this._enableSSAO=!0},rh.prototype.disableSSAO=function(){this._enableSSAO=!1},rh.prototype.enableSSR=function(){this._enableSSR=!0},rh.prototype.disableSSR=function(){this._enableSSR=!1},rh.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},rh.prototype.getSourceFrameBuffer=function(){return this._framebuffer},rh.prototype.getSourceTexture=function(){return this._sourceTexture},rh.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},rh.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},rh.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},rh.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},rh.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},rh.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},rh.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},rh.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},rh.prototype.enableEdge=function(){this._enableEdge=!0},rh.prototype.disableEdge=function(){this._enableEdge=!1},rh.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)},rh.prototype.setSSAOParameter=function(e,t){switch(e){case"quality":var r={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",r);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/200);break;case"intensity":this._ssaoPass.setParameter(e,t)}},rh.prototype.setDOFParameter=function(e,t){switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].setParameter("blurRadius",t);break;case"quality":var n={low:4,medium:8,high:16,ultra:32}[t]||8;this._dofBlurKernelSize=n;for(r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].pass.material.define("POISSON_KERNEL_SIZE",n);this._dofBlurKernel=new Float32Array(2*n)}},rh.prototype.setSSRParameter=function(e,t){if(null!=t)switch(e){case"quality":var r={low:10,medium:15,high:30,ultra:80}[t]||20,n={low:32,medium:16,high:8,ultra:4}[t]||16;this._ssrPass.setParameter("maxIteration",r),this._ssrPass.setParameter("pixelStride",n);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)}},rh.prototype.setPhysicallyCorrectSSR=function(e){this._ssrPass.setPhysicallyCorrect(e)},rh.prototype.setEdgeColor=function(e){var t=ul.parseColor(e);this._edgePass.setParameter("edgeColor",t)},rh.prototype.setExposure=function(e){this._compositeNode.setParameter("exposure",Math.pow(2,e))},rh.prototype.setColorLookupTexture=function(e,t){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?e:"none",t,{minFilter:ul.Texture.NEAREST,magFilter:ul.Texture.NEAREST,flipY:!1})},rh.prototype.setColorCorrection=function(e,t){this._compositeNode.setParameter(e,t)},rh.prototype.isSSREnabled=function(){return this._enableSSR},rh.prototype.composite=function(e,t,r,n,i){var a=this._sourceTexture,o=a;this._enableEdge&&(this._edgePass.update(e,r,a,i),a=o=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(e,r,a,i),o=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=o,this._cocNode.setParameter("depth",this._depthTexture);for(var s=this._dofBlurKernel,l=this._dofBlurKernelSize,u=i%Math.floor(Zu.length/2/l),h=0;h<2*l;h++)s[h]=Zu[h+u*l*2];for(h=0;h<this._dofBlurNodes.length;h++)this._dofBlurNodes[h].setParameter("percent",i/30),this._dofBlurNodes[h].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",r.near),this._cocNode.setParameter("zFar",r.far),this._compositor.render(e,n)},rh.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)},nh.prototype={constructor:nh,jitterProjection:function(e,t){var r=e.viewport,n=r.devicePixelRatio||e.getDevicePixelRatio(),i=r.width*n,a=r.height*n,o=this._haltonSequence[this._frame%this._haltonSequence.length],s=new Ta;s.array[12]=(2*o[0]-1)/i,s.array[13]=(2*o[1]-1)/a,Ta.mul(t.projectionMatrix,s,t.projectionMatrix),Ta.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,r){var n=this._blendPass;0===this._frame?(n.setUniform("weight1",0),n.setUniform("weight2",1)):(n.setUniform("weight1",.9),n.setUniform("weight2",.1)),n.setUniform("texture1",this._prevFrameTex),n.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),n.render(e),this._blendFb.unbind(e),r||(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)}},ih.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof Ko||(this.camera=new Ko,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof Ls||(this.camera=new Ls,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},ih.prototype.setViewport=function(e,t,r,n,i){this.camera instanceof Ko&&(this.camera.aspect=r/n),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=r,this.viewport.height=n,this.viewport.devicePixelRatio=i,this._compositor.resize(r*i,n*i),this._temporalSS.resize(r*i,n*i)},ih.prototype.containPoint=function(e,t){var r=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var ah=new li;function oh(e,t){var r=e.getBoxLayoutParams(),n=be(r,{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 i=e.get("boxWidth"),a=e.get("boxHeight"),o=e.get("boxDepth");this.getAxis("x").setExtent(-i/2,i/2),this.getAxis("y").setExtent(o/2,-o/2),this.getAxis("z").setExtent(-a/2,a/2),this.size=[i,a,o]}function sh(e,t){var r={};e.eachSeries(function(e){if(e.coordinateSystem===this){var t=e.getData();["x","y","z"].forEach(function(e){t.mapDimensionsAll(e,!0).forEach(function(n){var i,a;i=e,a=t.getDataExtent(n,!0),r[i]=r[i]||[1/0,-1/0],r[i][0]=Math.min(a[0],r[i][0]),r[i][1]=Math.max(a[1],r[i][1])})})}},this),["xAxis3D","yAxis3D","zAxis3D"].forEach(function(t){e.eachComponent(t,function(e){var n=t.charAt(0),i=e.getReferringComponents("grid3D").models[0],a=i.coordinateSystem;if(a===this){var o=a.getAxis(n);if(!o){(o=new nu(n,we(r[n]||[1/0,-1/0],e))).type=e.get("type");var s="category"===o.type;o.onBand=s&&e.get("boundaryGap"),o.inverse=e.get("inverse"),e.axis=o,o.model=e,o.getLabelModel=function(){return e.getModel("axisLabel",i.getModel("axisLabel"))},o.getTickModel=function(){return e.getModel("axisTick",i.getModel("axisTick"))},a.addAxis(o)}}},this)},this),this.resize(this.model,t)}ih.prototype.castRay=function(e,t,r){var n=this.layer.renderer,i=n.viewport;return n.viewport=this.viewport,n.screenToNDC(e,t,ah),this.camera.castRay(ah,r),n.viewport=i,r},ih.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 r=e.transparent[t].geometry;r.needsSortVerticesProgressively&&r.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),r.needsSortTrianglesProgressively&&r.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},ih.prototype.render=function(e,t){this._doRender(e,t,this._frame),this._frame++},ih.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},ih.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"===e&&(e=this._enablePostEffect),e},ih.prototype.hasDOF=function(){return this._enableDOF},ih.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},ih.prototype._doRender=function(e,t,r){var n=this.scene,i=this.camera;r=r||0,this._updateTransparent(e,n,i,r),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,n,i,!0)),this._updateShadowPCFKernel(r);var a,o=e.clearColor;(e.gl.clearColor(o[0],o[1],o[2],o[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,n,i,this._temporalSS.getFrame())),this._updateSSAO(e,n,i,this._temporalSS.getFrame()),this._enablePostEffect)?((a=this._compositor.getSourceFrameBuffer()).bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(n,i,!0,!0),a.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,n,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,n,i,null,0))):this.needsTemporalSS()&&t?((a=this._temporalSS.getSourceFrameBuffer()).bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(n,i,!0,!0),e.restoreClear(),a.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),e.render(n,i,!0,!0))},ih.prototype._updateTransparent=function(e,t,r,n){for(var i=new Ji,a=new Ta,o=r.getWorldPosition(),s=t.getRenderList(r).transparent,l=0;l<s.length;l++){var u=s[l],h=u.geometry;Ta.invert(a,u.worldTransform),Ji.transformMat4(i,o,a),h.needsSortTriangles&&h.needsSortTriangles()&&h.doSortTriangles(i,n),h.needsSortVertices&&h.needsSortVertices()&&h.doSortVertices(i,n)}},ih.prototype._updateSSAO=function(e,t,r){var n=this._enableSSAO&&this._enablePostEffect;n&&this._compositor.updateSSAO(e,t,r,this._temporalSS.getFrame());for(var i=t.getRenderList(r),a=0;a<i.opaque.length;a++){var o=i.opaque[a];o.renderNormal&&o.material[n?"enableTexture":"disableTexture"]("ssaoMap"),n&&o.material.set("ssaoMap",this._compositor.getSSAOTexture())}},ih.prototype._updateShadowPCFKernel=function(e){for(var t=this._pcfKernels[e%this._pcfKernels.length],r=this.scene.getRenderList(this.camera).opaque,n=0;n<r.length;n++)r[n].receiveShadow&&(r[n].material.set("pcfKernel",t),r[n].material.define("fragment","PCF_KERNEL_SIZE",t.length/2))},ih.prototype.dispose=function(e){this._compositor.dispose(e.gl),this._temporalSS.dispose(e.gl),this._shadowMapPass.dispose(e)},ih.prototype.setPostEffect=function(e,t){var r=this._compositor;this._enablePostEffect=e.get("enable");var n=e.getModel("bloom"),i=e.getModel("edge"),a=e.getModel("DOF",e.getModel("depthOfField")),o=e.getModel("SSAO",e.getModel("screenSpaceAmbientOcclusion")),s=e.getModel("SSR",e.getModel("screenSpaceReflection")),l=e.getModel("FXAA"),u=e.getModel("colorCorrection");n.get("enable")?r.enableBloom():r.disableBloom(),a.get("enable")?r.enableDOF():r.disableDOF(),s.get("enable")?r.enableSSR():r.disableSSR(),u.get("enable")?r.enableColorCorrection():r.disableColorCorrection(),i.get("enable")?r.enableEdge():r.disableEdge(),l.get("enable")?r.enableFXAA():r.disableFXAA(),this._enableDOF=a.get("enable"),this._enableSSAO=o.get("enable"),this._enableSSAO?r.enableSSAO():r.disableSSAO(),r.setBloomIntensity(n.get("intensity")),r.setEdgeColor(i.get("color")),r.setColorLookupTexture(u.get("lookupTexture"),t),r.setExposure(u.get("exposure")),["radius","quality","intensity"].forEach(function(e){r.setSSAOParameter(e,o.get(e))}),["quality","maxRoughness","physical"].forEach(function(e){r.setSSRParameter(e,s.get(e))}),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach(function(e){r.setDOFParameter(e,a.get(e))}),["brightness","contrast","saturation"].forEach(function(e){r.setColorCorrection(e,u.get(e))})},ih.prototype.setDOFFocusOnPoint=function(e){if(this._enablePostEffect){if(e>this.camera.far||e<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",e),!0}},ih.prototype.setTemporalSuperSampling=function(e){this._enableTemporalSS=e.get("enable")},ih.prototype.isLinearSpace=function(){return this._enablePostEffect},ih.prototype.setRootNode=function(e){if(this.rootNode!==e){for(var t=this.rootNode.children(),r=0;r<t.length;r++)e.add(t[r]);e!==this.scene&&this.scene.add(e),this.rootNode=e}},ih.prototype.add=function(e){this.rootNode.add(e)},ih.prototype.remove=function(e){this.rootNode.remove(e)},ih.prototype.removeAll=function(e){this.rootNode.removeAll(e)},Object.assign(ih.prototype,Dr);var lh={dimensions:ru.prototype.dimensions,create:function(e,t){var r=[];e.eachComponent("grid3D",function(e){e.__viewGL=e.__viewGL||new ih;var t=new ru;t.model=e,t.viewGL=e.__viewGL,e.coordinateSystem=t,r.push(t),t.resize=oh,t.update=sh});var n=["xAxis3D","yAxis3D","zAxis3D"];return e.eachSeries(function(t){if("cartesian3D"===t.get("coordinateSystem")){if(null==(i=t.getReferringComponents("grid3D").models[0])){var r=function(e,t){return n.map(function(r){var n=e.getReferringComponents(r).models[0];return null==n&&(n=t.getComponent(r)),n})}(t,e),i=r[0].getCoordSysModel();r.forEach(function(e){e.getCoordSysModel()})}var a=i.coordinateSystem;t.coordinateSystem=a}}),r}},uh=le.extend({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});Te(uh);var hh={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},ch=ue({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},hh),dh=ue({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},hh),fh=he({scale:!0,min:"dataMin",max:"dataMax"},dh),ph=he({logBase:10},dh);ph.scale=!0;var mh={categoryAxis3D:ch,valueAxis3D:dh,timeAxis3D:fh,logAxis3D:ph},gh=["value","category","time","log"];function vh(e,t){return t.type||(t.data?"category":"value")}W(function(e){e.registerComponentModel(El),e.registerComponentView(tu),e.registerCoordinateSystem("grid3D",lh),["x","y","z"].forEach(function(t){!function(e,t,r,n,i){gh.forEach(function(a){var o=r.extend({type:t+"Axis3D."+a,__ordinalMeta:null,mergeDefaultAndTheme:function(e,r){var i=r.getTheme();ue(e,i.get(a+"Axis3D")),ue(e,this.getDefaultOption()),e.type=n(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=Se.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:ue(Me(mh[a+"Axis3D"]),i||{},!0)});e.registerComponentModel(o)}),e.registerSubTypeDefaulter(t+"Axis3D",Ae(n,t))}(e,t,uh,vh,{name:t.toUpperCase()});var r=e.ComponentView.extend({type:t+"Axis3D"});e.registerComponentView(r)}),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 _h={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"}}},yh={getFilledRegions:function(e,t){var r,n=(e||[]).slice();if("string"==typeof t?r=(t=Ee(t))&&t.geoJson:t&&t.features&&(r=t),!r)return[];for(var i={},a=r.features,o=0;o<n.length;o++)i[n[o].name]=n[o];for(o=0;o<a.length;o++){var s=a[o].properties.name;i[s]||n.push({name:s})}return n},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}}}},xh=le.extend({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=Ce(e.data||[],{coordDimensions:["value"],encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),r=new De(t,this);r.initData(e.regions);var n={};r.each(function(e){var t=r.getName(e),i=r.getItemModel(e);n[t]=i}),this._regionModelMap=n,this._data=r},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new fe(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),r=this.coordinateSystem.getRegion(t);return r?r.geometries:[]},getFormattedLabel:function(e,t){var r=this._data.getName(e),n=this.getRegionModel(e),i=n.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=n.get(["label","formatter"]));var a={name:r};if("function"==typeof i)return a.status=t,i(a);if("string"==typeof i){var o=a.seriesName;return i.replace("{a}",null!=o?o:"")}return r},defaultOption:{regions:[]}});function bh(e,t,r){r=r||2;var n,i,a,o,s,l,u,h=t&&t.length,c=h?t[0]*r:e.length,d=wh(e,0,c,r,!0),f=[];if(!d)return f;if(h&&(d=function(e,t,r,n){var i,a,o,s=[];for(i=0,a=t.length;i<a;i++)(o=wh(e,t[i]*n,i<a-1?t[i+1]*n:e.length,n,!1))===o.next&&(o.steiner=!0),s.push(Oh(o));for(s.sort(Dh),i=0;i<s.length;i++)Lh(s[i],r),r=Th(r,r.next);return r}(e,t,d,r)),e.length>80*r){n=a=e[0],i=o=e[1];for(var p=r;p<c;p+=r)(s=e[p])<n&&(n=s),(l=e[p+1])<i&&(i=l),s>a&&(a=s),l>o&&(o=l);u=Math.max(a-n,o-i)}return Sh(d,f,r,n,i,u),f}function wh(e,t,r,n,i){var a,o;if(i===Vh(e,t,r,n)>0)for(a=t;a<r;a+=n)o=Uh(a,e[a],e[a+1],o);else for(a=r-n;a>=t;a-=n)o=Uh(a,e[a],e[a+1],o);return o&&Bh(o,o.next)&&(Gh(o),o=o.next),o}function Th(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!Bh(n,n.next)&&0!==Ih(n.prev,n,n.next))n=n.next;else{if(Gh(n),(n=t=n.prev)===n.next)return null;r=!0}}while(r||n!==t);return t}function Sh(e,t,r,n,i,a,o){if(e){!o&&a&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=Ph(i.x,i.y,t,r,n)),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,r,n,i,a,o,s,l,u=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,n=r,s=0,t=0;t<u&&(s++,n=n.nextZ);t++);for(l=u;s>0||l>0&&n;)0!==s&&(0===l||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=n}a.nextZ=null,u*=2}while(o>1)}(i)}(e,n,i,a);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,a?Ah(e,n,i,a):Mh(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),Gh(e),e=l.next,u=l.next;else if((e=l)===u){o?1===o?Sh(e=Eh(e,t,r),t,r,n,i,a,2):2===o&&Ch(e,t,r,n,i,a):Sh(Th(e),t,r,n,i,a,1);break}}}function Mh(e){var t=e.prev,r=e,n=e.next;if(Ih(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(Nh(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&Ih(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Ah(e,t,r,n){var i=e.prev,a=e,o=e.next;if(Ih(i,a,o)>=0)return!1;for(var s=i.x<a.x?i.x<o.x?i.x:o.x:a.x<o.x?a.x:o.x,l=i.y<a.y?i.y<o.y?i.y:o.y:a.y<o.y?a.y:o.y,u=i.x>a.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,h=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,c=Ph(s,l,t,r,n),d=Ph(u,h,t,r,n),f=e.nextZ;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&Nh(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Ih(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=c;){if(f!==e.prev&&f!==e.next&&Nh(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Ih(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function Eh(e,t,r){var n=e;do{var i=n.prev,a=n.next.next;!Bh(i,a)&&zh(i,n,n.next,a)&&Fh(i,a)&&Fh(a,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(a.i/r),Gh(n),Gh(n.next),n=e=a),n=n.next}while(n!==e);return n}function Ch(e,t,r,n,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Rh(o,s)){var l=kh(o,s);return o=Th(o,o.next),l=Th(l,l.next),Sh(o,t,r,n,i,a),void Sh(l,t,r,n,i,a)}s=s.next}o=o.next}while(o!==e)}function Dh(e,t){return e.x-t.x}function Lh(e,t){if(t=function(e,t){var r,n=t,i=e.x,a=e.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===o)return r.prev;var l,u=r,h=r.x,c=r.y,d=1/0;n=r.next;for(;n!==u;)i>=n.x&&n.x>=h&&i!==n.x&&Nh(a<c?i:o,a,h,c,a<c?o:i,a,n.x,n.y)&&((l=Math.abs(a-n.y)/(i-n.x))<d||l===d&&n.x>r.x)&&Fh(n,e)&&(r=n,d=l),n=n.next;return r}(e,t),t){var r=kh(t,e);Th(r,r.next)}}function Ph(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)/i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)/i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Oh(e){var t=e,r=e;do{t.x<r.x&&(r=t),t=t.next}while(t!==e);return r}function Nh(e,t,r,n,i,a,o,s){return(i-o)*(t-s)-(e-o)*(a-s)>=0&&(e-o)*(n-s)-(r-o)*(t-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function Rh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&zh(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&Fh(e,t)&&Fh(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)}function Ih(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Bh(e,t){return e.x===t.x&&e.y===t.y}function zh(e,t,r,n){return!!(Bh(e,t)&&Bh(r,n)||Bh(e,n)&&Bh(r,t))||Ih(e,t,r)>0!=Ih(e,t,n)>0&&Ih(r,n,e)>0!=Ih(r,n,t)>0}function Fh(e,t){return Ih(e.prev,e,e.next)<0?Ih(e,t,e.next)>=0&&Ih(e,e.prev,t)>=0:Ih(e,t,e.prev)<0||Ih(e,e.next,t)<0}function kh(e,t){var r=new Hh(e.i,e.x,e.y),n=new Hh(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function Uh(e,t,r,n){var i=new Hh(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Gh(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 Hh(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vh(e,t,r,n){for(var i=0,a=t,o=r-n;a<r;a+=n)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function Wh(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function jh(e,t,r,n,i){var a=r,o=e[t];Wh(e,t,n);for(var s=r;s<n;s++)i(e[s],o)<0&&(Wh(e,s,a),a++);return Wh(e,n,a),a}function Xh(e,t,r,n){if(r<n){var i=jh(e,Math.floor((r+n)/2),r,n,t);Xh(e,t,r,i-1),Xh(e,t,i+1,n)}}function qh(){this._parts=[]}ue(xh.prototype,yh),ue(xh.prototype,Sl),ue(xh.prototype,Ml),ue(xh.prototype,Al),ue(xh.prototype,_h),bh.deviation=function(e,t,r,n){var i=t&&t.length,a=i?t[0]*r:e.length,o=Math.abs(Vh(e,0,a,r));if(i)for(var s=0,l=t.length;s<l;s++){var u=t[s]*r,h=s<l-1?t[s+1]*r:e.length;o-=Math.abs(Vh(e,u,h,r))}var c=0;for(s=0;s<n.length;s+=3){var d=n[s]*r,f=n[s+1]*r,p=n[s+2]*r;c+=Math.abs((e[d]-e[p])*(e[f+1]-e[d+1])-(e[d]-e[f])*(e[p+1]-e[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},qh.prototype.step=function(e,t,r){var n=e.length;if(0===r){this._parts=[],this._sorted=!1;var i=Math.floor(n/2);this._parts.push({pivot:i,left:0,right:n-1}),this._currentSortPartIdx=0}if(!this._sorted){var a=this._parts;if(0===a.length)return this._sorted=!0,!0;if(a.length<512){for(var o=0;o<a.length;o++)a[o].pivot=jh(e,a[o].pivot,a[o].left,a[o].right,t);var s=[];for(o=0;o<a.length;o++){var l=a[o].left;(u=a[o].pivot-1)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u});var u;l=a[o].pivot+1;(u=a[o].right)>l&&s.push({pivot:Math.floor((u+l)/2),left:l,right:u})}a=this._parts=s}else for(o=0;o<Math.floor(a.length/10);o++){var h=a.length-1-this._currentSortPartIdx;if(Xh(e,t,a[h].left,a[h].right),this._currentSortPartIdx++,this._currentSortPartIdx===a.length)return this._sorted=!0,!0}return!1}},qh.sort=Xh;var Zh=Nl.vec3,Yh=Zh.create(),Kh=Zh.create(),Qh=Zh.create(),Jh={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(e,t){var r=this.indices;if(0===t){var n=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 r.constructor(r.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,a=0,o=0;o<r.length;){n.get(r[o++],Yh),n.get(r[o++],Kh),n.get(r[o++],Qh);var s=Zh.sqrDist(Yh,e),l=Zh.sqrDist(Kh,e),u=Zh.sqrDist(Qh,e),h=Math.min(s,l);h=Math.min(h,u),3===o?(i=h,h=0):h-=i,this._triangleZList[a++]=h}}var c=this._sortedTriangleIndices;for(o=0;o<c.length;o++)c[o]=o;if(this.triangleCount<2e4)0===t&&this._simpleSort(!0);else for(o=0;o<3;o++)this._progressiveQuickSort(3*t+o);var d=this._indicesTmp,f=this._triangleZListTmp,p=this._triangleZList;for(o=0;o<this.triangleCount;o++){var m=3*c[o],g=3*o;d[g++]=r[m++],d[g++]=r[m++],d[g]=r[m],f[o]=p[c[o]]}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,r=this._sortedTriangleIndices;function n(e,r){return t[r]-t[e]}e?Array.prototype.sort.call(r,n):qh.sort(r,n,0,r.length-1)},_progressiveQuickSort:function(e){var t=this._triangleZList,r=this._sortedTriangleIndices;this._quickSort=this._quickSort||new qh,this._quickSort.step(r,function(e,r){return t[r]-t[e]},e)}};function $h(e,t){var r=e.getItemVisual(t,"style");if(r)return r[e.getVisual("drawType")]}function ec(e,t){var r=e.getItemVisual(t,"style");return r&&r.opacity}function tc(e,t,r){this._labelsMesh=new ql,this._labelTextureSurface=new Fl({width:512,height:512,devicePixelRatio:r.getDevicePixelRatio(),onupdate:function(){r.getZr().refresh()}}),this._api=r,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}tc.prototype.getLabelPosition=function(e,t,r){return[0,0,0]},tc.prototype.getLabelDistance=function(e,t,r){return 0},tc.prototype.getMesh=function(){return this._labelsMesh},tc.prototype.updateData=function(e,t,r){null==t&&(t=0),null==r&&(r=e.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===r-t||(this._labelsVisibilitiesBits=new Uint8Array(r-t));for(var n=["label","show"],i=["emphasis","label","show"],a=t;a<r;a++){var o=e.getItemModel(a),s=o.get(n),l=o.get(i);null==l&&(l=s);var u=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[a-t]=u}this._start=t,this._end=r,this._data=e},tc.prototype.updateLabels=function(e){if(this._data){for(var t=(e=e||[]).length>0,r={},n=0;n<e.length;n++)r[e[n]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var i=["label"],a=["emphasis","label"],o=this._data.hostModel,s=this._data,l=o.getModel(i),u=o.getModel(a,l),h={left:"right",right:"left",top:"center",bottom:"center"},c={left:"middle",right:"middle",top:"bottom",bottom:"top"},d=this._start;d<this._end;d++){var f=!1;if(t&&r[d]&&(f=!0),this._labelsVisibilitiesBits[d-this._start]&(f?2:1)){var p=s.getItemModel(d).getModel(f?a:i,f?u:l),m=p.get("distance")||0,g=p.get("position"),v=this._api.getDevicePixelRatio(),_=o.getFormattedLabel(d,f?"emphasis":"normal");if(null==_||""===_)return;var y=new pe({style:me(p,{text:_,fill:p.get("color")||$h(s,d)||"#000",align:"left",verticalAlign:"top",opacity:Vs(p.get("opacity"),ec(s,d),1)})}),x=y.getBoundingRect();x.height*=1.2;var b=this._labelTextureSurface.add(y),w=h[g]||"center",T=c[g]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(d,g,m),[x.width*v,x.height*v],b,w,T,this.getLabelDistance(d,g,m)*v)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}},tc.prototype.dispose=function(){this._labelTextureSurface.dispose()};var rc=Nl.vec3;function nc(e){this.rootNode=new ul.Node,this._triangulationResults={},this._shadersMap=ul.COMMON_SHADERS.filter(function(e){return"shadow"!==e}).reduce(function(e,t){return e[t]=ul.createShader("ecgl."+t),e},{}),this._linesShader=ul.createShader("ecgl.meshLines3D");var t={};ul.COMMON_SHADERS.forEach(function(e){t[e]=new ul.Material({shader:ul.createShader("ecgl."+e)})}),this._groundMaterials=t,this._groundMesh=new ul.Mesh({geometry:new ul.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new tc(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}ul.Shader.import(Jl),nc.prototype={constructor:nc,extrudeY:!0,update:function(e,t,r,n,i){var a=e.getData();null==n&&(n=0),null==i&&(i=a.count()),this._startIndex=n,this._endIndex=i-1,this._triangulation(e,n,i);var o=this._getShader(e.get("shading"));this._prepareMesh(e,o,r,n,i),this.rootNode.updateWorldTransform(),this._updateRegionMesh(e,r,n,i);var s=e.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(e,s,r);var l=this;this._labelsBuilder.updateData(a,n,i),this._labelsBuilder.getLabelPosition=function(e,t,r){var n=a.getName(e),i=r;if("geo3D"===s.type){var o=s.getRegion(n);return o?(h=o.getCenter(),s.dataToPoint([h[0],h[1],i])):[NaN,NaN,NaN]}var u=l._triangulationResults[e-l._startIndex],h=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=a,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(e),this._lastHoverDataIndex=0},_initMeshes:function(){var e=this;var t=function(){var t=new ul.Mesh({name:"Polygon",material:new ul.Material({shader:e._shadersMap.lambert}),geometry:new ul.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return Object.assign(t.geometry,Jh),t}(),r=new ul.Mesh({material:new ul.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new Bl({useNativeLine:!1})});this.rootNode.add(t),this.rootNode.add(r),t.material.define("both","VERTEX_COLOR"),t.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=t,this._linesMesh=r,this.rootNode.add(this._groundMesh)},_getShader:function(e){var t=this._shadersMap[e];return t||(t=this._shadersMap.lambert),t.__shading=e,t},_prepareMesh:function(e,t,r,n,i){for(var a=0,o=0,s=0,l=0,u=n;u<i;u++){var h=this._getRegionPolygonInfo(u),c=this._getRegionLinesInfo(u,e,this._linesMesh.geometry);a+=h.vertexCount,o+=h.triangleCount,s+=c.vertexCount,l+=c.triangleCount}var d=this._polygonMesh,f=d.geometry;["position","normal","texcoord0","color"].forEach(function(e){f.attributes[e].init(a)}),f.indices=a>65535?new Uint32Array(3*o):new Uint16Array(3*o),d.material.shader!==t&&d.material.attachShader(t,!0),ul.setMaterialFromModel(t.__shading,d.material,e,r),s>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(s),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(a),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-n))},_updateRegionMesh:function(e,t,r,n){for(var i=e.getData(),a=0,o=0,s=!1,l=this._polygonMesh,u=this._linesMesh,h=r;h<n;h++){var c=e.getRegionModel(h),d=c.getModel("itemStyle"),f=Vs($h(i,h),d.get("color"),"#fff"),p=Vs(ec(i,h),d.get("opacity"),1),m=ul.parseColor(f),g=ul.parseColor(d.get("borderColor"));m[3]*=p,g[3]*=p;var v=m[3]<.99;l.material.set("color",[1,1,1,1]),s=s||v;for(var _=Vs(c.get("height",!0),e.get("regionHeight")),y=this._updatePolygonGeometry(e,l.geometry,h,_,a,o,m),x=a;x<y.vertexOffset;x++)this._dataIndexOfVertex[x]=h;this._vertexRangeOfDataIndex[2*(h-r)]=a,this._vertexRangeOfDataIndex[2*(h-r)+1]=y.vertexOffset,a=y.vertexOffset,o=y.triangleOffset;var b=d.get("borderWidth"),w=b>0;w&&(b*=t.getDevicePixelRatio(),this._updateLinesGeometry(u.geometry,e,h,_,b,e.coordinateSystem.transform)),u.invisible=!w,u.material.set({color:g})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?ul.Mesh.CCW:ul.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 r=ul.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),n=Vs(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",r),i.material.set("wireframeLineWidth",n)}},_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,r){var n=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!n.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),a=this._groundMaterials[i];a||(a=this._groundMaterials.lambert),ul.setMaterialFromModel(i,a,n,r),a.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=a,this._groundMesh.material.set("color",ul.parseColor(n.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,r){this._triangulationResults=[];for(var n=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],a=e.coordinateSystem,o=t;o<r;o++){for(var s=[],l=e.getRegionPolygonCoords(o),u=0;u<l.length;u++){var h=l[u].exterior,c=l[u].interiors,d=[],f=[];if(!(h.length<3)){for(var p=0,m=0;m<h.length;m++){var g=h[m];d[p++]=g[0],d[p++]=g[1]}for(m=0;m<c.length;m++)if(!(c[m].length<3)){for(var v=d.length/2,_=0;_<c[m].length;_++){g=c[m][_];d.push(g[0]),d.push(g[1])}f.push(v)}var y=bh(d,f),x=new Float64Array(d.length/2*3),b=[],w=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0],S=0;for(m=0;m<d.length;)rc.set(b,d[m++],0,d[m++]),a&&a.transform&&rc.transformMat4(b,b,a.transform),rc.min(w,w,b),rc.max(T,T,b),x[S++]=b[0],x[S++]=b[1],x[S++]=b[2];rc.min(n,n,w),rc.max(i,i,T),s.push({points:x,indices:y,min:w,max:T})}}this._triangulationResults.push(s)}this._geoBoundingBox=[n,i]},_getRegionPolygonInfo:function(e){for(var t=this._triangulationResults[e-this._startIndex],r=0,n=0,i=0;i<t.length;i++)r+=t[i].points.length/3,n+=t[i].indices.length/3;return{vertexCount:2*r+4*r,triangleCount:2*n+2*r}},_updatePolygonGeometry:function(e,t,r,n,i,a,o){var s=e.get("projectUVOnGround"),l=t.attributes.position,u=t.attributes.normal,h=t.attributes.texcoord0,c=t.attributes.color,d=this._triangulationResults[r-this._startIndex],f=c.value&&o,p=t.indices,m=this.extrudeY?1:2,g=this.extrudeY?2:1,v=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],_=rc.mul([],this._geoBoundingBox[0],v),y=rc.mul([],this._geoBoundingBox[1],v),x=Math.max(y[0]-_[0],y[2]-_[2]);function b(e,t,r){var n=i;!function(e,t){for(var r=e.points,n=r.length,a=[],s=[],u=0;u<n;u+=3)a[0]=r[u],a[m]=t,a[g]=r[u+2],s[0]=(r[u]*v[0]-_[0])/x,s[1]=(r[u+2]*v[g]-_[2])/x,l.set(i,a),f&&c.set(i,o),h.set(i++,s)}(e,t);for(var s=e.indices.length,u=0;u<s;u++)p[3*a+u]=e.indices[u]+n;a+=e.indices.length/3}for(var w=this.extrudeY?[0,1,0]:[0,0,1],T=rc.negate([],w),S=0;S<d.length;S++){var M=i,A=d[S];b(A,0),b(A,n);for(var E=A.points.length/3,C=0;C<E;C++)u.set(M+C,T),u.set(M+C+E,w);var D=[0,3,1,1,3,2],L=[[],[],[],[]],P=[],O=[],N=[],R=[],I=0;for(C=0;C<E;C++){for(var B=(C+1)%E,z=(A.points[3*B]-A.points[3*C])*v[0],F=(A.points[3*B+2]-A.points[3*C+2])*v[g],k=Math.sqrt(z*z+F*F),U=0;U<4;U++){var G=0===U||3===U,H=3*(G?C:B);L[U][0]=A.points[H],L[U][m]=U>1?n:0,L[U][g]=A.points[H+2],l.set(i+U,L[U]),s?(R[0]=(A.points[H]*v[0]-_[0])/x,R[1]=(A.points[H+2]*v[g]-_[g])/x):(R[0]=(G?I:I+k)/x,R[1]=(L[U][m]*v[m]-_[m])/x),h.set(i+U,R)}rc.sub(P,L[1],L[0]),rc.sub(O,L[3],L[0]),rc.cross(N,P,O),rc.normalize(N,N);for(U=0;U<4;U++)u.set(i+U,N),f&&c.set(i+U,o);for(U=0;U<6;U++)p[3*a+U]=D[U]+i;i+=4,a+=2,I+=k}}return t.dirty(),{vertexOffset:i,triangleOffset:a}},_getRegionLinesInfo:function(e,t,r){var n=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach(function(e){var t=e.exterior,a=e.interiors;n+=r.getPolylineVertexCount(t),i+=r.getPolylineTriangleCount(t);for(var o=0;o<a.length;o++)n+=r.getPolylineVertexCount(a[o]),i+=r.getPolylineTriangleCount(a[o])},this);return{vertexCount:n,triangleCount:i}},_updateLinesGeometry:function(e,t,r,n,i,a){function o(e){for(var t=new Float64Array(3*e.length),r=0,i=[],o=0;o<e.length;o++)i[0]=e[o][0],i[1]=n+.1,i[2]=e[o][1],a&&rc.transformMat4(i,i,a),t[r++]=i[0],t[r++]=i[1],t[r++]=i[2];return t}var s=[1,1,1,1];t.getRegionPolygonCoords(r).forEach(function(t){var r=t.exterior,n=t.interiors;e.addPolyline(o(r),s,i);for(var a=0;a<n.length;a++)e.addPolyline(o(n[a]),s,i)})},highlight:function(e){var t=this._data;if(t){var r=t.getItemModel(e).getModel(["emphasis","itemStyle"]),n=r.get("color"),i=Vs(r.get("opacity"),ec(t,e),1);if(null==n){var a=$h(t,e);n=Le(a,-.4)}null==i&&(i=ec(t,e));var o=ul.parseColor(n);o[3]*=i,this._setColorOfDataIndex(t,e,o)}},downplay:function(e){var t=this._data;if(t){var r=t.getItemModel(e),n=Vs($h(t,e),r.get(["itemStyle","color"]),"#fff"),i=Vs(ec(t,e),r.get(["itemStyle","opacity"]),1),a=ul.parseColor(n);a[3]*=i,this._setColorOfDataIndex(t,e,a)}},dispose:function(){this._labelsBuilder.dispose()},_setColorOfDataIndex:function(e,t,r){if(!(t<this._startIndex&&t>this._endIndex)){t-=this._startIndex;for(var n=this._vertexRangeOfDataIndex[2*t];n<this._vertexRangeOfDataIndex[2*t+1];n++)this._polygonMesh.geometry.attributes.color.set(n,r);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};var ic=ge.extend({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new nc(t),this.groupGL=new ul.Node,this._lightRoot=new ul.Node,this._sceneHelper=new kl(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new Pl({zr:t.getZr()}),this._control.init()},render:function(e,t,r){this.groupGL.add(this._geo3DBuilder.rootNode);var n=e.coordinateSystem;if(n&&n.viewGL){n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(n.viewGL);var a=e.getModel("viewControl");i.setFromViewControlModel(a,0),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,r,0,e.getData().count());var o=n.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse(function(e){e.material&&e.material[o]("fragment","SRGB_DECODE")}),i.off("update"),i.on("update",function(){r.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,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},dispose:function(){this._control.dispose(),this._geo3DBuilder.dispose()}}),ac={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]};var oc=Nl.vec3,sc=Nl.mat4,lc=[Oe,function(e,t){if("world"===e){var r=ac[t.name];if(r){var n=[r[0],r[1]];t.setCenter(n)}}}];function uc(e,t,r,n,i){this.name=e,this.map=t,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(r,n,i),this.transform=sc.identity(new Float64Array(16)),this.invTransform=sc.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}function hc(e,t){var r=e.getBoxLayoutParams(),n=be(r,{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 i=this.getGeoBoundingRect(),a=i.width/i.height*(e.get("aspectScale")||.75),o=e.get("boxWidth"),s=e.get("boxDepth"),l=e.get("boxHeight");null==l&&(l=5),isNaN(o)&&isNaN(s)&&(o=100),isNaN(s)?s=o/a:isNaN(o)&&(o=s/a),this.setSize(o,l,s),this.regionHeight=e.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(l-this.regionHeight,0))}function cc(e,t){var r=[1/0,-1/0];if(e.eachSeries(function(e){if(e.coordinateSystem===this&&"series.map3D"!==e.type){var t=e.getData(),n=e.coordDimToDataDim("alt"),i=n&&n[0];if(i){var a=t.getDataExtent(i,!0);r[0]=Math.min(r[0],a[0]),r[1]=Math.max(r[1],a[1])}}},this),r&&isFinite(r[1]-r[0])){var n=we(r,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new xe("altitude",n),this.resize(this.model,t)}}uc.prototype={constructor:uc,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(e,t,r){var n=Ne||Ne;try{this.regions=e?n(e):[]}catch(Sc){throw"Invalid geoJson format\n"+Sc}t=t||{},r=r||{};for(var i=this.regions,a={},o=0;o<i.length;o++){var s=i[o].name;s=r[s]||s,i[o].name=s,a[s]=i[o],this.addGeoCoord(s,i[o].getCenter());var l=t[s];l&&i[o].transformTo(l.left,l.top,l.width,l.height)}this._regionsMap=a,this._geoRect=null,lc.forEach(function(e){e(this)},this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var e,t=this.regions,r=0;r<t.length;r++){var n=t[r].getBoundingRect();(e=e||n.clone()).union(n)}return this._geoRect=e||new Pe(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,r=0;r<t.length;r++)if(t[r].contain(e))return t[r]},setSize:function(e,t,r){this.size=[e,t,r];var n=this.getGeoBoundingRect(),i=e/n.width,a=-r/n.height,o=-e/2-n.x*i,s=r/2-n.y*a,l=this.extrudeY?[o,0,s]:[o,s,0],u=this.extrudeY?[i,1,a]:[i,a,1],h=this.transform;sc.identity(h),sc.translate(h,h,l),sc.scale(h,h,u),sc.invert(this.invTransform,h)},dataToPoint:function(e,t){t=t||[];var r=this.extrudeY?1:2,n=this.extrudeY?2:1,i=e[2];return isNaN(i)&&(i=0),t[0]=e[0],t[n]=e[1],this.altitudeAxis?t[r]=this.altitudeAxis.dataToCoord(i):t[r]=0,t[r]+=this.regionHeight,oc.transformMat4(t,t,this.transform),t},pointToData:function(e,t){}};var dc=0,fc={dimensions:uc.prototype.dimensions,create:function(e,t){var r=[];if(!Ee)throw new Error("geo3D component depends on geo component");function n(e,n){var i=fc.createGeo3D(e);e.__viewGL=e.__viewGL||new ih,i.viewGL=e.__viewGL,e.coordinateSystem=i,i.model=e,r.push(i),i.resize=hc,i.resize(e,t),i.update=cc}return e.eachComponent("geo3D",function(e,t){n(e)}),e.eachSeriesByType("map3D",function(e,t){var r=e.get("coordinateSystem");null==r&&(r="geo3D"),"geo3D"===r&&n(e)}),e.eachSeries(function(t){if("geo3D"===t.get("coordinateSystem")){if("series.map3D"===t.type)return;var r=t.getReferringComponents("geo3D").models[0];if(r||(r=e.getComponent("geo3D")),!r)throw new Error('geo "'+Vs(t.get("geo3DIndex"),t.get("geo3DId"),0)+'" not found');t.coordinateSystem=r.coordinateSystem}}),r},createGeo3D:function(e){var t,r=e.get("map");return"string"==typeof r?(t=r,r=Ee(r)):r&&r.features&&(r={geoJson:r}),null==t&&(t="GEO_ANONYMOUS_"+dc++),new uc(t+dc++,t,r&&r.geoJson,r&&r.specialAreas,e.get("nameMap"))}};function pc(e){e.registerComponentModel(xh),e.registerComponentView(ic),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",fc)}function mc(e,t){e.id=e.id||e.name||t+""}W(pc);var gc=le.extend({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){gc.superApply(this,"init",arguments),re(this.option.layers,function(e,t){ue(e,this.defaultLayerOption),mc(e,t)},this)},mergeOption:function(e){var t=this.option.layers;function r(e){return Re(e,function(e,t,r){return mc(t,r),e[t.id]=t,e},{})}if(this.option.layers=null,gc.superApply(this,"mergeOption",arguments),t&&t.length){var n=r(e.layers),i=r(t);for(var a in n)i[a]?ue(i[a],n[a],!0):t.push(e.layers[a]);this.option.layers=t}re(this.option.layers,function(e){ue(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,r){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=r},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}});ue(gc.prototype,Sl),ue(gc.prototype,Ml),ue(gc.prototype,Al),ue(gc.prototype,_h);var vc=Math.PI,_c=Math.sin,yc=Math.cos,xc=Math.tan,bc=Math.asin,wc=Math.atan2,Tc=vc/180;var Sc=23.4397*Tc;function Mc(e,t){return wc(_c(e)*yc(Sc)-xc(t)*_c(Sc),yc(e))}function Ac(e,t,r){return wc(_c(e),yc(e)*_c(t)-xc(r)*yc(t))}function Ec(e,t,r){return bc(_c(t)*_c(r)+yc(t)*yc(r)*yc(e))}function Cc(e){var t,r,n=function(e){return Tc*(357.5291+.98560028*e)}(e),i=function(e){return e+Tc*(1.9148*_c(e)+.02*_c(2*e)+3e-4*_c(3*e))+102.9372*Tc+vc}(n);return{dec:(t=i,r=0,bc(_c(r)*yc(Sc)+yc(r)*_c(Sc)*_c(t))),ra:Mc(i,0)}}var Dc={};Dc.getPosition=function(e,t,r){var n=Tc*-r,i=Tc*t,a=function(e){return function(e){return e.valueOf()/864e5-.5+2440588}(e)-2451545}(e),o=Cc(a),s=function(e,t){return Tc*(280.16+360.9856235*e)-t}(a,n)-o.ra;return{azimuth:Ac(s,i,o.dec),altitude:Ec(s,i,o.dec)}};ul.Shader.import(al),ul.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 Lc=ge.extend({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new ul.Node,this._sphereGeometry=new ul.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new ul.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new ul.PlaneGeometry,this._earthMesh=new ul.Mesh({renderNormal:!0}),this._atmosphereMesh=new ul.Mesh,this._atmosphereGeometry=new ul.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new ul.Material({shader:new ul.Shader(ul.Shader.source("ecgl.atmosphere.vertex"),ul.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=ul.Mesh.CW,this._lightRoot=new ul.Node,this._sceneHelper=new kl,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new Pl({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,r){var n=e.coordinateSystem,i=e.get("shading");n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL),this._sceneHelper.setScene(n.viewGL.scene),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var a=this._earthMesh;a.geometry=this._sphereGeometry;var o="ecgl."+i;a.material&&a.material.shader.name===o||(a.material=ul.createMaterial(o)),ul.setMaterialFromModel(i,a.material,e,r),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach(function(e){var t=a.material.get(e);t&&(t.flipY=!1)}),a.material.set("color",ul.parseColor(e.get("baseColor")));var s=.99*n.radius;if(a.scale.set(s,s,s),e.get("atmosphere.show")){a.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:e.get("atmosphere.glowPower")||6,glowColor:e.get("atmosphere.color")||"#ffffff"}),a.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 a.material.undefine("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!0;var u=a.material.setTextureImage("diffuseMap",e.get("baseTexture"),r,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(a);var h=a.material.setTextureImage("bumpMap",e.get("heightTexture"),r,{flipY:!1,anisotropic:8});h&&h.surface&&h.surface.attachToMesh(a),a.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,r),this._displaceVertices(e,r),this._updateViewControl(e,r),this._updateLayers(e,r)},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},_updateLayers:function(e,t){var r=e.coordinateSystem,n=e.get("layers"),i=r.radius,a=[],o=[],s=[],l=[];re(n,function(e){var n=new fe(e),u=n.get("type"),h=ul.loadTexture(n.get("texture"),t,{flipY:!1,anisotropic:8});if(h.surface&&h.surface.attachToMesh(this._earthMesh),"blend"===u){var c=n.get("blendTo"),d=Vs(n.get("intensity"),1);"emission"===c?(s.push(h),l.push(d)):(a.push(h),o.push(d))}else{var f=n.get("id"),p=this._layerMeshes[f];p||(p=this._layerMeshes[f]=new ul.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===n.get("shading")?(p.material=p.__lambertMaterial||new ul.Material({autoUpdateTextureStatus:!1,shader:ul.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),p.__lambertMaterial=p.material):(p.material=p.__colorMaterial||new ul.Material({autoUpdateTextureStatus:!1,shader:ul.createShader("ecgl.color"),transparent:!0,depthMask:!1}),p.__colorMaterial=p.material),p.material.enableTexture("diffuseMap");var m=n.get("distance"),g=i+(null==m?r.radius/100:m);p.scale.set(g,g,g),i=g;var v=this._blankTexture||(this._blankTexture=ul.createBlankTexture("rgba(255, 255, 255, 0)"));p.material.set("diffuseMap",v),ul.loadTexture(n.get("texture"),t,{flipY:!1,anisotropic:8},function(e){e.surface&&e.surface.attachToMesh(p),p.material.set("diffuseMap",e),t.getZr().refresh()}),n.get("show")?this.groupGL.add(p):this.groupGL.remove(p)}},this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",a.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",s.length),u.set("layerDiffuseMap",a),u.set("layerDiffuseIntensity",o),u.set("layerEmissiveMap",s),u.set("layerEmissionIntensity",l);var h=e.getModel("debug.wireframe");if(h.get("show")){u.define("both","WIREFRAME_TRIANGLE");var c=ul.parseColor(h.get("lineStyle.color")||"rgba(0,0,0,0.5)"),d=Vs(h.get("lineStyle.width"),1);u.set("wireframeLineWidth",d),u.set("wireframeLineColor",c)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){var r=e.coordinateSystem,n=e.getModel("viewControl");r.viewGL.camera;var i=this;var a=this._control;a.setViewGL(r.viewGL);var o,s,l=n.get("targetCoord");null!=l&&(s=l[0]+90,o=l[1]),a.setFromViewControlModel(n,{baseDistance:r.radius,alpha:o,beta:s}),a.off("update"),a.on("update",function(){t.dispatchAction({type:"globeChangeCamera",alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()-r.radius,center:a.getCenter(),from:i.uid,globeId:e.id})})},_displaceVertices:function(e,t){var r=e.get("displacementQuality"),n=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||r!==this._displacementQuality||n!==this._showDebugWireframe){this._displacementQuality=r,this._showDebugWireframe=n;var a=this._sphereGeometry,o={low:100,medium:200,high:400,ultra:800}[r]||200,s=o/2;(a.widthSegments!==o||n)&&(a.widthSegments=o,a.heightSegments=s,a.build()),this._doDisplaceVertices(a,i),n&&a.generateBarycentric()}},_doDisplaceVertices:function(e,t){var r=e.attributes.position.value,n=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===r.length||((i=new Float32Array(r.length)).set(r),e.__originalPosition=i);for(var a=t.displacementWidth,o=t.displacementHeight,s=t.displacementData,l=0;l<e.vertexCount;l++){var u=3*l,h=2*l,c=i[u+1],d=i[u+2],f=i[u+3],p=n[h++],m=n[h++],g=Math.round(p*(a-1)),v=Math.round(m*(o-1)),_=s?s[v*a+g]:0;r[u+1]=c+c*_,r[u+2]=d+d*_,r[u+3]=f+f*_}e.generateVertexNormals(),e.dirty(),e.updateBoundingBox()},_updateLight:function(e,t){var r=this._earthMesh;this._sceneHelper.updateLight(e);var n=this._sceneHelper.mainLight,i=e.get("light.main.time")||new Date,a=Dc.getPosition(Ie(i),0,0),o=Math.cos(a.altitude);n.position.y=-o*Math.cos(a.azimuth),n.position.x=Math.sin(a.altitude),n.position.z=o*Math.sin(a.azimuth),n.lookAt(r.getWorldPosition())},dispose:function(e,t){this.groupGL.removeAll(),this._control.dispose()}}),Pc=Nl.vec3;function Oc(e){this.radius=e,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}function Nc(e,t){var r=e.getBoxLayoutParams(),n=be(r,{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 i=e.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,i-this.radius)}function Rc(e,t){var r=[1/0,-1/0];if(e.eachSeries(function(e){if(e.coordinateSystem===this){var t=e.getData(),n=e.coordDimToDataDim("alt"),i=n&&n[0];if(i){var a=t.getDataExtent(i,!0);r[0]=Math.min(r[0],a[0]),r[1]=Math.max(r[1],a[1])}}},this),r&&isFinite(r[1]-r[0])){var n=we(r,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new xe("altitude",n),this.resize(this.model,t)}}Oc.prototype={constructor:Oc,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(e,t,r){this.displacementData=e,this.displacementWidth=t,this.displacementHeight=r},_getDisplacementScale:function(e,t){var r=(e+180)/360*(this.displacementWidth-1),n=(90-t)/180*(this.displacementHeight-1),i=Math.round(r)+Math.round(n)*this.displacementWidth;return this.displacementData[i]},dataToPoint:function(e,t){var r=e[0],n=e[1],i=e[2]||0,a=this.radius;this.displacementData&&(a*=1+this._getDisplacementScale(r,n)),this.altitudeAxis&&(a+=this.altitudeAxis.dataToCoord(i)),r=r*Math.PI/180,n=n*Math.PI/180;var o=Math.cos(n)*a;return(t=t||[])[0]=-o*Math.cos(r+Math.PI),t[1]=Math.sin(n)*a,t[2]=o*Math.sin(r+Math.PI),t},pointToData:function(e,t){var r=e[0],n=e[1],i=e[2],a=Pc.len(e);r/=a,n/=a,i/=a;var o=Math.asin(n),s=Math.atan2(i,-r);s<0&&(s=2*Math.PI+s);var l=180*o/Math.PI,u=180*s/Math.PI-180;return(t=t||[])[0]=u,t[1]=l,t[2]=a-this.radius,this.altitudeAxis&&(t[2]=this.altitudeAxis.coordToData(t[2])),t}};var Ic={dimensions:Oc.prototype.dimensions,create:function(e,t){var r=[];return e.eachComponent("globe",function(e){e.__viewGL=e.__viewGL||new ih;var n=new Oc;n.viewGL=e.__viewGL,e.coordinateSystem=n,n.model=e,r.push(n),n.resize=Nc,n.resize(e,t),n.update=Rc}),e.eachSeries(function(t){if("globe"===t.get("coordinateSystem")){var r=t.getReferringComponents("globe").models[0];if(r||(r=e.getComponent("globe")),!r)throw new Error('globe "'+Vs(t.get("globe3DIndex"),t.get("globe3DId"),0)+'" not found');var n=r.coordinateSystem;t.coordinateSystem=n}}),e.eachComponent("globe",function(e,r){var n=e.coordinateSystem,i=e.getDisplacementTexture(),a=e.getDisplacemenScale();if(e.isDisplacementChanged()){if(e.hasDisplacement()){var o=!0;ul.loadTexture(i,t,function(r){var n=function(e,t){var r=document.createElement("canvas"),n=r.getContext("2d"),i=e.width,a=e.height;r.width=i,r.height=a,n.drawImage(e,0,0,i,a);for(var o=n.getImageData(0,0,i,a).data,s=new Float32Array(o.length/4),l=0;l<o.length/4;l++){var u=o[4*l];s[l]=u/255*t}return{data:s,width:i,height:a}}(r.image,a);e.setDisplacementData(n.data,n.width,n.height),o||t.dispatchAction({type:"globeUpdateDisplacment"})}),o=!1}else n.setDisplacementData(null,0,0);n.setDisplacementData(e.displacementData,e.displacementWidth,e.displacementHeight)}}),r}};function Bc(e){e.registerComponentModel(gc),e.registerComponentView(Lc),e.registerCoordinateSystem("globe",Ic),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){})}W(Bc);var zc=["zoom","center","pitch","bearing"],Fc=le.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 zc.reduce(function(t,r){return t[r]=e.get(r),t},{})},setMapboxCameraOption:function(e){null!=e&&zc.forEach(function(t){null!=e[t]&&(this.option[t]=e[t])},this)},getMapbox:function(){return this._mapbox},setMapbox:function(e){this._mapbox=e}});function kc(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()}ue(Fc.prototype,Ml),ue(Fc.prototype,Al),kc.prototype.setUnpainted=function(){},kc.prototype.resize=function(){this._mapbox.resize()},kc.prototype.getMapbox=function(){return this._mapbox},kc.prototype.clear=function(){},kc.prototype.refresh=function(){this._mapbox.resize()};var Uc=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];kc.prototype._initEvents=function(){var e=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},Uc.forEach(function(t){this._handlers[t]=function(t){var r={};for(var n in t)r[n]=t[n];r.bubbles=!1;var i=new t.constructor(t.type,r);e.dispatchEvent(i)},this.zr.dom.addEventListener(t,this._handlers[t])},this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},kc.prototype.dispose=function(){Uc.forEach(function(e){this.zr.dom.removeEventListener(e,this._handlers[e])},this)};var Gc="\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";ul.Shader.import(Gc);var Hc=ge.extend({type:"mapbox3D",__ecgl__:!0,init:function(e,t){var r=t.getZr();this._zrLayer=new kc("mapbox3D",r),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new ul.Node,this._sceneHelper=new kl(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var n=this._zrLayer.getMapbox(),i=this._dispatchInteractAction.bind(this,t,n);["zoom","rotate","drag","pitch","rotate","move"].forEach(function(e){n.on(e,i)}),this._groundMesh=new ul.Mesh({geometry:new ul.PlaneGeometry,material:new ul.Material({shader:new ul.Shader({vertex:ul.Shader.source("ecgl.displayShadow.vertex"),fragment:ul.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(e,t,r){var n=this._zrLayer.getMapbox(),i=e.get("style"),a=JSON.stringify(i);a!==this._oldStyleStr&&i&&n.setStyle(i),this._oldStyleStr=a,n.setCenter(e.get("center")),n.setZoom(e.get("zoom")),n.setPitch(e.get("pitch")),n.setBearing(e.get("bearing")),e.setMapbox(n);var o=e.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(e),o.viewGL.setPostEffect(e.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._mapbox3DModel=e},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r),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,r,n){e.coordinateSystem.setCameraOption(n),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(e,t,r){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 r=new ul.Plane(new ul.Vector3(0,0,1),0),n=e.viewGL.camera.castRay(new ul.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new ul.Vector2(1,1)),a=n.intersectPlane(r),o=i.intersectPlane(r),s=a.dist(o)/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)}}),Vc=Nl.mat4,Wc=512,jc=.6435011087932844,Xc=Math.PI,qc=.1;function Zc(){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 Yc(){Zc.apply(this,arguments)}function Kc(e,t,r){function n(e,t){var r=t.getWidth(),n=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,r,n,i),this.width=r,this.height=n,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function i(e,t){if("auto"!==this.model.get("boxHeight")){var r=[1/0,-1/0];e.eachSeries(function(e){if(e.coordinateSystem===this){var t=e.getData(),n=e.coordDimToDataDim("alt")[0];if(n){var i=t.getDataExtent(n,!0);r[0]=Math.min(r[0],i[0]),r[1]=Math.max(r[1],i[1])}}},this),r&&isFinite(r[1]-r[0])&&(this.altitudeExtent=r)}}return{dimensions:t.prototype.dimensions,create:function(a,o){var s=[];return a.eachComponent(e,function(e){var r=e.__viewGL;r||(r=e.__viewGL=new ih).setRootNode(new ul.Node);var a=new t;a.viewGL=e.__viewGL,a.resize=n,a.resize(e,o),s.push(a),e.coordinateSystem=a,a.model=e,a.update=i}),a.eachSeries(function(t){if(t.get("coordinateSystem")===e){var r=t.getReferringComponents(e).models[0];if(r||(r=a.getComponent(e)),!r)throw new Error(e+' "'+Vs(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=r.coordinateSystem}}),r&&r(s,a,o),s}}}Zc.prototype={constructor:Zc,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,Wc)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var e=.5/Math.tan(jc/2)*this.height*qc,t=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,r=jc/2,n=Math.PI/2+t,i=Math.sin(r)*e/Math.sin(Math.PI-n-r),a=1.1*(Math.cos(Math.PI/2-t)*i+e);this.pitch>50&&(a=1e3);var o=[];Vc.perspective(o,jc,this.width/this.height,1,a),this.viewGL.camera.projectionMatrix.setArray(o),this.viewGL.camera.decomposeProjectionMatrix();o=Vc.identity([]);var s=this.dataToPoint(this.center);Vc.scale(o,o,[1,-1,1]),Vc.translate(o,o,[0,0,-e]),Vc.rotateX(o,o,t),Vc.rotateZ(o,o,-this.bearing/180*Math.PI),Vc.translate(o,o,[-s[0]*this.getScale()*qc,-s[1]*this.getScale()*qc,0]),this.viewGL.camera.viewMatrix.array=o;var l=[];Vc.invert(l,o),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var u,h=Wc*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var c=this.altitudeExtent[1]-this.altitudeExtent[0];u=this.boxHeight/c*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else u=h/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*qc;this.viewGL.rootNode.scale.set(this.getScale()*qc,this.getScale()*qc,u)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,this.getScale()*Wc,t)},projectOnTileWithScale:function(e,t,r){var n=e[0],i=e[1]*Xc/180,a=t*(n*Xc/180+Xc)/(2*Xc),o=t*(Xc-Math.log(Math.tan(Xc/4+.5*i)))/(2*Xc);return(r=r||[])[0]=a,r[1]=o,r},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,this.getScale()*Wc,t)},unprojectOnTileWithScale:function(e,t,r){var n=e[0],i=e[1],a=n/t*(2*Xc)-Xc,o=2*(Math.atan(Math.exp(Xc-i/t*(2*Xc)))-Xc/4);return(r=r||[])[0]=180*a/Xc,r[1]=180*o/Xc,r},dataToPoint:function(e,t){return(t=this.projectOnTileWithScale(e,Wc,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}},Yc.prototype=new Zc,Yc.prototype.constructor=Yc,Yc.prototype.type="mapbox3D";var Qc=Kc("mapbox3D",Yc,function(e){e.forEach(function(e){e.setCameraOption(e.model.getMapboxCameraOption())})});W(function(e){e.registerComponentModel(Fc),e.registerComponentView(Hc),e.registerCoordinateSystem("mapbox3D",Qc),e.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},function(e,t){t.eachComponent({mainType:"mapbox3D",query:e},function(t){t.setMapboxCameraOption(e)})})});var Jc=["zoom","center","pitch","bearing"],$c=le.extend({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'© <a href="http://osm.org">OpenStreetMap</a> contributors, © <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 Jc.reduce(function(t,r){return t[r]=e.get(r),t},{})},setMaptalksCameraOption:function(e){null!=e&&Jc.forEach(function(t){null!=e[t]&&(this.option[t]=e[t])},this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});function ed(e,t,r,n){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:r,zoom:n,doubleClickZoom:!1,fog:!1}),this._initEvents()}ue($c.prototype,Ml),ue($c.prototype,Al),ed.prototype.setUnpainted=function(){},ed.prototype.resize=function(){this._maptalks.checkSize()},ed.prototype.getMaptalks=function(){return this._maptalks},ed.prototype.clear=function(){},ed.prototype.refresh=function(){this._maptalks.checkSize()};var td=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];ed.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},td.forEach(function(t){this._handlers[t]=function(r){var n={};for(var i in r)n[i]=r[i];n.bubbles=!1;var a=new r.constructor(r.type,n);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(a):e.firstElementChild.dispatchEvent(a)},this.zr.dom.addEventListener(t,this._handlers[t])},this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},ed.prototype.dispose=function(){td.forEach(function(e){this.zr.dom.removeEventListener(e,this._handlers[e])},this),this._maptalks.remove()},ul.Shader.import(Gc);var rd=ge.extend({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new ul.Mesh({geometry:new ul.PlaneGeometry,material:new ul.Material({shader:new ul.Shader({vertex:ul.Shader.source("ecgl.displayShadow.vertex"),fragment:ul.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var r=t.getZr();this._zrLayer=new ed("maptalks3D",r,e.get("center"),e.get("zoom")),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new ul.Node,this._sceneHelper=new kl(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var n=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,n);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach(function(e){n.on(e,i)})},render:function(e,t,r){this._zrLayer||this._initMaptalksLayer(e,r);var n=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),a=n.getBaseLayer();i!==this._oldUrlTemplate&&(a?a.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(a=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),n.setBaseLayer(a))),this._oldUrlTemplate=i,n.setCenter(e.get("center")),n.setZoom(e.get("zoom"),{animation:!1}),n.setPitch(e.get("pitch")),n.setBearing(e.get("bearing")),e.setMaptalks(n);var o=e.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(e),o.viewGL.setPostEffect(e.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r),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,r,n){e.coordinateSystem.setCameraOption(n),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(e,t,r){var n;e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:(n=t.getResolution(),19-Math.log(n/nd)/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 r=new ul.Plane(new ul.Vector3(0,0,1),0),n=e.viewGL.camera.castRay(new ul.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new ul.Vector2(1,1)),a=n.intersectPlane(r),o=i.intersectPlane(r),s=a.dist(o)/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)}}),nd=12756274*Math.PI/(256*Math.pow(2,20));function id(){Zc.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}id.prototype=new Zc,id.prototype.constructor=id,id.prototype.type="maptalks3D";var ad=Kc("maptalks3D",id,function(e){e.forEach(function(e){e.setCameraOption(e.model.getMaptalksCameraOption())})});W(function(e){e.registerComponentModel($c),e.registerComponentView(rd),e.registerCoordinateSystem("maptalks3D",ad),e.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},function(e,t){t.eachComponent({mainType:"maptalks3D",query:e},function(t){t.setMaptalksCameraOption(e)})})});var od=Nl.vec3,sd=Be.isDimensionStacked;function ld(e,t,r){for(var n=e.getDataExtent(t),i=e.getDataExtent(r),a=n[1]-n[0]||n[0],o=i[1]-i[0]||i[0],s=new Uint8Array(2500),l=0;l<e.count();l++){var u=e.get(t,l),h=e.get(r,l),c=Math.floor((u-n[0])/a*49),d=50*Math.floor((h-i[0])/o*49)+c;s[d]=s[d]||1}var f=0;for(l=0;l<s.length;l++)s[l]&&f++;return f/s.length}var ud=Nl.vec3,hd=Be.isDimensionStacked;function cd(e,t){var r=hd(e,t[2]);return{dimension:r?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:r}}function dd(e){e.registerLayout(function(e,t){e.eachSeriesByType("bar3D",function(e){var t=e.coordinateSystem,r=t&&t.type;"globe"===r?function(e,t){var r=e.getData(),n=e.get("minHeight")||0,i=e.get("barSize"),a=["lng","lat","alt"].map(function(t){return e.coordDimToDataDim(t)[0]});if(null==i){var o=t.radius*Math.PI,s=ld(r,a[0],a[1]);i=[o/Math.sqrt(r.count()/s),o/Math.sqrt(r.count()/s)]}else Z(i)||(i=[i,i]);var l=cd(r,a);r.each(a,function(e,a,o,s){var u=r.get(l.dimension,s),h=l.isStacked?u-o:t.altitudeAxis.scale.getExtent()[0],c=Math.max(t.altitudeAxis.dataToCoord(o),n),d=t.dataToPoint([e,a,h]),f=t.dataToPoint([e,a,u]),p=ud.sub([],f,d);ud.normalize(p,p);var m=[i[0],c,i[1]];r.setItemLayout(s,[d,p,m])}),r.setLayout("orient",Ji.UP.array)}(e,t):"cartesian3D"===r?function(e,t){var r=e.getData(),n=e.get("barSize");if(null==n){var i,a,o=t.size,s=t.getAxis("x"),l=t.getAxis("y");i="category"===s.type?.7*s.getBandWidth():.6*Math.round(o[0]/Math.sqrt(r.count())),a="category"===l.type?.7*l.getBandWidth():.6*Math.round(o[1]/Math.sqrt(r.count())),n=[i,a]}else Z(n)||(n=[n,n]);var u,h,c,d=t.getAxis("z").scale.getExtent(),f=(h=(u=d)[0],c=u[1],!(h>0&&c>0||h<0&&c<0)),p=["x","y","z"].map(function(t){return e.coordDimToDataDim(t)[0]}),m=sd(r,p[2]),g=m?r.getCalculationInfo("stackResultDimension"):p[2];r.each(p,function(e,i,a,o){var s=r.get(g,o),l=m?s-a:f?0:d[0],u=t.dataToPoint([e,i,l]),h=t.dataToPoint([e,i,s]),c=od.dist(u,h),p=[0,h[1]<u[1]?-1:1,0];0===Math.abs(c)&&(c=.1);var v=[n[0],c,n[1]];r.setItemLayout(o,[u,p,v])}),r.setLayout("orient",[1,0,0])}(e,t):"geo3D"===r?function(e,t){var r=e.getData(),n=e.get("barSize"),i=e.get("minHeight")||0,a=["lng","lat","alt"].map(function(t){return e.coordDimToDataDim(t)[0]});if(null==n){var o=Math.min(t.size[0],t.size[2]),s=ld(r,a[0],a[1]);n=[o/Math.sqrt(r.count()/s),o/Math.sqrt(r.count()/s)]}else Z(n)||(n=[n,n]);var l=[0,1,0],u=cd(r,a);r.each(a,function(e,a,o,s){var h=r.get(u.dimension,s),c=u.isStacked?h-o:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(o),i),f=t.dataToPoint([e,a,c]),p=[n[0],d,n[1]];r.setItemLayout(s,[f,l,p])}),r.setLayout("orient",[1,0,0])}(e,t):"mapbox3D"!==r&&"maptalks3D"!==r||function(e,t){var r=e.getData(),n=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],a=e.coordDimToDataDim("alt")[0],o=e.get("barSize"),s=e.get("minHeight")||0;if(null==o){var l=r.getDataExtent(n),u=r.getDataExtent(i),h=t.dataToPoint([l[0],u[0]]),c=t.dataToPoint([l[1],u[1]]),d=Math.min(Math.abs(h[0]-c[0]),Math.abs(h[1]-c[1]))||1,f=ld(r,n,i);o=[d/Math.sqrt(r.count()/f),d/Math.sqrt(r.count()/f)]}else Z(o)||(o=[o,o]),o[0]/=t.getScale()/16,o[1]/=t.getScale()/16;var p=[0,0,1],m=[n,i,a],g=cd(r,m);r.each(m,function(e,n,i,a){var l=r.get(g.dimension,a),u=g.isStacked?l-i:0,h=t.dataToPoint([e,n,u]),c=t.dataToPoint([e,n,l]),d=Math.max(c[2]-h[2],s),f=[o[0],d,o[1]];r.setItemLayout(a,[h,p,f])}),r.setLayout("orient",[1,0,0])}(e,t)})})}var fd={};function pd(e,t,r){var n=e.getData(),i=e.getRawValue(t),a=Z(i)?function(e){var i=[],a=function(e,t){var r=[];return re(e.dimensions,function(n){var i=e.getDimensionInfo(n),a=i.otherDims[t];null!=a&&!1!==a&&(r[a]=i.name)}),r}(n,"tooltip");function o(e,t){var a=n.getDimensionInfo(t);if(a&&!1!==a.otherDims.tooltip){var o=a.type,s="- "+(a.tooltipName||a.name)+": "+("ordinal"===o?e+"":"time"===o?r?"":He("yyyy/MM/dd hh:mm:ss",e):ke(e));s&&i.push(Fe(s))}}return a.length?re(a,function(e){o(n.get(e,t),e)}):re(e,o),"<br/>"+i.join("<br/>")}(i):Fe(ke(i)),o=n.getName(t),s=$h(n,t);Ue(s)&&s.colorStops&&(s=(s.colorStops[0]||{}).color);var l=Ge(s=s||"transparent"),u=e.name;return"\0-"===u&&(u=""),u=u?Fe(u)+(r?": ":"<br/>"):"",r?l+u+a:u+l+(o?Fe(o)+": "+a:a)}function md(e,t,r){r=r||e.getSource();var n=t||Ve(e.get("coordinateSystem"))||["x","y","z"],i=Ce(r,{dimensionsDefine:r.dimensionsDefine||e.get("dimensions"),encodeDefine:r.encodeDefine||e.get("encode"),coordDimensions:n.map(function(t){var r=e.getReferringComponents(t+"Axis3D").models[0];return{type:r&&"category"===r.get("type")?"ordinal":"float",name:t}})});"cartesian3D"===e.get("coordinateSystem")&&i.forEach(function(t){if(n.indexOf(t.coordDim)>=0){var r=e.getReferringComponents(t.coordDim+"Axis3D").models[0];r&&"category"===r.get("type")&&(t.ordinalMeta=r.getOrdinalMeta())}});var a=Be.enableDataStack(e,i,{byIndex:!0,stackedCoordDimension:"z"}),o=new De(i,e);return o.setCalculationInfo(a),o.initData(r),o}fd.getFormattedLabel=function(e,t,r,n,i){r=r||"normal";var a=e.getData(n).getItemModel(t),o=e.getDataParams(t,n);null!=i&&o.value instanceof Array&&(o.value=o.value[i]);var s,l=a.get("normal"===r?["label","formatter"]:["emphasis","label","formatter"]);return null==l&&(l=a.get(["label","formatter"])),"function"==typeof l?(o.status=r,s=l(o)):"string"==typeof l&&(s=ze(l,o)),s},fd.normalizeToArray=function(e){return e instanceof Array?e:null==e?[]:[e]};var gd=We.extend({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(e,t){return md(this)},getFormattedLabel:function(e,t,r,n){var i=fd.getFormattedLabel(this,e,t,r,n);return null==i&&(i=this.getData().get("z",e)),i},formatTooltip:function(e){return pd(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}});ue(gd.prototype,_h);var vd,_d,yd,xd,bd,wd,Td,Sd,Md=Nl.vec3,Ad=Nl.mat3,Ed=mo.extend(function(){return{attributes:{position:new mo.Attribute("position","float",3,"POSITION"),normal:new mo.Attribute("normal","float",3,"NORMAL"),color:new mo.Attribute("color","float",4,"COLOR"),prevPosition:new mo.Attribute("prevPosition","float",3),prevNormal:new mo.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,r=this.getBarVertexCount()*e,n=this.getBarTriangleCount()*e;this.vertexCount!==r&&(this.attributes.position.init(r),t?this.attributes.normal.init(r):this.attributes.normal.value=null,this.attributes.color.init(r)),this.triangleCount!==n&&(this.indices=r>65535?new Uint32Array(3*n):new Uint16Array(3*n),this._dataIndices=new Uint32Array(r))},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 r=this.getBarVertexCount(),n=r*(e+1),i=r*e;i<n;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=Md.create,t=Md.scaleAndAdd,r=e(),n=e(),i=e(),a=e(),o=e(),s=e(),l=e(),u=[],h=[],c=0;c<8;c++)u[c]=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]],f=[0,1,2,0,2,3],p=[];for(c=0;c<d.length;c++)for(var m=d[c],g=0;g<2;g++){for(var v=[],_=0;_<3;_++)v.push(m[f[3*g+_]]);p.push(v)}return function(e,c,m,g,v,_){var y=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(e,c,m,g,this.bevelSize,this.bevelSegments,v);else{Md.copy(i,c),Md.normalize(i,i),Md.cross(a,m,i),Md.normalize(a,a),Md.cross(n,i,a),Md.normalize(a,a),Md.negate(o,n),Md.negate(s,i),Md.negate(l,a),t(u[0],e,n,g[0]/2),t(u[0],u[0],a,g[2]/2),t(u[1],e,n,g[0]/2),t(u[1],u[1],l,g[2]/2),t(u[2],e,o,g[0]/2),t(u[2],u[2],l,g[2]/2),t(u[3],e,o,g[0]/2),t(u[3],u[3],a,g[2]/2),t(r,e,i,g[1]),t(u[4],r,n,g[0]/2),t(u[4],u[4],a,g[2]/2),t(u[5],r,n,g[0]/2),t(u[5],u[5],l,g[2]/2),t(u[6],r,o,g[0]/2),t(u[6],u[6],l,g[2]/2),t(u[7],r,o,g[0]/2),t(u[7],u[7],a,g[2]/2);var x=this.attributes;if(this.enableNormal){h[0]=n,h[1]=o,h[2]=i,h[3]=s,h[4]=a,h[5]=l;for(var b=this._vertexOffset,w=0;w<d.length;w++){for(var T=3*this._triangleOffset,S=0;S<6;S++)this.indices[T++]=b+f[S];b+=4,this._triangleOffset+=2}for(w=0;w<d.length;w++){var M=h[w];for(S=0;S<4;S++){var A=d[w][S];x.position.set(this._vertexOffset,u[A]),x.normal.set(this._vertexOffset,M),x.color.set(this._vertexOffset++,v)}}}else{for(w=0;w<p.length;w++){for(T=3*this._triangleOffset,S=0;S<3;S++)this.indices[T+S]=p[w][S]+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 E=this._vertexOffset;for(w=y;w<E;w++)this._dataIndices[w]=_}}(),_addBevelBar:(vd=Md.create(),_d=Md.create(),yd=Md.create(),xd=Ad.create(),bd=[],wd=[1,-1,-1,1],Td=[1,1,-1,-1],Sd=[2,0],function(e,t,r,n,i,a,o){Md.copy(_d,t),Md.normalize(_d,_d),Md.cross(yd,r,_d),Md.normalize(yd,yd),Md.cross(vd,_d,yd),Md.normalize(yd,yd),xd[0]=vd[0],xd[1]=vd[1],xd[2]=vd[2],xd[3]=_d[0],xd[4]=_d[1],xd[5]=_d[2],xd[6]=yd[0],xd[7]=yd[1],xd[8]=yd[2],i=Math.min(n[0],n[2])/2*i;for(var s=0;s<3;s++)bd[s]=Math.max(n[s]-2*i,0);var l=(n[0]-bd[0])/2,u=(n[1]-bd[1])/2,h=(n[2]-bd[2])/2,c=[],d=[],f=this._vertexOffset,p=[];for(s=0;s<2;s++){p[s]=p[s]=[];for(var m=0;m<=a;m++)for(var g=0;g<4;g++){(0===m&&0===s||1===s&&m===a)&&p[s].push(f);for(var v=0;v<=a;v++){var _=v/a*Math.PI/2+Math.PI/2*g,y=m/a*Math.PI/2+Math.PI/2*s;d[0]=l*Math.cos(_)*Math.sin(y),d[1]=u*Math.cos(y),d[2]=h*Math.sin(_)*Math.sin(y),c[0]=d[0]+wd[g]*bd[0]/2,c[1]=d[1]+u+Sd[s]*bd[1]/2,c[2]=d[2]+Td[g]*bd[2]/2,Math.abs(l-u)<1e-6&&Math.abs(u-h)<1e-6||(d[0]/=l*l,d[1]/=u*u,d[2]/=h*h),Md.normalize(d,d),Md.transformMat3(c,c,xd),Md.transformMat3(d,d,xd),Md.add(c,c,e),this.attributes.position.set(f,c),this.enableNormal&&this.attributes.normal.set(f,d),this.attributes.color.set(f,o),f++}}}var x=4*a+3,b=2*a+1,w=x+1;for(g=0;g<b;g++)for(s=0;s<=x;s++){var T=g*w+s+this._vertexOffset,S=g*w+(s+1)%w+this._vertexOffset,M=(g+1)*w+(s+1)%w+this._vertexOffset,A=(g+1)*w+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[M,T,S]),this.setTriangleIndices(this._triangleOffset++,[M,A,T])}this.setTriangleIndices(this._triangleOffset++,[p[0][0],p[0][2],p[0][1]]),this.setTriangleIndices(this._triangleOffset++,[p[0][0],p[0][3],p[0][2]]),this.setTriangleIndices(this._triangleOffset++,[p[1][0],p[1][1],p[1][2]]),this.setTriangleIndices(this._triangleOffset++,[p[1][0],p[1][2],p[1][3]]),this._vertexOffset=f})});he(Ed.prototype,Ol),he(Ed.prototype,Jh);var Cd=Nl.vec3,Dd=je.extend({type:"bar3D",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this._api=t,this._labelsBuilder=new tc(256,256,t);var r=this;this._labelsBuilder.getLabelPosition=function(e,t,n){if(r._data){var i=r._data.getItemLayout(e),a=i[0],o=i[1],s=i[2][1];return Cd.scaleAndAdd([],a,o,n+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(e,t,r){var n=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=n,this._barMesh||(this._barMesh=new ul.Mesh({geometry:new Ed,shadowDepthMaterial:new ul.Material({shader:new ul.Shader(ul.Shader.source("ecgl.sm.depth.vertex"),ul.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,r),i&&i.viewGL){i.viewGL.add(this.groupGL);var a=i.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[a]("fragment","SRGB_DECODE")}this._data=e.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(e)},_updateAnimation:function(e){ul.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,e)},_doRender:function(e,t){var r=e.getData(),n=e.get("shading"),i="color"!==n,a=this,o=this._barMesh,s="ecgl."+n;o.material&&o.material.shader.name===s||(o.material=ul.createMaterial(s,["VERTEX_COLOR"])),ul.setMaterialFromModel(n,o.material,e,t),o.geometry.enableNormal=i,o.geometry.resetOffset();var l=e.get("bevelSize"),u=e.get("bevelSmoothness");o.geometry.bevelSegments=u,o.geometry.bevelSize=l;var h=[],c=new Float32Array(4*r.count()),d=0,f=0,p=!1;r.each(function(e){if(r.hasValue(e)){var t=$h(r,e),n=ec(r,e);null==n&&(n=1),ul.parseColor(t,h),h[3]*=n,c[d++]=h[0],c[d++]=h[1],c[d++]=h[2],c[d++]=h[3],h[3]>0&&(f++,h[3]<.99&&(p=!0))}}),o.geometry.setBarCount(f);var m=r.getLayout("orient"),g=this._barIndexOfData=new Int32Array(r.count());f=0;r.each(function(e){if(r.hasValue(e)){var t=r.getItemLayout(e),n=t[0],i=t[1],o=t[2],s=4*e;h[0]=c[s++],h[1]=c[s++],h[2]=c[s++],h[3]=c[s++],h[3]>0&&(a._barMesh.geometry.addBar(n,i,m,o,h,e),g[e]=f++)}else g[e]=-1}),o.geometry.dirty(),o.geometry.updateBoundingBox();var v=o.material;v.transparent=p,v.depthMask=!p,o.geometry.sortTriangles=p,this._initHandler(e,t)},_initHandler:function(e,t){var r=e.getData(),n=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;n.seriesIndex=e.seriesIndex;var a=-1;n.off("mousemove"),n.off("mouseout"),n.on("mousemove",function(e){var o=n.geometry.getDataIndexOfVertex(e.triangle[0]);o!==a&&(this._downplay(a),this._highlight(o),this._labelsBuilder.updateLabels([o]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",o),r.get("y",o),r.get("z",o,!0)]})),a=o,n.dataIndex=o},this),n.on("mouseout",function(e){this._downplay(a),this._labelsBuilder.updateLabels(),a=-1,n.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_highlight:function(e){var t=this._data;if(t){var r=this._barIndexOfData[e];if(!(r<0)){var n=t.getItemModel(e).getModel("emphasis.itemStyle"),i=n.get("color"),a=n.get("opacity");if(null==i){var o=$h(t,e);i=Le(o,-.4)}null==a&&(a=ec(t,e));var s=ul.parseColor(i);s[3]*=a,this._barMesh.geometry.setColor(r,s),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var r=this._barIndexOfData[e];if(!(r<0)){var n=$h(t,e),i=ec(t,e),a=ul.parseColor(n);a[3]*=i,this._barMesh.geometry.setColor(r,a),this._api.getZr().refresh()}}},highlight:function(e,t,r,n){this._toggleStatus("highlight",e,t,r,n)},downplay:function(e,t,r,n){this._toggleStatus("downplay",e,t,r,n)},_toggleStatus:function(e,t,r,n,i){var a=t.getData(),o=Ws(a,i),s=this;null!=o?re(fd.normalizeToArray(o),function(t){"highlight"===e?this._highlight(t):this._downplay(t)},this):a.each(function(t){"highlight"===e?s._highlight(t):s._downplay(t)})},remove:function(){this.groupGL.removeAll()},dispose:function(){this._labelsBuilder.dispose(),this.groupGL.removeAll()}});function Ld(e){e.registerChartView(Dd),e.registerSeriesModel(gd),dd(e),e.registerProcessor(function(e,t){e.eachSeriesByType("bar3d",function(e){var t=e.getData();t.filterSelf(function(e){return t.hasValue(e)})})})}W(Ld);var Pd=We.extend({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){return md(this)},formatTooltip:function(e){return pd(this,e)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}}),Od=Nl.vec3;ul.Shader.import(Jl);var Nd=je.extend({type:"line3D",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this._api=t},render:function(e,t,r){var n=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=n,this._line3DMesh||(this._line3DMesh=new ul.Mesh({geometry:new Bl({useNativeLine:!1,sortTriangles:!0}),material:new ul.Material({shader:ul.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 a=i.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[a]("fragment","SRGB_DECODE")}this._doRender(e,r),this._data=e.getData(),this._camera=i.viewGL.camera,this.updateCamera(),this._updateAnimation(e)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(e,t){var r=e.getData(),n=this._line3DMesh;n.geometry.resetOffset();var i=r.getLayout("points"),a=[],o=new Float32Array(i.length/3*4),s=0,l=!1;r.each(function(e){var t=$h(r,e),n=ec(r,e);null==n&&(n=1),ul.parseColor(t,a),a[3]*=n,o[s++]=a[0],o[s++]=a[1],o[s++]=a[2],o[s++]=a[3],a[3]<.99&&(l=!0)}),n.geometry.setVertexCount(n.geometry.getPolylineVertexCount(i)),n.geometry.setTriangleCount(n.geometry.getPolylineTriangleCount(i)),n.geometry.addPolyline(i,o,Vs(e.get("lineStyle.width"),1)),n.geometry.dirty(),n.geometry.updateBoundingBox();var u=n.material;u.transparent=l,u.depthMask=!l;var h=e.getModel("debug.wireframe");h.get("show")?(n.geometry.createAttribute("barycentric","float",3),n.geometry.generateBarycentric(),n.material.set("both","WIREFRAME_TRIANGLE"),n.material.set("wireframeLineColor",ul.parseColor(h.get("lineStyle.color")||"rgba(0,0,0,0.5)")),n.material.set("wireframeLineWidth",Vs(h.get("lineStyle.width"),1))):n.material.set("both","WIREFRAME_TRIANGLE"),this._points=i,this._initHandler(e,t)},_updateAnimation:function(e){ul.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,e)},_initHandler:function(e,t){var r=e.getData(),n=e.coordinateSystem,i=this._line3DMesh,a=-1;i.seriesIndex=e.seriesIndex,i.off("mousemove"),i.off("mouseout"),i.on("mousemove",function(e){var o=n.pointToData(e.point.array),s=r.indicesOfNearest("x",o[0])[0];s!==a&&(t.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",s),r.get("y",s),r.get("z",s)]}),i.dataIndex=s),a=s},this),i.on("mouseout",function(e){a=-1,i.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_updateNDCPosition:function(){var e=new Ta,t=this._camera;Ta.multiply(e,t.projectionMatrix,t.viewMatrix);var r=this._positionNDC,n=this._points,i=n.length/3;r&&r.length/2===i||(r=this._positionNDC=new Float32Array(2*i));for(var a=[],o=0;o<i;o++){var s=3*o,l=2*o;a[0]=n[s],a[1]=n[s+1],a[2]=n[s+2],a[3]=1,Od.transformMat4(a,a,e.array),r[l]=a[0]/a[3],r[l+1]=a[1]/a[3]}},_pick:function(e,t,r,n,i,a){var o=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,u=.5*r.viewport.width,h=.5*r.viewport.height;e=(e+1)*u,t=(t+1)*h;for(var c=1;c<o.length/2;c++){var d=(o[2*(c-1)]+1)*u,f=(o[2*(c-1)+1]+1)*h,p=(o[2*c]+1)*u,m=(o[2*c+1]+1)*h;if(Xe(d,f,p,m,s,e,t))l=(d-e)*(d-e)+(f-t)*(f-t)<(p-e)*(p-e)+(m-t)*(m-t)?c-1:c}if(l>=0){var g=3*l,v=new Ji(this._points[g],this._points[g+1],this._points[g+2]);a.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()}});W(function(e){e.registerChartView(Nd),e.registerSeriesModel(Pd),e.registerLayout(function(e,t){e.eachSeriesByType("line3D",function(e){var t=e.getData(),r=e.coordinateSystem;if(r){if("cartesian3D"!==r.type)return;var n=new Float32Array(3*t.count()),i=[],a=[],o=r.dimensions.map(function(t){return e.coordDimToDataDim(t)[0]});r&&t.each(o,function(e,t,o,s){i[0]=e,i[1]=t,i[2]=o,r.dataToPoint(i,a),n[3*s]=a[0],n[3*s+1]=a[1],n[3*s+2]=a[2]}),t.setLayout("points",n)}})})});var Rd=We.extend({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(e,t){return md(this)},getFormattedLabel:function(e,t,r,n){var i=fd.getFormattedLabel(this,e,t,r,n);if(null==i){var a=this.getData(),o=a.dimensions[a.dimensions.length-1];i=a.get(o,e)}return i},formatTooltip:function(e){return pd(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 Id(e,t,r){(t=t||document.createElement("canvas")).width=e,t.height=e;var n=t.getContext("2d");return r&&r(n),t}var Bd={getMarginByStyle:function(e){var t=e.minMargin||0,r=0;e.stroke&&"none"!==e.stroke&&(r=null==e.lineWidth?1:e.lineWidth);var n=e.shadowBlur||0,i=e.shadowOffsetX||0,a=e.shadowOffsetY||0,o={};return o.left=Math.max(r/2,-i+n,t),o.right=Math.max(r/2,i+n,t),o.top=Math.max(r/2,-a+n,t),o.bottom=Math.max(r/2,a+n,t),o},createSymbolSprite:function(e,t,r,n){var i=function(e,t,r,n){Z(t)||(t=[t,t]);var i=Bd.getMarginByStyle(r,n),a=t[0]+i.left+i.right,o=t[1]+i.top+i.bottom,s=qe(e,0,0,t[0],t[1]),l=Math.max(a,o);s.x=i.left,s.y=i.top,a>o?s.y+=(l-o)/2:s.x+=(l-a)/2;var u=s.getBoundingRect();return s.x-=u.x,s.y-=u.y,s.setStyle(r),s.update(),s.__size=l,s}(e,t,r),a=Bd.getMarginByStyle(r);return{image:Id(i.__size,n,function(e){de(e,i)}),margin:a}},createSDFFromCanvas:function(e,t,r,n){return Id(t,n,function(t){var n=e.getContext("2d").getImageData(0,0,e.width,e.height);t.putImageData(function(e,t,r){var n=t.width,i=t.height,a=e.canvas.width,o=e.canvas.height,s=n/a,l=i/o;function u(e){return e<128?1:-1}function h(e,a){var o=1/0;e=Math.floor(e*s);for(var h=(a=Math.floor(a*l))*n+e,c=u(t.data[4*h]),d=Math.max(a-r,0);d<Math.min(a+r,i);d++)for(var f=Math.max(e-r,0);f<Math.min(e+r,n);f++){h=d*n+f;var p=f-e,m=d-a;if(c!==u(t.data[4*h])){var g=p*p+m*m;g<o&&(o=g)}}return c*Math.sqrt(o)}for(var c=e.createImageData(a,o),d=0;d<o;d++)for(var f=0;f<a;f++){var p=h(f,d)/r*.5+.5,m=4*(d*a+f);c.data[m++]=255*(1-p),c.data[m++]=255*(1-p),c.data[m++]=255*(1-p),c.data[m++]=255}return c}(t,n,r),0,0)})},createSimpleSprite:function(e,t){return Id(e,t,function(t){var r=e/2;t.beginPath(),t.arc(r,r,60,0,2*Math.PI,!1),t.closePath();var n=t.createRadialGradient(r,r,0,r,r,r);n.addColorStop(0,"rgba(255, 255, 255, 1)"),n.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),n.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=n,t.fill()})}},zd=Nl.vec3,Fd={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(e,t){var r=this.indices,n=zd.create();if(!r){r=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i<r.length;i++)r[i]=i}if(0===t){var a,o=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++){o.get(i,n);var l=zd.sqrDist(n,e);isNaN(l)&&(l=1e7,s++),0===i?(a=l,l=0):l-=a,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,r=this.indices;function n(e,r){return t[r]-t[e]}e?Array.prototype.sort.call(r,n):qh.sort(r,n,0,r.length-1)},_progressiveQuickSort:function(e){var t=this._zList,r=this.indices;this._quickSort=this._quickSort||new qh,this._quickSort.step(r,function(e,r){return t[r]-t[e]},e)}},kd=Nl.vec4;ul.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 Ud=ul.Mesh.extend(function(){var e=new ul.Geometry({dynamic:!0,attributes:{color:new ul.Geometry.Attribute("color","float",4,"COLOR"),position:new ul.Geometry.Attribute("position","float",3,"POSITION"),size:new ul.Geometry.Attribute("size","float",1),prevPosition:new ul.Geometry.Attribute("prevPosition","float",3),prevSize:new ul.Geometry.Attribute("prevSize","float",1)}});Object.assign(e,Fd);var t=new ul.Material({shader:ul.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});t.enableTexture("sprite"),t.define("both","VERTEX_COLOR"),t.define("both","VERTEX_SIZE");var r=new ul.Texture2D({image:document.createElement("canvas"),flipY:!1});return t.set("sprite",r),e.pick=this._pick.bind(this),{geometry:e,material:t,mode:ul.Mesh.POINTS,sizeScale:1}},{_pick:function(e,t,r,n,i,a){var o=this._positionNDC;if(o)for(var s=r.viewport,l=2/s.width,u=2/s.height,h=this.geometry.vertexCount-1;h>=0;h--){var c,d=o[2*(c=this.geometry.indices?this.geometry.indices[h]:h)],f=o[2*c+1],p=this.geometry.attributes.size.get(c)/this.sizeScale/2;if(e>d-p*l&&e<d+p*l&&t>f-p*u&&t<f+p*u){var m=new ul.Vector3,g=new ul.Vector3;this.geometry.attributes.position.get(c,m.array),ul.Vector3.transformMat4(g,m,this.worldTransform),a.push({vertexIndex:c,point:m,pointWorld:g,target:this,distance:g.distance(n.getWorldPosition())})}}},updateNDCPosition:function(e,t,r){var n=this._positionNDC,i=this.geometry;n&&n.length/2===i.vertexCount||(n=this._positionNDC=new Float32Array(2*i.vertexCount));for(var a=kd.create(),o=0;o<i.vertexCount;o++)i.attributes.position.get(o,a),a[3]=1,kd.transformMat4(a,a,e.array),kd.scale(a,a,1/a[3]),n[2*o]=a[0],n[2*o+1]=a[1]}});function Gd(e,t){this.rootNode=new ul.Node,this.is2D=e,this._labelsBuilder=new tc(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}Gd.prototype={constructor:Gd,highlightOnMouseover:!0,update:function(e,t,r,n,i){var a=this._prevMesh;this._prevMesh=this._mesh,this._mesh=a;var o=e.getData();if(null==n&&(n=0),null==i&&(i=o.count()),this._startDataIndex=n,this._endDataIndex=i-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new Ud({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 h=this._getSymbolInfo(e,n,i),c=r.getDevicePixelRatio(),d=e.getModel("itemStyle").getItemStyle(),f=e.get("large"),p=1;h.maxSize>2?(p=this._updateSymbolSprite(e,d,h,c),s.enableTexture("sprite")):s.disableTexture("sprite"),u.position.init(i-n);var m=[];if(f){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var g=function(e){var t=e.getVisual("style");if(t)return t[e.getVisual("drawType")]}(o),v=function(e){return e.getVisual("style").opacity}(o);ul.parseColor(g,m),m[3]*=v,s.set({color:m,u_Size:h.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),u.size.init(i-n),u.color.init(i-n),this._originalOpacity=new Float32Array(i-n);for(var _=o.getLayout("points"),y=u.position.value,x=0;x<i-n;x++){var b=3*x,w=2*x;if(this.is2D?(y[b]=_[w],y[b+1]=_[w+1],y[b+2]=-10):(y[b]=_[b],y[b+1]=_[b+1],y[b+2]=_[b+2]),!f){g=$h(o,x),v=ec(o,x);ul.parseColor(g,m),m[3]*=v,u.color.set(x,m),m[3];var T=o.getItemVisual(x,"symbolSize");T=T instanceof Array?Math.max(T[0],T[1]):T,isNaN(T)&&(T=0),u.size.value[x]=T*p*this._sizeScale,this._originalOpacity[x]=m[3]}}this._mesh.sizeScale=p,l.updateBoundingBox(),l.dirty(),this._updateMaterial(e,d);var S=e.coordinateSystem;S&&S.viewGL&&s[S.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE");f||this._updateLabelBuilder(e,n,i),this._updateHandler(e,t,r),this._updateAnimation(e),this._api=r},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,r,n){r.maxSize=Math.min(2*r.maxSize,200);var i,a,o=[];return r.aspect>1?(o[0]=r.maxSize,o[1]=r.maxSize/r.aspect):(o[1]=r.maxSize,o[0]=r.maxSize*r.aspect),o[0]=o[0]||1,o[1]=o[1]||1,this._symbolType===r.type&&(i=this._symbolSize,a=o,i&&a&&i[0]===a[0]&&i[1]===a[1])&&this._lineWidth===t.lineWidth||(Bd.createSymbolSprite(r.type,o,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(o[0]/2,10)},this._spriteImageCanvas),Bd.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=r.type,this._symbolSize=o,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/r.maxSize*n},_updateMaterial:function(e,t){var r="lighter"===e.get("blendMode")?ul.additiveBlend:null,n=this._mesh.material;n.blend=r,n.set("lineWidth",t.lineWidth/20);var i=ul.parseColor(t.stroke);n.set("strokeColor",i),n.transparent=!0,n.depthMask=!1,n.depthTest=!this.is2D,n.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,r){var n=e.getData(),i=this._mesh.geometry,a=i.attributes.position.value,o=(t=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(n,t,r),this._labelsBuilder.getLabelPosition=function(e,r,n){var i=3*(e-t);return[a[i],a[i+1],a[i+2]]},this._labelsBuilder.getLabelDistance=function(e,r,n){return i.attributes.size.get(e-t)/o/2+n},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){ul.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,r){var n,i=e.getData(),a=this._mesh,o=this,s=-1,l=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;l&&(n=e.coordinateSystem.model),a.seriesIndex=e.seriesIndex,a.off("mousemove"),a.off("mouseout"),a.on("mousemove",function(t){var u=t.vertexIndex+o._startDataIndex;u!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,u),this._labelsBuilder.updateLabels([u])),l&&r.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:n.componentIndex})),a.dataIndex=u,s=u},this),a.on("mouseout",function(e){var t=e.vertexIndex+o._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,a.dataIndex=-1,l&&r.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:n.componentIndex})},this)},updateLayout:function(e,t,r){var n=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,a=n.getLayout("points");if(this.is2D)for(var o=0;o<a.length/2;o++){var s=3*o,l=2*o;i[s]=a[l],i[s+1]=a[l+1],i[s+2]=-10}else for(o=0;o<a.length;o++)i[o]=a[o];this._mesh.geometry.dirty(),r.getZr().refresh()}},updateView:function(e){if(this._mesh){var t=new Ta;Ta.mul(t,e.viewMatrix,this._mesh.worldTransform),Ta.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 r=e.getItemModel(t).getModel("emphasis.itemStyle"),n=r.get("color"),i=r.get("opacity");if(null==n){var a=$h(e,t);n=Le(a,-.4)}null==i&&(i=ec(e,t));var o=ul.parseColor(n);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 r=$h(e,t),n=ec(e,t),i=ul.parseColor(r);i[3]*=n,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,r=0;r<t.vertexCount;r++){var n=this._originalOpacity[r]*e;t.attributes.color.value[4*r+3]=n}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 r=this._mesh.geometry.attributes;if(r.size.value)for(var n=0;n<r.size.value.length;n++)r.size.value[n]=r.size.value[n]/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,r){if(e.get("large"))return(u=Vs(e.get("symbolSize"),1))instanceof Array?(o=Math.max(u[0],u[1]),n=u[0]/u[1]):(o=u,n=1),{maxSize:u,type:e.get("symbol"),aspect:n};for(var n,i=e.getData(),a=i.getItemVisual(0,"symbol")||"circle",o=0,s=t;s<r;s++){var l,u=i.getItemVisual(s,"symbolSize"),h=i.getItemVisual(s,"symbol");if(u instanceof Array)l=u[0]/u[1],o=Math.max(Math.max(u[0],u[1]),o);else{if(isNaN(u))continue;l=1,o=Math.max(u,o)}a=h,n=l}return{maxSize:o,type:a,aspect:n}}};var Hd=je.extend({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(e,t,r){if(this.groupGL.removeAll(),e.getData().count()){var n=e.coordinateSystem;if(n&&n.viewGL){n.viewGL.add(this.groupGL),this._camera=n.viewGL.camera;var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new Gd(!1,r)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),i.update(e,t,r),i.updateView(n.viewGL.camera)}}},incrementalPrepareRender:function(e,t,r){var n=e.coordinateSystem;n&&n.viewGL&&(n.viewGL.add(this.groupGL),this._camera=n.viewGL.camera),this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(e,t,r,n){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new Gd(!1,n),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),i.update(t,r,n,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,r,n){this._toggleStatus("highlight",e,t,r,n)},downplay:function(e,t,r,n){this._toggleStatus("downplay",e,t,r,n)},_toggleStatus:function(e,t,r,n,i){var a=t.getData(),o=Ws(a,i),s="highlight"===e;null!=o?re(fd.normalizeToArray(o),function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var r=this._pointsBuilderList[t];s?r.highlight(a,e):r.downplay(a,e)}},this):a.each(function(e){for(var t=0;t<this._pointsBuilderList.length;t++){var r=this._pointsBuilderList[t];s?r.highlight(a,e):r.downplay(a,e)}})},dispose:function(){this._pointsBuilderList.forEach(function(e){e.dispose()}),this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});W(function(e){e.registerChartView(Hd),e.registerSeriesModel(Rd),e.registerLayout({seriesType:"scatter3D",reset:function(e){var t=e.coordinateSystem;if(t){var r=t.dimensions;if(r.length<3)return;var n=r.map(function(t){return e.coordDimToDataDim(t)[0]}),i=[],a=[];return{progress:function(e,r){for(var o=new Float32Array(3*(e.end-e.start)),s=e.start;s<e.end;s++){var l=3*(s-e.start);i[0]=r.get(n[0],s),i[1]=r.get(n[1],s),i[2]=r.get(n[2],s),t.dataToPoint(i,a),o[l]=a[0],o[l+1]=a[1],o[l+2]=a[2]}r.setLayout("points",o)}}}}})});var Vd=Nl.vec3,Wd=Nl.vec2,jd=Vd.normalize,Xd=Vd.cross,qd=Vd.sub,Zd=Vd.add,Yd=Vd.create,Kd=Yd(),Qd=Yd(),Jd=Yd(),$d=Yd(),ef=[],tf=[];function rf(e,t){Wd.copy(ef,e[0]),Wd.copy(tf,e[1]);var r=[],n=r[0]=Yd(),i=r[1]=Yd(),a=r[2]=Yd(),o=r[3]=Yd();t.dataToPoint(ef,n),t.dataToPoint(tf,o),jd(Kd,n),qd(Qd,o,n),jd(Qd,Qd),Xd(Jd,Qd,Kd),jd(Jd,Jd),Xd(Qd,Kd,Jd),Zd(i,Kd,Qd),jd(i,i),jd(Kd,o),qd(Qd,n,o),jd(Qd,Qd),Xd(Jd,Qd,Kd),jd(Jd,Jd),Xd(Qd,Kd,Jd),Zd(a,Kd,Qd),jd(a,a),Zd($d,n,o),jd($d,$d);var s=Vd.dot(n,$d),l=Vd.dot($d,i),u=(Math.max(Vd.len(n),Vd.len(o))-s)/l*2;return Vd.scaleAndAdd(i,n,i,u),Vd.scaleAndAdd(a,o,a,u),r}function nf(e,t){for(var r=new Float32Array(3*e.length),n=0,i=[],a=0;a<e.length;a++)t.dataToPoint(e[a],i),r[n++]=i[0],r[n++]=i[1],r[n++]=i[2];return r}function af(e){var t=[];return e.each(function(r){var n=e.getItemModel(r),i=n.option instanceof Array?n.option:n.getShallow("coords",!0);t.push(i)}),{coordsList:t}}function of(e,t,r){var n=e.getData(),i=e.get("polyline"),a=af(n);n.setLayout("lineType",i?"polyline":"cubicBezier"),n.each(function(e){var o=a.coordsList[e],s=i?nf(o,t):function(e,t,r){var n=[],i=n[0]=Vd.create(),a=n[1]=Vd.create(),o=n[2]=Vd.create(),s=n[3]=Vd.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var l=Vd.dist(i,s);return Vd.lerp(a,i,s,.3),Vd.lerp(o,i,s,.3),Vd.scaleAndAdd(a,a,r,Math.min(.1*l,10)),Vd.scaleAndAdd(o,o,r,Math.min(.1*l,10)),n}(o,t,r);n.setItemLayout(e,s)})}function sf(e,t){e.eachSeriesByType("lines3D",function(e){var t=e.coordinateSystem;"globe"===t.type?function(e,t){var r=e.getData(),n=e.get("polyline");r.setLayout("lineType",n?"polyline":"cubicBezier");var i=af(r);r.each(function(e){var a=i.coordsList[e],o=n?nf:rf;r.setItemLayout(e,o(a,t))})}(e,t):"geo3D"===t.type?of(e,t,[0,1,0]):"mapbox3D"!==t.type&&"maptalks3D"!==t.type||of(e,t,[0,0,1])})}var lf=We.extend({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",visualDrawType:"stroke",getInitialData:function(e,t){var r=new De(["value"],this);return r.hasItemOption=!1,r.initData(e.data,[],function(e,t,n,i){if(e instanceof Array)return NaN;r.hasItemOption=!0;var a=e.value;return null!=a?a instanceof Array?a[i]:a:void 0}),r},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}}}),uf=Nl.vec3;function hf(e){return e>0?1:-1}ul.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 cf=ul.Mesh.extend(function(){var e=new ul.Material({shader:new ul.Shader(ul.Shader.source("ecgl.trail2.vertex"),ul.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new Bl({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,r){var n=e.hostModel,i=this.geometry,a=n.getModel("effect"),o=a.get("trailWidth")*t.getDevicePixelRatio(),s=a.get("trailLength"),l=n.get("effect.constantSpeed"),u=1e3*n.get("effect.period"),h=null!=l;h?this.material.set("speed",l/1e3):this.material.set("period",u),this.material[h?"define":"undefine"]("vertex","CONSTANT_SPEED");var c=n.get("polyline");i.trailLength=s,this.material.set("trailLength",s),i.resetOffset(),["position","positionPrev","positionNext"].forEach(function(e){i.attributes[e].value=r.attributes[e].value});["dist","distAll","start","offset","color"].forEach(function(e){i.attributes[e].init(i.vertexCount)}),i.indices=r.indices;var d=[],f=a.get("trailColor"),p=a.get("trailOpacity"),m=null!=f,g=null!=p;this.updateWorldTransform();var v=this.worldTransform.x.len(),_=this.worldTransform.y.len(),y=this.worldTransform.z.len(),x=0,b=0;e.each(function(t){var n=e.getItemLayout(t),a=g?p:ec(e,t),s=$h(e,t);null==a&&(a=1),(d=ul.parseColor(m?f:s,d))[3]*=a;for(var l=c?r.getPolylineVertexCount(n):r.getCubicCurveVertexCount(n[0],n[1],n[2],n[3]),w=0,T=[],S=[],M=x;M<x+l;M++)i.attributes.position.get(M,T),T[0]*=v,T[1]*=_,T[2]*=y,M>x&&(w+=uf.dist(T,S)),i.attributes.dist.set(M,w),uf.copy(S,T);b=Math.max(b,w);var A=Math.random()*(h?w:u);for(M=x;M<x+l;M++)i.attributes.distAll.set(M,w),i.attributes.start.set(M,A),i.attributes.offset.set(M,hf(r.attributes.offset.get(M))*o/2),i.attributes.color.set(M,d);x+=l}),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",a.get("spotIntensity")),i.dirty()},setAnimationTime:function(e){this.material.set("time",e)}});ul.Shader.import(Jl);var df=je.extend({type:"lines3D",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this._meshLinesMaterial=new ul.Material({shader:ul.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new ul.Mesh({geometry:new Bl,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new cf},render:function(e,t,r){this.groupGL.add(this._linesMesh);var n=e.coordinateSystem,i=e.getData();if(n&&n.viewGL){n.viewGL.add(this.groupGL),this._updateLines(e,t,r);var a=n.viewGL.isLinearSpace()?"define":"undefine";this._linesMesh.material[a]("fragment","SRGB_DECODE"),this._trailMesh.material[a]("fragment","SRGB_DECODE")}var o=this._trailMesh;if(o.stopAnimation(),e.get("effect.show")){this.groupGL.add(o),o.updateData(i,r,this._linesMesh.geometry),o.__time=o.__time||0;var s=36e5;this._curveEffectsAnimator=o.animate("",{loop:!0}).when(s,{__time:s}).during(function(){o.setAnimationTime(o.__time)}).start()}else this.groupGL.remove(o),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===e.get("blendMode")?ul.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,r){var n=e.getData(),i=e.coordinateSystem,a=this._linesMesh.geometry,o=e.get("polyline");a.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);a.segmentScale=s/20;var l="lineStyle.width".split("."),u=r.getDevicePixelRatio();n.each(function(e){var t=n.getItemModel(e).get(l);null==t&&(t=1),n.setItemVisual(e,"lineWidth",t)}),a.useNativeLine=!1;var h=0,c=0;n.each(function(e){var t=n.getItemLayout(e);o?(h+=a.getPolylineVertexCount(t),c+=a.getPolylineTriangleCount(t)):(h+=a.getCubicCurveVertexCount(t[0],t[1],t[2],t[3]),c+=a.getCubicCurveTriangleCount(t[0],t[1],t[2],t[3]))}),a.setVertexCount(h),a.setTriangleCount(c),a.resetOffset();var d=[];n.each(function(e){var t=n.getItemLayout(e),r=$h(n,e),i=ec(n,e),s=n.getItemVisual(e,"lineWidth")*u;null==i&&(i=1),(d=ul.parseColor(r,d))[3]*=i,o?a.addPolyline(t,d,s):a.addCubicCurve(t[0],t[1],t[2],t[3],d,s)}),a.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function ff(e){e.registerChartView(df),e.registerSeriesModel(lf),e.registerLayout(sf),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(){})}function pf(e,t){for(var r=[],n=0;n<t.length;n++)r.push(e.dataToPoint(t[n]));return r}W(ff);var mf=We.extend({type:"series.polygons3D",getRegionModel:function(e){return this.getData().getItemModel(e)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,r=this.getData().getItemModel(e),n=r.option instanceof Array?r.option:r.getShallow("coords");r.get("multiPolygon")||(n=[n]);for(var i=[],a=0;a<n.length;a++){for(var o=[],s=1;s<n[a].length;s++)o.push(pf(t,n[a][s]));i.push({exterior:pf(t,n[a][0]),interiors:o})}return i},getInitialData:function(e){var t=new De(["value"],this);return t.hasItemOption=!1,t.initData(e.data,[],function(e,r,n,i){if(e instanceof Array)return NaN;t.hasItemOption=!0;var a=e.value;return null!=a?a instanceof Array?a[i]:a: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}}}});ue(mf.prototype,_h);var gf=je.extend({type:"polygons3D",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(e,t,r){this.groupGL.removeAll();var n=e.coordinateSystem;n&&n.viewGL&&n.viewGL.add(this.groupGL);var i=this._geo3DBuilderList[0];i||((i=new nc(r)).extrudeY="mapbox3D"!==n.type&&"maptalks3D"!==n.type,this._geo3DBuilderList[0]=i),this._updateShaderDefines(n,i),i.update(e,t,r),this._geo3DBuilderList.length=1,this.groupGL.add(i.rootNode)},incrementalPrepareRender:function(e,t,r){this.groupGL.removeAll();var n=e.coordinateSystem;n&&n.viewGL&&n.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(e,t,r,n){var i=this._geo3DBuilderList[this._currentStep],a=t.coordinateSystem;i||((i=new nc(n)).extrudeY="mapbox3D"!==a.type&&"maptalks3D"!==a.type,this._geo3DBuilderList[this._currentStep]=i),i.update(t,r,n,e.start,e.end),this.groupGL.add(i.rootNode),this._updateShaderDefines(a,i),this._currentStep++},_updateShaderDefines:function(e,t){var r=e.viewGL.isLinearSpace()?"define":"undefine";t.rootNode.traverse(function(t){t.material&&(t.material[r]("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()})}});W(function(e){e.registerChartView(gf),e.registerSeriesModel(mf)});var vf=We.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return pd(this,e)},getInitialData:function(e,t){var r=e.data;function n(e){return!(isNaN(e.min)||isNaN(e.max)||isNaN(e.step))}function i(e){var t=ve;return Math.max(t(e.min),t(e.max),t(e.step))+1}if(!r)if(e.parametric){var a=e.parametricEquation||{},o=a.u||{},s=a.v||{};["u","v"].forEach(function(e){n(a[e])}),["x","y","z"].forEach(function(e){a[e]});var l=Math.floor((o.max+o.step-o.min)/o.step),u=Math.floor((s.max+s.step-s.min)/s.step);r=new Float32Array(l*u*5);var h=i(o),c=i(s);for(T=0,S=0;S<u;S++)for(M=0;M<l;M++){var d=M*o.step+o.min,f=S*s.step+s.min,p=Ze(Math.min(d,o.max),h),m=Ze(Math.min(f,s.max),c);A=a.x(p,m),E=a.y(p,m),L=a.z(p,m);r[T++]=A,r[T++]=E,r[T++]=L,r[T++]=p,r[T++]=m}}else{var g=e.equation||{},v=g.x||{},_=g.y||{};if(["x","y"].forEach(function(e){n(g[e])}),"function"!=typeof g.z)return;var y=Math.floor((v.max+v.step-v.min)/v.step),x=Math.floor((_.max+_.step-_.min)/_.step);r=new Float32Array(y*x*3);for(var b=i(v),w=i(_),T=0,S=0;S<x;S++)for(var M=0;M<y;M++){var A=M*v.step+v.min,E=S*_.step+_.min,C=Ze(Math.min(A,v.max),b),D=Ze(Math.min(E,_.max),w),L=g.z(C,D);r[T++]=C,r[T++]=D,r[T++]=L}}var P=["x","y","z"];return e.parametric&&P.push("u","v"),md(this,P,r)},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}});ue(vf.prototype,_h);var _f=Nl.vec3;function yf(e){return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])}var xf=je.extend({type:"surface",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node},render:function(e,t,r){var n=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=n,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var i=e.coordinateSystem,a=e.get("shading"),o=e.getData(),s="ecgl."+a;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=ul.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),ul.setMaterialFromModel(a,this._surfaceMesh.material,e,r),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"),h=e.get("dataShape");h||(h=this._getDataShape(o,u));var c=e.getModel("wireframe"),d=c.get("lineStyle.width"),f=c.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,e,h,f);var p=this._surfaceMesh.material;f?(p.define("WIREFRAME_QUAD"),p.set("wireframeLineWidth",d),p.set("wireframeLineColor",ul.parseColor(c.get("lineStyle.color")))):p.undefine("WIREFRAME_QUAD"),this._initHandler(e,r),this._updateAnimation(e)},_updateAnimation:function(e){ul.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new ul.Mesh({geometry:new ul.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new ul.Material({shader:new ul.Shader(ul.Shader.source("ecgl.sm.depth.vertex"),ul.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,Jh),e},_initHandler:function(e,t){var r=e.getData(),n=this._surfaceMesh,i=e.coordinateSystem;n.seriesIndex=e.seriesIndex;var a=-1;n.off("mousemove"),n.off("mouseout"),n.on("mousemove",function(e){var o=function(e,t){for(var r=1/0,i=-1,a=[],o=0;o<e.length;o++){n.geometry.attributes.position.get(e[o],a);var s=_f.dist(t.array,a);s<r&&(r=s,i=e[o])}return i}(e.triangle,e.point);if(o>=0){var s=[];n.geometry.attributes.position.get(o,s);for(var l=i.pointToData(s),u=1/0,h=-1,c=[],d=0;d<r.count();d++){c[0]=r.get("x",d),c[1]=r.get("y",d),c[2]=r.get("z",d);var f=_f.squaredDistance(c,l);f<u&&(h=d,u=f)}h!==a&&t.dispatchAction({type:"grid3DShowAxisPointer",value:l}),a=h,n.dataIndex=h}else n.dataIndex=-1},this),n.on("mouseout",function(e){a=-1,n.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_updateSurfaceMesh:function(e,t,r,n){var i=e.geometry,a=t.getData(),o=a.getLayout("points"),s=0;a.each(function(e){a.hasValue(e)||s++});var l=s||n,u=i.attributes.position,h=i.attributes.normal,c=i.attributes.texcoord0,d=i.attributes.barycentric,f=i.attributes.color,p=r[0],m=r[1],g="color"!==t.get("shading");if(l){var v=(p-1)*(m-1)*4;u.init(v),n&&d.init(v)}else u.value=new Float32Array(o);f.init(i.vertexCount),c.init(i.vertexCount);var _=[0,3,1,1,3,2],y=[[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)((p-1)*(m-1)*6),b=function(e,t,r){r[1]=e*m+t,r[0]=e*m+t+1,r[3]=(e+1)*m+t+1,r[2]=(e+1)*m+t},w=!1;if(l){var T=[],S=[],M=0;g?h.init(i.vertexCount):h.value=null;for(var A=[[],[],[]],E=[],C=[],D=_f.create(),L=function(e,t,r){var n=3*t;return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r},P=new Float32Array(o.length),O=new Float32Array(o.length/3*4),N=0;N<a.count();N++)if(a.hasValue(N)){var R=ul.parseColor($h(a,N));null!=(j=ec(a,N))&&(R[3]*=j),R[3]<.99&&(w=!0);for(var I=0;I<4;I++)O[4*N+I]=R[I]}var B=[1e7,1e7,1e7];for(N=0;N<p-1;N++)for(var z=0;z<m-1;z++){var F=4*(N*(m-1)+z);b(N,z,T);var k=!1;for(I=0;I<4;I++)L(o,T[I],S),yf(S)&&(k=!0);for(I=0;I<4;I++)k?u.set(F+I,B):(L(o,T[I],S),u.set(F+I,S)),n&&d.set(F+I,y[I]);for(I=0;I<6;I++)x[M++]=_[I]+F;if(g&&!k)for(I=0;I<2;I++){for(var U=3*I,G=0;G<3;G++){L(o,W=T[_[U]+G],A[G])}_f.sub(E,A[0],A[1]),_f.sub(C,A[1],A[2]),_f.cross(D,E,C);for(G=0;G<3;G++){var H=3*T[_[U]+G];P[H]=P[H]+D[0],P[H+1]=P[H+1]+D[1],P[H+2]=P[H+2]+D[2]}}}if(g)for(N=0;N<P.length/3;N++)L(P,N,D),_f.normalize(D,D),P[3*N]=D[0],P[3*N+1]=D[1],P[3*N+2]=D[2];R=[];var V=[];for(N=0;N<p-1;N++)for(z=0;z<m-1;z++){F=4*(N*(m-1)+z);b(N,z,T);for(I=0;I<4;I++){for(G=0;G<4;G++)R[G]=O[4*T[I]+G];f.set(F+I,R),g&&(L(P,T[I],D),h.set(F+I,D));var W=T[I];V[0]=W%m/(m-1),V[1]=Math.floor(W/m)/(p-1),c.set(F+I,V)}0}}else{for(V=[],N=0;N<a.count();N++){V[0]=N%m/(m-1),V[1]=Math.floor(N/m)/(p-1);var j;R=ul.parseColor($h(a,N));null!=(j=ec(a,N))&&(R[3]*=j),R[3]<.99&&(w=!0),f.set(N,R),c.set(N,V)}T=[];var X=0;for(N=0;N<p-1;N++)for(z=0;z<m-1;z++){b(N,z,T);for(I=0;I<6;I++)x[X++]=T[_[I]]}g?i.generateVertexNormals():h.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 r=-1/0,n=0,i=0,a=!1,o=t?"u":"x",s=e.count(),l=0;l<s;l++){var u=e.get(o,l);u<r&&(i=0,n++),r=u,i++}if(n&&1!==i||(a=!0),!a)return[n+1,i];for(var h=Math.floor(Math.sqrt(s));h>0;){if(Math.floor(s/h)===s/h)return[h,s/h];h--}return[h=Math.floor(Math.sqrt(s)),h]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function bf(e,t){for(var r=[],n=0;n<t.length;n++)r.push(e.dataToPoint(t[n]));return r}W(function(e){e.registerChartView(xf),e.registerSeriesModel(vf),e.registerLayout(function(e,t){e.eachSeriesByType("surface",function(e){var t=e.coordinateSystem;!t||t.type;var r=e.getData(),n=new Float32Array(3*r.count()),i=[NaN,NaN,NaN];if(t&&"cartesian3D"===t.type){var a=t.dimensions.map(function(t){return e.coordDimToDataDim(t)[0]});r.each(a,function(e,a,o,s){var l;l=r.hasValue(s)?t.dataToPoint([e,a,o]):i,n[3*s]=l[0],n[3*s+1]=l[1],n[3*s+2]=l[2]})}r.setLayout("points",n)})})});var wf=We.extend({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(e){var t=this.get("coordinateSystem");null!=t&&"geo3D"!==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=Ce(e.data,{coordDimensions:["value"]}),r=new De(t,this);r.initData(e.data);var n={};return r.each(function(e){var t=r.getName(e),i=r.getItemModel(e);n[t]=i}),this._regionModelMap=n,r},formatTooltip:function(e){return pd(this,e)},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new fe(null,this)},getRegionPolygonCoords:function(e){var t=this.coordinateSystem,r=this.getData().getName(e);if(t.transform)return(n=t.getRegion(r))?n.geometries:[];this._geo||(this._geo=fc.createGeo3D(this));for(var n=this._geo.getRegion(r),i=[],a=0;a<n.geometries.length;a++){var o=n.geometries[a],s=[],l=bf(t,o.exterior);if(s&&s.length)for(var u=0;u<o.interiors.length;u++)s.push(bf(t,s[u]));i.push({interiors:s,exterior:l})}return i},getFormattedLabel:function(e,t){var r=fd.getFormattedLabel(this,e,t);return null==r&&(r=this.getData().getName(e)),r},defaultOption:{coordinateSystem:"geo3D",data:null}});ue(wf.prototype,yh),ue(wf.prototype,Sl),ue(wf.prototype,Ml),ue(wf.prototype,Al),ue(wf.prototype,_h);var Tf=je.extend({type:"map3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new nc(t),this.groupGL=new ul.Node},render:function(e,t,r){var n=e.coordinateSystem;if(n&&n.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),n.viewGL.add(this.groupGL),"geo3D"===n.type){this._sceneHelper||(this._sceneHelper=new kl,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var i=this._control;i||(i=this._control=new Pl({zr:r.getZr()}),this._control.init());var a=e.getModel("viewControl");i.setViewGL(n.viewGL),i.setFromViewControlModel(a,0),i.off("update"),i.on("update",function(){r.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,r,0,e.getData().count());var o=n.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse(function(e){e.material&&e.material[o]("fragment","SRGB_DECODE")})}},afterRender:function(e,t,r,n){var i=n.renderer,a=e.coordinateSystem;a&&"geo3D"===a.type&&(this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r))},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._geo3DBuilder.dispose()}});W(function(e){pc(e),e.registerChartView(Tf),e.registerSeriesModel(wf),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 Sf=We.extend({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(){return Ye(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 Mf(e){this.viewGL=e}Mf.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=Ke(),this.updateTransform(e,t)},Mf.prototype.updateTransform=function(e,t){var r=e.coordinateSystem;r.getRoamTransform&&(Qe(this._viewTransform,r.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},Mf.prototype.dataToPoint=function(e,t,r){r=e.dataToPoint(t,null,r);var n=this._viewTransform;n&&Je(r,r,n)},Mf.prototype.removeTransformInPoint=function(e){return this._viewTransform&&Je(e,e,this._viewTransform),e},Mf.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},Mf.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)},Mf.prototype._updateCamera=function(e,t,r){this.viewGL.setViewport(0,0,e,t,r);var n=this.viewGL.camera;n.left=n.top=0,n.bottom=t,n.right=e,n.near=0,n.far=100};var Af=je.extend({type:"scatterGL",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this.viewGL=new ih("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new Mf(this.viewGL)},render:function(e,t,r){if(this.groupGL.removeAll(),this._glViewHelper.reset(e,r),e.getData().count()){var n=this._pointsBuilderList[0];n||(n=this._pointsBuilderList[0]=new Gd(!0,r)),this._pointsBuilderList.length=1,this.groupGL.add(n.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),n.update(e,t,r),this.viewGL.setPostEffect(e.getModel("postEffect"),r)}},incrementalPrepareRender:function(e,t,r){this.groupGL.removeAll(),this._glViewHelper.reset(e,r),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),r)},incrementalRender:function(e,t,r,n){if(!(e.end<=e.start)){var i=this._pointsBuilderList[this._currentStep];i||(i=new Gd(!0,n),this._pointsBuilderList[this._currentStep]=i),this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.setSizeScale(this._sizeScale),i.update(t,r,n,e.start,e.end),n.getZr().refresh(),this._currentStep++}},updateTransform:function(e,t,r){if(e.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(e,r);var n=this._glViewHelper.getZoom(),i=Math.max((e.get("zoomScale")||0)*(n-1)+1,0);this._sizeScale=i,this._pointsBuilderList.forEach(function(e){e.setSizeScale(i)})}},_removeTransformInPoints:function(e){if(e)for(var t=[],r=0;r<e.length;r+=2)t[0]=e[r],t[1]=e[r+1],this._glViewHelper.removeTransformInPoint(t),e[r]=t[0],e[r+1]=t[1]},dispose:function(){this.groupGL.removeAll(),this._pointsBuilderList.forEach(function(e){e.dispose()})},remove:function(){this.groupGL.removeAll()}});W(function(e){e.registerChartView(Af),e.registerSeriesModel(Sf),e.registerLayout({seriesType:"scatterGL",reset:function(e){var t,r=e.coordinateSystem,n=e.getData();if(r){var i=r.dimensions.map(function(e){return n.mapDimension(e)}).slice(0,2),a=[];1===i.length?t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),a=e.start;a<e.end;a++){var o=2*(a-e.start),s=n.get(i[0],a),l=r.dataToPoint(s);t[o]=l[0],t[o+1]=l[1]}n.setLayout("points",t)}:2===i.length&&(t=function(e){for(var t=new Float32Array(2*(e.end-e.start)),o=e.start;o<e.end;o++){var s=2*(o-e.start),l=n.get(i[0],o),u=n.get(i[1],o);a[0]=l,a[1]=u,a=r.dataToPoint(a),t[s]=a[0],t[s+1]=a[1]}n.setLayout("points",t)})}return{progress:t}}})});var Ef=We.extend({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(e){Ef.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(e){Ef.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(e,t,r,n){var i=fd.getFormattedLabel(this,e,t,r,n);if(null==i){var a=this.getData(),o=a.dimensions[a.dimensions.length-1];i=a.get(o,e)}return i},getInitialData:function(e,t){var r=e.edges||e.links||[],n=e.data||e.nodes||[],i=this;if(n&&r)return function(e,t,r,n,i){for(var a=new et(n),o=0;o<e.length;o++)a.addNode(Vs(e[o].id,e[o].name,o),o);var s,l=[],u=[],h=0;for(o=0;o<t.length;o++){var c=t[o],d=c.source,f=c.target;a.addEdge(d,f,h)&&(u.push(c),l.push(Vs(c.id,d+" > "+f)),h++)}var p=Ce(e,{coordDimensions:["value"]});(s=new De(p,r)).initData(e);var m=new De(["value"],r);return m.initData(u,l),i&&i(s,m),$e({mainData:s,struct:a,structAttr:"graph",datas:{node:s,edge:m},datasAttr:{node:"data",edge:"edgeData"}}),a.update(),a}(n,r,this,!0,function(e,r){e.wrapMethod("getItemModel",function(e){var t=i._categoriesModels[e.getShallow("category")];return t&&(t.parentModel=e.parentModel,e.parentModel=t),e});var n=t.getModel([]).getModel;function a(e,t){var r=n.call(this,e,t);return r.resolveParentPath=o,r}function o(e){if(e&&("label"===e[0]||"label"===e[1])){var t=e.slice();return"label"===e[0]?t[0]="edgeLabel":"label"===e[1]&&(t[1]="edgeLabel"),t}return e}r.wrapMethod("getItemModel",function(e){return e.resolveParentPath=o,e.getModel=a,e})}).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(e,t,r){if("edge"===r){var n=this.getData(),i=this.getDataParams(e,r),a=n.graph.getEdgeByIndex(e),o=n.getName(a.node1.dataIndex),s=n.getName(a.node2.dataIndex),l=[];return null!=o&&l.push(o),null!=s&&l.push(s),l=Fe(l.join(" > ")),i.value&&(l+=" : "+Fe(i.value)),l}return Ef.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 De(["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 r=e[2*t],n=e[2*t+1],i=this.getData().getRawDataItem(t);i.x=r,i.y=n}},isAnimationEnabled:function(){return Ef.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}}),Cf=Nl.vec2,Df=[[0,0],[1,1]],Lf=mo.extend(function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new mo.Attribute("position","float",2,"POSITION"),normal:new mo.Attribute("normal","float",2),offset:new mo.Attribute("offset","float",1),color:new mo.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,r,n){return 1/(Cf.dist(e,t)+Cf.dist(r,t)+Cf.dist(n,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(Df)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Df)},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,r,n,i,a){null==a&&(a=1);var o=e[0],s=e[1],l=t[0],u=t[1],h=r[0],c=r[1],d=n[0],f=n[1],p=this._getCubicCurveApproxStep(e,t,r,n),m=p*p,g=m*p,v=3*p,_=3*m,y=6*m,x=6*g,b=o-2*l+h,w=s-2*u+c,T=3*(l-h)-o+d,S=3*(u-c)-s+f,M=o,A=s,E=(l-o)*v+b*_+T*g,C=(u-s)*v+w*_+S*g,D=b*y+T*x,L=w*y+S*x,P=T*x,O=S*x,N=0,R=0,I=Math.ceil(1/p),B=new Float32Array(3*(I+1)),z=(B=[],0);for(R=0;R<I+1;R++)B[z++]=M,B[z++]=A,M+=E,A+=C,E+=D,C+=L,D+=P,L+=O,(N+=p)>1&&(M=E>0?Math.min(M,d):Math.max(M,d),A=C>0?Math.min(A,f):Math.max(A,f));this.addPolyline(B,i,a)},addLine:function(e,t,r,n){this.addPolyline([e,t],r,n)},addPolyline:function(){var e=Cf.create(),t=Cf.create(),r=Cf.create(),n=Cf.create(),i=[],a=[],o=[];return function(s,l,u,h,c){if(s.length){var d="number"!=typeof s[0];if(null==c&&(c=d?s.length:s.length/2),!(c<2)){null==h&&(h=0),null==u&&(u=1),this._itemVertexOffsets.push(this._vertexOffset);for(var f,p=d?"number"!=typeof l[0]:l.length/4===c,m=this.attributes.position,g=this.attributes.color,v=this.attributes.offset,_=this.attributes.normal,y=this.indices,x=this._vertexOffset,b=0;b<c;b++){if(d)i=s[b+h],f=p?l[b+h]:l;else{var w=2*b+h;if((i=i||[])[0]=s[w],i[1]=s[w+1],p){var T=4*b+h;(f=f||[])[0]=l[T],f[1]=l[T+1],f[2]=l[T+2],f[3]=l[T+3]}else f=l}if(this.useNativeLine)b>1&&(m.copy(x,x-1),g.copy(x,x-1),x++);else{var S;if(b<c-1){if(d)Cf.copy(a,s[b+1]);else{w=2*(b+1)+h;(a=a||[])[0]=s[w],a[1]=s[w+1]}if(b>0){Cf.sub(e,i,o),Cf.sub(t,a,i),Cf.normalize(e,e),Cf.normalize(t,t),Cf.add(n,e,t),Cf.normalize(n,n);var M=u/2*Math.min(1/Cf.dot(e,n),2);r[0]=-n[1],r[1]=n[0],S=M}else Cf.sub(e,a,i),Cf.normalize(e,e),r[0]=-e[1],r[1]=e[0],S=u/2}else Cf.sub(e,i,o),Cf.normalize(e,e),r[0]=-e[1],r[1]=e[0],S=u/2;_.set(x,r),_.set(x+1,r),v.set(x,S),v.set(x+1,-S),Cf.copy(o,i),m.set(x,i),m.set(x+1,i),g.set(x,f),g.set(x+1,f),x+=2}if(this.useNativeLine)g.set(x,f),m.set(x,i),x++;else if(b>0){var A=3*this._faceOffset;(y=this.indices)[A]=x-4,y[A+1]=x-3,y[A+2]=x-2,y[A+3]=x-3,y[A+4]=x-1,y[A+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,i=r;i<n;i++)this.attributes.color.set(i,t);this.dirty("color")}});he(Lf.prototype,Ol);ul.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 Pf={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function Of(e){var t={type:ul.Texture.FLOAT,minFilter:ul.Texture.NEAREST,magFilter:ul.Texture.NEAREST};this._positionSourceTex=new ul.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new ul.Texture2D(t),this._positionPrevTex=new ul.Texture2D(t),this._forceTex=new ul.Texture2D(t),this._forcePrevTex=new ul.Texture2D(t),this._weightedSumTex=new ul.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new ul.Texture2D(t),this._globalSpeedPrevTex=new ul.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new Rs({fragment:ul.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new Rs({fragment:ul.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new Rs({fragment:ul.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new Rs({fragment:ul.Shader.source("clay.compositor.output")});var r=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new ul.Mesh({geometry:new ul.Geometry({attributes:{node1:new ul.Geometry.Attribute("node1","float",2),node2:new ul.Geometry.Attribute("node2","float",2),weight:new ul.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new ul.Material({transparent:!0,shader:ul.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:r,depthMask:!1,depthText:!1}),mode:ul.Mesh.POINTS}),this._weightedSumMesh=new ul.Mesh({geometry:new ul.Geometry({attributes:{node:new ul.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new ul.Material({transparent:!0,shader:ul.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:r,depthMask:!1,depthText:!1}),mode:ul.Mesh.POINTS}),this._framebuffer=new ss({depthBuffer:!1}),this._dummyCamera=new ul.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}Of.prototype.updateOption=function(e){for(var t in Pf)this[t]=Pf[t];var r=this._nodes.length;if(this.jitterTolerence=r>5e4?10:r>5e3?1:.1,this.scaling=r>100?2:10,e)for(var t in Pf)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var n=this._positionSourceTex.pixels,i=0;i<this._nodes.length;i++)n[4*i+2]=(this._nodes[i].degree||0)+1},Of.prototype._updateGravityCenter=function(e){var t=this._nodes,r=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var n=[1/0,1/0],i=[-1/0,-1/0],a=0;a<t.length;a++)n[0]=Math.min(t[a].x,n[0]),n[1]=Math.min(t[a].y,n[1]),i[0]=Math.max(t[a].x,i[0]),i[1]=Math.max(t[a].y,i[1]);this._gravityCenter=[.5*(n[0]+i[0]),.5*(n[1]+i[1])]}for(a=0;a<r.length;a++){var o=r[a].node1,s=r[a].node2;t[o].degree=(t[o].degree||0)+1,t[s].degree=(t[s].degree||0)+1}},Of.prototype.initData=function(e,t){this._nodes=e,this._edges=t,this._updateGravityCenter();var r=Math.ceil(Math.sqrt(e.length)),n=r,i=new Float32Array(r*n*4);this._resize(r,n);for(var a=0,o=0;o<e.length;o++){var s=e[o];i[a++]=s.x||0,i[a++]=s.y||0,i[a++]=s.mass||1,i[a++]=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 h=[];for(o=0;o<t.length;o++){var c=l.attributes,d=t[o].weight;null==d&&(d=1),c.node1.set(o,this.getNodeUV(t[o].node1,h)),c.node2.set(o,this.getNodeUV(t[o].node2,h)),c.weight.set(o,d),c.node1.set(o+u,this.getNodeUV(t[o].node2,h)),c.node2.set(o+u,this.getNodeUV(t[o].node1,h)),c.weight.set(o+u,d)}var f=this._weightedSumMesh.geometry;f.attributes.node.init(e.length);for(o=0;o<e.length;o++)f.attributes.node.set(o,this.getNodeUV(o,h));l.dirty(),f.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",e.length),this._nodeRepulsionPass.material.setUniform("textureSize",[r,n]),this._inited=!1,this._frame=0},Of.prototype.getNodes=function(){return this._nodes},Of.prototype.getEdges=function(){return this._edges},Of.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 r=this._edgeForceMesh;r.material.set("linLogMode",this.linLogMode),r.material.set("edgeWeightInfluence",this.edgeWeightInfluence),r.material.set("preventOverlap",this.preventOverlap),r.material.set("positionTex",this._positionPrevTex),e.gl.enable(e.gl.BLEND),e.renderPass([r],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 n=this._weightedSumMesh;n.material.set("positionTex",this._positionPrevTex),n.material.set("forceTex",this._forceTex),n.material.set("forcePrevTex",this._forcePrevTex),e.renderPass([n],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 a=this._positionPass;this._framebuffer.attach(this._positionTex),a.setUniform("globalSpeedTex",this._globalSpeedTex),a.setUniform("positionTex",this._positionPrevTex),a.setUniform("forceTex",this._forceTex),a.setUniform("forcePrevTex",this._forcePrevTex),a.render(e),this._framebuffer.unbind(e),this._swapTexture()},Of.prototype.update=function(e,t,r){null==t&&(t=1),t=Math.max(t,1);for(var n=0;n<t;n++)this.step(e);r&&r()},Of.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},Of.prototype.getNodeUV=function(e,t){t=t||[];var r=this._positionTex.width,n=this._positionTex.height;return t[0]=e%r/(r-1),t[1]=Math.floor(e/r)/(n-1)||0,t},Of.prototype.getNodePosition=function(e,t){var r=this._positionArr,n=this._positionTex.width,i=this._positionTex.height,a=n*i;r&&r.length===4*a||(r=this._positionArr=new Float32Array(4*a)),this._framebuffer.bind(e),this._framebuffer.attach(this._positionPrevTex),e.gl.readPixels(0,0,n,i,e.gl.RGBA,e.gl.FLOAT,r),this._framebuffer.unbind(e),t||(t=new Float32Array(2*this._nodes.length));for(var o=0;o<this._nodes.length;o++)t[2*o]=r[4*o],t[2*o+1]=r[4*o+1];return t},Of.prototype.getTextureData=function(e,t){var r=this["_"+t+"Tex"],n=r.width,i=r.height;this._framebuffer.bind(e),this._framebuffer.attach(r);var a=new Float32Array(n*i*4);return e.gl.readPixels(0,0,n,i,e.gl.RGBA,e.gl.FLOAT,a),this._framebuffer.unbind(e),a},Of.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},Of.prototype.isFinished=function(e){return this._frame>e},Of.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},Of.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)},Of.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach(function(r){this[r].width=e,this[r].height=t,this[r].dirty()},this)},Of.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 Nf=function(){var e=function(){return new Float32Array(2)},t=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)},r=function(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)},n=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},i=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},a=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e},o=function(e,t){return e[0]=t[0],e[1]=t[1],e},s=function(e,t,r){return e[0]=t,e[1]=r,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 h(){this.position=new Float32Array(2),this.force=e(),this.forcePrev=e(),this.mass=1,this.inDegree=0,this.outDegree=0}function c(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 r=0;r<this.nSubRegions;r++){var n=this.subRegions[r];if(n.contain(e,t))return n}},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,r,n){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=r,this.bbox[3]=n,this.size=(r-e+n-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]),r=this.bbox;if(!t){var n=(r[0]+r[2])/2,i=(r[1]+r[3])/2,a=(r[2]-r[0])/2,o=(r[3]-r[1])/2,s=e.position[0]>=n?1:0,l=e.position[1]>=i?1:0;(t=this._newSubRegion()).setBBox(s*a+r[0],l*o+r[1],(s+1)*a+r[0],(l+1)*o+r[1])}t.addNode(e)},u._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,r=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,r+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=r/this.mass};var f=d.prototype;f.initNodes=function(e,t,r){var n=t.length;this.nodes.length=0;for(var i=void 0!==r,a=0;a<n;a++){var o=new h;o.position[0]=e[2*a],o.position[1]=e[2*a+1],o.mass=t[a],i&&(o.size=r[a]),this.nodes.push(o)}this._massArr=t,this._swingingArr=new Float32Array(n),i&&(this._sizeArr=r)},f.initEdges=function(e,t){var r=e.length/2;this.edges.length=0;for(var n=0;n<r;n++){var i=e[2*n],a=e[2*n+1],o=this.nodes[i],s=this.nodes[a];if(!o||!s)return void console.error("Node not exists, try initNodes before initEdges");o.outDegree++,s.inDegree++;var l=new c(o,s);t&&(l.weight=t[n]),this.edges.push(l)}},f.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]}},f.update=function(){var a=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<a;l++)this.rootRegion.addNode(this.nodes[l]);this.rootRegion.afterUpdate()}for(l=0;l<a;l++){var u=this.nodes[l];o(u.forcePrev,u.force),s(u.force,0,0)}for(l=0;l<a;l++){var h=this.nodes[l];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,h);else for(var c=l+1;c<a;c++){var d=this.nodes[c];this.applyNodeToNodeRepulsion(h,d,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(h):this.applyNodeGravity(h))}for(l=0;l<this.edges.length;l++)this.applyEdgeAttraction(this.edges[l]);var f=0,p=0,m=e();for(l=0;l<a;l++){u=this.nodes[l];f+=(v=t(u.force,u.forcePrev))*u.mass,i(m,u.force,u.forcePrev),p+=.5*r(m)*u.mass,this._swingingArr[l]=v}var g=this.jitterTolerence*this.jitterTolerence*p/f;this._globalSpeed>0&&(g=Math.min(g/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=g;for(l=0;l<a;l++){u=this.nodes[l];var v=this._swingingArr[l],_=.1*g/(1+g*Math.sqrt(v)),y=r(u.force);y>0&&(_=Math.min(y*_,10)/y,n(u.position,u.position,u.force,_))}},f.applyRegionToNodeRepulsion=function(){var t=e();return function(e,r){if(e.node)this.applyNodeToNodeRepulsion(e.node,r,!0);else{a(t,r.position,e.centerOfMass);var i=t[0]*t[0]+t[1]*t[1];if(i>this.barnesHutTheta*e.size*e.size){var o=this.scaling*r.mass*e.mass/i;n(r.force,r.force,t,o)}else for(var s=0;s<e.nSubRegions;s++)this.applyRegionToNodeRepulsion(e.subRegions[s],r)}}}(),f.applyNodeToNodeRepulsion=function(){var t=e();return function(e,r,i){if(e!=r){a(t,e.position,r.position);var o=t[0]*t[0]+t[1]*t[1];if(0!==o){var s;if(this.preventOverlap){var l=Math.sqrt(o);if((l=l-e.size-r.size)>0)s=this.scaling*e.mass*r.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*e.mass*r.mass}}else s=this.scaling*e.mass*r.mass/o;n(e.force,e.force,t,s),n(r.force,r.force,t,-s)}}}}(),f.applyEdgeAttraction=function(){var t=e();return function(e){var i=e.source,o=e.target;a(t,i.position,o.position);var s,l,u=r(t);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?e.weight:Math.pow(e.weight,this.edgeWeightInfluence),this.preventOverlap&&(u=u-i.size-o.size)<=0||(l=this.linLogMode?-s*Math.log(u+1)/(u+1):-s,n(i.force,i.force,t,l),n(o.force,o.force,t,-l))}}(),f.applyNodeGravity=function(){var t=e();return function(e){a(t,this.gravityCenter,e.position);var i=r(t);n(e.force,e.force,t,this.gravity*e.mass/(i+1))}}(),f.applyNodeStrongGravity=function(){var t=e();return function(e){a(t,this.gravityCenter,e.position),n(e.force,e.force,t,this.gravity*e.mass)}}(),f.updateBBox=function(){for(var e=1/0,t=1/0,r=-1/0,n=-1/0,i=0;i<this.nodes.length;i++){var a=this.nodes[i].position;e=Math.min(e,a[0]),t=Math.min(t,a[1]),r=Math.max(r,a[0]),n=Math.max(n,a[1])}this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=r,this.bbox[3]=n},f.getGlobalSpeed=function(){return this._globalSpeed};var p=null;self.onmessage=function(e){switch(e.data.cmd){case"init":(p=new d).initNodes(e.data.nodesPosition,e.data.nodesMass,e.data.nodesSize),p.initEdges(e.data.edges,e.data.edgesWeight);break;case"updateConfig":if(p)for(var t in e.data.config)p[t]=e.data.config[t];break;case"update":var r=e.data.steps;if(p){for(var n=0;n<r;n++)p.update();var i=p.nodes.length,a=new Float32Array(2*i);for(n=0;n<i;n++){var o=p.nodes[n];a[2*n]=o.position[0],a[2*n+1]=o.position[1]}self.postMessage({buffer:a.buffer,globalSpeed:p.getGlobalSpeed()},[a.buffer])}else{var s=new Float32Array;self.postMessage({buffer:s.buffer,globalSpeed:p.getGlobalSpeed()},[s.buffer])}}}}.toString();Nf=Nf.slice(Nf.indexOf("{")+1,Nf.lastIndexOf("}"));var Rf={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},If=function(e){for(var t in Rf)this[t]=Rf[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new no({type:Ja.FLOAT,flipY:!1,minFilter:Ja.NEAREST,magFilter:Ja.NEAREST})};If.prototype.initData=function(e,t){var r=new Blob([Nf]),n=window.URL.createObjectURL(r);this._worker=new Worker(n),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,a=t.length,o=new Float32Array(2*i),s=new Float32Array(i),l=new Float32Array(i),u=new Float32Array(2*a),h=new Float32Array(a),c=0;c<e.length;c++){var d=e[c];o[2*c]=d.x,o[2*c+1]=d.y,s[c]=null==d.mass?1:d.mass,l[c]=null==d.size?1:d.size}for(c=0;c<t.length;c++){var f=t[c],p=f.node1,m=f.node2;u[2*c]=p,u[2*c+1]=m,h[c]=null==f.weight?1:f.weight}var g=Math.ceil(Math.sqrt(e.length)),v=g,_=new Float32Array(g*v*4),y=this._positionTex;y.width=g,y.height=v,y.pixels=_,this._worker.postMessage({cmd:"init",nodesPosition:o,nodesMass:s,nodesSize:l,edges:u,edgesWeight:h}),this._globalSpeed=1/0},If.prototype.updateOption=function(e){var t={};for(var r in Rf)t[r]=Rf[r];var n=this._nodes,i=this._edges,a=n.length;if(t.jitterTolerence=a>5e4?10:a>5e3?1:.1,t.scaling=a>100?2:10,t.barnesHutOptimize=a>1e3,e)for(var r in Rf)null!=e[r]&&(t[r]=e[r]);if(!t.gravityCenter){for(var o=[1/0,1/0],s=[-1/0,-1/0],l=0;l<n.length;l++)o[0]=Math.min(n[l].x,o[0]),o[1]=Math.min(n[l].y,o[1]),s[0]=Math.max(n[l].x,s[0]),s[1]=Math.max(n[l].y,s[1]);t.gravityCenter=[.5*(o[0]+s[0]),.5*(o[1]+s[1])]}for(l=0;l<i.length;l++){var u=i[l].node1,h=i[l].node2;n[u].degree=(n[u].degree||0)+1,n[h].degree=(n[h].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:t})},If.prototype.update=function(e,t,r){null==t&&(t=1),t=Math.max(t,1),this._frame+=t,this._onupdate=r,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(t)})},If.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()}},If.prototype.getNodePositionTexture=function(){return this._positionTex},If.prototype.getNodeUV=function(e,t){t=t||[];var r=this._positionTex.width,n=this._positionTex.height;return t[0]=e%r/(r-1),t[1]=Math.floor(e/r)/(n-1),t},If.prototype.getNodes=function(){return this._nodes},If.prototype.getEdges=function(){return this._edges},If.prototype.isFinished=function(e){return this._frame>e},If.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var r=0;r<this._positionArr.length;r++)t[r]=this._positionArr[r];return t},If.prototype._updateTexture=function(e){for(var t=this._positionTex.pixels,r=0,n=0;n<e.length;)t[r++]=e[n++],t[r++]=e[n++],t[r++]=1,t[r++]=1;this._positionTex.dirty()},If.prototype.dispose=function(e){this._disposed=!0,this._worker=null};var Bf=Nr.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,r=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(t,r)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var n=this._convertPos(t,r);this._x=n.x,this._y=n.y}}},_convertPos:function(e,t){var r=this.viewGL.camera,n=this.viewGL.viewport;return{x:(e-n.x)/n.width*(r.right-r.left)+r.left,y:(t-n.y)/n.height*(r.bottom-r.top)+r.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 r=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,n)){var i=t>0?1.1:.9,a=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=a/this._zoom;var o=this._convertPos(r,n),s=(o.x-this._dx)*(i-1),l=(o.y-this._dy)*(i-1);this._dx-=s,this._dy-=l,this._zoom=a,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)}}),zf=Nl.vec2;ul.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 Ff=1,kf=je.extend({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this.viewGL=new ih("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new Gd(!0,t),this._forceEdgesMesh=new ul.Mesh({material:new ul.Material({shader:ul.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new ul.Geometry({attributes:{node:new ul.Geometry.Attribute("node","float",2),color:new ul.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:ul.Mesh.LINES}),this._edgesMesh=new ul.Mesh({material:new ul.Material({shader:ul.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new Lf({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new Bf({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,r){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=r,this._initLayout(e,t,r),this._pointsBuilder.update(e,t,r),this._forceLayoutInstance instanceof Of||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,r),this._control.off("update"),this._control.on("update",function(){r.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)},this),this._control.setZoom(Vs(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var n=this._pointsBuilder.getPointsMesh();if(n.off("mousemove",this._mousemoveHandler),n.off("mouseout",this._mouseOutHandler,this),r.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?r.getZr().on("click",this._clickHandler):"mouseover"===i&&(n.on("mousemove",this._mousemoveHandler,this),n.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1)}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 r=this._forceEdgesMesh.geometry,n=t.getEdgeData(),i=0,a=this._forceLayoutInstance,o=2*n.count();r.attributes.node.init(o),r.attributes.color.init(o),n.each(function(t){var o=e[t];r.attributes.node.set(i,a.getNodeUV(o.node1)),r.attributes.node.set(i+1,a.getNodeUV(o.node2));var s=$h(n,o.dataIndex),l=ul.parseColor(s);l[3]*=Vs(ec(n,o.dataIndex),1),r.attributes.color.set(i,l),r.attributes.color.set(i+1,l),i+=2}),r.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,r=(e=this._model.getEdgeData(),this._model.getData().getLayout("points"));t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var n=[],i=[],a=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each(function(o){var s=e.graph.getEdgeByIndex(o),l=2*s.node1.dataIndex,u=2*s.node2.dataIndex;n[0]=r[l],n[1]=r[l+1],i[0]=r[u],i[1]=r[u+1];var h=$h(e,s.dataIndex),c=ul.parseColor(h);c[3]*=Vs(ec(e,s.dataIndex),1);var d=e.getItemModel(s.dataIndex),f=Vs(d.get(a),1)*this._api.getDevicePixelRatio();t.addLine(n,i,c,f);for(var p=0;p<4;p++)this._originalEdgeColors[4*s.dataIndex+p]=c[p];this._edgeIndicesMap[s.dataIndex]=o},this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),r=[],n=0;n<e.count();n++)this._forceLayoutInstance.getNodeUV(n,r),t.geometry.attributes.position.set(n,r);t.geometry.dirty("position")},_initLayout:function(e,t,r){var n=e.get("layout"),i=e.getGraph(),a=e.getBoxLayoutParams(),o=be(a,{width:r.getWidth(),height:r.getHeight()});"force"===n&&(n="forceAtlas2"),this.stopLayout(e,t,r,{beforeLayout:!0});var s=e.getData(),l=e.getData();if("forceAtlas2"===n){var u=e.getModel("forceAtlas2"),h=this._forceLayoutInstance,c=[],d=[],f=s.getDataExtent("value"),p=l.getDataExtent("value"),m=Vs(u.get("edgeWeight"),1),g=Vs(u.get("nodeWeight"),1);"number"==typeof m&&(m=[m,m]),"number"==typeof g&&(g=[g,g]);var v=0,_={},y=new Float32Array(2*s.count());if(i.eachNode(function(e){var t,r,n=e.dataIndex,i=s.get("value",n);if(s.hasItemOption){var a=s.getItemModel(n);t=a.get("x"),r=a.get("y")}null==t&&(t=o.x+Math.random()*o.width,r=o.y+Math.random()*o.height),y[2*v]=t,y[2*v+1]=r,_[e.id]=v++;var l=tt(i,f,g);isNaN(l)&&(l=isNaN(g[0])?1:g[0]),c.push({x:t,y:r,mass:l,size:s.getItemVisual(n,"symbolSize")})}),s.setLayout("points",y),i.eachEdge(function(e){var t=e.dataIndex,r=s.get("value",t),n=tt(r,p,m);isNaN(n)&&(n=isNaN(m[0])?1:m[0]),d.push({node1:_[e.node1.id],node2:_[e.node2.id],weight:n,dataIndex:t})}),!h){var x=u.get("GPU");this._forceLayoutInstance&&((!x||this._forceLayoutInstance instanceof Of)&&(x||this._forceLayoutInstance instanceof If)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),h=this._forceLayoutInstance=x?new Of:new If}h.initData(c,d),h.updateOption(u.option),this._updateForceEdgesGeometry(h.getEdges(),e),this._updatePositionTexture(),r.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else{y=new Float32Array(2*s.count()),v=0;i.eachNode(function(e){var t,r,n=e.dataIndex;if(s.hasItemOption){var i=s.getItemModel(n);t=i.get("x"),r=i.get("y")}y[v++]=t,y[v++]=r}),s.setLayout("points",y),this._updateAfterLayout(e,t,r)}},_updatePositionTexture:function(){var e=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(e),this._forceEdgesMesh.material.set("positionTex",e)},startLayout:function(e,t,r,n){if(!n||null==n.from||n.from===this.uid){var i=this.viewGL,a=(r=this._api,this._forceLayoutInstance),o=this._model.getData(),s=this._model.getModel("forceAtlas2");if(a&&(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=Ff++,h=s.getShallow("maxSteps"),c=s.getShallow("steps"),d=0,f=Math.max(2*c,20),p=function(t){if(t===l._layoutId)return a.isFinished(h)?(r.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void r.dispatchAction({type:"graphGLFinishLayout",points:o.getLayout("points"),from:l.uid})):void a.update(i.layer.renderer,c,function(){l._updatePositionTexture(),(d+=c)>=f&&(l._syncNodePosition(e),d=0),r.getZr().refresh(),te(function(){p(t)})})};te(function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(i.layer.renderer),l._forceLayoutInstanceToDispose=null),p(u)}),this._layouting=!0}}},stopLayout:function(e,t,r,n){n&&null!=n.from&&n.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(n&&n.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,r)),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,r){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,r),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,r,n){var i=this._model.getData();this._downplayAll();var a=n.dataIndex,o=i.graph,s=[],l=o.getNodeByIndex(a);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,r,n){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),r=ul.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),n=Vs(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);r[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],r)},_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,r){this._getColor(t,e),e[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var r=0;r<4;r++)t[r]=this._originalEdgeColors[4*e+r];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 r=this.viewGL.camera,n=e.getData().getLayout("points"),i=zf.create(1/0,1/0),a=zf.create(-1/0,-1/0),o=[],s=0;s<n.length;)o[0]=n[s++],o[1]=n[s++],zf.min(i,i,o),zf.max(a,a,o);var l=(a[1]+i[1])/2,u=(a[0]+i[0])/2;if(!(u>r.left&&u<r.right&&l<r.bottom&&l>r.top)){var h=Math.max(a[0]-i[0],10),c=h/t.getWidth()*t.getHeight();h*=1.4,c*=1.4,i[0]-=.2*h,r.left=i[0],r.top=l-c/2,r.bottom=l+c/2,r.right=h+i[0],r.near=0,r.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 Uf(e){return e instanceof Array||(e=[e,e]),e}W(function(e){function t(){}e.registerChartView(kf),e.registerSeriesModel(Ef),e.registerVisual(function(e){var t={};e.eachSeriesByType("graphGL",function(e){var r=e.getCategoriesData(),n=e.getData(),i={};r.each(function(n){var a=r.getName(n);i["ec-"+a]=n;var o=r.getItemModel(n),s=o.getModel("itemStyle").getItemStyle();s.fill||(s.fill=e.getColorFromPalette(a,t)),r.setItemVisual(n,"style",s);for(var l=["symbol","symbolSize","symbolKeepAspect"],u=0;u<l.length;u++){var h=o.getShallow(l[u],!0);null!=h&&r.setItemVisual(n,l[u],h)}}),r.count()&&n.each(function(e){var t=n.getItemModel(e).getShallow("category");if(null!=t){"string"==typeof t&&(t=i["ec-"+t]);var a=r.getItemVisual(t,"style"),o=n.ensureUniqueItemVisual(e,"style");rt(o,a);for(var s=["symbol","symbolSize","symbolKeepAspect"],l=0;l<s.length;l++)n.setItemVisual(e,s[l],r.getItemVisual(t,s[l]))}})})}),e.registerVisual(function(e){e.eachSeriesByType("graphGL",function(e){var t=e.getGraph(),r=e.getEdgeData(),n=Uf(e.get("edgeSymbol")),i=Uf(e.get("edgeSymbolSize"));r.setVisual("drawType","stroke"),r.setVisual("fromSymbol",n&&n[0]),r.setVisual("toSymbol",n&&n[1]),r.setVisual("fromSymbolSize",i&&i[0]),r.setVisual("toSymbolSize",i&&i[1]),r.setVisual("style",e.getModel("lineStyle").getLineStyle()),r.each(function(e){var n=r.getItemModel(e),i=t.getEdgeByIndex(e),a=Uf(n.getShallow("symbol",!0)),o=Uf(n.getShallow("symbolSize",!0)),s=n.getModel("lineStyle").getLineStyle(),l=r.ensureUniqueItemVisual(e,"style");switch(rt(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}a[0]&&i.setVisual("fromSymbol",a[0]),a[1]&&i.setVisual("toSymbol",a[1]),o[0]&&i.setVisual("fromSymbolSize",o[0]),o[1]&&i.setVisual("toSymbolSize",o[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 Gf=We.extend({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(e,t){var r=this.get("coordinateSystem"),n="geo"===r?["lng","lat"]:Ve(r)||["x","y"];n.push("vx","vy");var i=Ce(this.getSource(),{coordDimensions:n,encodeDefine:this.get("encode"),dimensionsDefine:this.get("dimensions")}),a=new De(i,this);return a.initData(this.getSource()),a},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}}}),Hf=mo.extend(function(){return{dynamic:!0,attributes:{position:new mo.Attribute("position","float",3,"POSITION")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(e){var t=this.attributes,r=4*e,n=2*e;this.vertexCount!==r&&t.position.init(r),this.triangleCount!==n&&(this.indices=0===n?null:this.vertexCount>65535?new Uint32Array(3*n):new Uint16Array(3*n))},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}});Ri.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 Vf=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new no({type:Ja.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()};Vf.prototype={constructor:Vf,init:function(){var e={type:Ja.FLOAT,minFilter:Ja.NEAREST,magFilter:Ja.NEAREST,useMipmap:!1};this._spawnTexture=new no(e),this._particleTexture0=new no(e),this._particleTexture1=new no(e),this._frameBuffer=new ss({depthBuffer:!1}),this._particlePass=new Rs({fragment:Ri.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new Rs({fragment:Ri.source("clay.compositor.downsample")});var t=new $a({renderOrder:10,material:new ni({shader:new Ri(Ri.source("ecgl.vfParticle.renderPoints.vertex"),Ri.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:$a.POINTS,geometry:new mo({dynamic:!0,mainAttribute:"texcoord0"})}),r=new $a({renderOrder:10,material:new ni({shader:new Ri(Ri.source("ecgl.vfParticle.renderLines.vertex"),Ri.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new Hf,culling:!1}),n=new $a({material:new ni({shader:new Ri(Ri.source("ecgl.color.vertex"),Ri.source("ecgl.color.fragment"))}),geometry:new hs});n.material.enableTexture("diffuseMap"),this._particlePointsMesh=t,this._particleLinesMesh=r,this._lastFrameFullQuadMesh=n,this._camera=new Ls,this._thisFrameTexture=new no,this._lastFrameTexture=new no},setParticleDensity:function(e,t){for(var r=new Float32Array(4*(e*t)),n=0,i=this.particleLife,a=0;a<e;a++)for(var o=0;o<t;o++,n++){r[4*n]=Math.random(),r[4*n+1]=Math.random(),r[4*n+2]=Math.random();var s=(i[1]-i[0])*Math.random()+i[0];r[4*n+3]=s}"line"===this._particleType?this._setLineGeometry(e,t):this._setPointsGeometry(e,t),this._spawnTexture.width=e,this._spawnTexture.height=t,this._spawnTexture.pixels=r,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 r=e*t,n=this._particlePointsMesh.geometry,i=n.attributes;i.texcoord0.init(r);for(var a=0,o=0;o<e;o++)for(var s=0;s<t;s++,a++)i.texcoord0.value[2*a]=o/e,i.texcoord0.value[2*a+1]=s/t;n.dirty()},_setLineGeometry:function(e,t){var r=e*t,n=this._getParticleMesh().geometry;n.setLineCount(r),n.resetOffset();for(var i=0;i<e;i++)for(var a=0;a<t;a++)n.addLine([i/e,a/t]);n.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(e,t,r,n){var i=this._getParticleMesh(),a=this._frameBuffer,o=this._particlePass;n&&this._updateDownsampleTextures(e,t),i.material.set("size",this._particleSize*this._supersampling),i.material.set("color",this.particleColor),o.setUniform("speedScaling",this.particleSpeedScaling),a.attach(this._particleTexture1),o.setUniform("firstFrameTime",n?(this.particleLife[1]+this.particleLife[0])/2:0),o.setUniform("particleTexture",this._particleTexture0),o.setUniform("deltaTime",r),o.setUniform("elapsedTime",this._elapsedTime),o.render(e,a),i.material.set("particleTexture",this._particleTexture1),i.material.set("prevParticleTexture",this._particleTexture0),a.attach(this._thisFrameTexture),a.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),a.unbind(e),this._downsample(e),this._swapTexture(),this._elapsedTime+=r},_downsample:function(e){var t=this._downsampleTextures;if(0!==t.length)for(var r=0,n=this._thisFrameTexture,i=t[r];i;)this._frameBuffer.attach(i),this._downsamplePass.setUniform("texture",n),this._downsamplePass.setUniform("textureSize",[n.width,n.height]),this._downsamplePass.render(e,this._frameBuffer),n=i,i=t[++r]},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 no),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=function(e){var t=document.createElement("canvas");t.width=t.height=e;var r=t.getContext("2d");return r.fillStyle="#fff",r.arc(e/2,e/2,e/2,0,2*Math.PI),r.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 r=this._downsampleTextures,n=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,a=this._width*this._supersampling,o=this._height*this._supersampling,s=0;s<n;s++)r[s]=r[s]||new no,r[s].width=a/i,r[s].height=o/i,i*=2;for(;s<r.length;s++)r[s].dispose(e);r.length=n},_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 Wf=je.extend({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new ih("orthographic"),this.groupGL=new ul.Node,this.viewGL.add(this.groupGL),this._particleSurface=new Vf;var r=new ul.Mesh({geometry:new ul.PlaneGeometry,material:new ul.Material({shader:new ul.Shader({vertex:ul.Shader.source("ecgl.color.vertex"),fragment:ul.Shader.source("ecgl.color.fragment")}),transparent:!0})});r.material.enableTexture("diffuseMap"),this.groupGL.add(r),this._planeMesh=r},render:function(e,t,r){var n=this._particleSurface;n.setParticleType(e.get("particleType")),n.setSupersampling(e.get("supersampling")),this._updateData(e,r),this._updateCamera(r.getWidth(),r.getHeight(),r.getDevicePixelRatio());var i=Vs(e.get("particleDensity"),128);n.setParticleDensity(i,i);var a=this._planeMesh,o=+new Date,s=this,l=!0;a.__percent=0,a.stopAnimation(),a.animate("",{loop:!0}).when(1e5,{__percent:1}).during(function(){var e=+new Date,t=Math.min(e-o,20);o+=t,s._renderer&&(n.update(s._renderer,r,t/1e3,l),a.material.set("diffuseMap",n.getSurfaceTexture())),l=!1}).start();var u=e.getModel("itemStyle"),h=ul.parseColor(u.get("color"));h[3]*=Vs(u.get("opacity"),1),a.material.set("color",h),n.setColorTextureImage(e.get("colorTexture"),r),n.setParticleSize(e.get("particleSize")),n.particleSpeedScaling=e.get("particleSpeed"),n.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,r){this._updateData(e,r)},afterRender:function(e,t,r,n){var i=n.renderer;this._renderer=i},_updateData:function(e,t){var r=e.coordinateSystem,n=r.dimensions.map(function(t){return e.coordDimToDataDim(t)[0]}),i=e.getData(),a=i.getDataExtent(n[0]),o=i.getDataExtent(n[1]),s=e.get("gridWidth"),l=e.get("gridHeight");if(null==s||"auto"===s){var u=(a[1]-a[0])/(o[1]-o[0]);s=Math.round(Math.sqrt(u*i.count()))}null!=l&&"auto"!==l||(l=Math.ceil(i.count()/s));var h=this._particleSurface.vectorFieldTexture,c=h.pixels;if(c&&c.length===l*s*4)for(var d=0;d<c.length;d++)c[d]=0;else c=h.pixels=new Float32Array(s*l*4);var f=0,p=1/0,m=new Float32Array(2*i.count()),g=0,v=[[1/0,1/0],[-1/0,-1/0]];i.each([n[0],n[1],"vx","vy"],function(e,t,n,i){var a=r.dataToPoint([e,t]);m[g++]=a[0],m[g++]=a[1],v[0][0]=Math.min(a[0],v[0][0]),v[0][1]=Math.min(a[1],v[0][1]),v[1][0]=Math.max(a[0],v[1][0]),v[1][1]=Math.max(a[1],v[1][1]);var o=Math.sqrt(n*n+i*i);f=Math.max(f,o),p=Math.min(p,o)}),i.each(["vx","vy"],function(e,t,r){var n=Math.round((m[2*r]-v[0][0])/(v[1][0]-v[0][0])*(s-1)),i=4*((l-1-Math.round((m[2*r+1]-v[0][1])/(v[1][1]-v[0][1])*(l-1)))*s+n);c[i]=e/f*.5+.5,c[i+1]=t/f*.5+.5,c[i+3]=1}),h.width=s,h.height=l,"bmap"===e.get("coordinateSystem")&&this._fillEmptyPixels(h),h.dirty(),this._updatePlanePosition(v[0],v[1],e,t),this._updateGradientTexture(i.getVisual("visualMeta"),[p,f])},_fillEmptyPixels:function(e){var t=e.pixels,r=e.width,n=e.height;function i(e,i,a){e=Math.max(Math.min(e,r-1),0);var o=4*((i=Math.max(Math.min(i,n-1),0))*(r-1)+e);return 0!==t[o+3]&&(a[0]=t[o],a[1]=t[o+1],!0)}function a(e,t,r){r[0]=e[0]+t[0],r[1]=e[1]+t[1]}for(var o=[],s=[],l=[],u=[],h=[],c=0,d=0;d<n;d++)for(var f=0;f<r;f++){var p=4*(d*(r-1)+f);0===t[p+3]&&(c=o[0]=o[1]=0,i(f-1,d,s)&&(c++,a(s,o,o)),i(f+1,d,l)&&(c++,a(l,o,o)),i(f,d-1,u)&&(c++,a(u,o,o)),i(f,d+1,h)&&(c++,a(h,o,o)),o[0]/=c,o[1]/=c,t[p]=o[0],t[p+1]=o[1]),t[p+3]=1}},_updateGradientTexture:function(e,t){if(e&&e.length){this._gradientTexture=this._gradientTexture||new ul.Texture2D({image:document.createElement("canvas")});var r=this._gradientTexture,n=r.image;n.width=200,n.height=1;var i=n.getContext("2d"),a=i.createLinearGradient(0,.5,n.width,.5);e[0].stops.forEach(function(e){var r;t[1]===t[0]?r=0:(r=e.value/t[1],r=Math.min(Math.max(r,0),1)),a.addColorStop(r,e.color)}),i.fillStyle=a,i.fillRect(0,0,n.width,n.height),r.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(e,t,r,n){var i=this._limitInViewportAndFullFill(e,t,r,n);e=i.leftTop,t=i.rightBottom,this._particleSurface.setRegion(i.region),this._planeMesh.position.set((e[0]+t[0])/2,n.getHeight()-(e[1]+t[1])/2,0);var a=t[0]-e[0],o=t[1]-e[1];this._planeMesh.scale.set(a/2,o/2,1),this._particleSurface.resize(Math.max(Math.min(a,2048),1),Math.max(Math.min(o,2048),1)),this._renderer&&this._particleSurface.clearFrame(this._renderer)},_limitInViewportAndFullFill:function(e,t,r,n){var i=[Math.max(e[0],0),Math.max(e[1],0)],a=[Math.min(t[0],n.getWidth()),Math.min(t[1],n.getHeight())];if("bmap"===r.get("coordinateSystem")){var o=r.getData().getDataExtent(r.coordDimToDataDim("lng")[0]);Math.floor(o[1]-o[0])>=359&&(i[0]>0&&(i[0]=0),a[0]<n.getWidth()&&(a[0]=n.getWidth()))}var s=t[0]-e[0],l=t[1]-e[1],u=a[0]-i[0],h=a[1]-i[1];return{leftTop:i,rightBottom:a,region:[(i[0]-e[0])/s,1-h/l-(i[1]-e[1])/l,u/s,h/l]}},_updateCamera:function(e,t,r){this.viewGL.setViewport(0,0,e,t,r);var n=this.viewGL.camera;n.left=n.bottom=0,n.top=t,n.right=e,n.near=0,n.far=100,n.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}});W(function(e){e.registerChartView(Wf),e.registerSeriesModel(Gf)});var jf=We.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)),jf.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)),jf.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=nt(this._flatCoords,t.flatCoords),this._flatCoordsOffset=nt(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);return t.option instanceof Array?t.option:t.getShallow("coords")},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var r=this._flatCoordsOffset[2*e],n=this._flatCoordsOffset[2*e+1],i=0;i<n;i++)t[i]=t[i]||[],t[i][0]=this._flatCoords[r+2*i],t[i][1]=this._flatCoords[r+2*i+1];return n}var a=this._getCoordsFromItemModel(e);for(i=0;i<a.length;i++)t[i]=t[i]||[],t[i][0]=a[i][0],t[i][1]=a[i][1];return a.length},_processFlatCoordsArray:function(e){var t=0;if(this._flatCoords&&(t=this._flatCoords.length),"number"==typeof e[0]){for(var r=e.length,n=new Uint32Array(r),i=new Float64Array(r),a=0,o=0,s=0,l=0;l<r;){s++;var u=e[l++];n[o++]=a+t,n[o++]=u;for(var h=0;h<u;h++){var c=e[l++],d=e[l++];i[a++]=c,i[a++]=d}}return{flatCoordsOffset:new Uint32Array(n.buffer,0,o),flatCoords:i,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:e.length}},getInitialData:function(e,t){var r=new De(["value"],this);return r.hasItemOption=!1,r.initData(e.data,[],function(e,t,n,i){if(e instanceof Array)return NaN;r.hasItemOption=!0;var a=e.value;return null!=a?a instanceof Array?a[i]:a:void 0}),r},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}}}}),Xf=je.extend({type:"linesGL",__ecgl__:!0,init:function(e,t){this.groupGL=new ul.Node,this.viewGL=new ih("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new Mf(this.viewGL),this._nativeLinesShader=ul.createShader("ecgl.lines3D"),this._meshLinesShader=ul.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(e,t,r){this.groupGL.removeAll(),this._glViewHelper.reset(e,r);var n=this._linesMeshes[0];n||(n=this._linesMeshes[0]=this._createLinesMesh(e)),this._linesMeshes.length=1,this.groupGL.add(n),this._updateLinesMesh(e,n,0,e.getData().count()),this.viewGL.setPostEffect(e.getModel("postEffect"),r)},incrementalPrepareRender:function(e,t,r){this.groupGL.removeAll(),this._glViewHelper.reset(e,r),this._currentStep=0,this.viewGL.setPostEffect(e.getModel("postEffect"),r)},incrementalRender:function(e,t,r,n){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),n.getZr().refresh(),this._currentStep++},updateTransform:function(e,t,r){e.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(e,r)},_createLinesMesh:function(e){return new ul.Mesh({$ignorePicking:!0,material:new ul.Material({shader:ul.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new Lf({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:ul.Mesh.LINES,culling:!1})},_updateLinesMesh:function(e,t,r,n){var i=e.getData();t.material.blend="lighter"===e.get("blendMode")?ul.additiveBlend:null;var a=e.get("lineStyle.curveness")||0,o=e.get("polyline"),s=t.geometry,l=e.coordinateSystem,u=Vs(e.get("lineStyle.width"),1);u>1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=ul.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=ul.Mesh.LINES),r=r||0,n=n||i.count(),s.resetOffset();var h=0,c=0,d=[],f=[],p=[],m=[],g=[],v=.3,_=.7;function y(){f[0]=d[0]*_+m[0]*v-(d[1]-m[1])*a,f[1]=d[1]*_+m[1]*v-(m[0]-d[0])*a,p[0]=d[0]*v+m[0]*_-(d[1]-m[1])*a,p[1]=d[1]*v+m[1]*_-(m[0]-d[0])*a}if(o||0!==a)for(var x=r;x<n;x++)if(o){var b=e.getLineCoordsCount(x);h+=s.getPolylineVertexCount(b),c+=s.getPolylineTriangleCount(b)}else e.getLineCoords(x,g),this._glViewHelper.dataToPoint(l,g[0],d),this._glViewHelper.dataToPoint(l,g[1],m),y(),h+=s.getCubicCurveVertexCount(d,f,p,m),c+=s.getCubicCurveTriangleCount(d,f,p,m);else{var w=n-r;h+=w*s.getLineVertexCount(),c+=w*s.getLineVertexCount()}s.setVertexCount(h),s.setTriangleCount(c);var T=r,S=[];for(x=r;x<n;x++){ul.parseColor($h(i,T),S);var M=Vs(ec(i,T),1);S[3]*=M;b=e.getLineCoords(x,g);for(var A=0;A<b;A++)this._glViewHelper.dataToPoint(l,g[A],g[A]);o?s.addPolyline(g,S,u,0,b):0!==a?(d=g[0],m=g[1],y(),s.addCubicCurve(d,f,p,m,S,u)):s.addPolyline(g,S,u,0,2),T++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});W(function(e){e.registerChartView(Xf),e.registerSeriesModel(jf)});var qf=H(u({__name:"attack-map-3d",props:{mapApiData:{}},setup:function(e){W([Ld,ff,Bc,j]),yt(),A();var t=s(),r=e,n=null,i=null;function a(){if(i&&!i.isDisposed())return i;var e=document.createElement("canvas");return(i=it(e,null,{width:4096,height:2048})).setOption({backgroundColor:new at(0,0,0,1,[{offset:0,color:"#9ed6ff"},{offset:.7,color:"#fafcfa"},{offset:1,color:"#9ed6ff"}]),series:[{type:"map",map:"world",left:0,top:0,right:0,bottom:0,boundingCoords:[[-180,90],[180,-90]],label:{show:!1},itemStyle:{areaColor:"#44b359",borderColor:"#fff",borderWidth:1}}]}),i}function o(e){if(n){var t=a(),r=e.attack_ip.map(function(t){return{coords:[[t.ip_longitude,t.ip_latitude],[e.load_ip.longitude,e.load_ip.latitude]],value:1}});n.setOption({tooltip:{show:!0},globe:{silent:!0,shading:"color",baseTexture:t,viewControl:{distance:240,targetCoord:[e.load_ip.longitude,e.load_ip.latitude],maxDistance:240,minDistance:240,rotateSensitivity:2,autoRotateSpeed:10}},series:[{type:"bar3D",coordinateSystem:"globe",shading:"lambert",opacity:1,bevelSize:.2,itemStyle:{color:"#EBE806"},label:{show:!1,formatter:"{b}"},data:[]},{name:"lines3D",type:"lines3D",coordinateSystem:"globe",effect:{show:!0,period:2,trailWidth:4,trailLength:.5,trailOpacity:1,trailColor:"red"},blendMode:"lighter",lineStyle:{width:1,color:"red",opacity:0},data:r,silent:!1},{type:"lines3D",coordinateSystem:"globe",effect:{show:!0,trailWidth:5,trailOpacity:1,trailLength:.2,constantSpeed:5},blendMode:"lighter",lineStyle:{color:"#EBE806",width:1,opacity:1},data:[]}]})}}function l(){if(n){var e=a();n.setOption({tooltip:{show:!1},globe:{silent:!0,shading:"color",baseTexture:e,viewControl:{distance:240,rotateSensitivity:2,autoRotate:!0,autoRotateSpeed:3}},series:[]})}}S(function(){return r.mapApiData},function(e){e?o(e):l()},{immediate:!0});var u=function(){var e;return null===(e=n)||void 0===e?void 0:e.resize()};return E(function(){t.value&&(n=it(t.value,"light"),r.mapApiData?o(r.mapApiData):l(),window.addEventListener("resize",u))}),C(function(){var e;window.removeEventListener("resize",u),null===(e=n)||void 0===e||e.dispose(),n=null,i&&!i.isDisposed()&&(i.dispose(),i=null)}),function(e,r){return c(),d("div",{ref_key:"chartRef",ref:t,class:"attack-map-3d"},null,512)}}}),[["__scopeId","data-v-ebb1c8c6"]]),Zf={class:"flex h-full"},Yf={class:"relative flex-1"},Kf={class:"absolute top-2 left-2 z-10 flex items-center gap-4"},Qf={class:"flex flex-col w-[35rem]"},Jf=u({__name:"attack-map",props:{mapData:{},mapApiData:{},mapMode:{type:[String,Boolean]},mapRegion:{},rankMode:{},requestRankTable:{},attackRankTable:{}},emits:["update:mapMode","update:mapRegion","update:rankMode"],setup:function(e,t){var r=t.emit,n=e,i=r,a=s(!1===n.mapMode?"2d":n.mapMode),o=s(n.mapRegion),l=s(n.rankMode);function u(e){var t=e;"3d"===t&&"china"===o.value&&(o.value="world",i("update:mapRegion","world")),i("update:mapMode",t)}function p(e){i("update:mapRegion",e)}function m(e){i("update:rankMode",e)}return S(function(){return n.mapMode},function(e){a.value=!1===e?"2d":e}),S(function(){return n.mapRegion},function(e){return o.value=e}),S(function(){return n.rankMode},function(e){return l.value=e}),function(t,r){var n=N,i=R;return c(),d("div",Zf,[f("div",Yf,[f("div",Kf,[!1!==e.mapMode?(c(),w(i,{key:0,modelValue:x(a),"onUpdate:modelValue":r[0]||(r[0]=function(e){return L(a)?a.value=e:null}),size:"small",onChange:u},{default:D(function(){return[y(n,{value:"2d"},{default:D(function(){return h(r[3]||(r[3]=[b("2D",-1)]))}),_:1}),y(n,{value:"3d"},{default:D(function(){return h(r[4]||(r[4]=[b("3D",-1)]))}),_:1})]}),_:1},8,["modelValue"])):g("",!0),r[9]||(r[9]=f("span",{class:"text-[12px] text-[var(--el-text-color-secondary)]"},"(*仅展示坐标中的 TOP 5)",-1)),y(i,{modelValue:x(o),"onUpdate:modelValue":r[1]||(r[1]=function(e){return L(o)?o.value=e:null}),size:"small",onChange:p},{default:D(function(){return[y(n,{value:"world"},{default:D(function(){return h(r[5]||(r[5]=[b("世界",-1)]))}),_:1}),y(n,{value:"china",disabled:"3d"===x(a)},{default:D(function(){return h(r[6]||(r[6]=[b("中国",-1)]))}),_:1},8,["disabled"])]}),_:1},8,["modelValue"]),y(i,{modelValue:x(l),"onUpdate:modelValue":r[2]||(r[2]=function(e){return L(l)?l.value=e:null}),size:"small",onChange:m},{default:D(function(){return[y(n,{value:"request"},{default:D(function(){return h(r[7]||(r[7]=[b("请求数",-1)]))}),_:1}),y(n,{value:"attack"},{default:D(function(){return h(r[8]||(r[8]=[b("拦截数",-1)]))}),_:1})]}),_:1},8,["modelValue"])]),(c(),d("div",{key:x(a),class:"h-full"},["2d"===x(a)?(c(),w(Sr,{key:0,"map-data":e.mapData,"map-region":x(o)},null,8,["map-data","map-region"])):(c(),w(qf,{key:1,"map-api-data":e.mapApiData},null,8,["map-api-data"]))]))]),f("div",Qf,[P((c(),w(T(e.requestRankTable),{"max-height":342},null,512)),[[O,"request"===x(l)]]),P((c(),w(T(e.attackRankTable),{"max-height":342},null,512)),[[O,"request"!==x(l)]])])])}}}),$f={class:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--el-fill-color-light)] rounded transition-colors group"},ep=["title"],tp={class:"flex-1 h-4 bg-[var(--el-fill-color-lighter)] rounded overflow-hidden"},rp={class:"flex-shrink-0 text-[13px] text-[var(--el-text-color-regular)] font-medium min-w-[40px] text-right"},np=u({__name:"top-list-item",props:{rank:{},label:{},percentage:{},count:{},barColor:{},labelWidth:{default:"120px"}},setup:function(e){var t=e,r=_(function(){var e=t.barColor.replace("#","");if(6!==e.length)return"#ffffff";var r=Math.min(255,parseInt(e.slice(0,2),16)+100),n=Math.min(255,parseInt(e.slice(2,4),16)+100),i=Math.min(255,parseInt(e.slice(4,6),16)+100);return"#".concat(r.toString(16).padStart(2,"0")).concat(n.toString(16).padStart(2,"0")).concat(i.toString(16).padStart(2,"0"))});return function(t,n){return c(),d("div",$f,[f("span",{class:"w-9 h-9 rounded-full flex items-center justify-center text-[12px] font-bold text-white flex-shrink-0",style:v({backgroundColor:e.barColor})},m(e.rank),5),f("span",{class:"flex-shrink-0 truncate text-[13px] text-[var(--el-text-color-regular)] transition-colors",style:v({width:e.labelWidth}),title:e.label},m(e.label),13,ep),f("div",tp,[f("div",{class:"h-full rounded transition-all duration-300",style:v({width:"".concat(e.percentage,"%"),background:"linear-gradient(90deg, ".concat(e.barColor,", ").concat(x(r),")")})},null,4)]),f("span",rp,m(e.count),1)])}}}),ip={class:"flex flex-col h-full overflow-hidden"},ap={key:0,class:"flex-1 flex items-center justify-center text-[13px] text-[var(--el-text-color-secondary)]"},op=u({__name:"attacked-domains",props:{list:{default:function(){return[]}}},setup:function(e){var t=e;return function(r,n){var i=z;return c(),d("div",ip,[(c(!0),d(I,null,B(e.list,function(e,r){return c(),w(np,{key:r,rank:r+1,label:e[0],percentage:(n=e[1],t.list.length&&t.list[0][1]?Math.round(n/t.list[0][1]*100):0),count:String(e[1]),"bar-color":"#418f6b"},null,8,["rank","label","percentage","count"]);var n}),128)),e.list.length?g("",!0):(c(),d("div",ap,[y(i,{description:"暂无数据"})]))])}}}),sp={class:"flex flex-col h-full overflow-hidden"},lp={key:0,class:"flex-1 flex items-center justify-center text-[13px] text-[var(--el-text-color-secondary)]"},up=u({__name:"traffic-rank",props:{list:{default:function(){return[]}}},setup:function(e){var t=e;return function(r,n){var i=z;return c(),d("div",sp,[(c(!0),d(I,null,B(e.list,function(e,r){return c(),w(np,{key:r,rank:r+1,label:e.ip,percentage:(i=e.traffic,t.list.length&&t.list[0].traffic?Math.round(i/t.list[0].traffic*100):0),count:(n=e.traffic,n<1024?"".concat(n," B"):n<1048576?"".concat((n/1024).toFixed(2)," KB"):n<1073741824?"".concat((n/1024/1024).toFixed(2)," MB"):"".concat((n/1024/1024/1024).toFixed(2)," GB")),"bar-color":"#06a6c7"},null,8,["rank","label","percentage","count"]);var n,i}),128)),e.list.length?g("",!0):(c(),d("div",lp,[y(i,{description:"暂无数据"})]))])}}}),hp={class:"flex flex-col h-full overflow-hidden"},cp={key:0,class:"flex-1 flex items-center justify-center text-[13px] text-[var(--el-text-color-secondary)]"},dp=u({__name:"url-rank",props:{list:{default:function(){return[]}}},setup:function(e){var t=e;return function(r,n){var i=z;return c(),d("div",hp,[(c(!0),d(I,null,B(e.list,function(e,r){return c(),w(np,{key:r,rank:r+1,label:e.url,percentage:(n=e.count,t.list.length&&t.list[0].count?Math.round(n/t.list[0].count*100):0),count:e.count.toLocaleString(),"bar-color":"#0d5450","label-width":"160px"},null,8,["rank","label","percentage","count"]);var n}),128)),e.list.length?g("",!0):(c(),d("div",cp,[y(i,{description:"暂无数据"})]))])}}}),fp=u({__name:"intercept-type-pie",props:{chart:{}},setup:function(e){return function(t,r){return c(),w(T(e.chart),{style:{height:"100%",width:"100%"}})}}});function pp(){return(pp=o(r().m(function e(t){var n,i,o,s,l,u,h;return r().w(function(e){for(;;)switch(e.n){case 0:return n=t.row,i=n.http_log,o=n.uri,s=n.ip,l=n.incoming_value,e.n=1,wt({path:i});case 1:return u=e.v,h=u,e.n=2,ot({title:"URL加白",area:"400px",component:function(){return st(function(){return a.import("./url-whitelist-dialog-legacy.js?v=1777008528")},void 0,a.meta.url)},compData:{url:o,error_log:"".concat(s," >> ").concat(l),http_log:h,onSuccess:t.onSuccess},btn:["确定","取消"]});case 2:return e.a(2)}},e)}))).apply(this,arguments)}var mp=lt().request,gp=function(){var e=o(r().m(function e(){var t;return r().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,St();case 1:return t=e.v,e.a(2,t.data)}},e)}));return function(){return e.apply(this,arguments)}}(),vp=function(){var e=o(r().m(function e(){var t;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,Tt();case 1:return t=e.v,mp(t),e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}();function _p(e,t,r){return Dt([{title:"拉黑IP",onClick:function(t){return e(t.ip)}},{title:"URL加白",onClick:function(e){return t(e)}},{title:"详情",onClick:function(e){return r(e)}}],{width:160})}var yp=A();function xp(){return bp.apply(this,arguments)}function bp(){return(bp=o(r().m(function e(){return r().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,vp();case 1:e.v&&Em();case 2:return e.a(2)}},e)}))).apply(this,arguments)}yt(),_t();var wp,Tp,Sp,Mp,Ap,Ep,Cp=V({options:{}}),Dp=V({options:{}}),Lp=V({options:{}}),Pp=V({options:{}}),Op=V({options:{}}),Np=xt({request:(Mp=o(r().m(function e(){var t,n,i;return r().w(function(e){for(;;)if(0===e.n)return i=null!==(t=null===(n=Nt.value)||void 0===n?void 0:n.attack_report_log)&&void 0!==t?t:[],e.a(2,{data:i.slice(0,20),total:i.length})},e)})),function(){return Mp.apply(this,arguments)}),columns:(wp=bt,Tp=function(e){!function(e){pp.apply(this,arguments)}({row:e})},Sp=Ct,[{prop:"time_localtime",label:"时间",width:160},{prop:"ip",label:"IP地址"},{prop:"server_name",label:"域名"},{prop:"filter_rule",label:"攻击类型"},{prop:"uri",label:"URL地址"},_p(wp,Tp,Sp)])}),Rp=Np.BtTable,Ip=ht({request:(Ap=o(r().m(function e(){var t,n,i;return r().w(function(e){for(;;)if(0===e.n)return i=null!==(t=null===(n=Nt.value)||void 0===n?void 0:n.attack_details)&&void 0!==t?t:[],e.a(2,{data:i,total:i.length})},e)})),function(){return Ap.apply(this,arguments)}),columns:function(e){return[{prop:"ip",label:"请求IP",width:"120px",showOverfloeTooltip:!0,render:function(t){return y("span",{class:"bt-link cursor-pointer",onClick:function(){return e(t.ip)}},[t.ip])}},{prop:"count",label:"请求数",width:75},{prop:"flow",label:"流量",width:85,render:function(e){var t,r;return ut(null!==(t=null!==(r=e.flow)&&void 0!==r?r:e.traffic)&&void 0!==t?t:0,!0)}},{prop:"address",label:"IP归属地"}]}(bt)}),Bp=ht({request:(Ep=o(r().m(function e(){var t,n,i;return r().w(function(e){for(;;)if(0===e.n)return i=null!==(t=null===(n=Nt.value)||void 0===n?void 0:n.attack_details)&&void 0!==t?t:[],e.a(2,{data:i,total:i.length})},e)})),function(){return Ep.apply(this,arguments)}),columns:function(e){return[{prop:"ip",label:"攻击IP",isCustom:!0,render:function(t){return y("span",{class:"bt-link cursor-pointer",onClick:function(){return e(t.ip)}},[t.ip])}},{prop:"count",label:"攻击数",width:75},{prop:"address",label:"IP归属地"}]}(bt)}),zp=Ip.BtTable,Fp=Bp.BtTable;function kp(){return getComputedStyle(document.documentElement).getPropertyValue("--el-text-color-secondary").trim()||"#606266"}function Up(){return getComputedStyle(document.documentElement).getPropertyValue("--el-text-color-primary").trim()||"#303133"}var Gp=ct(function(){return Wp.apply(this,arguments)},60),Hp=Gp.loop,Vp=Gp.clearTimer;function Wp(){return(Wp=o(r().m(function e(){var t,n,i;return r().w(function(e){for(;;)switch(e.n){case 0:if(1===Pt.value){e.n=1;break}return e.a(2);case 1:return e.n=2,Et();case 2:if(t=e.v,n=t.data){e.n=3;break}return e.a(2);case 3:return(i=Nt.value)&&(i.qps=n.qps,i.traffic=n.traffic,i.proxy_time=n.proxy_time,n.type&&n.type.length>0&&(i.type=n.type),i.attack_details=n.attack_details,i.autoEvent=n.autoEvent),Pm(Nt.value),e.n=4,Nm(Nt.value);case 4:Bp.refresh();case 5:return e.a(2)}},e)}))).apply(this,arguments)}function jp(){return Xp.apply(this,arguments)}function Xp(){return(Xp=o(r().m(function e(){var t,n;return r().w(function(e){for(;;)switch(e.n){case 0:if(1===Pt.value){e.n=1;break}return e.a(2);case 1:return e.n=2,Et();case 2:if(t=e.v,n=t.data){e.n=3;break}return e.a(2);case 3:qp(n);case 4:return e.a(2)}},e)}))).apply(this,arguments)}function qp(e){var t=dt(e.time,"HH:mm:ss");zt.value.push({time:t,value:e.qps}),Ft.value.push({time:t,value:e.traffic}),kt.value.push({time:t,value:e.proxy_time}),zt.value.length>120&&zt.value.shift(),Ft.value.length>120&&Ft.value.shift(),kt.value.length>120&&kt.value.shift(),Nt.value&&(Nt.value.qps=e.qps,Nt.value.traffic=e.traffic,Nt.value.proxy_time=e.proxy_time),am(),om(),sm()}var Zp=1e3*Rt.value,Yp=null,Kp=0;function Qp(e){var t=e-Kp,r=Math.max(0,Zp-t);It.value=r/Zp*100;var n=Math.ceil(r/1e3)-1;Bt.value=Math.max(0,n),r>0?Yp=requestAnimationFrame(Qp):(Yp=null,function(){Jp.apply(this,arguments)}())}function Jp(){return(Jp=o(r().m(function e(){return r().w(function(e){for(;;)switch(e.n){case 0:if(1===Pt.value){e.n=1;break}return e.a(2);case 1:return e.n=2,jp();case 2:$p();case 3:return e.a(2)}},e)}))).apply(this,arguments)}function $p(){em(),Kp=performance.now(),It.value=100,Bt.value=Rt.value-1,Yp=requestAnimationFrame(Qp)}function em(){null!==Yp&&(cancelAnimationFrame(Yp),Yp=null)}var tm={left:"5%",right:"10%",bottom:"3%",top:"20%",containLabel:!0},rm={type:"value",splitNumber:4,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#666"},nameTextStyle:{color:"#666"},splitLine:{show:!0,lineStyle:{type:"dashed",width:1,color:"#ebeef5"}}};function nm(e){return{type:"category",boundaryGap:!1,data:e,axisLabel:{color:"#666"},nameTextStyle:{color:"#666"},axisLine:{show:!0,lineStyle:{color:"#666"}},axisTick:{show:!0,lineStyle:{color:"#666"}}}}function im(e){var t=getComputedStyle(document.documentElement).getPropertyValue("--el-color-primary").trim()||"#20a53a";return{type:"line",data:e,smooth:!0,symbol:"none",showSymbol:!1,sampling:"average",itemStyle:{color:t},areaStyle:{color:t,opacity:.15}}}function am(){var e=zt.value,t=e.map(function(e){return e.time}),r=e.map(function(e){return e.value});Dp.setOption({tooltip:{trigger:"axis",formatter:function(e){var t=Array.isArray(e)?e[0]:e;return"时间:".concat(t.axisValue,"<br />").concat(t.marker," QPS:").concat(t.value)}},grid:tm,xAxis:nm(t),yAxis:rm,series:[im(r)]})}function om(){var e=Ft.value,t=e.map(function(e){return e.time}),r=e.map(function(e){return e.value});Lp.setOption({tooltip:{trigger:"axis",formatter:function(e){var t=Array.isArray(e)?e[0]:e,r=t.value,n=0===r?"0":(r/1024).toFixed(1);return"时间:".concat(t.axisValue,"<br />").concat(t.marker," 流量:").concat(n," KB/s")}},grid:tm,xAxis:nm(t),yAxis:rm,series:[im(r)]})}function sm(){var e=kt.value,t=e.map(function(e){return e.time}),r=e.map(function(e){return e.value});Pp.setOption({tooltip:{trigger:"axis",formatter:function(e){var t=Array.isArray(e)?e[0]:e;return"时间:".concat(t.axisValue,"<br />").concat(t.marker," 时延:").concat(t.value," ms")}},grid:tm,xAxis:nm(t),yAxis:rm,series:[im(r)]})}var lm=Wt.activeTimeIndex,um=(Wt.customTimeRange,Wt.overviewData,Wt.countdownTotal,Wt.countdownPercentage),hm=Wt.countdownDisplaySec,cm=(Wt.qpsHistory,Wt.trafficHistory,Wt.latencyHistory,Wt.mapMode),dm=Wt.mapRegion,fm=Wt.mapApiData,pm=Wt.sourceRankMode,mm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.count.today_request)&&void 0!==e?e:0}),gm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.count.malicious_request)&&void 0!==e?e:0}),vm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.count.yesterday_request_total)&&void 0!==e?e:0}),_m=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.count.yesterday_malicious_request)&&void 0!==e?e:0}),ym=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.server_name_top)&&void 0!==e?e:[]}),xm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.traffic_top)&&void 0!==e?e:[]}),bm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.url_top)&&void 0!==e?e:[]}),wm=_(function(){var e,t=null===(e=Nt.value)||void 0===e?void 0:e.type;return Array.isArray(t)&&t.length>0}),Tm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.qps)&&void 0!==e?e:0}),Sm=_(function(){var e,t,r=null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.traffic)&&void 0!==e?e:0;if(0===r)return"0 KB/s";var n=(r/1024).toFixed(1);return"".concat(n," KB/s")}),Mm=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.proxy_time)&&void 0!==e?e:0}),Am=_(function(){var e,t;return null!==(e=null===(t=Nt.value)||void 0===t?void 0:t.map)&&void 0!==e?e:[]});function Em(){return Cm.apply(this,arguments)}function Cm(){return(Cm=o(r().m(function e(){var t,n,i,a;return r().w(function(e){for(;;)switch(e.n){case 0:return t=2===Pt.value?Ot.value:dt(Dm(),"yyyy-MM-dd"),e.n=1,Mt({country:"china"===Gt.value?1:0,request:"request"===Vt.value?0:1,start_time:t});case 1:if(n=e.v,i=n.data){e.n=2;break}return e.a(2);case 2:return Nt.value=i,i["3D"]||("3d"===Ut.value?(Ut.value=!1,ft("bwf_home_map","2D")):Ut.value=!1),Lt.value=i.open,Np.refresh(),"request"===Vt.value?Ip.refresh():Bp.refresh(),Pm(i),e.n=3,Nm(i);case 3:a=dt(i.time,"HH:mm:ss"),zt.value=[{time:a,value:i.qps}],Ft.value=[{time:a,value:i.traffic}],kt.value=[{time:a,value:i.proxy_time}],am(),om(),sm();case 4:return e.a(2)}},e)}))).apply(this,arguments)}function Dm(){if(0===Pt.value){var e=new Date;return e.setDate(e.getDate()-1),e.setHours(0,0,0,0),Math.floor(e.getTime()/1e3)}if(1===Pt.value){var t=new Date;return t.setHours(0,0,0,0),Math.floor(t.getTime()/1e3)}return 2}function Lm(e,t,r,n,i){var a,o,s,l,u,h,c=null!==(a=null===(o=window.__LAST_VIEWPORT_MOUSE__)||void 0===o?void 0:o.x)&&void 0!==a?a:0,d=(null!==(s=null===(l=window.__LAST_VIEWPORT_MOUSE__)||void 0===l?void 0:l.y)&&void 0!==s?s:0)-e[1],f=null!==(u=i.contentSize[0])&&void 0!==u?u:0,p=null!==(h=i.contentSize[1])&&void 0!==h?h:0,m=e[0]-f-20,g=e[1]-p-30;return d<p&&d<300&&(g=e[1]+20),c+f+20>window.innerWidth&&(m=e[0]-f-20),[m,g]}function Pm(t){var r,n,i=null!==(r=t.traffic_filter)&&void 0!==r?r:[],a=[],o=[],s=[],l=[],u=[],h=e(i);try{for(h.s();!(n=h.n()).done;){var c,d=n.value,f=String(d.hour).padStart(2,"0"),p=String(d.minute).padStart(2,"0");a.push("".concat(f,":").concat(p)),o.push(d.request),s.push(d.proxy_count),l.push(+(d.flow/1024/1024).toFixed(2)),u.push(null!==(c=d.ip_count)&&void 0!==c?c:0)}}catch(m){h.e(m)}finally{h.f()}Cp.setOption({tooltip:{trigger:"axis",position:Lm,formatter:function(t){var r,n=t,a="",o=e(n);try{for(o.s();!(r=o.n()).done;){var s=r.value,l=i[s.dataIndex];if(l){var u="";if("流量"===s.seriesName&&(u=" MB"),a+=s.marker+s.seriesName+":"+s.value+u+"<br />","IP数量"===s.seriesName){var h,c,d,f,p=null!==(h=l.flow)&&void 0!==h?h:0,g=null!==(c=l.static_flow)&&void 0!==c?c:0,v=p-g,_=p>=1048576?"MB":p>=1024?"KB":"B",y=ut(g,!0,2,_),x=ut(v,!0,2,_);a+='<div style="padding:0 12px 5px">499错误:'.concat(null!==(d=l.err_499)&&void 0!==d?d:0,"<br />502错误:").concat(null!==(f=l.err_502)&&void 0!==f?f:0,"<br />动态/静态(流量):").concat(x," / ").concat(y,"</div>")}}}}catch(m){o.e(m)}finally{o.f()}var b=i[n[0].dataIndex];return"时间:"+(null!=b&&b.date?"".concat(b.date," ").concat(n[0].name):n[0].name)+"<br />"+a}},legend:{icon:"circle",data:["总请求","滤后","流量","IP数量"],top:"-2%",itemWidth:10,itemHeight:10,itemGap:16},grid:{left:"5%",right:"4%",bottom:"3%",top:"20%",containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:a,axisLabel:{color:"#666"},nameTextStyle:{color:"#666"},axisLine:{show:!0,lineStyle:{color:"#666"}},axisTick:{show:!0,lineStyle:{color:"#666"}}},yAxis:{type:"value",splitNumber:4,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#666"},nameTextStyle:{color:"#666"},splitLine:{show:!0,lineStyle:{type:"dashed",width:1,color:"#ebeef5"}}},toolbox:{show:!1},brush:{brushType:"lineX",brushMode:"single",throttleType:"debounce",throttleDelay:1e3,toolbox:[]},dataZoom:[{type:"inside",start:0,end:100,zoomLock:!0,show:!1},{show:!1,bottom:10,start:0,end:100,handleIcon:"path://M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",handleSize:"80%",handleStyle:{color:"#fff",shadowBlur:3,shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:2,shadowOffsetY:2}}],series:[{name:"总请求",type:"line",data:o,smooth:!0,symbol:"none",sampling:"average",showSymbol:!1,itemStyle:{color:"#20a53a"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(32,164,58,0.6)"},{offset:1,color:"rgba(32,164,58,0)"}]}}},{name:"滤后",type:"line",data:s,smooth:!0,symbol:"none",sampling:"average",showSymbol:!1,itemStyle:{color:"#A0BFE0"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(242,242,242,0.6)"},{offset:.8,color:"rgba(242,242,242,0)"}]}}},{name:"流量",type:"line",data:l,smooth:!0,symbol:"none",sampling:"average",showSymbol:!1,itemStyle:{color:"#30aaf6"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(32,164,58,0.6)"},{offset:1,color:"rgba(32,164,58,0)"}]}}},{name:"IP数量",type:"line",data:u,smooth:!0,symbol:"none",sampling:"average",showSymbol:!1,itemStyle:{color:"#78e1b9"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(32,164,58,0.6)"},{offset:1,color:"rgba(32,164,58,0)"}]}}}]}),function(){Om.apply(this,arguments)}()}function Om(){return Om=o(r().m(function e(){var t,n;return r().w(function(e){for(;;)switch(e.n){case 0:return n=function(e){var r,n=null===(r=e.areas)||void 0===r?void 0:r[0];if(n){var i=n.coordRange||n.range;if(i&&!(i.length<2)){var a=n.coordRange?n.coordRange[0]:t.convertFromPixel({xAxisIndex:0},i[0]),o=n.coordRange?n.coordRange[1]:t.convertFromPixel({xAxisIndex:0},i[1]);setTimeout(function(){t.dispatchAction({type:"brush",areas:[]}),t.resize()},50),t.dispatchAction({type:"dataZoom",xAxisIndex:[0,1],startValue:a,endValue:o})}}},e.n=1,Cp.getEChart();case 1:if(t=e.v){e.n=2;break}return e.a(2);case 2:t.off("brushEnd",n),t.on("brushEnd",n),t.dispatchAction({type:"takeGlobalCursor",key:"brush",brushOption:{brushType:"lineX",brushMode:"single"}}),t.resize();case 3:return e.a(2)}},e)})),Om.apply(this,arguments)}function Nm(e){return Rm.apply(this,arguments)}function Rm(){return(Rm=o(r().m(function e(t){var n,i,a,o;return r().w(function(e){for(;;)switch(e.n){case 0:if(0!==(i=null!==(n=t.type)&&void 0!==n?n:[]).length){e.n=1;break}return e.a(2);case 1:return a=i.map(function(e){return{name:e[0],value:e[1]}}),o=a.reduce(function(e,t){return e+t.value},0),e.n=2,Op.getEChart();case 2:if(e.v){e.n=3;break}return e.a(2);case 3:Op.setOption({tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)"},legend:{type:"scroll",orient:"vertical",right:20,top:8,bottom:20,width:120,itemGap:8,formatter:function(e){return e.length>10?e.slice(0,10)+"...":e}},graphic:[{type:"text",left:"35%",top:"45%",style:{text:"拦截类型",fontSize:14,fontWeight:"bold",textAlign:"center",fill:kp()}},{type:"text",left:"35%",top:"55%",style:{text:String(o),fontSize:20,fontWeight:"bold",textAlign:"center",fill:Up()}}],series:[{type:"pie",radius:["45%","70%"],center:["40%","50%"],data:a,label:{show:!1},emphasis:{label:{show:!0,fontWeight:"bold"}}}]});case 4:return e.a(2)}},e)}))).apply(this,arguments)}function Im(e){Pt.value=e,Em(),1!==e?(Vp(),em()):(Hp(),$p())}function Bm(e){Ot.value=e,Pt.value=2,Vp(),em(),Em()}function zm(){var e=mt("bwf_home_map");Ut.value="3D"===e||"3d"===e?"3d":"2d";var t=mt("bwf_home_map_region");Gt.value="china"===t?"china":"world";var r=mt("bwf_home_map_count");Vt.value="intercept"===r||"attack"===r?"attack":"request"}function Fm(){return km.apply(this,arguments)}function km(){return(km=o(r().m(function e(){var t;return r().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,gp();case 1:(t=e.v)&&(Ht.value=t);case 2:return e.a(2)}},e)}))).apply(this,arguments)}function Um(e){return Gm.apply(this,arguments)}function Gm(){return(Gm=o(r().m(function e(t){return r().w(function(e){for(;;)switch(e.n){case 0:if(Ut.value=t,ft("bwf_home_map","2d"===t?"2D":"3D"),"3d"!==t){e.n=1;break}return e.n=1,Fm();case 1:return e.a(2)}},e)}))).apply(this,arguments)}function Hm(e){return Vm.apply(this,arguments)}function Vm(){return(Vm=o(r().m(function e(t){var n,i;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,n=t?"开启":"关闭",e.n=1,pt({content:"是否".concat(n,"3D地图?")});case 1:return e.n=2,At({obj:"3D"});case 2:if(i=e.v,lt().request(i),!i.status){e.n=5;break}if(!t){e.n=4;break}return Ut.value="3d",ft("bwf_home_map","3D"),e.n=3,Fm();case 3:e.n=5;break;case 4:Ut.value=!1,ft("bwf_home_map","2D");case 5:e.n=7;break;case 6:e.p=6,e.v;case 7:return e.a(2)}},e,null,[[0,6]])}))).apply(this,arguments)}function Wm(e){Gt.value=e,ft("bwf_home_map_region",e),Em()}function jm(e){Vt.value=e,ft("bwf_home_map_count","request"===e?"request":"intercept"),Em()}function Xm(e){var t=function(){var e=Pt.value;if(0===e){var t=new Date;return t.setDate(t.getDate()-1),dt(t,"yyyy-MM-dd")}return 2===e&&Ot.value?Ot.value:dt(new Date,"yyyy-MM-dd")}();ot({title:"traffic_top"===e?"流量排行 TOP100":"访问页面 TOP100",area:"traffic_top"===e?"900px":"1000px",component:function(){return st(function(){return a.import("./index-legacy430.js?v=1777008528")},void 0,a.meta.url)},compData:{type:e,day:t},showFooter:!1})}function qm(){return(qm=o(r().m(function e(){return r().w(function(e){for(;;)switch(e.n){case 0:return zm(),e.n=1,Em();case 1:if("3d"!==Ut.value){e.n=2;break}return e.n=2,Fm();case 2:Hp(),$p();case 3:return e.a(2)}},e)}))).apply(this,arguments)}S(yp,function(){Nt.value&&Nm(Nt.value)});var Zm={class:"flex flex-col gap-4 pt-[1.2rem] h-full overflow-auto"},Ym={class:"flex gap-4"},Km={class:"left-col flex flex-col gap-4"},Qm={class:"flex gap-4"},Jm={class:"left-col flex flex-col gap-4"},$m={class:"flex items-center gap-2 mr-4"},eg={class:"flex gap-4"},tg={class:"right-col flex gap-4"},rg={class:"flex gap-4"},ng=u({__name:"page",setup:function(e){function t(){Em(),1===Pt.value&&$p()}return E(function(){return function(){return qm.apply(this,arguments)}()}),C(function(){Vp(),em()}),function(e,r){var n=F,i=k,a=gt,o=U,s=G,l=z;return c(),d("div",Zm,[x(Lt)?g("",!0):(c(),w(i,{key:0,type:"error",closable:!1},{default:D(function(){return[r[4]||(r[4]=f("strong",{class:"text-secondary"},"防火墙已关闭防护",-1)),r[5]||(r[5]=f("span",{class:"mx-8 text-[var(--el-text-color-secondary)]"},"当前防火墙处于关闭状态,网站已经失去所有防护,建议立即开启",-1)),y(n,{onClick:x(xp)},{default:D(function(){return h(r[3]||(r[3]=[b("立即开启防护",-1)]))}),_:1},8,["onClick"])]}),_:1})),f("div",Ym,[f("div",Km,[y(Kt,{height:"70px"},{default:D(function(){return[y(rr,{percentage:x(um),"display-sec":x(hm),onChange:x(Im),onRefresh:t,onCustomChange:x(Bm)},null,8,["percentage","display-sec","onChange","onCustomChange"])]}),_:1}),y(dr,{"today-request":x(mm),"malicious-request":x(gm),"yesterday-total":x(vm),"yesterday-malicious-request":x(_m),"active-time-index":x(lm)},null,8,["today-request","malicious-request","yesterday-total","yesterday-malicious-request","active-time-index"])]),y(Kt,{title:"流量过滤请求图",class:"right-col"},{icon:D(function(){return h(r[6]||(r[6]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})],-1)]))}),extra:D(function(){return[y(a,{icon:"el-refresh",class:"cursor-pointer !text-[var(--el-text-color-primary)] !hover:text-[#20a53a]",onClick:t})]}),default:D(function(){return[y(fr,{chart:x(Cp).BtECharts},null,8,["chart"])]}),_:1})]),f("div",Qm,[f("div",Jm,[y(Kt,{title:"实时QPS: ".concat(x(Tm),"/s"),height:"200px","is-empty":!x(Tm)},{icon:D(function(){return h(r[7]||(r[7]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})],-1)]))}),default:D(function(){return[y(gr,{chart:x(Dp).BtECharts},null,8,["chart"])]}),_:1},8,["title","is-empty"]),y(Kt,{title:"网站实时流量: ".concat(x(Sm)),height:"200px"},{icon:D(function(){return h(r[8]||(r[8]=[f("svg",{t:"1766214102461",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"3552",width:"16",height:"16",fill:"currentColor"},[f("path",{d:"M290.1 409.6H155.135A371.405 371.405 0 0 0 140.851 512c0 35.533 4.967 69.888 14.336 102.4H290.15c-5.632-32.768-8.499-66.918-8.499-102.4s2.867-69.632 8.5-102.4z m52.07 0A542.106 542.106 0 0 0 332.8 512c0 35.738 3.072 69.888 9.37 102.4H486.4V409.6H342.17z m75.008 461.363A491.878 491.878 0 0 1 301.568 665.6h-127.59a372.07 372.07 0 0 0 243.2 205.363z m69.222-3.584V665.6H354.97c24.064 77.107 67.84 144.23 131.43 201.83z m-69.222-714.291a372.07 372.07 0 0 0-243.2 205.312h127.59a491.878 491.878 0 0 1 115.558-205.363z m69.222 3.584c-63.59 57.446-107.315 124.57-131.43 201.728H486.4V156.57zM733.9 409.6c5.633 32.768 8.5 66.918 8.5 102.4s-2.867 69.632-8.5 102.4h135.015c9.319-32.512 14.285-66.867 14.285-102.4s-4.966-69.888-14.336-102.4H733.901z m-52.07 0H537.6v204.8h144.23c6.247-32.512 9.37-66.662 9.37-102.4s-3.072-69.888-9.37-102.4z m-75.008 461.363a372.07 372.07 0 0 0 243.2-205.363h-127.59a491.878 491.878 0 0 1-115.558 205.363zM537.6 867.38c63.59-57.55 107.315-124.673 131.43-201.78H537.6v201.83z m69.222-714.291A491.878 491.878 0 0 1 722.432 358.4h127.642a372.07 372.07 0 0 0-243.2-205.363z m-69.222 3.584V358.4h131.43c-24.064-77.107-67.84-144.23-131.43-201.83zM512 947.2a435.2 435.2 0 1 1 0-870.4 435.2 435.2 0 0 1 0 870.4z",fill:"currentColor","p-id":"3553"})],-1)]))}),default:D(function(){return[y(yr,{chart:x(Lp).BtECharts},null,8,["chart"])]}),_:1},8,["title"]),y(Kt,{title:"实时回源: ".concat(x(Mm),"ms"),height:"200px"},{icon:D(function(){return h(r[9]||(r[9]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("circle",{cx:"12",cy:"12",r:"10"}),f("polyline",{points:"12 6 12 12 16 14"})],-1)]))}),default:D(function(){return[y(wr,{chart:x(Pp).BtECharts},null,8,["chart"])]}),_:1},8,["title"])]),y(Kt,{class:"right-col"},{icon:D(function(){return[r[11]||(r[11]=f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("circle",{cx:"12",cy:"12",r:"10"}),f("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),f("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})],-1)),r[12]||(r[12]=f("span",null,"访问/拦截地图",-1)),y(o,{content:"数据取最大的1w条数据",placement:"top"},{default:D(function(){return h(r[10]||(r[10]=[f("span",{class:"ml-1 bt-ico-ask"},"?",-1)]))}),_:1})]}),extra:D(function(){return[f("span",$m,[r[13]||(r[13]=f("span",{class:"text-[12px]"},"3D地图",-1)),y(s,{size:"small","model-value":!1!==x(cm),onChange:r[0]||(r[0]=function(e){return x(Hm)(!!e)})},null,8,["model-value"])]),r[14]||(r[14]=f("a",{class:"btlink text-[12px]",href:"/btwaf/content_report.html",target:"_blank"},"今日拦截报表>>",-1))]}),default:D(function(){return[y(Jf,{"map-data":x(Am),"map-api-data":x(fm),"map-mode":x(cm),"map-region":x(dm),"rank-mode":x(pm),"request-rank-table":x(zp),"attack-rank-table":x(Fp),"onUpdate:mapMode":x(Um),"onUpdate:mapRegion":x(Wm),"onUpdate:rankMode":x(jm)},null,8,["map-data","map-api-data","map-mode","map-region","rank-mode","request-rank-table","attack-rank-table","onUpdate:mapMode","onUpdate:mapRegion","onUpdate:rankMode"])]}),_:1})]),f("div",eg,[y(Kt,{title:"受攻击域名 TOP10",class:"left-col"},{icon:D(function(){return h(r[15]||(r[15]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),f("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),f("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})],-1)]))}),default:D(function(){return[y(op,{list:x(ym)},null,8,["list"])]}),_:1}),f("div",tg,[y(Kt,{title:"流量排行 TOP10",class:"flex-1"},{icon:D(function(){return h(r[16]||(r[16]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),f("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),f("line",{x1:"6",y1:"20",x2:"6",y2:"14"})],-1)]))}),extra:D(function(){return[f("a",{class:"btlink text-[12px] cursor-pointer",onClick:r[1]||(r[1]=function(e){return x(Xm)("traffic_top")})},"查看更多>>")]}),default:D(function(){return[y(up,{list:x(xm)},null,8,["list"])]}),_:1}),y(Kt,{title:"访问页面 TOP10",class:"flex-1"},{icon:D(function(){return h(r[17]||(r[17]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),f("polyline",{points:"14 2 14 8 20 8"}),f("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),f("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),f("polyline",{points:"10 9 9 9 8 9"})],-1)]))}),extra:D(function(){return[f("a",{class:"btlink text-[12px] cursor-pointer",onClick:r[2]||(r[2]=function(e){return x(Xm)("url_top")})},"查看更多>>")]}),default:D(function(){return[y(dp,{list:x(bm)},null,8,["list"])]}),_:1})])]),f("div",rg,[y(Kt,{title:"拦截类型",class:"left-col"},{icon:D(function(){return h(r[18]||(r[18]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})],-1)]))}),default:D(function(){return[x(wm)?(c(),w(fp,{key:0,chart:x(Op).BtECharts},null,8,["chart"])):(c(),w(l,{key:1,description:"暂无数据"}))]}),_:1}),y(Kt,{title:"最新拦截事件",class:"right-col",height:"410px"},{icon:D(function(){return h(r[19]||(r[19]=[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[f("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),f("polyline",{points:"14 2 14 8 20 8"}),f("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),f("line",{x1:"9",y1:"15",x2:"15",y2:"15"})],-1)]))}),default:D(function(){return[y(x(Rp),{"max-height":330})]}),_:1})])])}}});n("default",H(ng,[["__scopeId","data-v-0bf5107f"]]))}}})}();