MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / Ff

Function Ff

public/iframe/lib/js/echarts-gl.min.js:29–29  ·  view source on GitHub ↗
(t,e)

Source from the content-addressed store, hash-verified

27See the Apache Version 2.0 License for specific language governing permissions
28and limitations under the License.
29***************************************************************************** */var jc="___EC__EXTENDED_CLASS___";var qc=Math.round(10*Math.random());function Zc(t,e){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return this.superClass.prototype[e].apply(t,r)}function Yc(t,e,r){return this.superClass.prototype[e].apply(t,r)}function Kc(t,e){for(var r=0;r<t.length;r++)t[r][1]||(t[r][1]=t[r][0]);return e=e||!1,function(r,i,n){for(var a={},o=0;o<t.length;o++){var s=t[o][1];if(!(i&&Kn(i,s)>=0||n&&Kn(n,s)<0)){var l=r.getShallow(s,e);null!=l&&(a[t[o][0]]=l)}}return a}}var Qc,Jc,$c,td=Kc([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]]),ed=function(){function t(){}return t.prototype.getAreaStyle=function(t,e){return td(this,t,e)},t}(),rd=["textStyle","color"],id=new jh,nd=function(){function t(){}return t.prototype.getTextColor=function(t){var e=this.ecModel;return this.getShallow("color")||(!t&&e?e.get(rd):null)},t.prototype.getFont=function(){return t={fontStyle:this.getShallow("fontStyle"),fontWeight:this.getShallow("fontWeight"),fontSize:this.getShallow("fontSize"),fontFamily:this.getShallow("fontFamily")},e=this.ecModel,r=e&&e.getModel("textStyle"),ma([t.fontStyle||r&&r.getShallow("fontStyle")||"",t.fontWeight||r&&r.getShallow("fontWeight")||"",(t.fontSize||r&&r.getShallow("fontSize")||12)+"px",t.fontFamily||r&&r.getShallow("fontFamily")||"sans-serif"].join(" "));var t,e,r},t.prototype.getTextRect=function(t){return id.useStyle({text:t,fontStyle:this.getShallow("fontStyle"),fontWeight:this.getShallow("fontWeight"),fontSize:this.getShallow("fontSize"),fontFamily:this.getShallow("fontFamily"),verticalAlign:this.getShallow("verticalAlign")||this.getShallow("baseline"),padding:this.getShallow("padding"),lineHeight:this.getShallow("lineHeight"),rich:this.getShallow("rich")}),id.update(),id.getBoundingRect()},t}(),ad=Kc([["lineWidth","width"],["stroke","color"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"],["lineDash","type"],["lineDashOffset","dashOffset"],["lineCap","cap"],["lineJoin","join"],["miterLimit"]]),od=function(){function t(){}return t.prototype.getLineStyle=function(t){return ad(this,t)},t}(),sd=Kc([["fill","color"],["stroke","borderColor"],["lineWidth","borderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"],["lineDash","borderType"],["lineDashOffset","borderDashOffset"],["lineCap","borderCap"],["lineJoin","borderJoin"],["miterLimit","borderMiterLimit"]]),ld=function(){function t(){}return t.prototype.getItemStyle=function(t,e){return sd(this,t,e)},t}(),hd=function(){function t(t,e,r){this.parentModel=e,this.ecModel=r,this.option=t}return t.prototype.init=function(t,e,r){for(var i=[],n=3;n<arguments.length;n++)i[n-3]=arguments[n]},t.prototype.mergeOption=function(t,e){jn(this.option,t,!0)},t.prototype.get=function(t,e){return null==t?this.option:this._doGet(this.parsePath(t),!e&&this.parentModel)},t.prototype.getShallow=function(t,e){var r=this.option,i=null==r?r:r[t];if(null==i&&!e){var n=this.parentModel;n&&(i=n.getShallow(t))}return i},t.prototype.getModel=function(e,r){var i=null!=e,n=i?this.parsePath(e):null;return new t(i?this._doGet(n):this.option,r=r||this.parentModel&&this.parentModel.getModel(this.resolveParentPath(n)),this.ecModel)},t.prototype.isEmpty=function(){return null==this.option},t.prototype.restoreData=function(){},t.prototype.clone=function(){return new(0,this.constructor)(Xn(this.option))},t.prototype.parsePath=function(t){return"string"==typeof t?t.split("."):t},t.prototype.resolveParentPath=function(t){return t},t.prototype.isAnimationEnabled=function(){if(!Os.node&&this.option){if(null!=this.option.animation)return!!this.option.animation;if(this.parentModel)return this.parentModel.isAnimationEnabled()}},t.prototype._doGet=function(t,e){var r=this.option;if(!t)return r;for(var i=0;i<t.length&&(!t[i]||null!=(r=r&&"object"==typeof r?r[t[i]]:null));i++);return null==r&&e&&(r=e._doGet(this.resolveParentPath(t),e.parentModel)),r},t}();(Qc=hd).$constructor=Qc,Qc.extend=function(t){var e=this;function r(){for(var i,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];if(t.$constructor)t.$constructor.apply(this,arguments);else{if("function"==typeof(i=e)&&/^class\s/.test(Function.prototype.toString.call(i)))return Ta(r.prototype,new(e.bind.apply(e,function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var i=Array(t),n=0;for(e=0;e<r;e++)for(var a=arguments[e],o=0,s=a.length;o<s;o++,n++)i[n]=a[o];return i}([void 0],n))));e.apply(this,arguments)}}return r[jc]=!0,qn(r.prototype,t),r.extend=this.extend,r.superCall=Zc,r.superApply=Yc,function(t,e){var r=t.prototype;function i(){}for(var n in i.prototype=e.prototype,t.prototype=new i,r)r.hasOwnProperty(n)&&(t.prototype[n]=r[n]);t.prototype.constructor=t,t.superClass=e}(r,this),r.superClass=e,r},Jc=hd,$c=["__\0is_clz",qc++].join("_"),Jc.prototype[$c]=!0,Jc.isInstance=function(t){return!(!t||!t[$c])},Qn(hd,od),Qn(hd,ld),Qn(hd,ed),Qn(hd,nd);var ud=hd,cd="ZH",dd="EN",fd=dd,pd={},md={};Os.domSupported&&(document.documentElement.lang||navigator.language||navigator.browserLanguage).toUpperCase().indexOf(cd);function gd(t,e){t=t.toUpperCase(),md[t]=new ud(e),pd[t]=e}gd(dd,{time:{month:["January","February","March","April","May","June","July","August","September","October","November","December"],monthAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayOfWeekAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},legend:{selector:{all:"All",inverse:"Inv"}},toolbox:{brush:{title:{rect:"Box Select",polygon:"Lasso Select",lineX:"Horizontally Select",lineY:"Vertically Select",keep:"Keep Selections",clear:"Clear Selections"}},dataView:{title:"Data View",lang:["Data View","Close","Refresh"]},dataZoom:{title:{zoom:"Zoom",back:"Zoom Reset"}},magicType:{title:{line:"Switch to Line Chart",bar:"Switch to Bar Chart",stack:"Stack",tiled:"Tile"}},restore:{title:"Restore"},saveAsImage:{title:"Save as Image",lang:["Right Click to Save Image"]}},series:{typeNames:{pie:"Pie chart",bar:"Bar chart",line:"Line chart",scatter:"Scatter plot",effectScatter:"Ripple scatter plot",radar:"Radar chart",tree:"Tree",treemap:"Treemap",boxplot:"Boxplot",candlestick:"Candlestick",k:"K line chart",heatmap:"Heat map",map:"Map",parallel:"Parallel coordinate map",lines:"Line graph",graph:"Relationship graph",sankey:"Sankey diagram",funnel:"Funnel chart",gauge:"Guage",pictorialBar:"Pictorial bar",themeRiver:"Theme River Map",sunburst:"Sunburst"}},aria:{general:{withTitle:'This is a chart about "{title}"',withoutTitle:"This is a chart"},series:{single:{prefix:"",withName:" with type {seriesType} named {seriesName}.",withoutName:" with type {seriesType}."},multiple:{prefix:". It consists of {seriesCount} series count.",withName:" The {seriesId} series is a {seriesType} representing {seriesName}.",withoutName:" The {seriesId} series is a {seriesType}.",separator:{middle:"",end:""}}},data:{allData:"The data is as follows: ",partialData:"The first {displayCnt} items are: ",withName:"the data for {name} is {value}",withoutName:"{value}",separator:{middle:", ",end:". "}}}}),gd(cd,{time:{month:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthAbbr:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dayOfWeek:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],dayOfWeekAbbr:["日","一","二","三","四","五","六"]},legend:{selector:{all:"全选",inverse:"反选"}},toolbox:{brush:{title:{rect:"矩形选择",polygon:"圈选",lineX:"横向选择",lineY:"纵向选择",keep:"保持选择",clear:"清除选择"}},dataView:{title:"数据视图",lang:["数据视图","关闭","刷新"]},dataZoom:{title:{zoom:"区域缩放",back:"区域缩放还原"}},magicType:{title:{line:"切换为折线图",bar:"切换为柱状图",stack:"切换为堆叠",tiled:"切换为平铺"}},restore:{title:"还原"},saveAsImage:{title:"保存为图片",lang:["右键另存为图片"]}},series:{typeNames:{pie:"饼图",bar:"柱状图",line:"折线图",scatter:"散点图",effectScatter:"涟漪散点图",radar:"雷达图",tree:"树图",treemap:"矩形树图",boxplot:"箱型图",candlestick:"K线图",k:"K线图",heatmap:"热力图",map:"地图",parallel:"平行坐标图",lines:"线图",graph:"关系图",sankey:"桑基图",funnel:"漏斗图",gauge:"仪表盘图",pictorialBar:"象形柱图",themeRiver:"主题河流图",sunburst:"旭日图"}},aria:{general:{withTitle:"这是一个关于“{title}”的图表。",withoutTitle:"这是一个图表,"},series:{single:{prefix:"",withName:"图表类型是{seriesType},表示{seriesName}。",withoutName:"图表类型是{seriesType}。"},multiple:{prefix:"它由{seriesCount}个图表系列组成。",withName:"第{seriesId}个系列是一个表示{seriesName}的{seriesType},",withoutName:"第{seriesId}个系列是一个{seriesType},",separator:{middle:";",end:"。"}}},data:{allData:"其数据是——",partialData:"其中,前{displayCnt}项是——",withName:"{name}的数据是{value}",withoutName:"{value}",separator:{middle:",",end:""}}}});var _d={year:"{yyyy}",month:"{MMM}",day:"{d}",hour:"{HH}:{mm}",minute:"{HH}:{mm}",second:"{HH}:{mm}:{ss}",millisecond:"{hh}:{mm}:{ss} {SSS}",none:"{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}"};_d.hour,_d.minute,_d.second,_d.none;var vd=fa;function yd(t,e,r,i,n){var a=0,o=0;null==i&&(i=1/0),null==n&&(n=1/0);var s=0;e.eachChild(function(l,h){var u,c,d=l.getBoundingRect(),f=e.childAt(h+1),p=f&&f.getBoundingRect();if("horizontal"===t){var m=d.width+(p?-p.x+d.x:0);(u=a+m)>i||l.newline?(a=0,u=m,o+=s+r,s=d.height):s=Math.max(s,d.height)}else{var g=d.height+(p?-p.y+d.y:0);(c=o+g)>n||l.newline?(a+=s+r,o=0,c=g,s=d.width):s=Math.max(s,d.width)}l.newline||(l.x=a,l.y=o,l.markRedraw(),"horizontal"===t?a=u+r:o=c+r)})}ia(yd,"vertical"),ia(yd,"horizontal");function xd(t,e,r){r=vd(r||0);var i=e.width,n=e.height,a=qh(t.left,i),o=qh(t.top,n),s=qh(t.right,i),l=qh(t.bottom,n),h=qh(t.width,i),u=qh(t.height,n),c=r[2]+r[0],d=r[1]+r[3],f=t.aspect;switch(isNaN(h)&&(h=i-s-d-a),isNaN(u)&&(u=n-l-c-o),null!=f&&(isNaN(h)&&isNaN(u)&&(f>i/n?h=.8*i:u=.8*n),isNaN(h)&&(h=f*u),isNaN(u)&&(u=h/f)),isNaN(a)&&(a=i-s-h-d),isNaN(o)&&(o=n-l-u-c),t.left||t.right){case"center":a=i/2-h/2-r[3];break;case"right":a=i-h-d}switch(t.top||t.bottom){case"middle":case"center":o=n/2-u/2-r[0];break;case"bottom":o=n-u-c}a=a||0,o=o||0,isNaN(h)&&(h=i-d-a-(s||0)),isNaN(u)&&(u=n-c-o-(l||0));var p=new Ho(a+r[3],o+r[0],h,u);return p.margin=r,p}var Td=function(){this._pool={},this._allocatedTextures=[]};Td.prototype={constructor:Td,get:function(t){var e=Sd(t);this._pool.hasOwnProperty(e)||(this._pool[e]=[]);var r=this._pool[e];if(!r.length){var i=new ir(t);return this._allocatedTextures.push(i),i}return r.pop()},put:function(t){var e=Sd(t);this._pool.hasOwnProperty(e)||(this._pool[e]=[]),this._pool[e].push(t)},clear:function(t){for(var e=0;e<this._allocatedTextures.length;e++)this._allocatedTextures[e].dispose(t);this._pool={},this._allocatedTextures=[]}};var bd={width:512,height:512,type:_.UNSIGNED_BYTE,format:_.RGBA,wrapS:_.CLAMP_TO_EDGE,wrapT:_.CLAMP_TO_EDGE,minFilter:_.LINEAR_MIPMAP_LINEAR,magFilter:_.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},wd=Object.keys(bd);function Sd(t){c.defaultsWithPropList(t,bd,wd),function(t){var e=(r=t.width,i=t.height,0==(r&r-1)&&0==(i&i-1));var r,i;t.format===_.DEPTH_COMPONENT&&(t.useMipmap=!1);e&&t.useMipmap||(t.minFilter==_.NEAREST_MIPMAP_NEAREST||t.minFilter==_.NEAREST_MIPMAP_LINEAR?t.minFilter=_.NEAREST:t.minFilter!=_.LINEAR_MIPMAP_LINEAR&&t.minFilter!=_.LINEAR_MIPMAP_NEAREST||(t.minFilter=_.LINEAR));e||(t.wrapS=_.CLAMP_TO_EDGE,t.wrapT=_.CLAMP_TO_EDGE)}(t);for(var e="",r=0;r<wd.length;r++){e+=t[wd[r]].toString()}return e}var Ed=Td,Ad=["px","nx","py","ny","pz","nz"];function Md(t,e,r){return"alphaMap"===r?t.material.get("diffuseMap"):"alphaCutoff"===r?t.material.isDefined("fragment","ALPHA_TEST")&&t.material.get("diffuseMap")&&t.material.get("alphaCutoff")||0:"uvRepeat"===r?t.material.get("uvRepeat"):"uvOffset"===r?t.material.get("uvOffset"):e.get(r)}function Cd(t,e){var r=t.material,i=e.material;return r.get("diffuseMap")!==i.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(i.get("alphaCutoff")||0)}bt.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 Dd,Ld,Pd,Nd,Rd,Id,Od,Bd=f.extend(function(){return{softShadow:Bd.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 ai,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new Ed}},function(){this._gaussianPassH=new Bi({fragment:bt.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new Bi({fragment:bt.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 Bi({fragment:bt.source("clay.sm.debug_depth")})},{render:function(t,e,r,i){r||(r=e.getMainCamera()),this.trigger("beforerender",this,t,e,r),this._renderShadowPass(t,e,r,i),this.trigger("afterrender",this,t,e,r)},renderDebug:function(t,e){t.saveClear();var r=t.viewport,i=0,n=e||r.width/4,a=n;for(var o in this.softShadow===Bd.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[o];t.setViewport(i,0,n*s.width/s.height,a),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(t),i+=n*s.width/s.height}t.setViewport(r),t.restoreClear()},_updateReceivers:function(t,e){if(e.receiveShadow?(this._receivers.push(e),e.material.set("shadowEnabled",1),e.material.set("pcfKernel",this.kernelPCF)):e.material.set("shadowEnabled",0),this.softShadow===Bd.VSM)e.material.define("fragment","USE_VSM"),e.material.undefine("fragment","PCF_KERNEL_SIZE");else{e.material.undefine("fragment","USE_VSM");var r=this.kernelPCF;r&&r.length?e.material.define("fragment","PCF_KERNEL_SIZE",r.length/2):e.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(t,e){var r=this;e.traverse(function(e){e.isRenderable()&&r._updateReceivers(t,e)});for(var i=0;i<e.lights.length;i++){var n=e.lights[i];n.castShadow&&!n.invisible&&this._lightsCastShadow.push(n)}},_renderShadowPass:function(t,e,r,i){for(var n in this._shadowMapNumber)this._shadowMapNumber[n]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var a=t.gl;if(i||e.update(),r&&r.update(),e.updateLights(),this._update(t,e),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=[],h=[],u=[],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(t,e,r,p,c,u,h)}else"SPOT_LIGHT"===p.type?this.renderSpotLightShadow(t,e,p,l,s):"POINT_LIGHT"===p.type&&this.renderPointLightShadow(t,e,p,d);this._shadowMapNumber[p.type]++}for(var m in this._shadowMapNumber){var g=this._shadowMapNumber[m],_=m+"_SHADOWMAP_COUNT";for(f=0;f<this._receivers.length;f++){(v=this._receivers[f].material).fragmentDefines[_]!==g&&(g>0?v.define("fragment",_,g):v.isDefined("fragment",_)&&v.undefine("fragment",_))}}for(f=0;f<this._receivers.length;f++){var v=this._receivers[f].material;o?v.define("fragment","SHADOW_CASCADE",o.shadowCascade):v.undefine("fragment","SHADOW_CASCADE")}var y=e.shadowUniforms;if(h.length>0){var x=h.map(S);if(y.directionalLightShadowMaps={value:h,type:"tv"},y.directionalLightMatrices={value:u,type:"m4v"},y.directionalLightShadowMapSizes={value:x,type:"1fv"},o){var T=c.slice(),b=c.slice();T.pop(),b.shift(),T.reverse(),b.reverse(),u.reverse(),y.shadowCascadeClipsNear={value:T,type:"1fv"},y.shadowCascadeClipsFar={value:b,type:"1fv"}}}if(s.length>0){var w=s.map(S);(y=e.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},y.spotLightMatrices={value:l,type:"m4v"},y.spotLightShadowMapSizes={value:w,type:"1fv"}}d.length>0&&(y.pointLightShadowMaps={value:d,type:"tv"})}function S(t){return t.height}},renderDirectionalLightShadow:(Dd=new Br,Ld=new _e,Pd=new Ie,Nd=new _e,Rd=new _e,Id=new _e,Od=new _e,function(t,e,r,i,n,a,o){var s=this._getDepthMaterial(i),l={getMaterial:function(t){return t.shadowDepthMaterial||s},isMaterialChanged:Cd,getUniform:Md,ifRender:function(t){return t.castShadow},sortCompare:zt.opaqueSortCompare};if(!e.viewBoundingBoxLastFrame.isFinite()){var h=e.getBoundingBox();e.viewBoundingBoxLastFrame.copy(h).applyTransform(r.viewMatrix)}var u=Math.min(-e.viewBoundingBoxLastFrame.min.z,r.far),c=Math.max(-e.viewBoundingBoxLastFrame.max.z,r.near),d=this._getDirectionalLightCamera(i,e,r),f=Id.array;Od.copy(d.projectionMatrix),Et.invert(Rd.array,d.worldTransform.array),Et.multiply(Rd.array,Rd.array,r.worldTransform.array),Et.multiply(f,Od.array,Rd.array);for(var p=[],m=r instanceof $r,g=(r.near+r.far)/(r.near-r.far),_=2*r.near*r.far/(r.near-r.far),v=0;v<=i.shadowCascade;v++){var y=c*Math.pow(u/c,v/i.shadowCascade),x=c+(u-c)*v/i.shadowCascade,T=y*i.cascadeSplitLogFactor+x*(1-i.cascadeSplitLogFactor);p.push(T),n.push(-(-T*g+_)/-T)}var b=this._getTexture(i,i.shadowCascade);o.push(b);var w=t.viewport,S=t.gl;for(this._frameBuffer.attach(b),this._frameBuffer.bind(t),S.clear(S.COLOR_BUFFER_BIT|S.DEPTH_BUFFER_BIT),v=0;v<i.shadowCascade;v++){var E=p[v],A=p[v+1];m?Et.perspective(Ld.array,r.fov/180*Math.PI,r.aspect,E,A):Et.ortho(Ld.array,r.left,r.right,r.bottom,r.top,E,A),Dd.setFromProjection(Ld),Dd.getTransformedBoundingBox(Pd,Rd),Pd.applyProjection(Od);var M=Pd.min.array,C=Pd.max.array;M[0]=Math.max(M[0],-1),M[1]=Math.max(M[1],-1),C[0]=Math.min(C[0],1),C[1]=Math.min(C[1],1),Nd.ortho(M[0],C[0],M[1],C[1],1,-1),d.projectionMatrix.multiplyLeft(Nd);var D=i.shadowResolution||512;t.setViewport((i.shadowCascade-v-1)*D,0,D,D,1);var L=e.updateRenderList(d);t.renderPass(L.opaque,d,l),this.softShadow===Bd.VSM&&this._gaussianFilter(t,b,b.width);var P=new _e;P.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),a.push(P.array),d.projectionMatrix.copy(Od)}this._frameBuffer.unbind(t),t.setViewport(w)}),renderSpotLightShadow:function(t,e,r,i,n){var a=this._getTexture(r),o=this._getSpotLightCamera(r),s=t.gl;this._frameBuffer.attach(a),this._frameBuffer.bind(t),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(r),h={getMaterial:function(t){return t.shadowDepthMaterial||l},isMaterialChanged:Cd,getUniform:Md,ifRender:function(t){return t.castShadow},sortCompare:zt.opaqueSortCompare},u=e.updateRenderList(o);t.renderPass(u.opaque,o,h),this._frameBuffer.unbind(t),this.softShadow===Bd.VSM&&this._gaussianFilter(t,a,a.width);var c=new _e;c.copy(o.worldTransform).invert().multiplyLeft(o.projectionMatrix),n.push(a),i.push(c.array)},renderPointLightShadow:function(t,e,r,i){var n=this._getTexture(r),a=t.gl;i.push(n);var o=this._getDepthMaterial(r),s={getMaterial:function(t){return t.shadowDepthMaterial||o},getUniform:Md,sortCompare:zt.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},h=new Ie,u=r.getWorldPosition().array,c=new Ie,d=r.range;c.min.setArray(u),c.max.setArray(u);var f=new Qt(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};e.traverse(function(t){if(t.isRenderable()&&t.castShadow){var e=t.geometry;if(!e.boundingBox){for(var r=0;r<Ad.length;r++)l[Ad[r]].push(t);return}if(h.transformFrom(e.boundingBox,t.worldTransform),!h.intersectBoundingBox(c))return;h.updateVertices();for(r=0;r<Ad.length;r++)p[Ad[r]]=!1;for(r=0;r<8;r++){var i=h.vertices[r],n=i[0]-u[0],a=i[1]-u[1],o=i[2]-u[2],s=Math.abs(n),d=Math.abs(a),f=Math.abs(o);s>d?s>f?p[n>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<Ad.length;r++)p[Ad[r]]&&l[Ad[r]].push(t)}});for(var m=0;m<6;m++){var g=Ad[m],_=this._getPointLightCamera(r,g);this._frameBuffer.attach(n,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m),this._frameBuffer.bind(t),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),t.renderPass(l[g],_,s)}this._frameBuffer.unbind(t)},_getDepthMaterial:function(t){var e=this._lightMaterials[t.__uid__],r="POINT_LIGHT"===t.type;if(!e){var i=r?"clay.sm.distance.":"clay.sm.depth.";e=new G({precision:this.precision,shader:new bt(bt.source(i+"vertex"),bt.source(i+"fragment"))}),this._lightMaterials[t.__uid__]=e}return null!=t.shadowSlopeScale&&e.setUniform("slopeScale",t.shadowSlopeScale),null!=t.shadowBias&&e.setUniform("bias",t.shadowBias),this.softShadow===Bd.VSM?e.define("fragment","USE_VSM"):e.undefine("fragment","USE_VSM"),r&&(e.set("lightPosition",t.getWorldPosition().array),e.set("range",t.range)),e},_gaussianFilter:function(t,e,r){var i={width:r,height:r,type:Ye.FLOAT},n=this._texturePool.get(i);this._frameBuffer.attach(n),this._frameBuffer.bind(t),this._gaussianPassH.setUniform("texture",e),this._gaussianPassH.setUniform("textureWidth",r),this._gaussianPassH.render(t),this._frameBuffer.attach(e),this._gaussianPassV.setUniform("texture",n),this._gaussianPassV.setUniform("textureHeight",r),this._gaussianPassV.render(t),this._frameBuffer.unbind(t),this._texturePool.put(n)},_getTexture:function(t,e){var r=t.__uid__,i=this._textures[r],n=t.shadowResolution||512;return e=e||1,i||((i="POINT_LIGHT"===t.type?new Jr:new ir).width=n*e,i.height=n,this.softShadow===Bd.VSM?(i.type=Ye.FLOAT,i.anisotropic=4):(i.minFilter=_.NEAREST,i.magFilter=_.NEAREST,i.useMipmap=!1),this._textures[r]=i),i},_getPointLightCamera:function(t,e){this._lightCameras.point||(this._lightCameras.point={px:new $r,nx:new $r,py:new $r,ny:new $r,pz:new $r,nz:new $r});var r=this._lightCameras.point[e];switch(r.far=t.range,r.fov=90,r.position.set(0,0,0),e){case"px":r.lookAt(Qt.POSITIVE_X,Qt.NEGATIVE_Y);break;case"nx":r.lookAt(Qt.NEGATIVE_X,Qt.NEGATIVE_Y);break;case"py":r.lookAt(Qt.POSITIVE_Y,Qt.POSITIVE_Z);break;case"ny":r.lookAt(Qt.NEGATIVE_Y,Qt.NEGATIVE_Z);break;case"pz":r.lookAt(Qt.POSITIVE_Z,Qt.NEGATIVE_Y);break;case"nz":r.lookAt(Qt.NEGATIVE_Z,Qt.NEGATIVE_Y)}return t.getWorldPosition(r.position),r.update(),r},_getDirectionalLightCamera:function(){var t=new _e,e=new Ie,r=new Ie;return function(i,n,a){this._lightCameras.directional||(this._lightCameras.directional=new Ni);var o=this._lightCameras.directional;e.copy(n.viewBoundingBoxLastFrame),e.intersection(a.frustum.boundingBox),o.position.copy(e.min).add(e.max).scale(.5).transformMat4(a.worldTransform),o.rotation.copy(i.rotation),o.scale.copy(i.scale),o.updateWorldTransform(),_e.invert(t,o.worldTransform),_e.multiply(t,t,a.worldTransform),r.copy(e).applyTransform(t);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(t){this._lightCameras.spot||(this._lightCameras.spot=new $r);var e=this._lightCameras.spot;return e.fov=2*t.penumbraAngle,e.far=t.range,e.worldTransform.copy(t.worldTransform),e.updateProjectionMatrix(),Et.invert(e.viewMatrix.array,e.worldTransform.array),e},dispose:function(t){var e=t.gl||t;for(var r in this._frameBuffer&&this._frameBuffer.dispose(e),this._textures)this._textures[r].dispose(e);this._texturePool.clear(t.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var i=0;i<this._receivers.length;i++){var n=this._receivers[i];if(n.material){var a=n.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=[]}});Bd.VSM=1,Bd.PCF=2;var Fd,zd=Bd,Ud=f.extend(function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},{updateParameter:function(t,e){var r,i,n=this.outputs[t],a=n.parameters,o=n._parametersCopy;if(o||(o=n._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,e):a.width,i=a.height instanceof Function?a.height.call(this,e):a.height,o.width===r&&o.height===i||this._outputTextures[t]&&this._outputTextures[t].dispose(e.gl),o.width=r,o.height=i,o},setParameter:function(t,e){},getParameter:function(t){},setParameters:function(t){for(var e in t)this.setParameter(e,t[e])},render:function(){},getOutput:function(t,e){if(null==e)return e=t,this._outputTextures[e];var r=this.outputs[e];return r?this._rendered?r.outputLastFrame?this._prevOutputTextures[e]:this._outputTextures[e]:this._rendering?(this._prevOutputTextures[e]||(this._prevOutputTextures[e]=this._compositor.allocateTexture(r.parameters||{})),this._prevOutputTextures[e]):(this.render(t),this._outputTextures[e]):void 0},removeReference:function(t){(this._outputReferences[t]--,0===this._outputReferences[t])&&(this.outputs[t].keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t]))},link:function(t,e,r){this.inputLinks[t]={node:e,pin:r},e.outputLinks[r]||(e.outputLinks[r]=[]),e.outputLinks[r].push({node:this,pin:t}),this.pass.material.enableTexture(t)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(t){if(!this._rendering){for(var e in this._rendering=!0,this.inputLinks){var r=this.inputLinks[e];r.node.updateReference(r.pin)}this._rendering=!1}t&&this._outputReferences[t]++},beforeFrame:function(){for(var t in this._rendered=!1,this.outputLinks)this._outputReferences[t]=0},afterFrame:function(){for(var t in this.outputLinks){if(this._outputReferences[t]>0)this.outputs[t].keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t])}}}),kd=f.extend(function(){return{nodes:[]}},{dirty:function(){this._dirty=!0},addNode:function(t){this.nodes.indexOf(t)>=0||(this.nodes.push(t),this._dirty=!0)},removeNode:function(t){"string"==typeof t&&(t=this.getNodeByName(t));var e=this.nodes.indexOf(t);e>=0&&(this.nodes.splice(e,1),this._dirty=!0)},getNodeByName:function(t){for(var e=0;e<this.nodes.length;e++)if(this.nodes[e].name===t)return this.nodes[e]},update:function(){for(var t=0;t<this.nodes.length;t++)this.nodes[t].clear();for(t=0;t<this.nodes.length;t++){var e=this.nodes[t];if(e.inputs)for(var r in e.inputs)if(e.inputs[r])if(!e.pass||e.pass.material.isUniformEnabled(r)){var i=e.inputs[r],n=this.findPin(i);n?e.link(r,n.node,n.pin):"string"==typeof i?console.warn("Node "+i+" not exist"):console.warn("Pin of "+i.node+"."+i.pin+" not exist")}else console.warn("Pin "+e.name+"."+r+" not used.")}},findPin:function(t){var e;if(("string"==typeof t||t instanceof Ud)&&(t={node:t}),"string"==typeof t.node)for(var r=0;r<this.nodes.length;r++){var i=this.nodes[r];i.name===t.node&&(e=i)}else e=t.node;if(e){var n=t.pin;if(n||e.outputs&&(n=Object.keys(e.outputs)[0]),e.outputs[n])return{node:e,pin:n}}}}),Gd=kd.extend(function(){return{_outputs:[],_texturePool:new Ed,_frameBuffer:new ai({depthBuffer:!1})}},{addNode:function(t){kd.prototype.addNode.call(this,t),t._compositor=this},render:function(t,e){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(t,e);for(r=0;r<this.nodes.length;r++)this.nodes[r].afterFrame()},allocateTexture:function(t){return this._texturePool.get(t)},releaseTexture:function(t){this._texturePool.put(t)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(t){this._texturePool.clear(t)}}),Hd=Ud.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},function(){this.frameBuffer=new ai},{render:function(t){this._rendering=!0;var e,r=t.gl;if(this.trigger("beforerender"),this.outputs){var i=this.frameBuffer;for(var n in this.outputs){var a=this.updateParameter(n,t),o=this.outputs[n],s=this._compositor.allocateTexture(a);this._outputTextures[n]=s,"string"==typeof(u=o.attachment||r.COLOR_ATTACHMENT0)&&(u=r[u]),i.attach(s,u)}i.bind(t);var l=t.getGLExtension("EXT_draw_buffers");if(l){var h=[];for(var u in this.outputs)(u=parseInt(u))>=r.COLOR_ATTACHMENT0&&u<=r.COLOR_ATTACHMENT0+8&&h.push(u);l.drawBuffersEXT(h)}t.saveClear(),t.clearBit=_.DEPTH_BUFFER_BIT|_.COLOR_BUFFER_BIT,e=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),t.restoreClear(),i.unbind(t)}else e=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",e),this._rendering=!1,this._rendered=!0}}),Vd=Ud.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(t,e){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),Wd=Ud.extend(function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},function(){var t=new Bi({fragment:this.shader});this.pass=t},{render:function(t,e){this.trigger("beforerender",t),this._rendering=!0;var r=t.gl;for(var i in this.inputLinks){var n=(c=this.inputLinks[i]).node.getOutput(t,c.pin);this.pass.setUniform(i,n)}if(this.outputs){this.pass.outputs={};var a={};for(var o in this.outputs){var s=this.updateParameter(o,t);isNaN(s.width)&&this.updateParameter(o,t);var l=this.outputs[o],h=this._compositor.allocateTexture(s);this._outputTextures[o]=h,"string"==typeof(u=l.attachment||r.COLOR_ATTACHMENT0)&&(u=r[u]),a[u]=h}for(var u in this._compositor.getFrameBuffer().bind(t),a)this._compositor.getFrameBuffer().attach(a[u],u);this.pass.render(t),this._compositor.getFrameBuffer().updateMipmap(t)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(t),this.pass.render(t,e);for(var i in this.inputLinks){var c;(c=this.inputLinks[i]).node.removeReference(c.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",t)},updateParameter:function(t,e){var r,i,n=this.outputs[t],a=n.parameters,o=n._parametersCopy;if(o||(o=n._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,e):a.width,i="function"==typeof a.height?a.height.call(this,e):a.height,r=Math.ceil(r),i=Math.ceil(i),o.width===r&&o.height===i||this._outputTextures[t]&&this._outputTextures[t].dispose(e),o.width=r,o.height=i,o},setParameter:function(t,e){this.pass.setUniform(t,e)},getParameter:function(t){return this.pass.getUniform(t)},setParameters:function(t){for(var e in t)this.setParameter(e,t[e])},define:function(t,e){this.pass.material.define("fragment",t,e)},undefine:function(t){this.pass.material.undefine("fragment",t)},removeReference:function(t){(this._outputReferences[t]--,0===this._outputReferences[t])&&(this.outputs[t].keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t]))},clear:function(){Ud.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),Xd="@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",jd="@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",qd="@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",Zd="\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",Yd="@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",Kd="@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",Qd="@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",Jd="@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",$d="\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",tf="@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",ef="@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",rf="@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",nf="@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";(Fd=bt).import(Xd),Fd.import(jd),Fd.import(qd),Fd.import(Zd),Fd.import(Yd),Fd.import(Kd),Fd.import(Qd),Fd.import(Jd),Fd.import($d),Fd.import(tf),Fd.import(ef),Fd.import(rf),Fd.import(nf);var af=/^#source\((.*?)\)/;function of(t,e,r){var i,n,a,o,s=t.type||"filter";if("filter"===s){var l=t.shader.trim(),h=af.exec(l);if(h?i=bt.source(h[1].trim()):"#"===l.charAt(0)&&(i=e.shaders[l.substr(1)]),i||(i=l),!i)return}if(t.inputs)for(var u in n={},t.inputs)"string"==typeof t.inputs[u]?n[u]=t.inputs[u]:n[u]={node:t.inputs[u].node,pin:t.inputs[u].pin};if(t.outputs)for(var u in a={},t.outputs){var c=t.outputs[u];a[u]={},null!=c.attachment&&(a[u].attachment=c.attachment),null!=c.keepLastFrame&&(a[u].keepLastFrame=c.keepLastFrame),null!=c.outputLastFrame&&(a[u].outputLastFrame=c.outputLastFrame),c.parameters&&(a[u].parameters=hf(c.parameters))}if(o="scene"===s?new Hd({name:t.name,scene:r.scene,camera:r.camera,outputs:a}):"texture"===s?new Vd({name:t.name,outputs:a}):new Wd({name:t.name,shader:i,inputs:n,outputs:a})){if(t.parameters)for(var u in t.parameters){"string"==typeof(d=t.parameters[u])?"#"===(d=d.trim()).charAt(0)?d=e.textures[d.substr(1)]:o.on("beforerender",uf(u,cf(d))):"function"==typeof d&&o.on("beforerender",d),o.setParameter(u,d)}if(t.defines&&o.pass)for(var u in t.defines){var d=t.defines[u];o.pass.material.define("fragment",u,d)}}return o}function sf(t,e){return t}function lf(t,e){return e}function hf(t){var e={};if(!t)return e;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach(function(r){var i=t[r];null!=i&&("string"==typeof i&&(i=Ye[i]),e[r]=i)});var r=t.scale||1;return["width","height"].forEach(function(i){if(null!=t[i]){var n=t[i];"string"==typeof n?(n=n.trim(),e[i]=(a=cf(n),o=(o=r)||1,function(t){var e=t.getDevicePixelRatio(),r=t.getWidth()*o,i=t.getHeight()*o;return a(r,i,e)})):e[i]=n}var a,o}),e.width||(e.width=sf),e.height||(e.height=lf),null!=t.useMipmap&&(e.useMipmap=t.useMipmap),e}function uf(t,e){return function(r){var i=r.getDevicePixelRatio(),n=r.getWidth(),a=r.getHeight(),o=e(n,a,i);this.setParameter(t,o)}}function cf(t){var e=/^expr\((.*)\)$/.exec(t);if(e)try{var r=new Function("width","height","dpr","return "+e[1]);return r(1,1),r}catch(t){throw new Error("Invalid expression.")}}var df=function(t,e){var r=new Gd;e=e||{};var i={textures:{},parameters:{}};for(var n in t.parameters){var a=t.parameters[n];i.parameters[n]=hf(a)}return function(t,e,r,i){if(t.textures){var n={},a=0,o=!1,s=r.textureRootPath;c.each(t.textures,function(t,e){var r,l=t.path,h=hf(t.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map(function(t){return c.relative2absolute(t,s)})),r=new Jr(h);else{if("string"!=typeof l)return;s&&(l=c.relative2absolute(l,s)),r=new ir(h)}r.load(l),a++,r.once("success",function(){n[e]=r,0==--a&&(i(n),o=!0)})}),0!==a||o||i(n)}else i({})}(t,0,e,function(n){i.textures=n,function(n,a){for(var o=0;o<t.nodes.length;o++){var s=of(t.nodes[o],i,e);s&&r.addNode(s)}}()}),r};var ff=function(t,e){for(var r=0,i=1/e,n=t;n>0;)r+=i*(n%e),n=Math.floor(n/e),i/=e;return r};function pf(t){for(var e=new Uint8Array(t*t*4),r=0,i=new Qt,n=0;n<t;n++)for(var a=0;a<t;a++)i.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),e[r++]=255*(.5*i.x+.5),e[r++]=255*(.5*i.y+.5),e[r++]=0,e[r++]=255;return e}function mf(t){return new ir({pixels:pf(t),wrapS:Ye.REPEAT,wrapT:Ye.REPEAT,width:t,height:t})}function gf(t,e,r){var i=new Float32Array(3*t);e=e||0;for(var n=0;n<t;n++){var a=ff(n+e,2)*(r?1:2)*Math.PI,o=ff(n+e,3)*Math.PI,s=Math.random(),l=Math.cos(a)*Math.sin(o)*s,h=Math.cos(o)*s,u=Math.sin(a)*Math.sin(o)*s;i[3*n]=l,i[3*n+1]=h,i[3*n+2]=u}return i}function _f(t){t=t||{},this._ssaoPass=new Bi({fragment:bt.source("ecgl.ssao.estimate")}),this._blurPass=new Bi({fragment:bt.source("ecgl.ssao.blur")}),this._framebuffer=new ai({depthBuffer:!1}),this._ssaoTexture=new ir,this._blurTexture=new ir,this._blurTexture2=new ir,this._depthTex=t.depthTexture,this._normalTex=t.normalTexture,this.setNoiseSize(4),this.setKernelSize(t.kernelSize||12),null!=t.radius&&this.setParameter("radius",t.radius),null!=t.power&&this.setParameter("power",t.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)}bt.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"),_f.prototype.setDepthTexture=function(t){this._depthTex=t},_f.prototype.setNormalTexture=function(t){this._normalTex=t,this._ssaoPass.material[t?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},_f.prototype.update=function(t,e,r){var i=t.getWidth(),n=t.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 _e;_e.transpose(s,e.worldTransform),a.setUniform("projection",e.projectionMatrix.array),a.setUniform("projectionInv",e.invProjectionMatrix.array),a.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,h=this._blurTexture,u=this._blurTexture2;l.width=i/2,l.height=n/2,h.width=i,h.height=n,u.width=i,u.height=n,this._framebuffer.attach(l),this._framebuffer.bind(t),t.gl.clearColor(1,1,1,1),t.gl.clear(t.gl.COLOR_BUFFER_BIT),a.render(t),o.setUniform("textureSize",[i/2,n/2]),o.setUniform("projection",e.projectionMatrix.array),this._framebuffer.attach(h),o.setUniform("direction",0),o.setUniform("ssaoTexture",l),o.render(t),this._framebuffer.attach(u),o.setUniform("textureSize",[i,n]),o.setUniform("direction",1),o.setUniform("ssaoTexture",h),o.render(t),this._framebuffer.unbind(t);var c=t.clearColor;t.gl.clearColor(c[0],c[1],c[2],c[3])},_f.prototype.getTargetTexture=function(){return this._blurTexture2},_f.prototype.setParameter=function(t,e){"noiseTexSize"===t?this.setNoiseSize(e):"kernelSize"===t?this.setKernelSize(e):"intensity"===t?this._ssaoPass.material.set("intensity",e):this._ssaoPass.setUniform(t,e)},_f.prototype.setKernelSize=function(t){this._kernelSize=t,this._ssaoPass.material.define("fragment","KERNEL_SIZE",t),this._kernels=this._kernels||[];for(var e=0;e<30;e++)this._kernels[e]=gf(t,e*t,!!this._normalTex)},_f.prototype.setNoiseSize=function(t){var e=this._ssaoPass.getUniform("noiseTex");e?(e.data=pf(t),e.width=e.height=t,e.dirty()):(e=mf(t),this._ssaoPass.setUniform("noiseTex",mf(t))),this._ssaoPass.setUniform("noiseTexSize",[t,t])},_f.prototype.dispose=function(t){this._blurTexture.dispose(t),this._ssaoTexture.dispose(t),this._blurTexture2.dispose(t)};var vf=_f;function yf(t){t=t||{},this._ssrPass=new Bi({fragment:bt.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new Bi({fragment:bt.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new Bi({fragment:bt.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new Bi({fragment:bt.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",t.normalTexture),this._ssrPass.setUniform("gBufferTexture2",t.depthTexture),this._blurPass1.setUniform("gBufferTexture1",t.normalTexture),this._blurPass1.setUniform("gBufferTexture2",t.depthTexture),this._blurPass2.setUniform("gBufferTexture1",t.normalTexture),this._blurPass2.setUniform("gBufferTexture2",t.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new ir({type:Ye.HALF_FLOAT}),this._texture2=new ir({type:Ye.HALF_FLOAT}),this._texture3=new ir({type:Ye.HALF_FLOAT}),this._prevTexture=new ir({type:Ye.HALF_FLOAT}),this._currentTexture=new ir({type:Ye.HALF_FLOAT}),this._frameBuffer=new ai({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}bt.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"),yf.prototype.setAmbientCubemap=function(t,e){this._ssrPass.material.set("specularCubemap",t),this._ssrPass.material.set("specularIntensity",e);var r=t&&e;this._ssrPass.material[r?"enableTexture":"disableTexture"]("specularCubemap")},yf.prototype.update=function(t,e,r,i){var n=t.getWidth(),a=t.getHeight(),o=this._ssrTexture,s=this._texture2,l=this._texture3;o.width=this._prevTexture.width=this._currentTexture.width=n/this._downScale,o.height=this._prevTexture.height=this._currentTexture.height=a/this._downScale,s.width=l.width=n,s.height=l.height=a;var h=this._frameBuffer,u=this._ssrPass,c=this._blurPass1,d=this._blurPass2,f=this._blendPass,p=new _e,m=new _e;_e.transpose(p,e.worldTransform),_e.transpose(m,e.viewMatrix),u.setUniform("sourceTexture",r),u.setUniform("projection",e.projectionMatrix.array),u.setUniform("projectionInv",e.invProjectionMatrix.array),u.setUniform("toViewSpace",p.array),u.setUniform("toWorldSpace",m.array),u.setUniform("nearZ",e.near);var g=i/this._totalSamples*this._samplePerFrame;if(u.setUniform("jitterOffset",g),u.setUniform("sampleOffset",i*this._samplePerFrame),c.setUniform("textureSize",[o.width,o.height]),d.setUniform("textureSize",[n,a]),d.setUniform("sourceTexture",r),c.setUniform("projection",e.projectionMatrix.array),d.setUniform("projection",e.projectionMatrix.array),h.attach(o),h.bind(t),u.render(t),this._physicallyCorrect&&(h.attach(this._currentTexture),f.setUniform("texture1",this._prevTexture),f.setUniform("texture2",o),f.material.set({weight1:i>=1?.95:0,weight2:i>=1?.05:1}),f.render(t)),h.attach(s),c.setUniform("texture",this._physicallyCorrect?this._currentTexture:o),c.render(t),h.attach(l),d.setUniform("texture",s),d.render(t),h.unbind(t),this._physicallyCorrect){var _=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=_}},yf.prototype.getTargetTexture=function(){return this._texture3},yf.prototype.setParameter=function(t,e){"maxIteration"===t?this._ssrPass.material.define("fragment","MAX_ITERATION",e):this._ssrPass.setUniform(t,e)},yf.prototype.setPhysicallyCorrect=function(t){t?(this._normalDistribution||(this._normalDistribution=Ui.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=t},yf.prototype.setSSAOTexture=function(t){var e=this._blurPass2;t?(e.material.enableTexture("ssaoTex"),e.material.set("ssaoTex",t)):e.material.disableTexture("ssaoTex")},yf.prototype.isFinished=function(t){return!this._physicallyCorrect||t>this._totalSamples/this._samplePerFrame},yf.prototype.dispose=function(t){this._ssrTexture.dispose(t),this._texture2.dispose(t),this._texture3.dispose(t),this._prevTexture.dispose(t),this._currentTexture.dispose(t),this._frameBuffer.dispose(t)};var xf=yf,Tf=[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 bf(t,e,r,i,n){var a=t.gl;e.setUniform(a,"1i",r,n),a.activeTexture(a.TEXTURE0+n),i.isRenderable()?i.bind(t):i.unbind(t)}function wf(t){t=t||{},this._depthTex=new ir({format:Ye.DEPTH_COMPONENT,type:Ye.UNSIGNED_INT}),this._normalTex=new ir({type:Ye.HALF_FLOAT}),this._framebuffer=new ai,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,ai.DEPTH_ATTACHMENT),this._normalMaterial=new G({shader:new bt(bt.source("ecgl.normal.vertex"),bt.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=Mi.createBlank("#000"),this._defaultBumpMap=Mi.createBlank("#000"),this._defaultRoughessMap=Mi.createBlank("#000"),this._debugPass=new Bi({fragment:bt.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}bt.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"),wf.prototype.getDepthTexture=function(){return this._depthTex},wf.prototype.getNormalTexture=function(){return this._normalTex},wf.prototype.update=function(t,e,r){var i=t.getWidth(),n=t.getHeight(),a=this._depthTex,o=this._normalTex,s=this._normalMaterial;a.width=i,a.height=n,o.width=i,o.height=n;var l=e.getRenderList(r).opaque;this._framebuffer.bind(t),t.gl.clearColor(0,0,0,0),t.gl.clear(t.gl.COLOR_BUFFER_BIT|t.gl.DEPTH_BUFFER_BIT),t.gl.disable(t.gl.BLEND),t.renderPass(l,r,{getMaterial:function(){return s},ifRender:function(t){return t.renderNormal},beforeRender:function(t,e,r,i,n){var a,o,s,l,h=t.gl;return function(n,u,c){if(!l||l.material!==n.material){var d=n.material,f=n.__program,p=d.get("roughness");null==p&&(p=1);var m=d.get("normalMap")||e,g=d.get("roughnessMap"),_=d.get("bumpMap"),v=d.get("uvRepeat"),y=d.get("uvOffset"),x=d.get("detailUvRepeat"),T=d.get("detailUvOffset"),b=!!_&&d.isTextureEnabled("bumpMap"),w=!!g&&d.isTextureEnabled("roughnessMap"),S=d.isDefined("fragment","DOUBLE_SIDED");_=_||r,g=g||i,c!==u?(u.set("normalMap",m),u.set("bumpMap",_),u.set("roughnessMap",g),u.set("useBumpMap",b),u.set("useRoughnessMap",w),u.set("doubleSide",S),null!=v&&u.set("uvRepeat",v),null!=y&&u.set("uvOffset",y),null!=x&&u.set("detailUvRepeat",x),null!=T&&u.set("detailUvOffset",T),u.set("roughness",p)):(f.setUniform(h,"1f","roughness",p),a!==m&&bf(t,f,"normalMap",m,0),o!==_&&_&&bf(t,f,"bumpMap",_,1),s!==g&&g&&bf(t,f,"roughnessMap",g,2),null!=v&&f.setUniform(h,"2f","uvRepeat",v),null!=y&&f.setUniform(h,"2f","uvOffset",y),null!=x&&f.setUniform(h,"2f","detailUvRepeat",x),null!=T&&f.setUniform(h,"2f","detailUvOffset",T),f.setUniform(h,"1i","useBumpMap",+b),f.setUniform(h,"1i","useRoughnessMap",+w),f.setUniform(h,"1i","doubleSide",+S)),a=m,o=_,s=g,l=n}}}(t,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:t.opaqueSortCompare}),this._framebuffer.unbind(t)},wf.prototype.renderDebug=function(t){this._debugPass.render(t)},wf.prototype.dispose=function(t){this._depthTex.dispose(t),this._normalTex.dispose(t)};var Sf=wf;function Ef(t){t=t||{},this._edgePass=new Bi({fragment:bt.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",t.normalTexture),this._edgePass.setUniform("depthTexture",t.depthTexture),this._targetTexture=new ir({type:Ye.HALF_FLOAT}),this._frameBuffer=new ai,this._frameBuffer.attach(this._targetTexture)}Ef.prototype.update=function(t,e,r,i){var n=t.getWidth(),a=t.getHeight(),o=this._targetTexture;o.width=n,o.height=a;var s=this._frameBuffer;s.bind(t),this._edgePass.setUniform("projectionInv",e.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[n,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(t),s.unbind(t)},Ef.prototype.getTargetTexture=function(){return this._targetTexture},Ef.prototype.setParameter=function(t,e){this._edgePass.setUniform(t,e)},Ef.prototype.dispose=function(t){this._targetTexture.dispose(t),this._frameBuffer.dispose(t)};var Af=Ef,Mf={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 Cf(t,e){return{color:{parameters:{width:t,height:e}}}}bt.import(jd),bt.import(Zd),bt.import(Kd),bt.import(Qd),bt.import(Jd),bt.import($d),bt.import(tf),bt.import(rf),bt.import(nf),bt.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"),bt.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 Df=["composite","FXAA"];function Lf(){this._width,this._height,this._dpr,this._sourceTexture=new ir({type:Ye.HALF_FLOAT}),this._depthTexture=new ir({format:Ye.DEPTH_COMPONENT,type:Ye.UNSIGNED_INT}),this._framebuffer=new ai,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,ai.DEPTH_ATTACHMENT),this._normalPass=new Sf,this._compositor=df(Mf);var t=this._compositor.getNodeByName("source");t.texture=this._sourceTexture;var e=this._compositor.getNodeByName("coc");this._sourceNode=t,this._cocNode=e,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(t){return this._compositor.getNodeByName(t)},this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=Df.map(function(t){return this._compositor.getNodeByName(t)},this);var r={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new vf(r),this._ssrPass=new xf(r),this._edgePass=new Af(r)}Lf.prototype.resize=function(t,e,r){t*=r=r||1,e*=r;var i=this._sourceTexture,n=this._depthTexture;i.width=t,i.height=e,n.width=t,n.height=e;var a={getWidth:function(){return t},getHeight:function(){return e},getDevicePixelRatio:function(){return r}};function o(t,e){if("function"==typeof t[e]){var r=t[e].__original||t[e];t[e]=function(t){return r.call(this,a)},t[e].__original=r}}this._compositor.nodes.forEach(function(t){for(var e in t.outputs){var r=t.outputs[e].parameters;r&&(o(r,"width"),o(r,"height"))}for(var i in t.parameters)o(t.parameters,i)}),this._width=t,this._height=e,this._dpr=r},Lf.prototype.getWidth=function(){return this._width},Lf.prototype.getHeight=function(){return this._height},Lf.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},Lf.prototype._getPrevNode=function(t){for(var e=Df.indexOf(t.name)-1,r=this._finalNodesChain[e];r&&!this._compositor.getNodeByName(r.name);)e-=1,r=this._finalNodesChain[e];return r},Lf.prototype._getNextNode=function(t){for(var e=Df.indexOf(t.name)+1,r=this._finalNodesChain[e];r&&!this._compositor.getNodeByName(r.name);)e+=1,r=this._finalNodesChain[e];return r},Lf.prototype._addChainNode=function(t){var e=this._getPrevNode(t),r=this._getNextNode(t);e&&(t.inputs.texture=e.name,r?(t.outputs=Cf(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=t.name):t.outputs=null,this._compositor.addNode(t))},Lf.prototype._removeChainNode=function(t){var e=this._getPrevNode(t),r=this._getNextNode(t);e&&(r?(e.outputs=Cf(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=e.name):e.outputs=null,this._compositor.removeNode(t))},Lf.prototype.updateNormal=function(t,e,r,i){this._ifRenderNormalPass()&&this._normalPass.update(t,e,r)},Lf.prototype.updateSSAO=function(t,e,r,i){this._ssaoPass.update(t,r,i)},Lf.prototype.enableSSAO=function(){this._enableSSAO=!0},Lf.prototype.disableSSAO=function(){this._enableSSAO=!1},Lf.prototype.enableSSR=function(){this._enableSSR=!0},Lf.prototype.disableSSR=function(){this._enableSSR=!1},Lf.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},Lf.prototype.getSourceFrameBuffer=function(){return this._framebuffer},Lf.prototype.getSourceTexture=function(){return this._sourceTexture},Lf.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},Lf.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},Lf.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},Lf.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},Lf.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},Lf.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},Lf.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},Lf.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},Lf.prototype.enableEdge=function(){this._enableEdge=!0},Lf.prototype.disableEdge=function(){this._enableEdge=!1},Lf.prototype.setBloomIntensity=function(t){this._compositeNode.setParameter("bloomIntensity",t)},Lf.prototype.setSSAOParameter=function(t,e){switch(t){case"quality":var r={low:6,medium:12,high:32,ultra:62}[e]||12;this._ssaoPass.setParameter("kernelSize",r);break;case"radius":this._ssaoPass.setParameter(t,e),this._ssaoPass.setParameter("bias",e/200);break;case"intensity":this._ssaoPass.setParameter(t,e);break;default:0}},Lf.prototype.setDOFParameter=function(t,e){switch(t){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(t,e);break;case"blurRadius":for(var r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].setParameter("blurRadius",e);break;case"quality":var i={low:4,medium:8,high:16,ultra:32}[e]||8;this._dofBlurKernelSize=i;for(r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].pass.material.define("POISSON_KERNEL_SIZE",i);this._dofBlurKernel=new Float32Array(2*i);break;default:0}},Lf.prototype.setSSRParameter=function(t,e){if(null!=e)switch(t){case"quality":var r={low:10,medium:15,high:30,ultra:80}[e]||20,i={low:32,medium:16,high:8,ultra:4}[e]||16;this._ssrPass.setParameter("maxIteration",r),this._ssrPass.setParameter("pixelStride",i);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-e,1),0));break;case"physical":this.setPhysicallyCorrectSSR(e);break;default:console.warn("Unkown SSR parameter "+t)}},Lf.prototype.setPhysicallyCorrectSSR=function(t){this._ssrPass.setPhysicallyCorrect(t)},Lf.prototype.setEdgeColor=function(t){var e=Wa.parseColor(t);this._edgePass.setParameter("edgeColor",e)},Lf.prototype.setExposure=function(t){this._compositeNode.setParameter("exposure",Math.pow(2,t))},Lf.prototype.setColorLookupTexture=function(t,e){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?t:"none",e,{minFilter:Wa.Texture.NEAREST,magFilter:Wa.Texture.NEAREST,flipY:!1})},Lf.prototype.setColorCorrection=function(t,e){this._compositeNode.setParameter(t,e)},Lf.prototype.isSSREnabled=function(){return this._enableSSR},Lf.prototype.composite=function(t,e,r,i,n){var a=this._sourceTexture,o=a;this._enableEdge&&(this._edgePass.update(t,r,a,n),a=o=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(t,r,a,n),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,h=n%Math.floor(Tf.length/2/l),u=0;u<2*l;u++)s[u]=Tf[u+h*l*2];for(u=0;u<this._dofBlurNodes.length;u++)this._dofBlurNodes[u].setParameter("percent",n/30),this._dofBlurNodes[u].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",r.near),this._cocNode.setParameter("zFar",r.far),this._compositor.render(t,i)},Lf.prototype.dispose=function(t){this._sourceTexture.dispose(t),this._depthTexture.dispose(t),this._framebuffer.dispose(t),this._compositor.dispose(t),this._normalPass.dispose(t),this._ssaoPass.dispose(t)};var Pf=Lf;function Nf(t){for(var e=[],r=0;r<30;r++)e.push([ff(r,2),ff(r,3)]);this._haltonSequence=e,this._frame=0,this._sourceTex=new ir,this._sourceFb=new ai,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new ir,this._outputTex=new ir;var i=this._blendPass=new Bi({fragment:bt.source("clay.compositor.blend")});i.material.disableTexturesAll(),i.material.enableTexture(["texture1","texture2"]),this._blendFb=new ai({depthBuffer:!1}),this._outputPass=new Bi({fragment:bt.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(t){t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)}}Nf.prototype={constructor:Nf,jitterProjection:function(t,e){var r=t.viewport,i=r.devicePixelRatio||t.getDevicePixelRatio(),n=r.width*i,a=r.height*i,o=this._haltonSequence[this._frame%this._haltonSequence.length],s=new _e;s.array[12]=(2*o[0]-1)/n,s.array[13]=(2*o[1]-1)/a,_e.mul(e.projectionMatrix,s,e.projectionMatrix),_e.invert(e.invProjectionMatrix,e.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(t,e){this._prevFrameTex.width=t,this._prevFrameTex.height=e,this._outputTex.width=t,this._outputTex.height=e,this._sourceTex.width=t,this._sourceTex.height=e,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(t,e,r){var i=this._blendPass;0===this._frame?(i.setUniform("weight1",0),i.setUniform("weight2",1)):(i.setUniform("weight1",.9),i.setUniform("weight2",.1)),i.setUniform("texture1",this._prevFrameTex),i.setUniform("texture2",e||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(t),i.render(t),this._blendFb.unbind(t),r||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(t));var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,this._frame++},dispose:function(t){this._sourceFb.dispose(t),this._blendFb.dispose(t),this._prevFrameTex.dispose(t),this._outputTex.dispose(t),this._sourceTex.dispose(t),this._outputPass.dispose(t),this._blendPass.dispose(t)}};var Rf=Nf;function If(t){t=t||"perspective",this.layer=null,this.scene=new Wr,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(t),this._compositor=new Pf,this._temporalSS=new Rf,this._shadowMapPass=new zd;for(var e=[],r=0,i=0;i<30;i++){for(var n=[],a=0;a<6;a++)n.push(4*ff(r,2)-2),n.push(4*ff(r,3)-2),r++;e.push(n)}this._pcfKernels=e,this.scene.on("beforerender",function(t,e,r){this.needsTemporalSS()&&this._temporalSS.jitterProjection(t,r)},this)}If.prototype.setProjection=function(t){var e=this.camera;e&&e.update(),"perspective"===t?this.camera instanceof $r||(this.camera=new $r,e&&this.camera.setLocalTransform(e.localTransform)):this.camera instanceof Ni||(this.camera=new Ni,e&&this.camera.setLocalTransform(e.localTransform)),this.camera.near=.1,this.camera.far=2e3},If.prototype.setViewport=function(t,e,r,i,n){this.camera instanceof $r&&(this.camera.aspect=r/i),n=n||1,this.viewport.x=t,this.viewport.y=e,this.viewport.width=r,this.viewport.height=i,this.viewport.devicePixelRatio=n,this._compositor.resize(r*n,i*n),this._temporalSS.resize(r*n,i*n)},If.prototype.containPoint=function(t,e){var r=this.viewport;return e=this.layer.renderer.getHeight()-e,t>=r.x&&e>=r.y&&t<=r.x+r.width&&e<=r.y+r.height};var Of=new Z;If.prototype.castRay=function(t,e,r){var i=this.layer.renderer,n=i.viewport;return i.viewport=this.viewport,i.screenToNDC(t,e,Of),this.camera.castRay(Of,r),i.viewport=n,r},If.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var t=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var e=0;e<t.transparent.length;e++){var r=t.transparent[e].geometry;r.needsSortVerticesProgressively&&r.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),r.needsSortTrianglesProgressively&&r.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},If.prototype.render=function(t,e){this._doRender(t,e,this._frame),this._frame++},If.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},If.prototype.needsTemporalSS=function(){var t=this._enableTemporalSS;return"auto"===t&&(t=this._enablePostEffect),t},If.prototype.hasDOF=function(){return this._enableDOF},If.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},If.prototype._doRender=function(t,e,r){var i=this.scene,n=this.camera;r=r||0,this._updateTransparent(t,i,n,r),e||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(t,i,n,!0)),this._updateShadowPCFKernel(r);var a,o=t.clearColor;(t.gl.clearColor(o[0],o[1],o[2],o[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(t,n),this._compositor.updateNormal(t,i,n,this._temporalSS.getFrame())),this._updateSSAO(t,i,n,this._temporalSS.getFrame()),this._enablePostEffect)?((a=this._compositor.getSourceFrameBuffer()).bind(t),t.gl.clear(t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT),t.render(i,n,!0,!0),a.unbind(t),this.needsTemporalSS()&&e?(this._compositor.composite(t,i,n,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),t.setViewport(this.viewport),this._temporalSS.render(t)):(t.setViewport(this.viewport),this._compositor.composite(t,i,n,null,0))):this.needsTemporalSS()&&e?((a=this._temporalSS.getSourceFrameBuffer()).bind(t),t.saveClear(),t.clearBit=t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT,t.render(i,n,!0,!0),t.restoreClear(),a.unbind(t),t.setViewport(this.viewport),this._temporalSS.render(t)):(t.setViewport(this.viewport),t.render(i,n,!0,!0))},If.prototype._updateTransparent=function(t,e,r,i){for(var n=new Qt,a=new _e,o=r.getWorldPosition(),s=e.getRenderList(r).transparent,l=0;l<s.length;l++){var h=s[l],u=h.geometry;_e.invert(a,h.worldTransform),Qt.transformMat4(n,o,a),u.needsSortTriangles&&u.needsSortTriangles()&&u.doSortTriangles(n,i),u.needsSortVertices&&u.needsSortVertices()&&u.doSortVertices(n,i)}},If.prototype._updateSSAO=function(t,e,r){var i=this._enableSSAO&&this._enablePostEffect;i&&this._compositor.updateSSAO(t,e,r,this._temporalSS.getFrame());for(var n=e.getRenderList(r),a=0;a<n.opaque.length;a++){var o=n.opaque[a];o.renderNormal&&o.material[i?"enableTexture":"disableTexture"]("ssaoMap"),i&&o.material.set("ssaoMap",this._compositor.getSSAOTexture())}},If.prototype._updateShadowPCFKernel=function(t){for(var e=this._pcfKernels[t%this._pcfKernels.length],r=this.scene.getRenderList(this.camera).opaque,i=0;i<r.length;i++)r[i].receiveShadow&&(r[i].material.set("pcfKernel",e),r[i].material.define("fragment","PCF_KERNEL_SIZE",e.length/2))},If.prototype.dispose=function(t){this._compositor.dispose(t.gl),this._temporalSS.dispose(t.gl),this._shadowMapPass.dispose(t)},If.prototype.setPostEffect=function(t,e){var r=this._compositor;this._enablePostEffect=t.get("enable");var i=t.getModel("bloom"),n=t.getModel("edge"),a=t.getModel("DOF",t.getModel("depthOfField")),o=t.getModel("SSAO",t.getModel("screenSpaceAmbientOcclusion")),s=t.getModel("SSR",t.getModel("screenSpaceReflection")),l=t.getModel("FXAA"),h=t.getModel("colorCorrection");i.get("enable")?r.enableBloom():r.disableBloom(),a.get("enable")?r.enableDOF():r.disableDOF(),s.get("enable")?r.enableSSR():r.disableSSR(),h.get("enable")?r.enableColorCorrection():r.disableColorCorrection(),n.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(i.get("intensity")),r.setEdgeColor(n.get("color")),r.setColorLookupTexture(h.get("lookupTexture"),e),r.setExposure(h.get("exposure")),["radius","quality","intensity"].forEach(function(t){r.setSSAOParameter(t,o.get(t))}),["quality","maxRoughness","physical"].forEach(function(t){r.setSSRParameter(t,s.get(t))}),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach(function(t){r.setDOFParameter(t,a.get(t))}),["brightness","contrast","saturation"].forEach(function(t){r.setColorCorrection(t,h.get(t))})},If.prototype.setDOFFocusOnPoint=function(t){if(this._enablePostEffect){if(t>this.camera.far||t<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",t),!0}},If.prototype.setTemporalSuperSampling=function(t){this._enableTemporalSS=t.get("enable")},If.prototype.isLinearSpace=function(){return this._enablePostEffect},If.prototype.setRootNode=function(t){if(this.rootNode!==t){for(var e=this.rootNode.children(),r=0;r<e.length;r++)t.add(e[r]);t!==this.scene&&this.scene.add(t),this.rootNode=t}},If.prototype.add=function(t){this.rootNode.add(t)},If.prototype.remove=function(t){this.rootNode.remove(t)},If.prototype.removeAll=function(t){this.rootNode.removeAll(t)},Object.assign(If.prototype,s);var Bf=If;function Ff(t,e){var r=xd(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});r.y=e.getHeight()-r.y-r.height,this.viewGL.setViewport(r.x,r.y,r.width,r.height,e.getDevicePixelRatio());var i=t.get("boxWidth"),n=t.get("boxHeight"),a=t.get("boxDepth");this.getAxis("x").setExtent(-i/2,i/2),this.getAxis("y").setExtent(a/2,-a/2),this.getAxis("z").setExtent(-n/2,n/2),this.size=[i,n,a]}function zf(t,e){var r={};t.eachSeries(function(t){if(t.coordinateSystem===this){var e=t.getData();["x","y","z"].forEach(function(t){e.mapDimensionsAll(t,!0).forEach(function(i){var n,a;n=t,a=e.getDataExtent(i,!0),r[n]=r[n]||[1/0,-1/0],r[n][0]=Math.min(a[0],r[n][0]),r[n][1]=Math.max(a[1],r[n][1])})})}},this),["xAxis3D","yAxis3D","zAxis3D"].forEach(function(e){t.eachComponent(e,function(t){var n=e.charAt(0),a=t.getReferringComponents("grid3D").models[0],o=a.coordinateSystem;if(o===this){var s=o.getAxis(n);if(!s){var l=i.helper.createScale(r[n]||[1/0,-1/0],t);(s=new Xc(n,l)).type=t.get("type");var h="category"===s.type;s.onBand=h&&t.get("boundaryGap"),s.inverse=t.get("inverse"),t.axis=s,s.model=t,s.getLabelModel=function(){return t.getModel("axisLabel",a.getModel("axisLabel"))},s.getTickModel=function(){return t.getModel("axisTick",a.getModel("axisTick"))},o.addAxis(s)}}},this)},this),this.resize(this.model,e)}var Uf={dimensions:Vc.prototype.dimensions,create:function(t,e){var r=[];t.eachComponent("grid3D",function(t){t.__viewGL=t.__viewGL||new Bf;var e=new Vc;e.model=t,e.viewGL=t.__viewGL,t.coordinateSystem=e,r.push(e),e.resize=Ff,e.update=zf});var i=["xAxis3D","yAxis3D","zAxis3D"];return t.eachSeries(function(e){if("cartesian3D"===e.get("coordinateSystem")){if(null==(n=e.getReferringComponents("grid3D").models[0])){var r=function(t,e){return i.map(function(r){var i=t.getReferringComponents(r).models[0];return null==i&&(i=e.getComponent(r)),i})}(e,t),n=r[0].getCoordSysModel();r.forEach(function(t){t.getCoordSysModel()})}var a=n.coordinateSystem;e.coordinateSystem=a}}),r}};i.registerCoordinateSystem("grid3D",Uf);i.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},function(t,e){e.eachComponent({mainType:"grid3D",query:t},function(e){e.setView(t)})}),i.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},function(t,e){}),i.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},function(t,e){});var kf={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"}}},Gf={getFilledRegions:function(t,e){var r,n=(t||[]).slice();if("string"==typeof e?r=(e=i.getMap(e))&&e.geoJson:e&&e.features&&(r=e),!r)return[];for(var a={},o=r.features,s=0;s<n.length;s++)a[n[s].name]=n[s];for(s=0;s<o.length;s++){var l=o[s].properties.name;a[l]||n.push({name:l})}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}}}},Hf=i.extendComponentModel({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var t=this.option;t.regions=this.getFilledRegions(t.regions,t.map);var e=i.helper.createDimensions(["value"],t.data,{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),r=new i.List(e,this);r.initData(t.regions);var n={};r.each(function(t){var e=r.getName(t),i=r.getItemModel(t);n[e]=i}),this._regionModelMap=n,this._data=r},getData:function(){return this._data},getRegionModel:function(t){var e=this.getData().getName(t);return this._regionModelMap[e]||new i.Model(null,this)},getRegionPolygonCoords:function(t){var e=this.getData().getName(t),r=this.coordinateSystem.getRegion(e);return r?r.geometries:[]},getFormattedLabel:function(t,e){var r=this._data.getName(t),i=this.getRegionModel(t),n=i.get("normal"===e?["label","formatter"]:["emphasis","label","formatter"]);null==n&&(n=i.get(["label","formatter"]));var a={name:r};if("function"==typeof n)return a.status=e,n(a);if("string"==typeof n){var o=a.seriesName;return n.replace("{a}",null!=o?o:"")}return r},defaultOption:{regions:[]}});i.util.merge(Hf.prototype,Gf),i.util.merge(Hf.prototype,_o),i.util.merge(Hf.prototype,vo),i.util.merge(Hf.prototype,yo),i.util.merge(Hf.prototype,kf);var Vf=Wf;function Wf(t,e,r){r=r||2;var i,n,a,o,s,l,h,u=e&&e.length,c=u?e[0]*r:t.length,d=Xf(t,0,c,r,!0),f=[];if(!d)return f;if(u&&(d=function(t,e,r,i){var n,a,o,s,l,h=[];for(n=0,a=e.length;n<a;n++)o=e[n]*i,s=n<a-1?e[n+1]*i:t.length,(l=Xf(t,o,s,i,!1))===l.next&&(l.steiner=!0),h.push(ep(l));for(h.sort(Jf),n=0;n<h.length;n++)$f(h[n],r),r=jf(r,r.next);return r}(t,e,d,r)),t.length>80*r){i=a=t[0],n=o=t[1];for(var p=r;p<c;p+=r)s=t[p],l=t[p+1],s<i&&(i=s),l<n&&(n=l),s>a&&(a=s),l>o&&(o=l);h=Math.max(a-i,o-n)}return qf(d,f,r,i,n,h),f}function Xf(t,e,r,i,n){var a,o;if(n===dp(t,e,r,i)>0)for(a=e;a<r;a+=i)o=hp(a,t[a],t[a+1],o);else for(a=r-i;a>=e;a-=i)o=hp(a,t[a],t[a+1],o);return o&&ap(o,o.next)&&(up(o),o=o.next),o}function jf(t,e){if(!t)return t;e||(e=t);var r,i=t;do{if(r=!1,i.steiner||!ap(i,i.next)&&0!==np(i.prev,i,i.next))i=i.next;else{if(up(i),(i=e=i.prev)===i.next)return null;r=!0}}while(r||i!==e);return e}function qf(t,e,r,i,n,a,o){if(t){!o&&a&&function(t,e,r,i){var n=t;do{null===n.z&&(n.z=tp(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,r,i,n,a,o,s,l,h=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,i=r,s=0,e=0;e<h&&(s++,i=i.nextZ);e++);for(l=h;s>0||l>0&&i;)0!==s&&(0===l||!i||r.z<=i.z)?(n=r,r=r.nextZ,s--):(n=i,i=i.nextZ,l--),a?a.nextZ=n:t=n,n.prevZ=a,a=n;r=i}a.nextZ=null,h*=2}while(o>1)}(n)}(t,i,n,a);for(var s,l,h=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?Yf(t,i,n,a):Zf(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),up(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?qf(t=Kf(t,e,r),e,r,i,n,a,2):2===o&&Qf(t,e,r,i,n,a):qf(jf(t),e,r,i,n,a,1);break}}}function Zf(t){var e=t.prev,r=t,i=t.next;if(np(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(rp(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&np(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Yf(t,e,r,i){var n=t.prev,a=t,o=t.next;if(np(n,a,o)>=0)return!1;for(var s=n.x<a.x?n.x<o.x?n.x:o.x:a.x<o.x?a.x:o.x,l=n.y<a.y?n.y<o.y?n.y:o.y:a.y<o.y?a.y:o.y,h=n.x>a.x?n.x>o.x?n.x:o.x:a.x>o.x?a.x:o.x,u=n.y>a.y?n.y>o.y?n.y:o.y:a.y>o.y?a.y:o.y,c=tp(s,l,e,r,i),d=tp(h,u,e,r,i),f=t.nextZ;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&rp(n.x,n.y,a.x,a.y,o.x,o.y,f.x,f.y)&&np(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=c;){if(f!==t.prev&&f!==t.next&&rp(n.x,n.y,a.x,a.y,o.x,o.y,f.x,f.y)&&np(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function Kf(t,e,r){var i=t;do{var n=i.prev,a=i.next.next;!ap(n,a)&&op(n,i,i.next,a)&&sp(n,a)&&sp(a,n)&&(e.push(n.i/r),e.push(i.i/r),e.push(a.i/r),up(i),up(i.next),i=t=a),i=i.next}while(i!==t);return i}function Qf(t,e,r,i,n,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&ip(o,s)){var l=lp(o,s);return o=jf(o,o.next),l=jf(l,l.next),qf(o,e,r,i,n,a),void qf(l,e,r,i,n,a)}s=s.next}o=o.next}while(o!==t)}function Jf(t,e){return t.x-e.x}function $f(t,e){if(e=function(t,e){var r,i=e,n=t.x,a=t.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&s>o){if(o=s,s===n){if(a===i.y)return i;if(a===i.next.y)return i.next}r=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!r)return null;if(n===o)return r.prev;var l,h=r,u=r.x,c=r.y,d=1/0;i=r.next;for(;i!==h;)n>=i.x&&i.x>=u&&n!==i.x&&rp(a<c?n:o,a,u,c,a<c?o:n,a,i.x,i.y)&&((l=Math.abs(a-i.y)/(n-i.x))<d||l===d&&i.x>r.x)&&sp(i,t)&&(r=i,d=l),i=i.next;return r}(t,e)){var r=lp(e,t);jf(r,r.next)}}function tp(t,e,r,i,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)/n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ep(t){var e=t,r=t;do{e.x<r.x&&(r=e),e=e.next}while(e!==t);return r}function rp(t,e,r,i,n,a,o,s){return(n-o)*(e-s)-(t-o)*(a-s)>=0&&(t-o)*(i-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(n-o)*(i-s)>=0}function ip(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&op(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&sp(t,e)&&sp(e,t)&&function(t,e){var r=t,i=!1,n=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==t);return i}(t,e)}function np(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function ap(t,e){return t.x===e.x&&t.y===e.y}function op(t,e,r,i){return!!(ap(t,e)&&ap(r,i)||ap(t,i)&&ap(r,e))||np(t,e,r)>0!=np(t,e,i)>0&&np(r,i,t)>0!=np(r,i,e)>0}function sp(t,e){return np(t.prev,t,t.next)<0?np(t,e,t.next)>=0&&np(t,t.prev,e)>=0:np(t,e,t.prev)<0||np(t,t.next,e)<0}function lp(t,e){var r=new cp(t.i,t.x,t.y),i=new cp(e.i,e.x,e.y),n=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function hp(t,e,r,i){var n=new cp(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function up(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function cp(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function dp(t,e,r,i){for(var n=0,a=e,o=r-i;a<r;a+=i)n+=(t[o]-t[a])*(t[a+1]+t[o+1]),o=a;return n}function fp(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function pp(t,e,r,i,n){var a=r,o=t[e];fp(t,e,i);for(var s=r;s<i;s++)n(t[s],o)<0&&(fp(t,s,a),a++);return fp(t,i,a),a}function mp(t,e,r,i){if(r<i){var n=pp(t,Math.floor((r+i)/2),r,i,e);mp(t,e,r,n-1),mp(t,e,n+1,i)}}function gp(){this._parts=[]}Wf.deviation=function(t,e,r,i){var n=e&&e.length,a=n?e[0]*r:t.length,o=Math.abs(dp(t,0,a,r));if(n)for(var s=0,l=e.length;s<l;s++){var h=e[s]*r,u=s<l-1?e[s+1]*r:t.length;o-=Math.abs(dp(t,h,u,r))}var c=0;for(s=0;s<i.length;s+=3){var d=i[s]*r,f=i[s+1]*r,p=i[s+2]*r;c+=Math.abs((t[d]-t[p])*(t[f+1]-t[d+1])-(t[d]-t[f])*(t[p+1]-t[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},gp.prototype.step=function(t,e,r){var i=t.length;if(0===r){this._parts=[],this._sorted=!1;var n=Math.floor(i/2);this._parts.push({pivot:n,left:0,right:i-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=pp(t,a[o].pivot,a[o].left,a[o].right,e);var s=[];for(o=0;o<a.length;o++){var l=a[o].left;(h=a[o].pivot-1)>l&&s.push({pivot:Math.floor((h+l)/2),left:l,right:h});var h;l=a[o].pivot+1;(h=a[o].right)>l&&s.push({pivot:Math.floor((h+l)/2),left:l,right:h})}a=this._parts=s}else for(o=0;o<Math.floor(a.length/10);o++){var u=a.length-1-this._currentSortPartIdx;if(mp(t,e,a[u].left,a[u].right),this._currentSortPartIdx++,this._currentSortPartIdx===a.length)return this._sorted=!0,!0}return!1}},gp.sort=mp;var _p=gp,vp=lc.vec3,yp=vp.create(),xp=vp.create(),Tp=vp.create(),bp={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(t,e){var r=this.indices;if(0===e){var i=this.attributes.position;t=t.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 n,a=0,o=0;o<r.length;){i.get(r[o++],yp),i.get(r[o++],xp),i.get(r[o++],Tp);var s=vp.sqrDist(yp,t),l=vp.sqrDist(xp,t),h=vp.sqrDist(Tp,t),u=Math.min(s,l);u=Math.min(u,h),3===o?(n=u,u=0):u-=n,this._triangleZList[a++]=u}}var c=this._sortedTriangleIndices;for(o=0;o<c.length;o++)c[o]=o;if(this.triangleCount<2e4)0===e&&this._simpleSort(!0);else for(o=0;o<3;o++)this._progressiveQuickSort(3*e+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 _=this._indicesTmp;this._indicesTmp=this.indices,this.indices=_;_=this._triangleZListTmp;this._triangleZListTmp=this._triangleZList,this._triangleZList=_,this.dirtyIndices()},_simpleSort:function(t){var e=this._triangleZList,r=this._sortedTriangleIndices;function i(t,r){return e[r]-e[t]}t?Array.prototype.sort.call(r,i):_p.sort(r,i,0,r.length-1)},_progressiveQuickSort:function(t){var e=this._triangleZList,r=this._sortedTriangleIndices;this._quickSort=this._quickSort||new _p,this._quickSort.step(r,function(t,r){return e[r]-e[t]},t)}};function wp(t,e){const r=t.getItemVisual(e,"style");if(r){return r[t.getVisual("drawType")]}}function Sp(t,e){const r=t.getItemVisual(e,"style");return r&&r.opacity}function Ep(t,e,r){this._labelsMesh=new Nc,this._labelTextureSurface=new mc({width:512,height:512,devicePixelRatio:r.getDevicePixelRatio(),onupdate:function(){r.getZr().refresh()}}),this._api=r,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}Ep.prototype.getLabelPosition=function(t,e,r){return[0,0,0]},Ep.prototype.getLabelDistance=function(t,e,r){return 0},Ep.prototype.getMesh=function(){return this._labelsMesh},Ep.prototype.updateData=function(t,e,r){null==e&&(e=0),null==r&&(r=t.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===r-e||(this._labelsVisibilitiesBits=new Uint8Array(r-e));for(var i=["label","show"],n=["emphasis","label","show"],a=e;a<r;a++){var o=t.getItemModel(a),s=o.get(i),l=o.get(n);null==l&&(l=s);var h=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[a-e]=h}this._start=e,this._end=r,this._data=t},Ep.prototype.updateLabels=function(t){if(this._data){for(var e=(t=t||[]).length>0,r={},n=0;n<t.length;n++)r[t[n]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var a=["label"],o=["emphasis","label"],s=this._data.hostModel,l=this._data,h=s.getModel(a),u=s.getModel(o,h),c={left:"right",right:"left",top:"center",bottom:"center"},d={left:"middle",right:"middle",top:"bottom",bottom:"top"},f=this._start;f<this._end;f++){var p=!1;if(e&&r[f]&&(p=!0),this._labelsVisibilitiesBits[f-this._start]&(p?2:1)){var m=l.getItemModel(f).getModel(p?o:a,p?u:h),g=m.get("distance")||0,_=m.get("position"),v=m.getModel("textStyle"),y=this._api.getDevicePixelRatio(),x=s.getFormattedLabel(f,p?"emphasis":"normal");if(null==x||""===x)return;var T=new i.graphic.Text({style:Qu(v,{text:x,fill:v.get("color")||wp(l,f)||"#000",align:"left",verticalAlign:"top",opacity:qi.firstNotNull(v.get("opacity"),Sp(l,f),1)})}),b=T.getBoundingRect();b.height*=1.2;var w=this._labelTextureSurface.add(T),S=c[_]||"center",E=d[_]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(f,_,g),[b.width*y,b.height*y],w,S,E,this.getLabelDistance(f,_,g)*y)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}};var Ap=Ep,Mp=lc.vec3;function Cp(t){this.rootNode=new Wa.Node,this._triangulationResults={},this._shadersMap=Wa.COMMON_SHADERS.reduce(function(t,e){return t[e]=Wa.createShader("ecgl."+e),t},{}),this._linesShader=Wa.createShader("ecgl.meshLines3D");var e={};Wa.COMMON_SHADERS.forEach(function(t){e[t]=new Wa.Material({shader:Wa.createShader("ecgl."+t)})}),this._groundMaterials=e,this._groundMesh=new Wa.Mesh({geometry:new Wa.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new Ap(512,512,t),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=t}Wa.Shader.import(zc),Cp.prototype={constructor:Cp,extrudeY:!0,update:function(t,e,r,i,n){var a=t.getData();null==i&&(i=0),null==n&&(n=a.count()),this._startIndex=i,this._endIndex=n-1,this._triangulation(t,i,n);var o=this._getShader(t.get("shading"));this._prepareMesh(t,o,r,i,n),this.rootNode.updateWorldTransform(),this._updateRegionMesh(t,r,i,n);var s=t.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(t,s,r);var l=this;this._labelsBuilder.updateData(a,i,n),this._labelsBuilder.getLabelPosition=function(t,e,r){var i=a.getName(t),n=r;if("geo3D"===s.type){var o=s.getRegion(i);return o?(u=o.center,s.dataToPoint([u[0],u[1],n])):[NaN,NaN,NaN]}var h=l._triangulationResults[t-l._startIndex],u=l.extrudeY?[(h.max[0]+h.min[0])/2,h.max[1]+n,(h.max[2]+h.min[2])/2]:[(h.max[0]+h.min[0])/2,(h.max[1]+h.min[1])/2,h.max[2]+n]},this._data=a,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(t),this._lastHoverDataIndex=0},_initMeshes:function(){var t=this;var e,r=(e=new Wa.Mesh({name:"Polygon",material:new Wa.Material({shader:t._shadersMap.lambert}),geometry:new Wa.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0}),Object.assign(e.geometry,bp),e),i=new Wa.Mesh({material:new Wa.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new dc({useNativeLine:!1})});this.rootNode.add(r),this.rootNode.add(i),r.material.define("both","VERTEX_COLOR"),r.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=r,this._linesMesh=i,this.rootNode.add(this._groundMesh)},_getShader:function(t){var e=this._shadersMap[t];return e||(e=this._shadersMap.lambert),e.__shading=t,e},_prepareMesh:function(t,e,r,i,n){for(var a=0,o=0,s=0,l=0,h=i;h<n;h++){var u=this._getRegionPolygonInfo(h),c=this._getRegionLinesInfo(h,t,this._linesMesh.geometry);a+=u.vertexCount,o+=u.triangleCount,s+=c.vertexCount,l+=c.triangleCount}var d=this._polygonMesh,f=d.geometry;["position","normal","texcoord0","color"].forEach(function(t){f.attributes[t].init(a)}),f.indices=a>65535?new Uint32Array(3*o):new Uint16Array(3*o),d.material.shader!==e&&d.material.attachShader(e,!0),Wa.setMaterialFromModel(e.__shading,d.material,t,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*(n-i))},_updateRegionMesh:function(t,e,r,i){for(var n=t.getData(),a=0,o=0,s=!1,l=this._polygonMesh,h=this._linesMesh,u=r;u<i;u++){var c=t.getRegionModel(u),d=c.getModel("itemStyle"),f=qi.firstNotNull(wp(n,u),d.get("color"),"#fff"),p=qi.firstNotNull(Sp(n,u),1),m=Wa.parseColor(f),g=Wa.parseColor(d.get("borderColor"));m[3]*=p,g[3]*=p;var _=m[3]<.99;l.material.set("color",[1,1,1,1]),s=s||_;for(var v=qi.firstNotNull(c.get("height",!0),t.get("regionHeight")),y=this._updatePolygonGeometry(t,l.geometry,u,v,a,o,m),x=a;x<y.vertexOffset;x++)this._dataIndexOfVertex[x]=u;this._vertexRangeOfDataIndex[2*(u-r)]=a,this._vertexRangeOfDataIndex[2*(u-r)+1]=y.vertexOffset,a=y.vertexOffset,o=y.triangleOffset;var T=d.get("borderWidth"),b=T>0;b&&(T*=e.getDevicePixelRatio(),this._updateLinesGeometry(h.geometry,t,u,v,T,t.coordinateSystem.transform)),h.invisible=!b,h.material.set({color:g})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?Wa.Mesh.CCW:Wa.Mesh.CW,l.material.get("normalMap")&&l.geometry.generateTangents(),l.seriesIndex=t.seriesIndex,l.on("mousemove",this._onmousemove,this),l.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(t){var e=t.getModel("debug.wireframe");if(e.get("show")){var r=Wa.parseColor(e.get("lineStyle.color")||"rgba(0,0,0,0.5)"),i=qi.firstNotNull(e.get("lineStyle.width"),1),n=this._polygonMesh;n.geometry.generateBarycentric(),n.material.define("both","WIREFRAME_TRIANGLE"),n.material.set("wireframeLineColor",r),n.material.set("wireframeLineWidth",i)}},_onmousemove:function(t){var e=this._dataIndexOfVertex[t.triangle[0]];null==e&&(e=-1),e!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(e),this._labelsBuilder.updateLabels([e])),this._lastHoverDataIndex=e,this._polygonMesh.dataIndex=e},_onmouseout:function(t){t.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(t,e,r){var i=t.getModel("groundPlane",t);if(this._groundMesh.invisible=!i.get("show",!0),!this._groundMesh.invisible){var n=t.get("shading"),a=this._groundMaterials[n];a||(a=this._groundMaterials.lambert),Wa.setMaterialFromModel(n,a,i,r),a.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=a,this._groundMesh.material.set("color",Wa.parseColor(i.get("color"))),this._groundMesh.scale.set(e.size[0],e.size[2],1)}},_triangulation:function(t,e,r){this._triangulationResults=[];for(var i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],a=t.coordinateSystem,o=e;o<r;o++){for(var s=[],l=t.getRegionPolygonCoords(o),h=0;h<l.length;h++){var u=l[h].exterior,c=l[h].interiors,d=[],f=[];if(!(u.length<3)){for(var p=0,m=0;m<u.length;m++){var g=u[m];d[p++]=g[0],d[p++]=g[1]}for(m=0;m<c.length;m++)if(!(c[m].length<3)){for(var _=d.length/2,v=0;v<c[m].length;v++){g=c[m][v];d.push(g[0]),d.push(g[1])}f.push(_)}var y=Vf(d,f),x=new Float64Array(d.length/2*3),T=[],b=[1/0,1/0,1/0],w=[-1/0,-1/0,-1/0],S=0;for(m=0;m<d.length;)Mp.set(T,d[m++],0,d[m++]),a&&a.transform&&Mp.transformMat4(T,T,a.transform),Mp.min(b,b,T),Mp.max(w,w,T),x[S++]=T[0],x[S++]=T[1],x[S++]=T[2];Mp.min(i,i,b),Mp.max(n,n,w),s.push({points:x,indices:y,min:b,max:w})}}this._triangulationResults.push(s)}this._geoBoundingBox=[i,n]},_getRegionPolygonInfo:function(t){for(var e=this._triangulationResults[t-this._startIndex],r=0,i=0,n=0;n<e.length;n++)r+=e[n].points.length/3,i+=e[n].indices.length/3;return{vertexCount:2*r+4*r,triangleCount:2*i+2*r}},_updatePolygonGeometry:function(t,e,r,i,n,a,o){var s=t.get("projectUVOnGround"),l=e.attributes.position,h=e.attributes.normal,u=e.attributes.texcoord0,c=e.attributes.color,d=this._triangulationResults[r-this._startIndex],f=c.value&&o,p=e.indices,m=this.extrudeY?1:2,g=this.extrudeY?2:1,_=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],v=Mp.mul([],this._geoBoundingBox[0],_),y=Mp.mul([],this._geoBoundingBox[1],_),x=Math.max(y[0]-v[0],y[2]-v[2]);function T(t,e,r){var i=n;!function(t,e,r){for(var i=t.points,a=i.length,s=[],h=[],d=0;d<a;d+=3)s[0]=i[d],s[m]=e,s[g]=i[d+2],h[0]=(i[d]*_[0]-v[0])/x,h[1]=(i[d+2]*_[g]-v[2])/x,l.set(n,s),f&&c.set(n,o),u.set(n++,h)}(t,e);for(var s=t.indices.length,h=0;h<s;h++)p[3*a+h]=t.indices[h]+i;a+=t.indices.length/3}for(var b=this.extrudeY?[0,1,0]:[0,0,1],w=Mp.negate([],b),S=0;S<d.length;S++){var E=n,A=d[S];T(A,0),T(A,i);for(var M=A.points.length/3,C=0;C<M;C++)h.set(E+C,w),h.set(E+C+M,b);var D=[0,3,1,1,3,2],L=[[],[],[],[]],P=[],N=[],R=[],I=[],O=0;for(C=0;C<M;C++){for(var B=(C+1)%M,F=(A.points[3*B]-A.points[3*C])*_[0],z=(A.points[3*B+2]-A.points[3*C+2])*_[g],U=Math.sqrt(F*F+z*z),k=0;k<4;k++){var G=0===k||3===k,H=3*(G?C:B);L[k][0]=A.points[H],L[k][m]=k>1?i:0,L[k][g]=A.points[H+2],l.set(n+k,L[k]),s?(I[0]=(A.points[H]*_[0]-v[0])/x,I[1]=(A.points[H+2]*_[g]-v[g])/x):(I[0]=(G?O:O+U)/x,I[1]=(L[k][m]*_[m]-v[m])/x),u.set(n+k,I)}Mp.sub(P,L[1],L[0]),Mp.sub(N,L[3],L[0]),Mp.cross(R,P,N),Mp.normalize(R,R);for(k=0;k<4;k++)h.set(n+k,R),f&&c.set(n+k,o);for(k=0;k<6;k++)p[3*a+k]=D[k]+n;n+=4,a+=2,O+=U}}return e.dirty(),{vertexOffset:n,triangleOffset:a}},_getRegionLinesInfo:function(t,e,r){var i=0,n=0;e.getRegionModel(t).getModel("itemStyle").get("borderWidth")>0&&e.getRegionPolygonCoords(t).forEach(function(t){var e=t.exterior,a=t.interiors;i+=r.getPolylineVertexCount(e),n+=r.getPolylineTriangleCount(e);for(var o=0;o<a.length;o++)i+=r.getPolylineVertexCount(a[o]),n+=r.getPolylineTriangleCount(a[o])},this);return{vertexCount:i,triangleCount:n}},_updateLinesGeometry:function(t,e,r,i,n,a){function o(t){for(var e=new Float64Array(3*t.length),r=0,n=[],o=0;o<t.length;o++)n[0]=t[o][0],n[1]=i+.1,n[2]=t[o][1],a&&Mp.transformMat4(n,n,a),e[r++]=n[0],e[r++]=n[1],e[r++]=n[2];return e}var s=[1,1,1,1];e.getRegionPolygonCoords(r).forEach(function(e){var r=e.exterior,i=e.interiors;t.addPolyline(o(r),s,n);for(var a=0;a<i.length;a++)t.addPolyline(o(i[a]),s,n)})},highlight:function(t){var e=this._data;if(e){var r=e.getItemModel(t).getModel(["emphasis","itemStyle"]),n=r.get("color"),a=qi.firstNotNull(r.get("opacity"),Sp(e,t),1);if(null==n){var o=wp(e,t);n=i.color.lift(o,-.4)}null==a&&(a=Sp(e,t));var s=Wa.parseColor(n);s[3]*=a,this._setColorOfDataIndex(e,t,s)}},downplay:function(t){var e=this._data;if(e){var r=qi.firstNotNull(wp(e,t),e.getItemModel(t).get(["itemStyle","color"]),"#fff"),i=qi.firstNotNull(Sp(e,t),1),n=Wa.parseColor(r);n[3]*=i,this._setColorOfDataIndex(e,t,n)}},_setColorOfDataIndex:function(t,e,r){if(!(e<this._startIndex&&e>this._endIndex)){e-=this._startIndex;for(var i=this._vertexRangeOfDataIndex[2*e];i<this._vertexRangeOfDataIndex[2*e+1];i++)this._polygonMesh.geometry.attributes.color.set(i,r);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};var Dp=Cp,Lp=(i.extendComponentView({type:"geo3D",__ecgl__:!0,init:function(t,e){this._geo3DBuilder=new Dp(e),this.groupGL=new Wa.Node,this._lightRoot=new Wa.Node,this._sceneHelper=new Tc(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new oc({zr:e.getZr()}),this._control.init()},render:function(t,e,r){this.groupGL.add(this._geo3DBuilder.rootNode);var i=t.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this._lightRoot),t.get("show")?i.viewGL.add(this.groupGL):i.viewGL.remove(this.groupGL);var n=this._control;n.setViewGL(i.viewGL);var a=t.getModel("viewControl");n.setFromViewControlModel(a,0),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(t),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._geo3DBuilder.update(t,e,r,0,t.getData().count());var o=i.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse(function(t){t.material&&t.material[o]("fragment","SRGB_DECODE")}),n.off("update"),n.on("update",function(){r.dispatchAction({type:"geo3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),center:n.getCenter(),from:this.uid,geo3DId:t.id})}),n.update()}},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r)},dispose:function(){this._control.dispose()}}),{"南海诸岛":[32,80],"广东":[0,-10],"香港":[10,5],"澳门":[-10,10],"天津":[5,5]});var Pp={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]};var Np=lc.vec3,Rp=lc.mat4,Ip=[function(t,e){if("china"===t){var r=Lp[e.name];if(r){var i=e.center;i[0]+=r[0]/10.5,i[1]+=-r[1]/14}}},function(t,e){if("world"===t){var r=Pp[e.name];if(r){var i=e.center;i[0]=r[0],i[1]=r[1]}}}];function Op(t,e,r,i,n){this.name=t,this.map=e,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(r,i,n),this.transform=Rp.identity(new Float64Array(16)),this.invTransform=Rp.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}Op.prototype={constructor:Op,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(t,e,r){var n=i.parseGeoJSON||i.parseGeoJson;try{this.regions=t?n(t):[]}catch(t){throw"Invalid geoJson format\n"+t}e=e||{},r=r||{};for(var a=this.regions,o={},s=0;s<a.length;s++){var l=a[s].name;l=r[l]||l,a[s].name=l,o[l]=a[s],this.addGeoCoord(l,a[s].center);var h=e[l];h&&a[s].transformTo(h.left,h.top,h.width,h.height)}this._regionsMap=o,this._geoRect=null,Ip.forEach(function(t){t(this)},this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var t,e=this.regions,r=0;r<e.length;r++){var n=e[r].getBoundingRect();(t=t||n.clone()).union(n)}return this._geoRect=t||new i.graphic.BoundingRect(0,0,0,0)},addGeoCoord:function(t,e){this._nameCoordMap[t]=e},getRegion:function(t){return this._regionsMap[t]},getRegionByCoord:function(t){for(var e=this.regions,r=0;r<e.length;r++)if(e[r].contain(t))return e[r]},setSize:function(t,e,r){this.size=[t,e,r];var i=this.getGeoBoundingRect(),n=t/i.width,a=-r/i.height,o=-t/2-i.x*n,s=r/2-i.y*a,l=this.extrudeY?[o,0,s]:[o,s,0],h=this.extrudeY?[n,1,a]:[n,a,1],u=this.transform;Rp.identity(u),Rp.translate(u,u,l),Rp.scale(u,u,h),Rp.invert(this.invTransform,u)},dataToPoint:function(t,e){e=e||[];var r=this.extrudeY?1:2,i=this.extrudeY?2:1,n=t[2];return isNaN(n)&&(n=0),e[0]=t[0],e[i]=t[1],this.altitudeAxis?e[r]=this.altitudeAxis.dataToCoord(n):e[r]=0,e[r]+=this.regionHeight,Np.transformMat4(e,e,this.transform),e},pointToData:function(t,e){}};var Bp=Op;function Fp(t,e){var r=xd(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});r.y=e.getHeight()-r.y-r.height,this.viewGL.setViewport(r.x,r.y,r.width,r.height,e.getDevicePixelRatio());var i=this.getGeoBoundingRect(),n=i.width/i.height*(t.get("aspectScale")||.75),a=t.get("boxWidth"),o=t.get("boxDepth"),s=t.get("boxHeight");null==s&&(s=5),isNaN(a)&&isNaN(o)&&(a=100),isNaN(o)?o=a/n:isNaN(a)&&(a=o/n),this.setSize(a,s,o),this.regionHeight=t.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(s-this.regionHeight,0))}function zp(t,e){var r=[1/0,-1/0];if(t.eachSeries(function(t){if(t.coordinateSystem===this&&"series.map3D"!==t.type){var e=t.getData(),i=t.coordDimToDataDim("alt"),n=i&&i[0];if(n){var a=e.getDataExtent(n,!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=i.helper.createScale(r,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new i.Axis("altitude",n),this.resize(this.model,e)}}var Up=0,kp={dimensions:Bp.prototype.dimensions,create:function(t,e){var r=[];if(!i.getMap)throw new Error("geo3D component depends on geo component");function n(t,i){var n=kp.createGeo3D(t);t.__viewGL=t.__viewGL||new Bf,n.viewGL=t.__viewGL,t.coordinateSystem=n,n.model=t,r.push(n),n.resize=Fp,n.resize(t,e),n.update=zp}return t.eachComponent("geo3D",function(t,e){n(t)}),t.eachSeriesByType("map3D",function(t,e){var r=t.get("coordinateSystem");null==r&&(r="geo3D"),"geo3D"===r&&n(t)}),t.eachSeries(function(e){if("geo3D"===e.get("coordinateSystem")){if("series.map3D"===e.type)return;var r=e.getReferringComponents("geo3D").models[0];if(r||(r=t.getComponent("geo3D")),!r)throw new Error('geo "'+qi.firstNotNull(e.get("geo3DIndex"),e.get("geo3DId"),0)+'" not found');e.coordinateSystem=r.coordinateSystem}}),r},createGeo3D:function(t){var e,r=t.get("map");return"string"==typeof r?(e=r,r=i.getMap(r)):r&&r.features&&(r={geoJson:r}),null==e&&(e="GEO_ANONYMOUS_"+Up++),new Bp(e+Up++,e,r&&r.geoJson,r&&r.specialAreas,t.get("nameMap"))}};i.registerCoordinateSystem("geo3D",kp);var Gp=kp;function Hp(t,e){t.id=t.id||t.name||e+""}i.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},function(t,e){e.eachComponent({mainType:"geo3D",query:t},function(e){e.setView(t)})});var Vp=i.extendComponentModel({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){Vp.superApply(this,"init",arguments),i.util.each(this.option.layers,function(t,e){i.util.merge(t,this.defaultLayerOption),Hp(t,e)},this)},mergeOption:function(t){var e=this.option.layers;function r(t){return i.util.reduce(t,function(t,e,r){return Hp(e,r),t[e.id]=e,t},{})}if(this.option.layers=null,Vp.superApply(this,"mergeOption",arguments),e&&e.length){var n=r(t.layers),a=r(e);for(var o in n)a[o]?i.util.merge(a[o],n[o],!0):e.push(t.layers[o]);this.option.layers=e}i.util.each(this.option.layers,function(t){i.util.merge(t,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(t,e,r){this.displacementData=t,this.displacementWidth=e,this.displacementHeight=r},getDisplacementTexture:function(){return this.get("displacementTexture")||this.get("heightTexture")},getDisplacemenScale:function(){var t=this.getDisplacementTexture(),e=this.get("displacementScale");return t&&"none"!==t||(e=0),e},hasDisplacement:function(){return this.getDisplacemenScale()>0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var t=this.getDisplacementTexture(),e=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==t||this._displacementScale!==e,this._displacementTexture=t,this._displacementScale=e},isDisplacementChanged:function(){return this._displacementChanged}});i.util.merge(Vp.prototype,_o),i.util.merge(Vp.prototype,vo),i.util.merge(Vp.prototype,yo),i.util.merge(Vp.prototype,kf);var Wp=Math.PI,Xp=Math.sin,jp=Math.cos,qp=Math.tan,Zp=Math.asin,Yp=Math.atan2,Kp=Wp/180,Qp=864e5,Jp=2440588,$p=2451545;function tm(t){return function(t){return t.valueOf()/Qp-.5+Jp}(t)-$p}var em=23.4397*Kp;function rm(t){var e,r,i=function(t){return t+Kp*(1.9148*Xp(t)+.02*Xp(2*t)+3e-4*Xp(3*t))+102.9372*Kp+Wp}(function(t){return Kp*(357.5291+.98560028*t)}(t));return{dec:(e=i,r=0,Zp(Xp(r)*jp(em)+jp(r)*Xp(em)*Xp(e))),ra:function(t,e){return Yp(Xp(t)*jp(em)-qp(e)*Xp(em),jp(t))}(i,0)}}var im={};im.getPosition=function(t,e,r){var i=Kp*-r,n=Kp*e,a=tm(t),o=rm(a),s=function(t,e){return Kp*(280.16+360.9856235*t)-e}(a,i)-o.ra;return{azimuth:function(t,e,r){return Yp(Xp(t),jp(t)*Xp(e)-qp(r)*jp(e))}(s,n,o.dec),altitude:function(t,e,r){return Zp(Xp(e)*Xp(r)+jp(e)*jp(r)*jp(t))}(s,n,o.dec)}};var nm=im;Wa.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");i.extendComponentView({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(t,e){this.groupGL=new Wa.Node,this._sphereGeometry=new Wa.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new Wa.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new Wa.PlaneGeometry,this._earthMesh=new Wa.Mesh({renderNormal:!0}),this._atmosphereMesh=new Wa.Mesh,this._atmosphereGeometry=new Wa.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new Wa.Material({shader:new Wa.Shader(Wa.Shader.source("ecgl.atmosphere.vertex"),Wa.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=Wa.Mesh.CW,this._lightRoot=new Wa.Node,this._sceneHelper=new Tc,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new oc({zr:e.getZr()}),this._control.init(),this._layerMeshes={}},render:function(t,e,r){var i=t.coordinateSystem,n=t.get("shading");i.viewGL.add(this._lightRoot),t.get("show")?i.viewGL.add(this.groupGL):i.viewGL.remove(this.groupGL),this._sceneHelper.setScene(i.viewGL.scene),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling"));var a=this._earthMesh;a.geometry=this._sphereGeometry;var o="ecgl."+n;a.material&&a.material.shader.name===o||(a.material=Wa.createMaterial(o)),Wa.setMaterialFromModel(n,a.material,t,r),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach(function(t){var e=a.material.get(t);e&&(e.flipY=!1)}),a.material.set("color",Wa.parseColor(t.get("baseColor")));var s=.99*i.radius;if(a.scale.set(s,s,s),t.get("atmosphere.show")){a.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:t.get("atmosphere.glowPower")||6,glowColor:t.get("atmosphere.color")||"#ffffff"}),a.material.setUniforms({glowPower:t.get("atmosphere.innerGlowPower")||2,glowColor:t.get("atmosphere.color")||"#ffffff"});var l=t.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 h=a.material.setTextureImage("diffuseMap",t.get("baseTexture"),r,{flipY:!1,anisotropic:8});h&&h.surface&&h.surface.attachToMesh(a);var u=a.material.setTextureImage("bumpMap",t.get("heightTexture"),r,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(a),a.material[t.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(t,r),this._displaceVertices(t,r),this._updateViewControl(t,r),this._updateLayers(t,r)},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r)},_updateLayers:function(t,e){var r=t.coordinateSystem,n=t.get("layers"),a=r.radius,o=[],s=[],l=[],h=[];i.util.each(n,function(t){var n=new i.Model(t),u=n.get("type"),c=Wa.loadTexture(n.get("texture"),e,{flipY:!1,anisotropic:8});if(c.surface&&c.surface.attachToMesh(this._earthMesh),"blend"===u){var d=n.get("blendTo"),f=qi.firstNotNull(n.get("intensity"),1);"emission"===d?(l.push(c),h.push(f)):(o.push(c),s.push(f))}else{var p=n.get("id"),m=this._layerMeshes[p];m||(m=this._layerMeshes[p]=new Wa.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===n.get("shading")?(m.material=m.__lambertMaterial||new Wa.Material({autoUpdateTextureStatus:!1,shader:Wa.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),m.__lambertMaterial=m.material):(m.material=m.__colorMaterial||new Wa.Material({autoUpdateTextureStatus:!1,shader:Wa.createShader("ecgl.color"),transparent:!0,depthMask:!1}),m.__colorMaterial=m.material),m.material.enableTexture("diffuseMap");var g=n.get("distance"),_=a+(null==g?r.radius/100:g);m.scale.set(_,_,_),a=_;var v=this._blankTexture||(this._blankTexture=Wa.createBlankTexture("rgba(255, 255, 255, 0)"));m.material.set("diffuseMap",v),Wa.loadTexture(n.get("texture"),e,{flipY:!1,anisotropic:8},function(t){t.surface&&t.surface.attachToMesh(m),m.material.set("diffuseMap",t),e.getZr().refresh()}),n.get("show")?this.groupGL.add(m):this.groupGL.remove(m)}},this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",o.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",l.length),u.set("layerDiffuseMap",o),u.set("layerDiffuseIntensity",s),u.set("layerEmissiveMap",l),u.set("layerEmissionIntensity",h);var c=t.getModel("debug.wireframe");if(c.get("show")){u.define("both","WIREFRAME_TRIANGLE");var d=Wa.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),f=qi.firstNotNull(c.get("lineStyle.width"),1);u.set("wireframeLineWidth",f),u.set("wireframeLineColor",d)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(t,e){var r=t.coordinateSystem,i=t.getModel("viewControl"),n=(r.viewGL.camera,this);var a=this._control;a.setViewGL(r.viewGL);var o,s,l=i.get("targetCoord");null!=l&&(s=l[0]+90,o=l[1]),a.setFromViewControlModel(i,{baseDistance:r.radius,alpha:o,beta:s}),a.off("update"),a.on("update",function(){e.dispatchAction({type:"globeChangeCamera",alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()-r.radius,center:a.getCenter(),from:n.uid,globeId:t.id})})},_displaceVertices:function(t,e){var r=t.get("displacementQuality"),i=t.get("debug.wireframe.show"),n=t.coordinateSystem;if(t.isDisplacementChanged()||r!==this._displacementQuality||i!==this._showDebugWireframe){this._displacementQuality=r,this._showDebugWireframe=i;var a=this._sphereGeometry,o={low:100,medium:200,high:400,ultra:800}[r]||200,s=o/2;(a.widthSegments!==o||i)&&(a.widthSegments=o,a.heightSegments=s,a.build()),this._doDisplaceVertices(a,n),i&&a.generateBarycentric()}},_doDisplaceVertices:function(t,e){var r=t.attributes.position.value,i=t.attributes.texcoord0.value,n=t.__originalPosition;n&&n.length===r.length||((n=new Float32Array(r.length)).set(r),t.__originalPosition=n);for(var a=e.displacementWidth,o=e.displacementHeight,s=e.displacementData,l=0;l<t.vertexCount;l++){var h=3*l,u=2*l,c=n[h+1],d=n[h+2],f=n[h+3],p=i[u++],m=i[u++],g=Math.round(p*(a-1)),_=Math.round(m*(o-1)),v=s?s[_*a+g]:0;r[h+1]=c+c*v,r[h+2]=d+d*v,r[h+3]=f+f*v}t.generateVertexNormals(),t.dirty(),t.updateBoundingBox()},_updateLight:function(t,e){var r=this._earthMesh;this._sceneHelper.updateLight(t);var n=this._sceneHelper.mainLight,a=t.get("light.main.time")||new Date,o=nm.getPosition(i.number.parseDate(a),0,0),s=Math.cos(o.altitude);n.position.y=-s*Math.cos(o.azimuth),n.position.x=Math.sin(o.altitude),n.position.z=s*Math.sin(o.azimuth),n.lookAt(r.getWorldPosition())},dispose:function(t,e){this.groupGL.removeAll(),this._control.dispose()}});var am=lc.vec3;function om(t){this.radius=t,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}om.prototype={constructor:om,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(t,e,r){this.displacementData=t,this.displacementWidth=e,this.displacementHeight=r},_getDisplacementScale:function(t,e){var r=(t+180)/360*(this.displacementWidth-1),i=(90-e)/180*(this.displacementHeight-1),n=Math.round(r)+Math.round(i)*this.displacementWidth;return this.displacementData[n]},dataToPoint:function(t,e){var r=t[0],i=t[1],n=t[2]||0,a=this.radius;this.displacementData&&(a*=1+this._getDisplacementScale(r,i)),this.altitudeAxis&&(a+=this.altitudeAxis.dataToCoord(n)),r=r*Math.PI/180,i=i*Math.PI/180;var o=Math.cos(i)*a;return(e=e||[])[0]=-o*Math.cos(r+Math.PI),e[1]=Math.sin(i)*a,e[2]=o*Math.sin(r+Math.PI),e},pointToData:function(t,e){var r=t[0],i=t[1],n=t[2],a=am.len(t);r/=a,i/=a,n/=a;var o=Math.asin(i),s=Math.atan2(n,-r);s<0&&(s=2*Math.PI+s);var l=180*o/Math.PI,h=180*s/Math.PI-180;return(e=e||[])[0]=h,e[1]=l,e[2]=a-this.radius,this.altitudeAxis&&(e[2]=this.altitudeAxis.coordToData(e[2])),e}};var sm=om;function lm(t,e){var r=xd(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});r.y=e.getHeight()-r.y-r.height,this.viewGL.setViewport(r.x,r.y,r.width,r.height,e.getDevicePixelRatio()),this.radius=t.get("globeRadius");var i=t.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,i-this.radius)}function hm(t,e){var r=[1/0,-1/0];if(t.eachSeries(function(t){if(t.coordinateSystem===this){var e=t.getData(),i=t.coordDimToDataDim("alt"),n=i&&i[0];if(n){var a=e.getDataExtent(n,!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=i.helper.createScale(r,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new i.Axis("altitude",n),this.resize(this.model,e)}}var um={dimensions:sm.prototype.dimensions,create:function(t,e){var r=[];return t.eachComponent("globe",function(t){t.__viewGL=t.__viewGL||new Bf;var i=new sm;i.viewGL=t.__viewGL,t.coordinateSystem=i,i.model=t,r.push(i),i.resize=lm,i.resize(t,e),i.update=hm}),t.eachSeries(function(e){if("globe"===e.get("coordinateSystem")){var r=e.getReferringComponents("globe").models[0];if(r||(r=t.getComponent("globe")),!r)throw new Error('globe "'+qi.firstNotNull(e.get("globe3DIndex"),e.get("globe3DId"),0)+'" not found');var i=r.coordinateSystem;e.coordinateSystem=i}}),t.eachComponent("globe",function(t,r){var i=t.coordinateSystem,n=t.getDisplacementTexture(),a=t.getDisplacemenScale();if(t.isDisplacementChanged()){if(t.hasDisplacement()){var o=!0;Wa.loadTexture(n,e,function(r){var i=function(t,e){var r=document.createElement("canvas"),i=r.getContext("2d"),n=t.width,a=t.height;r.width=n,r.height=a,i.drawImage(t,0,0,n,a);for(var o=i.getImageData(0,0,n,a).data,s=new Float32Array(o.length/4),l=0;l<o.length/4;l++){var h=o[4*l];s[l]=h/255*e}return{data:s,width:n,height:a}}(r.image,a);t.setDisplacementData(i.data,i.width,i.height),o||e.dispatchAction({type:"globeUpdateDisplacment"})}),o=!1}else i.setDisplacementData(null,0,0);i.setDisplacementData(t.displacementData,t.displacementWidth,t.displacementHeight)}}),r}};i.registerCoordinateSystem("globe",um);i.registerAction({type:"globeChangeCamera",event:"globecamerachanged",update:"series:updateCamera"},function(t,e){e.eachComponent({mainType:"globe",query:t},function(e){e.setView(t)})}),i.registerAction({type:"globeUpdateDisplacment",event:"globedisplacementupdated",update:"update"},function(t,e){});var cm=lc.mat4,dm=Math.PI;function fm(){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}fm.prototype={constructor:fm,dimensions:["lng","lat","alt"],containPoint:function(){},setCameraOption:function(t){this.bearing=t.bearing,this.pitch=t.pitch,this.center=t.center,this.zoom=t.zoom,this._origin||(this._origin=this.projectOnTileWithScale(this.center,512)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var t=.5/Math.tan(.3217505543966422)*this.height*.1,e=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,r=Math.PI/2+e,i=Math.sin(.3217505543966422)*t/Math.sin(Math.PI-r-.3217505543966422),n=1.1*(Math.cos(Math.PI/2-e)*i+t);this.pitch>50&&(n=1e3);var a=[];cm.perspective(a,.6435011087932844,this.width/this.height,1,n),this.viewGL.camera.projectionMatrix.setArray(a),this.viewGL.camera.decomposeProjectionMatrix();a=cm.identity([]);var o=this.dataToPoint(this.center);cm.scale(a,a,[1,-1,1]),cm.translate(a,a,[0,0,-t]),cm.rotateX(a,a,e),cm.rotateZ(a,a,-this.bearing/180*Math.PI),cm.translate(a,a,[-o[0]*this.getScale()*.1,-o[1]*this.getScale()*.1,0]),this.viewGL.camera.viewMatrix.array=a;var s=[];cm.invert(s,a),this.viewGL.camera.worldTransform.array=s,this.viewGL.camera.decomposeWorldTransform();var l,h=512*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var u=this.altitudeExtent[1]-this.altitudeExtent[0];l=this.boxHeight/u*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else l=h/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*.1;this.viewGL.rootNode.scale.set(.1*this.getScale(),.1*this.getScale(),l)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(t,e){return this.projectOnTileWithScale(t,512*this.getScale(),e)},projectOnTileWithScale:function(t,e,r){var i=t[0],n=t[1]*dm/180,a=e*(i*dm/180+dm)/(2*dm),o=e*(dm-Math.log(Math.tan(dm/4+.5*n)))/(2*dm);return(r=r||[])[0]=a,r[1]=o,r},unprojectFromTile:function(t,e){return this.unprojectOnTileWithScale(t,512*this.getScale(),e)},unprojectOnTileWithScale:function(t,e,r){var i=t[0],n=t[1],a=i/e*(2*dm)-dm,o=2*(Math.atan(Math.exp(dm-n/e*(2*dm)))-dm/4);return(r=r||[])[0]=180*a/dm,r[1]=180*o/dm,r},dataToPoint:function(t,e){return(e=this.projectOnTileWithScale(t,512,e))[0]-=this._origin[0],e[1]-=this._origin[1],e[2]=isNaN(t[2])?0:t[2],isNaN(t[2])||(e[2]=t[2],this.altitudeExtent&&(e[2]-=this.altitudeExtent[0])),e}};var pm=fm;function mm(){pm.apply(this,arguments)}mm.prototype=new pm,mm.prototype.constructor=mm,mm.prototype.type="mapbox3D";var gm=function(t,e,r){function i(t,e){var r=e.getWidth(),i=e.getHeight(),n=e.getDevicePixelRatio();this.viewGL.setViewport(0,0,r,i,n),this.width=r,this.height=i,this.altitudeScale=t.get("altitudeScale"),this.boxHeight=t.get("boxHeight")}function n(t,e){if("auto"!==this.model.get("boxHeight")){var r=[1/0,-1/0];t.eachSeries(function(t){if(t.coordinateSystem===this){var e=t.getData(),i=t.coordDimToDataDim("alt")[0];if(i){var n=e.getDataExtent(i,!0);r[0]=Math.min(r[0],n[0]),r[1]=Math.max(r[1],n[1])}}},this),r&&isFinite(r[1]-r[0])&&(this.altitudeExtent=r)}}return{dimensions:e.prototype.dimensions,create:function(a,o){var s=[];return a.eachComponent(t,function(t){var r=t.__viewGL;r||(r=t.__viewGL=new Bf).setRootNode(new Wa.Node);var a=new e;a.viewGL=t.__viewGL,a.resize=i,a.resize(t,o),s.push(a),t.coordinateSystem=a,a.model=t,a.update=n}),a.eachSeries(function(e){if(e.get("coordinateSystem")===t){var r=e.getReferringComponents(t).models[0];if(r||(r=a.getComponent(t)),!r)throw new Error(t+' "'+qi.firstNotNull(e.get(t+"Index"),e.get(t+"Id"),0)+'" not found');e.coordinateSystem=r.coordinateSystem}}),r&&r(s,a,o),s}}},_m=gm("mapbox3D",mm,function(t){t.forEach(function(t){t.setCameraOption(t.model.getMapboxCameraOption())})});i.registerCoordinateSystem("mapbox3D",_m);var vm=["zoom","center","pitch","bearing"],ym=i.extendComponentModel({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 t=this;return vm.reduce(function(e,r){return e[r]=t.get(r),e},{})},setMapboxCameraOption:function(t){null!=t&&vm.forEach(function(e){null!=t[e]&&(this.option[e]=t[e])},this)},getMapbox:function(){return this._mapbox},setMapbox:function(t){this._mapbox=t}});i.util.merge(ym.prototype,vo),i.util.merge(ym.prototype,yo);function xm(t,e){if(this.id=t,this.zr=e,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()}xm.prototype.resize=function(){this._mapbox.resize()},xm.prototype.getMapbox=function(){return this._mapbox},xm.prototype.clear=function(){},xm.prototype.refresh=function(){this._mapbox.resize()};var Tm=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];xm.prototype._initEvents=function(){var t=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(t){return t.preventDefault(),!1}},Tm.forEach(function(e){this._handlers[e]=function(e){var r={};for(var i in e)r[i]=e[i];r.bubbles=!1;var n=new e.constructor(e.type,r);t.dispatchEvent(n)},this.zr.dom.addEventListener(e,this._handlers[e])},this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},xm.prototype.dispose=function(){Tm.forEach(function(t){this.zr.dom.removeEventListener(t,this._handlers[t])},this)};var bm=xm,wm="\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";Wa.Shader.import(wm);i.extendComponentView({type:"mapbox3D",__ecgl__:!0,init:function(t,e){var r=e.getZr();this._zrLayer=new bm("mapbox3D",r),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new Wa.Node,this._sceneHelper=new Tc(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var i=this._zrLayer.getMapbox(),n=this._dispatchInteractAction.bind(this,e,i);["zoom","rotate","drag","pitch","rotate","move"].forEach(function(t){i.on(t,n)}),this._groundMesh=new Wa.Mesh({geometry:new Wa.PlaneGeometry,material:new Wa.Material({shader:new Wa.Shader({vertex:Wa.Shader.source("ecgl.displayShadow.vertex"),fragment:Wa.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(t,e,r){var i=this._zrLayer.getMapbox(),n=t.get("style"),a=JSON.stringify(n);a!==this._oldStyleStr&&n&&i.setStyle(n),this._oldStyleStr=a,i.setCenter(t.get("center")),i.setZoom(t.get("zoom")),i.setPitch(t.get("pitch")),i.setBearing(t.get("bearing")),t.setMapbox(i);var o=t.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(t),o.viewGL.setPostEffect(t.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._mapbox3DModel=t},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r),t.coordinateSystem.viewGL.scene.traverse(function(t){t.material&&(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1))})},updateCamera:function(t,e,r,i){t.coordinateSystem.setCameraOption(i),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(t,e,r){t.dispatchAction({type:"mapbox3DChangeCamera",pitch:e.getPitch(),zoom:e.getZoom(),center:e.getCenter().toArray(),bearing:e.getBearing(),mapbox3DId:this._mapbox3DModel&&this._mapbox3DModel.id})},_updateGroundMesh:function(){if(this._mapbox3DModel){var t=this._mapbox3DModel.coordinateSystem,e=t.dataToPoint(t.center);this._groundMesh.position.set(e[0],e[1],-.001);var r=new Wa.Plane(new Wa.Vector3(0,0,1),0),i=t.viewGL.camera.castRay(new Wa.Vector2(-1,-1)),n=t.viewGL.camera.castRay(new Wa.Vector2(1,1)),a=i.intersectPlane(r),o=n.intersectPlane(r),s=a.dist(o)/t.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(t,e){this._zrLayer&&this._zrLayer.dispose(),e.getZr().painter.delLayer(-1e3)}});function Sm(){pm.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}i.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},function(t,e){e.eachComponent({mainType:"mapbox3D",query:t},function(e){e.setMapboxCameraOption(t)})}),Sm.prototype=new pm,Sm.prototype.constructor=Sm,Sm.prototype.type="maptalks3D";var Em=gm("maptalks3D",Sm,function(t){t.forEach(function(t){t.setCameraOption(t.model.getMaptalksCameraOption())})});i.registerCoordinateSystem("maptalks3D",Em);var Am=["zoom","center","pitch","bearing"],Mm=i.extendComponentModel({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var t=this;return Am.reduce(function(e,r){return e[r]=t.get(r),e},{})},setMaptalksCameraOption:function(t){null!=t&&Am.forEach(function(e){null!=t[e]&&(this.option[e]=t[e])},this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(t){this._maptalks=t}});i.util.merge(Mm.prototype,vo),i.util.merge(Mm.prototype,yo);function Cm(t,e,r,i){if(this.id=t,this.zr=e,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:i,doubleClickZoom:!1,fog:!1}),this._initEvents()}Cm.prototype.resize=function(){this._maptalks.checkSize()},Cm.prototype.getMaptalks=function(){return this._maptalks},Cm.prototype.clear=function(){},Cm.prototype.refresh=function(){this._maptalks.checkSize()};var Dm=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];Cm.prototype._initEvents=function(){var t=this.dom;this._handlers=this._handlers||{contextmenu:function(t){return t.preventDefault(),!1}},Dm.forEach(function(e){this._handlers[e]=function(r){var i={};for(var n in r)i[n]=r[n];i.bubbles=!1;var a=new r.constructor(r.type,i);"mousewheel"===e||"DOMMouseScroll"===e?t.dispatchEvent(a):t.firstElementChild.dispatchEvent(a)},this.zr.dom.addEventListener(e,this._handlers[e])},this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},Cm.prototype.dispose=function(){Dm.forEach(function(t){this.zr.dom.removeEventListener(t,this._handlers[t])},this),this._maptalks.remove()};var Lm=Cm;Wa.Shader.import(wm);i.extendComponentView({type:"maptalks3D",__ecgl__:!0,init:function(t,e){this._groundMesh=new Wa.Mesh({geometry:new Wa.PlaneGeometry,material:new Wa.Material({shader:new Wa.Shader({vertex:Wa.Shader.source("ecgl.displayShadow.vertex"),fragment:Wa.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(t,e){var r=e.getZr();this._zrLayer=new Lm("maptalks3D",r,t.get("center"),t.get("zoom")),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new Wa.Node,this._sceneHelper=new Tc(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var i=this._zrLayer.getMaptalks(),n=this._dispatchInteractAction.bind(this,e,i);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach(function(t){i.on(t,n)})},render:function(t,e,r){this._zrLayer||this._initMaptalksLayer(t,r);var i=this._zrLayer.getMaptalks(),n=t.get("urlTemplate"),a=i.getBaseLayer();n!==this._oldUrlTemplate&&(a?a.setOptions({urlTemplate:n,attribution:t.get("attribution")}):(a=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:n,subdomains:["a","b","c"],attribution:t.get("attribution")}),i.setBaseLayer(a))),this._oldUrlTemplate=n,i.setCenter(t.get("center")),i.setZoom(t.get("zoom"),{animation:!1}),i.setPitch(t.get("pitch")),i.setBearing(t.get("bearing")),t.setMaptalks(i);var o=t.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(t),o.viewGL.setPostEffect(t.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._maptalks3DModel=t},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r),t.coordinateSystem.viewGL.scene.traverse(function(t){t.material&&(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1))})},updateCamera:function(t,e,r,i){t.coordinateSystem.setCameraOption(i),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(t,e,r){var i;t.dispatchAction({type:"maptalks3DChangeCamera",pitch:e.getPitch(),zoom:(i=e.getResolution(),19-Math.log(i/Pm)/Math.LN2+1),center:e.getCenter().toArray(),bearing:e.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var t=this._maptalks3DModel.coordinateSystem,e=t.dataToPoint(t.center);this._groundMesh.position.set(e[0],e[1],-.001);var r=new Wa.Plane(new Wa.Vector3(0,0,1),0),i=t.viewGL.camera.castRay(new Wa.Vector2(-1,-1)),n=t.viewGL.camera.castRay(new Wa.Vector2(1,1)),a=i.intersectPlane(r),o=n.intersectPlane(r),s=a.dist(o)/t.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(t,e){this._zrLayer&&this._zrLayer.dispose(),e.getZr().painter.delLayer(-1e3)}});const Pm=12756274*Math.PI/(256*Math.pow(2,20));i.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},function(t,e){e.eachComponent({mainType:"maptalks3D",query:t},function(e){e.setMaptalksCameraOption(t)})});var Nm=lc.vec3,Rm=i.helper.dataStack.isDimensionStacked;var Im=function(t,e){var r=t.getData(),n=t.get("barSize");if(null==n){var a,o,s=e.size,l=e.getAxis("x"),h=e.getAxis("y");a="category"===l.type?.7*l.getBandWidth():.6*Math.round(s[0]/Math.sqrt(r.count())),o="category"===h.type?.7*h.getBandWidth():.6*Math.round(s[1]/Math.sqrt(r.count())),n=[a,o]}else i.util.isArray(n)||(n=[n,n]);var u,c,d,f=e.getAxis("z").scale.getExtent(),p=(c=(u=f)[0],d=u[1],!(c>0&&d>0||c<0&&d<0)),m=["x","y","z"].map(function(e){return t.coordDimToDataDim(e)[0]}),g=Rm(r,m[2]),_=g?r.getCalculationInfo("stackResultDimension"):m[2];r.each(m,function(t,i,a,o){var s=r.get(_,o),l=g?s-a:p?0:f[0],h=e.dataToPoint([t,i,l]),u=e.dataToPoint([t,i,s]),c=Nm.dist(h,u),d=[0,u[1]<h[1]?-1:1,0];0===Math.abs(c)&&(c=.1);var m=[n[0],c,n[1]];r.setItemLayout(o,[h,d,m])}),r.setLayout("orient",[1,0,0])},Om=function(t,e,r){for(var i=t.getDataExtent(e),n=t.getDataExtent(r),a=i[1]-i[0]||i[0],o=n[1]-n[0]||n[0],s=new Uint8Array(2500),l=0;l<t.count();l++){var h=t.get(e,l),u=t.get(r,l),c=Math.floor((h-i[0])/a*49),d=50*Math.floor((u-n[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},Bm=lc.vec3,Fm=i.helper.dataStack.isDimensionStacked;function zm(t,e){var r=Fm(t,e[2]);return{dimension:r?t.getCalculationInfo("stackResultDimension"):e[2],isStacked:r}}i.registerLayout(function(t,e){t.eachSeriesByType("bar3D",function(t){var e=t.coordinateSystem,r=e&&e.type;"globe"===r?function(t,e){var r=t.getData(),n=t.get("minHeight")||0,a=t.get("barSize"),o=["lng","lat","alt"].map(function(e){return t.coordDimToDataDim(e)[0]});if(null==a){var s=e.radius*Math.PI,l=Om(r,o[0],o[1]);a=[s/Math.sqrt(r.count()/l),s/Math.sqrt(r.count()/l)]}else i.util.isArray(a)||(a=[a,a]);var h=zm(r,o);r.each(o,function(t,i,o,s){var l=r.get(h.dimension,s),u=h.isStacked?l-o:e.altitudeAxis.scale.getExtent()[0],c=Math.max(e.altitudeAxis.dataToCoord(o),n),d=e.dataToPoint([t,i,u]),f=e.dataToPoint([t,i,l]),p=Bm.sub([],f,d);Bm.normalize(p,p);var m=[a[0],c,a[1]];r.setItemLayout(s,[d,p,m])}),r.setLayout("orient",Qt.UP.array)}(t,e):"cartesian3D"===r?Im(t,e):"geo3D"===r?function(t,e){var r=t.getData(),n=t.get("barSize"),a=t.get("minHeight")||0,o=["lng","lat","alt"].map(function(e){return t.coordDimToDataDim(e)[0]});if(null==n){var s=Math.min(e.size[0],e.size[2]),l=Om(r,o[0],o[1]);n=[s/Math.sqrt(r.count()/l),s/Math.sqrt(r.count()/l)]}else i.util.isArray(n)||(n=[n,n]);var h=[0,1,0],u=zm(r,o);r.each(o,function(t,i,o,s){var l=r.get(u.dimension,s),c=u.isStacked?l-o:e.altitudeAxis.scale.getExtent()[0],d=Math.max(e.altitudeAxis.dataToCoord(o),a),f=e.dataToPoint([t,i,c]),p=[n[0],d,n[1]];r.setItemLayout(s,[f,h,p])}),r.setLayout("orient",[1,0,0])}(t,e):("mapbox3D"===r||"maptalks3D"===r)&&function(t,e){var r=t.getData(),n=t.coordDimToDataDim("lng")[0],a=t.coordDimToDataDim("lat")[0],o=t.coordDimToDataDim("alt")[0],s=t.get("barSize"),l=t.get("minHeight")||0;if(null==s){var h=r.getDataExtent(n),u=r.getDataExtent(a),c=e.dataToPoint([h[0],u[0]]),d=e.dataToPoint([h[1],u[1]]),f=Math.min(Math.abs(c[0]-d[0]),Math.abs(c[1]-d[1]))||1,p=Om(r,n,a);s=[f/Math.sqrt(r.count()/p),f/Math.sqrt(r.count()/p)]}else i.util.isArray(s)||(s=[s,s]),s[0]/=e.getScale()/16,s[1]/=e.getScale()/16;var m=[0,0,1],g=[n,a,o],_=zm(r,g);r.each(g,function(t,i,n,a){var o=r.get(_.dimension,a),h=_.isStacked?o-n:0,u=e.dataToPoint([t,i,h]),c=e.dataToPoint([t,i,o]),d=Math.max(c[2]-u[2],l),f=[s[0],d,s[1]];r.setItemLayout(a,[u,m,f])}),r.setLayout("orient",[1,0,0])}(t,e)})});var Um,km,Gm,Hm,Vm,Wm,Xm,jm,qm={getFormattedLabel:function(t,e,r,n,a){r=r||"normal";var o=t.getData(n).getItemModel(e),s=t.getDataParams(e,n);null!=a&&s.value instanceof Array&&(s.value=s.value[a]);var l,h=o.get("normal"===r?["label","formatter"]:["emphasis","label","formatter"]);return null==h&&(h=o.get(["label","formatter"])),"function"==typeof h?(s.status=r,l=h(s)):"string"==typeof h&&(l=i.format.formatTpl(h,s)),l},normalizeToArray:function(t){return t instanceof Array?t:null==t?[]:[t]}},Zm=qm,Ym=lc.vec3,Km=lc.mat3,Qm=gr.extend(function(){return{attributes:{position:new gr.Attribute("position","float",3,"POSITION"),normal:new gr.Attribute("normal","float",3,"NORMAL"),color:new gr.Attribute("color","float",4,"COLOR"),prevPosition:new gr.Attribute("prevPosition","float",3),prevNormal:new gr.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(t){var e=this.enableNormal,r=this.getBarVertexCount()*t,i=this.getBarTriangleCount()*t;this.vertexCount!==r&&(this.attributes.position.init(r),e?this.attributes.normal.init(r):this.attributes.normal.value=null,this.attributes.color.init(r)),this.triangleCount!==i&&(this.indices=r>65535?new Uint32Array(3*i):new Uint16Array(3*i),this._dataIndices=new Uint32Array(r))},getBarVertexCount:function(){var t=this.bevelSize>0?this.bevelSegments:0;return t>0?this._getBevelBarVertexCount(t):this.enableNormal?24:8},getBarTriangleCount:function(){var t=this.bevelSize>0?this.bevelSegments:0;return t>0?this._getBevelBarTriangleCount(t):12},_getBevelBarVertexCount:function(t){return 4*(t+1)*(t+1)*2},_getBevelBarTriangleCount:function(t){return(4*t+3+1)*(2*t+1)*2+4},setColor:function(t,e){for(var r=this.getBarVertexCount(),i=r*(t+1),n=r*t;n<i;n++)this.attributes.color.set(n,e);this.dirtyAttribute("color")},getDataIndexOfVertex:function(t){return this._dataIndices?this._dataIndices[t]:null},addBar:function(){for(var t=Ym.create,e=Ym.scaleAndAdd,r=t(),i=t(),n=t(),a=t(),o=t(),s=t(),l=t(),h=[],u=[],c=0;c<8;c++)h[c]=t();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;v<3;v++)_.push(m[f[3*g+v]]);p.push(_)}return function(t,c,m,g,_,v){var y=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(t,c,m,g,this.bevelSize,this.bevelSegments,_);else{Ym.copy(n,c),Ym.normalize(n,n),Ym.cross(a,m,n),Ym.normalize(a,a),Ym.cross(i,n,a),Ym.normalize(a,a),Ym.negate(o,i),Ym.negate(s,n),Ym.negate(l,a),e(h[0],t,i,g[0]/2),e(h[0],h[0],a,g[2]/2),e(h[1],t,i,g[0]/2),e(h[1],h[1],l,g[2]/2),e(h[2],t,o,g[0]/2),e(h[2],h[2],l,g[2]/2),e(h[3],t,o,g[0]/2),e(h[3],h[3],a,g[2]/2),e(r,t,n,g[1]),e(h[4],r,i,g[0]/2),e(h[4],h[4],a,g[2]/2),e(h[5],r,i,g[0]/2),e(h[5],h[5],l,g[2]/2),e(h[6],r,o,g[0]/2),e(h[6],h[6],l,g[2]/2),e(h[7],r,o,g[0]/2),e(h[7],h[7],a,g[2]/2);var x=this.attributes;if(this.enableNormal){u[0]=i,u[1]=o,u[2]=n,u[3]=s,u[4]=a,u[5]=l;for(var T=this._vertexOffset,b=0;b<d.length;b++){for(var w=3*this._triangleOffset,S=0;S<6;S++)this.indices[w++]=T+f[S];T+=4,this._triangleOffset+=2}for(b=0;b<d.length;b++){var E=u[b];for(S=0;S<4;S++){var A=d[b][S];x.position.set(this._vertexOffset,h[A]),x.normal.set(this._vertexOffset,E),x.color.set(this._vertexOffset++,_)}}}else{for(b=0;b<p.length;b++){for(w=3*this._triangleOffset,S=0;S<3;S++)this.indices[w+S]=p[b][S]+this._vertexOffset;this._triangleOffset++}for(b=0;b<h.length;b++)x.position.set(this._vertexOffset,h[b]),x.color.set(this._vertexOffset++,_)}}var M=this._vertexOffset;for(b=y;b<M;b++)this._dataIndices[b]=v}}(),_addBevelBar:(Um=Ym.create(),km=Ym.create(),Gm=Ym.create(),Hm=Km.create(),Vm=[],Wm=[1,-1,-1,1],Xm=[1,1,-1,-1],jm=[2,0],function(t,e,r,i,n,a,o){Ym.copy(km,e),Ym.normalize(km,km),Ym.cross(Gm,r,km),Ym.normalize(Gm,Gm),Ym.cross(Um,km,Gm),Ym.normalize(Gm,Gm),Hm[0]=Um[0],Hm[1]=Um[1],Hm[2]=Um[2],Hm[3]=km[0],Hm[4]=km[1],Hm[5]=km[2],Hm[6]=Gm[0],Hm[7]=Gm[1],Hm[8]=Gm[2],n=Math.min(i[0],i[2])/2*n;for(var s=0;s<3;s++)Vm[s]=Math.max(i[s]-2*n,0);var l=(i[0]-Vm[0])/2,h=(i[1]-Vm[1])/2,u=(i[2]-Vm[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 _=0;_<=a;_++){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(v)*Math.sin(y),d[1]=h*Math.cos(y),d[2]=u*Math.sin(v)*Math.sin(y),c[0]=d[0]+Wm[g]*Vm[0]/2,c[1]=d[1]+h+jm[s]*Vm[1]/2,c[2]=d[2]+Xm[g]*Vm[2]/2,Math.abs(l-h)<1e-6&&Math.abs(h-u)<1e-6||(d[0]/=l*l,d[1]/=h*h,d[2]/=u*u),Ym.normalize(d,d),Ym.transformMat3(c,c,Hm),Ym.transformMat3(d,d,Hm),Ym.add(c,c,t),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,T=2*a+1,b=x+1;for(g=0;g<T;g++)for(s=0;s<=x;s++){var w=g*b+s+this._vertexOffset,S=g*b+(s+1)%b+this._vertexOffset,E=(g+1)*b+(s+1)%b+this._vertexOffset,A=(g+1)*b+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[E,w,S]),this.setTriangleIndices(this._triangleOffset++,[E,A,w])}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})});i.util.defaults(Qm.prototype,sc),i.util.defaults(Qm.prototype,bp);var Jm=Qm,$m=lc.vec3;i.extendChartView({type:"bar3D",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this._api=e,this._labelsBuilder=new Ap(256,256,e);var r=this;this._labelsBuilder.getLabelPosition=function(t,e,i){if(r._data){var n=r._data.getItemLayout(t),a=n[0],o=n[1],s=n[2][1];return $m.scaleAndAdd([],a,o,i+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(t,e,r){var i=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=i,this._barMesh||(this._barMesh=new Wa.Mesh({geometry:new Jm,shadowDepthMaterial:new Wa.Material({shader:new Wa.Shader(Wa.Shader.source("ecgl.sm.depth.vertex"),Wa.Shader.source("ecgl.sm.depth.fragment"))}),culling:"cartesian3D"===t.coordinateSystem.type,renderOrder:10,renderNormal:!0})),this.groupGL.remove(this._prevBarMesh),this.groupGL.add(this._barMesh),this.groupGL.add(this._labelsBuilder.getMesh());var n=t.coordinateSystem;if(this._doRender(t,r),n&&n.viewGL){n.viewGL.add(this.groupGL);var a=n.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[a]("fragment","SRGB_DECODE")}this._data=t.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(t)},_updateAnimation:function(t){Wa.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,t)},_doRender:function(t,e){var r=t.getData(),i=t.get("shading"),n="color"!==i,a=this,o=this._barMesh,s="ecgl."+i;o.material&&o.material.shader.name===s||(o.material=Wa.createMaterial(s,["VERTEX_COLOR"])),Wa.setMaterialFromModel(i,o.material,t,e),o.geometry.enableNormal=n,o.geometry.resetOffset();var l=t.get("bevelSize"),h=t.get("bevelSmoothness");o.geometry.bevelSegments=h,o.geometry.bevelSize=l;var u=[],c=new Float32Array(4*r.count()),d=0,f=0,p=!1;r.each(function(t){if(r.hasValue(t)){var e=wp(r,t),i=Sp(r,t);null==i&&(i=1),Wa.parseColor(e,u),u[3]*=i,c[d++]=u[0],c[d++]=u[1],c[d++]=u[2],c[d++]=u[3],u[3]>0&&(f++,u[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(t){if(r.hasValue(t)){var e=r.getItemLayout(t),i=e[0],n=e[1],o=e[2],s=4*t;u[0]=c[s++],u[1]=c[s++],u[2]=c[s++],u[3]=c[s++],u[3]>0&&(a._barMesh.geometry.addBar(i,n,m,o,u,t),g[t]=f++)}else g[t]=-1}),o.geometry.dirty(),o.geometry.updateBoundingBox();var _=o.material;_.transparent=p,_.depthMask=!p,o.geometry.sortTriangles=p,this._initHandler(t,e)},_initHandler:function(t,e){var r=t.getData(),i=this._barMesh,n="cartesian3D"===t.coordinateSystem.type;i.seriesIndex=t.seriesIndex;var a=-1;i.off("mousemove"),i.off("mouseout"),i.on("mousemove",function(t){var o=i.geometry.getDataIndexOfVertex(t.triangle[0]);o!==a&&(this._downplay(a),this._highlight(o),this._labelsBuilder.updateLabels([o]),n&&e.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",o),r.get("y",o),r.get("z",o,!0)]})),a=o,i.dataIndex=o},this),i.on("mouseout",function(t){this._downplay(a),this._labelsBuilder.updateLabels(),a=-1,i.dataIndex=-1,n&&e.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_highlight:function(t){var e=this._data;if(e){var r=this._barIndexOfData[t];if(!(r<0)){var n=e.getItemModel(t).getModel("emphasis.itemStyle"),a=n.get("color"),o=n.get("opacity");if(null==a){var s=wp(e,t);a=i.color.lift(s,-.4)}null==o&&(o=Sp(e,t));var l=Wa.parseColor(a);l[3]*=o,this._barMesh.geometry.setColor(r,l),this._api.getZr().refresh()}}},_downplay:function(t){var e=this._data;if(e){var r=this._barIndexOfData[t];if(!(r<0)){var i=wp(e,t),n=Sp(e,t),a=Wa.parseColor(i);a[3]*=n,this._barMesh.geometry.setColor(r,a),this._api.getZr().refresh()}}},highlight:function(t,e,r,i){this._toggleStatus("highlight",t,e,r,i)},downplay:function(t,e,r,i){this._toggleStatus("downplay",t,e,r,i)},_toggleStatus:function(t,e,r,n,a){var o=e.getData(),s=qi.queryDataIndex(o,a),l=this;null!=s?i.util.each(Zm.normalizeToArray(s),function(e){"highlight"===t?this._highlight(e):this._downplay(e)},this):o.each(function(e){"highlight"===t?l._highlight(e):l._downplay(e)})},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});var tg=function(t,e,r){var n=t.getData(),a=t.getRawValue(e),o=i.util.isArray(a)?function(t){var a=!0,o=[],s=function(t,e){var r=[];return i.util.each(t.dimensions,function(i){var n=t.getDimensionInfo(i),a=n.otherDims[e];null!=a&&!1!==a&&(r[a]=n.name)}),r}(n,"tooltip");function l(t,e){var s=n.getDimensionInfo(e);if(s&&!1!==s.otherDims.tooltip){var l=s.type,h=(a?"- "+(s.tooltipName||s.name)+": ":"")+("ordinal"===l?t+"":"time"===l?r?"":i.format.formatTime("yyyy/MM/dd hh:mm:ss",t):i.format.addCommas(t));h&&o.push(i.format.encodeHTML(h))}}return s.length?i.util.each(s,function(t){l(n.get(t,e),t)}):i.util.each(t,l),(a?"<br/>":"")+o.join(a?"<br/>":", ")}(a):i.format.encodeHTML(i.format.addCommas(a)),s=n.getName(e),l=wp(n,e);i.util.isObject(l)&&l.colorStops&&(l=(l.colorStops[0]||{}).color),l=l||"transparent";var h=i.format.getTooltipMarker(l),u=t.name;return"\0-"===u&&(u=""),u=u?i.format.encodeHTML(u)+(r?": ":"<br/>"):"",r?h+u+o:u+h+(s?i.format.encodeHTML(s)+": "+o:o)},eg=function(t,e,r){r=r||t.getSource();var n=e||i.getCoordinateSystemDimensions(t.get("coordinateSystem"))||["x","y","z"],a=i.helper.createDimensions(r,{dimensionsDefine:r.dimensionsDefine||t.get("dimensions"),encodeDefine:r.encodeDefine||t.get("encode"),coordDimensions:n.map(function(e){var r=t.getReferringComponents(e+"Axis3D").models[0];return{type:r&&"category"===r.get("type")?"ordinal":"float",name:e}})});"cartesian3D"===t.get("coordinateSystem")&&a.forEach(function(e){if(n.indexOf(e.coordDim)>=0){var r=t.getReferringComponents(e.coordDim+"Axis3D").models[0];r&&"category"===r.get("type")&&(e.ordinalMeta=r.getOrdinalMeta())}});var o=i.helper.dataStack.enableDataStack(t,a,{byIndex:!0,stackedCoordDimension:"z"}),s=new i.List(a,t);return s.setCalculationInfo(o),s.initData(r),s},rg=i.extendSeriesModel({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(t,e){return eg(this)},getFormattedLabel:function(t,e,r,i){var n=Zm.getFormattedLabel(this,t,e,r,i);return null==n&&(n=this.getData().get("z",t)),n},formatTooltip:function(t){return tg(this,t)},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}});i.util.merge(rg.prototype,kf);i.registerProcessor(function(t,e){t.eachSeriesByType("bar3d",function(t){var e=t.getData();e.filterSelf(function(t){return e.hasValue(t)})})});i.extendSeriesModel({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",getInitialData:function(t,e){return eg(this)},formatTooltip:function(t){return tg(this,t)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}});var ig=lc.vec3;Wa.Shader.import(zc);i.extendChartView({type:"line3D",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this._api=e},render:function(t,e,r){var i=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=i,this._line3DMesh||(this._line3DMesh=new Wa.Mesh({geometry:new dc({useNativeLine:!1,sortTriangles:!0}),material:new Wa.Material({shader:Wa.createShader("ecgl.meshLines3D")}),renderOrder:10}),this._line3DMesh.geometry.pick=this._pick.bind(this)),this.groupGL.remove(this._prevLine3DMesh),this.groupGL.add(this._line3DMesh);var n=t.coordinateSystem;if(n&&n.viewGL){n.viewGL.add(this.groupGL);var a=n.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[a]("fragment","SRGB_DECODE")}this._doRender(t,r),this._data=t.getData(),this._camera=n.viewGL.camera,this.updateCamera(),this._updateAnimation(t)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(t,e){var r=t.getData(),i=this._line3DMesh;i.geometry.resetOffset();var n=r.getLayout("points"),a=[],o=new Float32Array(n.length/3*4),s=0,l=!1;r.each(function(t){var e=wp(r,t),i=Sp(r,t);null==i&&(i=1),Wa.parseColor(e,a),a[3]*=i,o[s++]=a[0],o[s++]=a[1],o[s++]=a[2],o[s++]=a[3],a[3]<.99&&(l=!0)}),i.geometry.setVertexCount(i.geometry.getPolylineVertexCount(n)),i.geometry.setTriangleCount(i.geometry.getPolylineTriangleCount(n)),i.geometry.addPolyline(n,o,qi.firstNotNull(t.get("lineStyle.width"),1)),i.geometry.dirty(),i.geometry.updateBoundingBox();var h=i.material;h.transparent=l,h.depthMask=!l;var u=t.getModel("debug.wireframe");u.get("show")?(i.geometry.createAttribute("barycentric","float",3),i.geometry.generateBarycentric(),i.material.set("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",Wa.parseColor(u.get("lineStyle.color")||"rgba(0,0,0,0.5)")),i.material.set("wireframeLineWidth",qi.firstNotNull(u.get("lineStyle.width"),1))):i.material.set("both","WIREFRAME_TRIANGLE"),this._points=n,this._initHandler(t,e)},_updateAnimation:function(t){Wa.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,t)},_initHandler:function(t,e){var r=t.getData(),i=t.coordinateSystem,n=this._line3DMesh,a=-1;n.seriesIndex=t.seriesIndex,n.off("mousemove"),n.off("mouseout"),n.on("mousemove",function(t){var o=i.pointToData(t.point.array),s=r.indicesOfNearest("x",o[0])[0];s!==a&&(e.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",s),r.get("y",s),r.get("z",s)]}),n.dataIndex=s),a=s},this),n.on("mouseout",function(t){a=-1,n.dataIndex=-1,e.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_updateNDCPosition:function(){var t=new _e,e=this._camera;_e.multiply(t,e.projectionMatrix,e.viewMatrix);var r=this._positionNDC,i=this._points,n=i.length/3;r&&r.length/2===n||(r=this._positionNDC=new Float32Array(2*n));for(var a=[],o=0;o<n;o++){var s=3*o,l=2*o;a[0]=i[s],a[1]=i[s+1],a[2]=i[s+2],a[3]=1,ig.transformMat4(a,a,t.array),r[l]=a[0]/a[3],r[l+1]=a[1]/a[3]}},_pick:function(t,e,r,i,n,a){var o=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,h=.5*r.viewport.width,u=.5*r.viewport.height;t=(t+1)*h,e=(e+1)*u;for(var c=1;c<o.length/2;c++){var d=(o[2*(c-1)]+1)*h,f=(o[2*(c-1)+1]+1)*u,p=(o[2*c]+1)*h,m=(o[2*c+1]+1)*u;if(th(d,f,p,m,s,t,e))l=(d-t)*(d-t)+(f-e)*(f-e)<(p-t)*(p-t)+(m-e)*(m-e)?c-1:c}if(l>=0){var g=3*l,_=new Qt(this._points[g],this._points[g+1],this._points[g+2]);a.push({dataIndex:l,point:_,pointWorld:_.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(_)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function ng(t,e,r){(e=e||document.createElement("canvas")).width=t,e.height=t;var i=e.getContext("2d");return r&&r(i),e}i.registerLayout(function(t,e){t.eachSeriesByType("line3D",function(t){var e=t.getData(),r=t.coordinateSystem;if(r){if("cartesian3D"!==r.type)return void 0;var i=new Float32Array(3*e.count()),n=[],a=[],o=r.dimensions.map(function(e){return t.coordDimToDataDim(e)[0]});r&&e.each(o,function(t,e,o,s){n[0]=t,n[1]=e,n[2]=o,r.dataToPoint(n,a),i[3*s]=a[0],i[3*s+1]=a[1],i[3*s+2]=a[2]}),e.setLayout("points",i)}})}),i.extendSeriesModel({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(t,e){return eg(this)},getFormattedLabel:function(t,e,r,i){var n=Zm.getFormattedLabel(this,t,e,r,i);if(null==n){var a=this.getData(),o=a.dimensions[a.dimensions.length-1];n=a.get(o,t)}return n},formatTooltip:function(t){return tg(this,t)},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}});var ag={getMarginByStyle:function(t){var e=t.minMargin||0,r=0;t.stroke&&"none"!==t.stroke&&(r=null==t.lineWidth?1:t.lineWidth);var i=t.shadowBlur||0,n=t.shadowOffsetX||0,a=t.shadowOffsetY||0,o={};return o.left=Math.max(r/2,-n+i,e),o.right=Math.max(r/2,n+i,e),o.top=Math.max(r/2,-a+i,e),o.bottom=Math.max(r/2,a+i,e),o},createSymbolSprite:function(t,e,r,n){var a=function(t,e,r,n){i.util.isArray(e)||(e=[e,e]);var a=ag.getMarginByStyle(r,n),o=e[0]+a.left+a.right,s=e[1]+a.top+a.bottom,l=i.helper.createSymbol(t,0,0,e[0],e[1]),h=Math.max(o,s);l.x=a.left,l.y=a.top,o>s?l.y+=(h-s)/2:l.x+=(h-o)/2;var u=l.getBoundingRect();return l.x-=u.x,l.y-=u.y,l.setStyle(r),l.update(),l.__size=h,l}(t,e,r),o=ag.getMarginByStyle(r);return{image:ng(a.__size,n,function(t){i.innerDrawElementOnCanvas(t,a)}),margin:o}},createSDFFromCanvas:function(t,e,r,i){return ng(e,i,function(e){var i=t.getContext("2d").getImageData(0,0,t.width,t.height);e.putImageData(function(t,e,r){var i=e.width,n=e.height,a=t.canvas.width,o=t.canvas.height,s=i/a,l=n/o;function h(t){return t<128?1:-1}function u(t,a){var o=1/0;t=Math.floor(t*s);for(var u=(a=Math.floor(a*l))*i+t,c=h(e.data[4*u]),d=Math.max(a-r,0);d<Math.min(a+r,n);d++)for(var f=Math.max(t-r,0);f<Math.min(t+r,i);f++){u=d*i+f;var p=f-t,m=d-a;if(c!==h(e.data[4*u])){var g=p*p+m*m;g<o&&(o=g)}}return c*Math.sqrt(o)}for(var c=t.createImageData(a,o),d=0;d<o;d++)for(var f=0;f<a;f++){var p=u(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}(e,i,r),0,0)})},createSimpleSprite:function(t,e){return ng(t,e,function(e){var r=t/2;e.beginPath(),e.arc(r,r,60,0,2*Math.PI,!1),e.closePath();var i=e.createRadialGradient(r,r,0,r,r,r);i.addColorStop(0,"rgba(255, 255, 255, 1)"),i.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),i.addColorStop(1,"rgba(255, 255, 255, 0)"),e.fillStyle=i,e.fill()})}},og=ag,sg=lc.vec3,lg={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(t,e){var r=this.indices,i=sg.create();if(!r){r=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var n=0;n<r.length;n++)r[n]=n}if(0===e){var a,o=this.attributes.position,s=(t=t.array,0);this._zList&&this._zList.length===this.vertexCount||(this._zList=new Float32Array(this.vertexCount));for(n=0;n<this.vertexCount;n++){o.get(n,i);var l=sg.sqrDist(i,t);isNaN(l)&&(l=1e7,s++),0===n?(a=l,l=0):l-=a,this._zList[n]=l}this._noneCount=s}if(this.vertexCount<2e4)0===e&&this._simpleSort(this._noneCount/this.vertexCount>.05);else for(n=0;n<3;n++)this._progressiveQuickSort(3*e+n);this.dirtyIndices()},_simpleSort:function(t){var e=this._zList,r=this.indices;function i(t,r){return e[r]-e[t]}t?Array.prototype.sort.call(r,i):_p.sort(r,i,0,r.length-1)},_progressiveQuickSort:function(t){var e=this._zList,r=this.indices;this._quickSort=this._quickSort||new _p,this._quickSort.step(r,function(t,r){return e[r]-e[t]},t)}},hg=lc.vec4;Wa.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 ug=Wa.Mesh.extend(function(){var t=new Wa.Geometry({dynamic:!0,attributes:{color:new Wa.Geometry.Attribute("color","float",4,"COLOR"),position:new Wa.Geometry.Attribute("position","float",3,"POSITION"),size:new Wa.Geometry.Attribute("size","float",1),prevPosition:new Wa.Geometry.Attribute("prevPosition","float",3),prevSize:new Wa.Geometry.Attribute("prevSize","float",1)}});Object.assign(t,lg);var e=new Wa.Material({shader:Wa.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});e.enableTexture("sprite"),e.define("both","VERTEX_COLOR"),e.define("both","VERTEX_SIZE");var r=new Wa.Texture2D({image:document.createElement("canvas"),flipY:!1});return e.set("sprite",r),t.pick=this._pick.bind(this),{geometry:t,material:e,mode:Wa.Mesh.POINTS,sizeScale:1}},{_pick:function(t,e,r,i,n,a){var o=this._positionNDC;if(o)for(var s=r.viewport,l=2/s.width,h=2/s.height,u=this.geometry.vertexCount-1;u>=0;u--){var c,d=o[2*(c=this.geometry.indices?this.geometry.indices[u]:u)],f=o[2*c+1],p=this.geometry.attributes.size.get(c)/this.sizeScale/2;if(t>d-p*l&&t<d+p*l&&e>f-p*h&&e<f+p*h){var m=new Wa.Vector3,g=new Wa.Vector3;this.geometry.attributes.position.get(c,m.array),Wa.Vector3.transformMat4(g,m,this.worldTransform),a.push({vertexIndex:c,point:m,pointWorld:g,target:this,distance:g.distance(i.getWorldPosition())})}}},updateNDCPosition:function(t,e,r){var i=this._positionNDC,n=this.geometry;i&&i.length/2===n.vertexCount||(i=this._positionNDC=new Float32Array(2*n.vertexCount));for(var a=hg.create(),o=0;o<n.vertexCount;o++)n.attributes.position.get(o,a),a[3]=1,hg.transformMat4(a,a,t.array),hg.scale(a,a,1/a[3]),i[2*o]=a[0],i[2*o+1]=a[1]}});function cg(t,e){this.rootNode=new Wa.Node,this.is2D=t,this._labelsBuilder=new Ap(256,256,e),this._labelsBuilder.getMesh().renderOrder=100,this.rootNode.add(this._labelsBuilder.getMesh()),this._api=e,this._spriteImageCanvas=document.createElement("canvas"),this._startDataIndex=0,this._endDataIndex=0,this._sizeScale=1}cg.prototype={constructor:cg,highlightOnMouseover:!0,update:function(t,e,r,i,n){var a=this._prevMesh;this._prevMesh=this._mesh,this._mesh=a;var o=t.getData();if(null==i&&(i=0),null==n&&(n=o.count()),this._startDataIndex=i,this._endDataIndex=n-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new ug({renderOrder:10,frustumCulling:!1}),s&&(this._mesh.material=s)}s=this._mesh.material;var l=this._mesh.geometry,h=l.attributes;this.rootNode.remove(this._prevMesh),this.rootNode.add(this._mesh),this._setPositionTextureToMesh(this._mesh,this._positionTexture);var u=this._getSymbolInfo(t,i,n),c=r.getDevicePixelRatio(),d=t.getModel("itemStyle").getItemStyle(),f=t.get("large"),p=1;u.maxSize>2?(p=this._updateSymbolSprite(t,d,u,c),s.enableTexture("sprite")):s.disableTexture("sprite"),h.position.init(n-i);var m=[];if(f){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var g=o.getVisual("color"),_=o.getVisual("opacity");Wa.parseColor(g,m),m[3]*=_,s.set({color:m,u_Size:u.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),h.size.init(n-i),h.color.init(n-i),this._originalOpacity=new Float32Array(n-i);for(var v=o.getLayout("points"),y=h.position.value,x=0;x<n-i;x++){var T=3*x,b=2*x;if(this.is2D?(y[T]=v[b],y[T+1]=v[b+1],y[T+2]=-10):(y[T]=v[T],y[T+1]=v[T+1],y[T+2]=v[T+2]),!f){g=wp(o,x),_=Sp(o,x);Wa.parseColor(g,m),m[3]*=_,h.color.set(x,m),m[3]<.99&&!0;var w=o.getItemVisual(x,"symbolSize");w=w instanceof Array?Math.max(w[0],w[1]):w,isNaN(w)&&(w=0),h.size.value[x]=w*p*this._sizeScale,this._originalOpacity[x]=m[3]}}this._mesh.sizeScale=p,l.updateBoundingBox(),l.dirty(),this._updateMaterial(t,d);var S=t.coordinateSystem;S&&S.viewGL&&s[S.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE");f||this._updateLabelBuilder(t,i,n),this._updateHandler(t,e,r),this._updateAnimation(t),this._api=r},getPointsMesh:function(){return this._mesh},updateLabels:function(t){this._labelsBuilder.updateLabels(t)},hideLabels:function(){this.rootNode.remove(this._labelsBuilder.getMesh())},showLabels:function(){this.rootNode.add(this._labelsBuilder.getMesh())},_updateSymbolSprite:function(t,e,r,i){r.maxSize=Math.min(2*r.maxSize,200);var n,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&&(n=this._symbolSize,a=o,n&&a&&n[0]===a[0]&&n[1]===a[1])&&this._lineWidth===e.lineWidth||(og.createSymbolSprite(r.type,o,{fill:"#fff",lineWidth:e.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(o[0]/2,10)},this._spriteImageCanvas),og.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=e.lineWidth),this._spriteImageCanvas.width/r.maxSize*i},_updateMaterial:function(t,e){var r="lighter"===t.get("blendMode")?Wa.additiveBlend:null,i=this._mesh.material;i.blend=r,i.set("lineWidth",e.lineWidth/20);var n=Wa.parseColor(e.stroke);i.set("strokeColor",n),i.transparent=!0,i.depthMask=!1,i.depthTest=!this.is2D,i.sortVertices=!this.is2D},_updateLabelBuilder:function(t,e,r){var i=t.getData(),n=this._mesh.geometry,a=n.attributes.position.value,o=(e=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(i,e,r),this._labelsBuilder.getLabelPosition=function(t,r,i){var n=3*(t-e);return[a[n],a[n+1],a[n+2]]},this._labelsBuilder.getLabelDistance=function(t,r,i){return n.attributes.size.get(t-e)/o/2+i},this._labelsBuilder.updateLabels()},_updateAnimation:function(t){Wa.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,t)},_updateHandler:function(t,e,r){var i,n=t.getData(),a=this._mesh,o=this,s=-1,l=t.coordinateSystem&&"cartesian3D"===t.coordinateSystem.type;l&&(i=t.coordinateSystem.model),a.seriesIndex=t.seriesIndex,a.off("mousemove"),a.off("mouseout"),a.on("mousemove",function(e){var h=e.vertexIndex+o._startDataIndex;h!==s&&(this.highlightOnMouseover&&(this.downplay(n,s),this.highlight(n,h),this._labelsBuilder.updateLabels([h])),l&&r.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get(t.coordDimToDataDim("x")[0],h),n.get(t.coordDimToDataDim("y")[0],h),n.get(t.coordDimToDataDim("z")[0],h)],grid3DIndex:i.componentIndex})),a.dataIndex=h,s=h},this),a.on("mouseout",function(t){var e=t.vertexIndex+o._startDataIndex;this.highlightOnMouseover&&(this.downplay(n,e),this._labelsBuilder.updateLabels()),s=-1,a.dataIndex=-1,l&&r.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:i.componentIndex})},this)},updateLayout:function(t,e,r){var i=t.getData();if(this._mesh){var n=this._mesh.geometry.attributes.position.value,a=i.getLayout("points");if(this.is2D)for(var o=0;o<a.length/2;o++){var s=3*o,l=2*o;n[s]=a[l],n[s+1]=a[l+1],n[s+2]=-10}else for(o=0;o<a.length;o++)n[o]=a[o];this._mesh.geometry.dirty(),r.getZr().refresh()}},updateView:function(t){if(this._mesh){var e=new _e;_e.mul(e,t.viewMatrix,this._mesh.worldTransform),_e.mul(e,t.projectionMatrix,e),this._mesh.updateNDCPosition(e,this.is2D,this._api)}},highlight:function(t,e){if(!(e>this._endDataIndex||e<this._startDataIndex)){var r=t.getItemModel(e).getModel("emphasis.itemStyle"),n=r.get("color"),a=r.get("opacity");if(null==n){var o=wp(t,e);n=i.color.lift(o,-.4)}null==a&&(a=Sp(t,e));var s=Wa.parseColor(n);s[3]*=a,this._mesh.geometry.attributes.color.set(e-this._startDataIndex,s),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},downplay:function(t,e){if(!(e>this._endDataIndex||e<this._startDataIndex)){var r=wp(t,e),i=Sp(t,e),n=Wa.parseColor(r);n[3]*=i,this._mesh.geometry.attributes.color.set(e-this._startDataIndex,n),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeOutAll:function(t){if(this._originalOpacity){for(var e=this._mesh.geometry,r=0;r<e.vertexCount;r++){var i=this._originalOpacity[r]*t;e.attributes.color.value[4*r+3]=i}e.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeInAll:function(){this.fadeOutAll(1)},setPositionTexture:function(t){this._mesh&&this._setPositionTextureToMesh(this._mesh,t),this._positionTexture=t},removePositionTexture:function(){this._positionTexture=null,this._mesh&&this._setPositionTextureToMesh(this._mesh,null)},setSizeScale:function(t){if(t!==this._sizeScale){if(this._mesh){var e=this._mesh.material.get("u_Size");this._mesh.material.set("u_Size",e/this._sizeScale*t);var r=this._mesh.geometry.attributes;if(r.size.value)for(var i=0;i<r.size.value.length;i++)r.size.value[i]=r.size.value[i]/this._sizeScale*t}this._sizeScale=t}},_setPositionTextureToMesh:function(t,e){e&&t.material.set("positionTexture",e),t.material[e?"enableTexture":"disableTexture"]("positionTexture")},_getSymbolInfo:function(t,e,r){if(t.get("large"))return(h=qi.firstNotNull(t.get("symbolSize"),1))instanceof Array?(o=Math.max(h[0],h[1]),i=h[0]/h[1]):(o=h,i=1),{maxSize:h,type:t.get("symbol"),aspect:i};for(var i,n=t.getData(),a=n.getItemVisual(0,"symbol")||"circle",o=0,s=e;s<r;s++){var l,h=n.getItemVisual(s,"symbolSize"),u=n.getItemVisual(s,"symbol");if(h instanceof Array)l=h[0]/h[1],o=Math.max(Math.max(h[0],h[1]),o);else{if(isNaN(h))continue;l=1,o=Math.max(h,o)}0,a=u,i=l}return{maxSize:o,type:a,aspect:i}}};var dg=cg;i.extendChartView({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(t,e,r){if(this.groupGL.removeAll(),t.getData().count()){var i=t.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this.groupGL),this._camera=i.viewGL.camera;var n=this._pointsBuilderList[0];n||(n=this._pointsBuilderList[0]=new dg(!1,r)),this._pointsBuilderList.length=1,this.groupGL.add(n.rootNode),n.update(t,e,r),n.updateView(i.viewGL.camera)}else 0}},incrementalPrepareRender:function(t,e,r){var i=t.coordinateSystem;i&&i.viewGL&&(i.viewGL.add(this.groupGL),this._camera=i.viewGL.camera),this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(t,e,r,i){if(!(t.end<=t.start)){var n=this._pointsBuilderList[this._currentStep];n||(n=new dg(!1,i),this._pointsBuilderList[this._currentStep]=n),this.groupGL.add(n.rootNode),n.update(e,r,i,t.start,t.end),n.updateView(e.coordinateSystem.viewGL.camera),this._currentStep++}},updateCamera:function(){this._pointsBuilderList.forEach(function(t){t.updateView(this._camera)},this)},highlight:function(t,e,r,i){this._toggleStatus("highlight",t,e,r,i)},downplay:function(t,e,r,i){this._toggleStatus("downplay",t,e,r,i)},_toggleStatus:function(t,e,r,n,a){var o=e.getData(),s=qi.queryDataIndex(o,a),l="highlight"===t;null!=s?i.util.each(Zm.normalizeToArray(s),function(t){for(var e=0;e<this._pointsBuilderList.length;e++){var r=this._pointsBuilderList[e];l?r.highlight(o,t):r.downplay(o,t)}},this):o.each(function(t){for(var e=0;e<this._pointsBuilderList.length;e++){var r=this._pointsBuilderList[e];l?r.highlight(o,t):r.downplay(o,t)}})},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}}),i.registerLayout({seriesType:"scatter3D",reset:function(t){var e=t.coordinateSystem;if(e){var r=e.dimensions;if(r.length<3)return void 0;var i=r.map(function(e){return t.coordDimToDataDim(e)[0]}),n=[],a=[];return{progress:function(t,r){for(var o=new Float32Array(3*(t.end-t.start)),s=t.start;s<t.end;s++){var l=3*(s-t.start);n[0]=r.get(i[0],s),n[1]=r.get(i[1],s),n[2]=r.get(i[2],s),e.dataToPoint(n,a),o[l]=a[0],o[l+1]=a[1],o[l+2]=a[2]}r.setLayout("points",o)}}}}});var fg=lc.vec3,pg=lc.vec2,mg=fg.normalize,gg=fg.cross,_g=fg.sub,vg=fg.add,yg=fg.create,xg=yg(),Tg=yg(),bg=yg(),wg=yg(),Sg=[],Eg=[];function Ag(t,e){pg.copy(Sg,t[0]),pg.copy(Eg,t[1]);var r=[],i=r[0]=yg(),n=r[1]=yg(),a=r[2]=yg(),o=r[3]=yg();e.dataToPoint(Sg,i),e.dataToPoint(Eg,o),mg(xg,i),_g(Tg,o,i),mg(Tg,Tg),gg(bg,Tg,xg),mg(bg,bg),gg(Tg,xg,bg),vg(n,xg,Tg),mg(n,n),mg(xg,o),_g(Tg,i,o),mg(Tg,Tg),gg(bg,Tg,xg),mg(bg,bg),gg(Tg,xg,bg),vg(a,xg,Tg),mg(a,a),vg(wg,i,o),mg(wg,wg);var s=fg.dot(i,wg),l=fg.dot(wg,n),h=(Math.max(fg.len(i),fg.len(o))-s)/l*2;return fg.scaleAndAdd(n,i,n,h),fg.scaleAndAdd(a,o,a,h),r}function Mg(t,e){for(var r=new Float32Array(3*t.length),i=0,n=[],a=0;a<t.length;a++)e.dataToPoint(t[a],n),r[i++]=n[0],r[i++]=n[1],r[i++]=n[2];return r}function Cg(t){var e=[];return t.each(function(r){var i=t.getItemModel(r),n=i.option instanceof Array?i.option:i.getShallow("coords",!0);e.push(n)}),{coordsList:e}}function Dg(t,e,r){var i=t.getData(),n=t.get("polyline"),a=Cg(i);i.setLayout("lineType",n?"polyline":"cubicBezier"),i.each(function(t){var o=a.coordsList[t],s=n?Mg(o,e):function(t,e,r){var i=[],n=i[0]=fg.create(),a=i[1]=fg.create(),o=i[2]=fg.create(),s=i[3]=fg.create();e.dataToPoint(t[0],n),e.dataToPoint(t[1],s);var l=fg.dist(n,s);return fg.lerp(a,n,s,.3),fg.lerp(o,n,s,.3),fg.scaleAndAdd(a,a,r,Math.min(.1*l,10)),fg.scaleAndAdd(o,o,r,Math.min(.1*l,10)),i}(o,e,r);i.setItemLayout(t,s)})}i.registerLayout(function(t,e){t.eachSeriesByType("lines3D",function(t){var e=t.coordinateSystem;"globe"===e.type?function(t,e){var r=t.getData(),i=t.get("polyline");r.setLayout("lineType",i?"polyline":"cubicBezier");var n=Cg(r);r.each(function(t){var a=n.coordsList[t],o=i?Mg:Ag;r.setItemLayout(t,o(a,e))})}(t,e):"geo3D"===e.type?Dg(t,e,[0,1,0]):"mapbox3D"!==e.type&&"maptalks3D"!==e.type||Dg(t,e,[0,0,1])})});var Lg=lc.vec3;Wa.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 Pg=Wa.Mesh.extend(function(){var t=new Wa.Material({shader:new Wa.Shader(Wa.Shader.source("ecgl.trail2.vertex"),Wa.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),e=new dc({dynamic:!0});return e.createAttribute("dist","float",1),e.createAttribute("distAll","float",1),e.createAttribute("start","float",1),{geometry:e,material:t,culling:!1,$ignorePicking:!0}},{updateData:function(t,e,r){var i=t.hostModel,n=this.geometry,a=i.getModel("effect"),o=a.get("trailWidth")*e.getDevicePixelRatio(),s=a.get("trailLength"),l=i.get("effect.constantSpeed"),h=1e3*i.get("effect.period"),u=null!=l;u?this.material.set("speed",l/1e3):this.material.set("period",h),this.material[u?"define":"undefine"]("vertex","CONSTANT_SPEED");var c=i.get("polyline");n.trailLength=s,this.material.set("trailLength",s),n.resetOffset(),["position","positionPrev","positionNext"].forEach(function(t){n.attributes[t].value=r.attributes[t].value});["dist","distAll","start","offset","color"].forEach(function(t){n.attributes[t].init(n.vertexCount)}),n.indices=r.indices;var d=[],f=a.get("trailColor"),p=a.get("trailOpacity"),m=null!=f,g=null!=p;this.updateWorldTransform();var _=this.worldTransform.x.len(),v=this.worldTransform.y.len(),y=this.worldTransform.z.len(),x=0,T=0;t.each(function(e){var i=t.getItemLayout(e),a=g?p:Sp(t,e),s=wp(t,e);null==a&&(a=1),(d=Wa.parseColor(m?f:s,d))[3]*=a;for(var l=c?r.getPolylineVertexCount(i):r.getCubicCurveVertexCount(i[0],i[1],i[2],i[3]),b=0,w=[],S=[],E=x;E<x+l;E++)n.attributes.position.get(E,w),w[0]*=_,w[1]*=v,w[2]*=y,E>x&&(b+=Lg.dist(w,S)),n.attributes.dist.set(E,b),Lg.copy(S,w);T=Math.max(T,b);var A=Math.random()*(u?b:h);for(E=x;E<x+l;E++)n.attributes.distAll.set(E,b),n.attributes.start.set(E,A),n.attributes.offset.set(E,(r.attributes.offset.get(E)>0?1:-1)*o/2),n.attributes.color.set(E,d);x+=l}),this.material.set("spotSize",.1*T*s),this.material.set("spotIntensity",a.get("spotIntensity")),n.dirty()},setAnimationTime:function(t){this.material.set("time",t)}});Wa.Shader.import(zc);i.extendChartView({type:"lines3D",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this._meshLinesMaterial=new Wa.Material({shader:Wa.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new Wa.Mesh({geometry:new dc,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new Pg},render:function(t,e,r){this.groupGL.add(this._linesMesh);var i=t.coordinateSystem,n=t.getData();if(i&&i.viewGL){i.viewGL.add(this.groupGL),this._updateLines(t,e,r);var a=i.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(),t.get("effect.show")){this.groupGL.add(o),o.updateData(n,r,this._linesMesh.geometry),o.__time=o.__time||0;this._curveEffectsAnimator=o.animate("",{loop:!0}).when(36e5,{__time:36e5}).during(function(){o.setAnimationTime(o.__time)}).start()}else this.groupGL.remove(o),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===t.get("blendMode")?Wa.additiveBlend:null},pauseEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.pause()},resumeEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.resume()},toggleEffect:function(){var t=this._curveEffectsAnimator;t&&(t.isPaused()?t.resume():t.pause())},_updateLines:function(t,e,r){var i=t.getData(),n=t.coordinateSystem,a=this._linesMesh.geometry,o=t.get("polyline");a.expandLine=!0;var s=function(t){return null!=t.radius?t.radius:null!=t.size?Math.max(t.size[0],t.size[1],t.size[2]):100}(n);a.segmentScale=s/20;var l="lineStyle.width".split("."),h=r.getDevicePixelRatio(),u=0;i.each(function(t){var e=i.getItemModel(t).get(l);null==e&&(e=1),i.setItemVisual(t,"lineWidth",e),u=Math.max(e,u)}),a.useNativeLine=!1;var c=0,d=0;i.each(function(t){var e=i.getItemLayout(t);o?(c+=a.getPolylineVertexCount(e),d+=a.getPolylineTriangleCount(e)):(c+=a.getCubicCurveVertexCount(e[0],e[1],e[2],e[3]),d+=a.getCubicCurveTriangleCount(e[0],e[1],e[2],e[3]))}),a.setVertexCount(c),a.setTriangleCount(d),a.resetOffset();var f=[];i.each(function(t){var e=i.getItemLayout(t),r=wp(i,t),n=Sp(i,t),s=i.getItemVisual(t,"lineWidth")*h;null==n&&(n=1),(f=Wa.parseColor(r,f))[3]*=n,o?a.addPolyline(e,f,s):a.addCubicCurve(e[0],e[1],e[2],e[3],f,s)}),a.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});function Ng(t,e){for(var r=[],i=0;i<e.length;i++)r.push(t.dataToPoint(e[i]));return r}i.extendSeriesModel({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",getInitialData:function(t,e){var r=new i.List(["value"],this);return r.hasItemOption=!1,r.initData(t.data,[],function(t,e,i,n){if(t instanceof Array)return NaN;r.hasItemOption=!0;var a=t.value;return null!=a?a instanceof Array?a[n]: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}}}),i.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},function(){}),i.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},function(){}),i.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},function(){});var Rg=i.extendSeriesModel({type:"series.polygons3D",getRegionModel:function(t){return this.getData().getItemModel(t)},getRegionPolygonCoords:function(t){var e=this.coordinateSystem,r=this.getData().getItemModel(t),i=r.option instanceof Array?r.option:r.getShallow("coords");r.get("multiPolygon")||(i=[i]);for(var n=[],a=0;a<i.length;a++){for(var o=[],s=1;s<i[a].length;s++)o.push(Ng(e,i[a][s]));n.push({exterior:Ng(e,i[a][0]),interiors:o})}return n},getInitialData:function(t){var e=new i.List(["value"],this);return e.hasItemOption=!1,e.initData(t.data,[],function(t,r,i,n){if(t instanceof Array)return NaN;e.hasItemOption=!0;var a=t.value;return null!=a?a instanceof Array?a[n]:a:void 0}),e},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}}}});i.util.merge(Rg.prototype,kf);i.extendChartView({type:"polygons3D",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(t,e,r){this.groupGL.removeAll();var i=t.coordinateSystem;i&&i.viewGL&&i.viewGL.add(this.groupGL);var n=this._geo3DBuilderList[0];n||((n=new Dp(r)).extrudeY="mapbox3D"!==i.type&&"maptalks3D"!==i.type,this._geo3DBuilderList[0]=n),this._updateShaderDefines(i,n),n.update(t,e,r),this._geo3DBuilderList.length=1,this.groupGL.add(n.rootNode)},incrementalPrepareRender:function(t,e,r){this.groupGL.removeAll();var i=t.coordinateSystem;i&&i.viewGL&&i.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(t,e,r,i){var n=this._geo3DBuilderList[this._currentStep],a=e.coordinateSystem;n||((n=new Dp(i)).extrudeY="mapbox3D"!==a.type&&"maptalks3D"!==a.type,this._geo3DBuilderList[this._currentStep]=n),n.update(e,r,i,t.start,t.end),this.groupGL.add(n.rootNode),this._updateShaderDefines(a,n),this._currentStep++},_updateShaderDefines:function(t,e){var r=t.viewGL.isLinearSpace()?"define":"undefine";e.rootNode.traverse(function(e){e.material&&(e.material[r]("fragment","SRGB_DECODE"),"mapbox3D"!==t.type&&"maptalks3D"!==t.type||(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1)))})},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});var Ig=i.extendSeriesModel({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(t){return tg(this,t)},getInitialData:function(t,e){var r=t.data;function n(t){return!(isNaN(t.min)||isNaN(t.max)||isNaN(t.step))}function a(t){var e=i.number.getPrecisionSafe;return Math.max(e(t.min),e(t.max),e(t.step))+1}if(!r)if(t.parametric){var o=t.parametricEquation||{},s=o.u||{},l=o.v||{};["u","v"].forEach(function(t){n(o[t])}),["x","y","z"].forEach(function(t){o[t]});var h=Math.floor((s.max+s.step-s.min)/s.step),u=Math.floor((l.max+l.step-l.min)/l.step);r=new Float32Array(h*u*5);var c=a(s),d=a(l);for(S=0,E=0;E<u;E++)for(A=0;A<h;A++){var f=A*s.step+s.min,p=E*l.step+l.min,m=i.number.round(Math.min(f,s.max),c),g=i.number.round(Math.min(p,l.max),d);M=o.x(m,g),C=o.y(m,g),P=o.z(m,g);r[S++]=M,r[S++]=C,r[S++]=P,r[S++]=m,r[S++]=g}}else{var _=t.equation||{},v=_.x||{},y=_.y||{};if(["x","y"].forEach(function(t){n(_[t])}),"function"!=typeof _.z)return void 0;var x=Math.floor((v.max+v.step-v.min)/v.step),T=Math.floor((y.max+y.step-y.min)/y.step);r=new Float32Array(x*T*3);for(var b=a(v),w=a(y),S=0,E=0;E<T;E++)for(var A=0;A<x;A++){var M=A*v.step+v.min,C=E*y.step+y.min,D=i.number.round(Math.min(M,v.max),b),L=i.number.round(Math.min(C,y.max),w),P=_.z(D,L);r[S++]=D,r[S++]=L,r[S++]=P}}var N=["x","y","z"];return t.parametric&&N.push("u","v"),eg(this,N,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}});i.util.merge(Ig.prototype,kf);var Og=lc.vec3;function Bg(t,e){for(var r=[],i=0;i<e.length;i++)r.push(t.dataToPoint(e[i]));return r}i.extendChartView({type:"surface",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node},render:function(t,e,r){var i=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=i,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var n=t.coordinateSystem,a=t.get("shading"),o=t.getData(),s="ecgl."+a;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=Wa.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),Wa.setMaterialFromModel(a,this._surfaceMesh.material,t,r),n&&n.viewGL){n.viewGL.add(this.groupGL);var l=n.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var h=t.get("parametric"),u=t.get("dataShape");u||(u=this._getDataShape(o,h));var c=t.getModel("wireframe"),d=c.get("lineStyle.width"),f=c.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,t,u,f);var p=this._surfaceMesh.material;f?(p.define("WIREFRAME_QUAD"),p.set("wireframeLineWidth",d),p.set("wireframeLineColor",Wa.parseColor(c.get("lineStyle.color")))):p.undefine("WIREFRAME_QUAD"),this._initHandler(t,r),this._updateAnimation(t)},_updateAnimation:function(t){Wa.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,t)},_createSurfaceMesh:function(){var t=new Wa.Mesh({geometry:new Wa.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new Wa.Material({shader:new Wa.Shader(Wa.Shader.source("ecgl.sm.depth.vertex"),Wa.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return t.geometry.createAttribute("barycentric","float",4),t.geometry.createAttribute("prevPosition","float",3),t.geometry.createAttribute("prevNormal","float",3),Object.assign(t.geometry,bp),t},_initHandler:function(t,e){var r=t.getData(),i=this._surfaceMesh,n=t.coordinateSystem;i.seriesIndex=t.seriesIndex;var a=-1;i.off("mousemove"),i.off("mouseout"),i.on("mousemove",function(t){var o=function(t,e){for(var r=1/0,n=-1,a=[],o=0;o<t.length;o++){i.geometry.attributes.position.get(t[o],a);var s=Og.dist(e.array,a);s<r&&(r=s,n=t[o])}return n}(t.triangle,t.point);if(o>=0){var s=[];i.geometry.attributes.position.get(o,s);for(var l=n.pointToData(s),h=1/0,u=-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=Og.squaredDistance(c,l);f<h&&(u=d,h=f)}u!==a&&e.dispatchAction({type:"grid3DShowAxisPointer",value:l}),a=u,i.dataIndex=u}else i.dataIndex=-1},this),i.on("mouseout",function(t){a=-1,i.dataIndex=-1,e.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_updateSurfaceMesh:function(t,e,r,i){var n=t.geometry,a=e.getData(),o=a.getLayout("points"),s=0;a.each(function(t){a.hasValue(t)||s++});var l=s||i,h=n.attributes.position,u=n.attributes.normal,c=n.attributes.texcoord0,d=n.attributes.barycentric,f=n.attributes.color,p=r[0],m=r[1],g="color"!==e.get("shading");if(l){var _=(p-1)*(m-1)*4;h.init(_),i&&d.init(_)}else h.value=new Float32Array(o);f.init(n.vertexCount),c.init(n.vertexCount);var v,y=[0,3,1,1,3,2],x=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],T=n.indices=new(n.vertexCount>65535?Uint32Array:Uint16Array)((p-1)*(m-1)*6),b=function(t,e,r){r[1]=t*m+e,r[0]=t*m+e+1,r[3]=(t+1)*m+e+1,r[2]=(t+1)*m+e},w=!1;if(l){var S=[],E=[],A=0;g?u.init(n.vertexCount):u.value=null;for(var M=[[],[],[]],C=[],D=[],L=Og.create(),P=function(t,e,r){var i=3*e;return r[0]=t[i],r[1]=t[i+1],r[2]=t[i+2],r},N=new Float32Array(o.length),R=new Float32Array(o.length/3*4),I=0;I<a.count();I++)if(a.hasValue(I)){var O=Wa.parseColor(wp(a,I)),B=Sp(a,I);O[3]*=B,O[3]<.99&&(w=!0);for(var F=0;F<4;F++)R[4*I+F]=O[F]}var z=[1e7,1e7,1e7];for(I=0;I<p-1;I++)for(var U=0;U<m-1;U++){var k=4*(I*(m-1)+U);b(I,U,S);var G=!1;for(F=0;F<4;F++)P(o,S[F],E),v=E,(isNaN(v[0])||isNaN(v[1])||isNaN(v[2]))&&(G=!0);for(F=0;F<4;F++)G?h.set(k+F,z):(P(o,S[F],E),h.set(k+F,E)),i&&d.set(k+F,x[F]);for(F=0;F<6;F++)T[A++]=y[F]+k;if(g&&!G)for(F=0;F<2;F++){for(var H=3*F,V=0;V<3;V++){P(o,j=S[y[H]+V],M[V])}Og.sub(C,M[0],M[1]),Og.sub(D,M[1],M[2]),Og.cross(L,C,D);for(V=0;V<3;V++){var W=3*S[y[H]+V];N[W]=N[W]+L[0],N[W+1]=N[W+1]+L[1],N[W+2]=N[W+2]+L[2]}}}if(g)for(I=0;I<N.length/3;I++)P(N,I,L),Og.normalize(L,L),N[3*I]=L[0],N[3*I+1]=L[1],N[3*I+2]=L[2];O=[];var X=[];for(I=0;I<p-1;I++)for(U=0;U<m-1;U++){k=4*(I*(m-1)+U);b(I,U,S);for(F=0;F<4;F++){for(V=0;V<4;V++)O[V]=R[4*S[F]+V];f.set(k+F,O),g&&(P(N,S[F],L),u.set(k+F,L));var j=S[F];X[0]=j%m/(m-1),X[1]=Math.floor(j/m)/(p-1),c.set(k+F,X)}0}}else{for(X=[],I=0;I<a.count();I++){X[0]=I%m/(m-1),X[1]=Math.floor(I/m)/(p-1);O=Wa.parseColor(wp(a,I)),B=Sp(a,I);O[3]*=B,O[3]<.99&&(w=!0),f.set(I,O),c.set(I,X)}S=[];var q=0;for(I=0;I<p-1;I++)for(U=0;U<m-1;U++){b(I,U,S);for(F=0;F<6;F++)T[q++]=S[y[F]]}g?n.generateVertexNormals():u.value=null}t.material.get("normalMap")&&n.generateTangents(),n.updateBoundingBox(),n.dirty(),t.material.transparent=w,t.material.depthMask=!w},_getDataShape:function(t,e){for(var r=-1/0,i=0,n=0,a=!1,o=e?"u":"x",s=t.count(),l=0;l<s;l++){var h=t.get(o,l);h<r&&(n,n=0,i++),r=h,n++}if(i&&1!==n||(a=!0),!a)return[i+1,n];for(var u=Math.floor(Math.sqrt(s));u>0;){if(Math.floor(s/u)===s/u)return[u,s/u];u--}return[u=Math.floor(Math.sqrt(s)),u]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}}),i.registerLayout(function(t,e){t.eachSeriesByType("surface",function(t){var e=t.coordinateSystem;e&&e.type;var r=t.getData(),i=new Float32Array(3*r.count()),n=[NaN,NaN,NaN];if(e&&"cartesian3D"===e.type){var a=e.dimensions.map(function(e){return t.coordDimToDataDim(e)[0]});r.each(a,function(t,a,o,s){var l;l=r.hasValue(s)?e.dataToPoint([t,a,o]):n,i[3*s]=l[0],i[3*s+1]=l[1],i[3*s+2]=l[2]})}r.setLayout("points",i)})});var Fg=i.extendSeriesModel({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(t){t=t||{};var e=this.get("coordinateSystem");null!=e&&"geo3D"!==e&&(this.get("groundPlane.show")&&(this.option.groundPlane.show=!1),this._geo=null)},getInitialData:function(t){t.data=this.getFilledRegions(t.data,t.map);var e=i.helper.createDimensions(["value"],t.data),r=new i.List(e,this);r.initData(t.data);var n={};return r.each(function(t){var e=r.getName(t),i=r.getItemModel(t);n[e]=i}),this._regionModelMap=n,r},formatTooltip:function(t){return tg(this,t)},getRegionModel:function(t){var e=this.getData().getName(t);return this._regionModelMap[e]||new i.Model(null,this)},getRegionPolygonCoords:function(t){var e=this.coordinateSystem,r=this.getData().getName(t);if(e.transform)return(i=e.getRegion(r))?i.geometries:[];this._geo||(this._geo=Gp.createGeo3D(this));for(var i=this._geo.getRegion(r),n=[],a=0;a<i.geometries.length;a++){var o=i.geometries[a],s=[],l=Bg(e,o.exterior);if(s&&s.length)for(var h=0;h<o.interiors.length;h++)s.push(Bg(e,s[h]));n.push({interiors:s,exterior:l})}return n},getFormattedLabel:function(t,e){var r=Zm.getFormattedLabel(this,t,e);return null==r&&(r=this.getData().getName(t)),r},defaultOption:{coordinateSystem:"geo3D",data:null}});i.util.merge(Fg.prototype,Gf),i.util.merge(Fg.prototype,_o),i.util.merge(Fg.prototype,vo),i.util.merge(Fg.prototype,yo),i.util.merge(Fg.prototype,kf);i.extendChartView({type:"map3D",__ecgl__:!0,init:function(t,e){this._geo3DBuilder=new Dp(e),this.groupGL=new Wa.Node},render:function(t,e,r){var i=t.coordinateSystem;if(i&&i.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),i.viewGL.add(this.groupGL),"geo3D"===i.type){i,this._sceneHelper||(this._sceneHelper=new Tc,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(t),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling"));var n=this._control;n||(n=this._control=new oc({zr:r.getZr()}),this._control.init());var a=t.getModel("viewControl");n.setViewGL(i.viewGL),n.setFromViewControlModel(a,0),n.off("update"),n.on("update",function(){r.dispatchAction({type:"map3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),from:this.uid,map3DId:t.id})}),this._geo3DBuilder.extrudeY=!0}else this._control&&(this._control.dispose(),this._control=null),this._sceneHelper&&(this._sceneHelper.dispose(),this._sceneHelper=null),t.getData().getLayout("geo3D"),this._geo3DBuilder.extrudeY=!1;this._geo3DBuilder.update(t,e,r,0,t.getData().count());var o=i.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse(function(t){t.material&&t.material[o]("fragment","SRGB_DECODE")})}},afterRender:function(t,e,r,i){var n=i.renderer,a=t.coordinateSystem;a&&"geo3D"===a.type&&(this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r))},dispose:function(){this.groupGL.removeAll(),this._control.dispose()}});function zg(t){this.viewGL=t}i.registerAction({type:"map3DChangeCamera",event:"map3dcamerachanged",update:"series:updateCamera"},function(t,e){e.eachComponent({mainType:"series",subType:"map3D",query:t},function(e){e.setView(t)})}),i.extendSeriesModel({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",getInitialData:function(){return i.helper.createList(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}}}}),zg.prototype.reset=function(t,e){this._updateCamera(e.getWidth(),e.getHeight(),e.getDevicePixelRatio()),this._viewTransform=[1,0,0,1,0,0],this.updateTransform(t,e)},zg.prototype.updateTransform=function(t,e){var r=t.coordinateSystem;r.getRoamTransform&&(Lo(this._viewTransform,r.getRoamTransform()),this._setCameraTransform(this._viewTransform),e.getZr().refresh())},zg.prototype.dataToPoint=function(t,e,r){r=t.dataToPoint(e,null,r);var i=this._viewTransform;i&&ys(r,r,i)},zg.prototype.removeTransformInPoint=function(t){return this._viewTransform&&ys(t,t,this._viewTransform),t},zg.prototype.getZoom=function(){if(this._viewTransform){var t=this._viewTransform;return 1/Math.max(Math.sqrt(t[0]*t[0]+t[1]*t[1]),Math.sqrt(t[2]*t[2]+t[3]*t[3]))}return 1},zg.prototype._setCameraTransform=function(t){var e=this.viewGL.camera;e.position.set(t[4],t[5],0),e.scale.set(Math.sqrt(t[0]*t[0]+t[1]*t[1]),Math.sqrt(t[2]*t[2]+t[3]*t[3]),1)},zg.prototype._updateCamera=function(t,e,r){this.viewGL.setViewport(0,0,t,e,r);var i=this.viewGL.camera;i.left=i.top=0,i.bottom=e,i.right=t,i.near=0,i.far=100};var Ug=zg;function kg(t){return"_EC_"+t}i.extendChartView({type:"scatterGL",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this.viewGL=new Bf("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new Ug(this.viewGL)},render:function(t,e,r){if(this.groupGL.removeAll(),this._glViewHelper.reset(t,r),t.getData().count()){var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new dg(!0,r)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.update(t,e,r),this.viewGL.setPostEffect(t.getModel("postEffect"),r)}},incrementalPrepareRender:function(t,e,r){this.groupGL.removeAll(),this._glViewHelper.reset(t,r),this._currentStep=0,this.viewGL.setPostEffect(t.getModel("postEffect"),r)},incrementalRender:function(t,e,r,i){if(!(t.end<=t.start)){var n=this._pointsBuilderList[this._currentStep];n||(n=new dg(!0,i),this._pointsBuilderList[this._currentStep]=n),this.groupGL.add(n.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),n.setSizeScale(this._sizeScale),n.update(e,r,i,t.start,t.end),i.getZr().refresh(),this._currentStep++}},updateTransform:function(t,e,r){if(t.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(t,r);var i=this._glViewHelper.getZoom(),n=Math.max((t.get("zoomScale")||0)*(i-1)+1,0);this._sizeScale=n,this._pointsBuilderList.forEach(function(t){t.setSizeScale(n)})}},_removeTransformInPoints:function(t){if(t)for(var e=[],r=0;r<t.length;r+=2)e[0]=t[r],e[1]=t[r+1],this._glViewHelper.removeTransformInPoint(e),t[r]=e[0],t[r+1]=e[1]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}}),i.registerLayout({seriesType:"scatterGL",reset:function(t){var e,r=t.coordinateSystem;if(r){var i=r.dimensions,n=[];1===i.length?e=function(t,e){for(var n=new Float32Array(2*(t.end-t.start)),a=t.start;a<t.end;a++){var o=2*(a-t.start),s=e.get(i[0],a),l=r.dataToPoint(s);n[o]=l[0],n[o+1]=l[1]}e.setLayout("points",n)}:2===i.length&&(e=function(t,e){for(var a=new Float32Array(2*(t.end-t.start)),o=t.start;o<t.end;o++){var s=2*(o-t.start),l=e.get(i[0],o),h=e.get(i[1],o);n[0]=l,n[1]=h,n=r.dataToPoint(n),a[s]=n[0],a[s+1]=n[1]}e.setLayout("points",a)})}return{progress:e}}});var Gg=function(){function t(t){this.type="graph",this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={},this._directed=t||!1}return t.prototype.isDirected=function(){return this._directed},t.prototype.addNode=function(t,e){t=null==t?""+e:""+t;var r=this._nodesMap;if(!r[kg(t)]){var i=new Hg(t,e);return i.hostGraph=this,this.nodes.push(i),r[kg(t)]=i,i}},t.prototype.getNodeByIndex=function(t){var e=this.data.getRawIndex(t);return this.nodes[e]},t.prototype.getNodeById=function(t){return this._nodesMap[kg(t)]},t.prototype.addEdge=function(t,e,r){var i=this._nodesMap,n=this._edgesMap;if("number"==typeof t&&(t=this.nodes[t]),"number"==typeof e&&(e=this.nodes[e]),t instanceof Hg||(t=i[kg(t)]),e instanceof Hg||(e=i[kg(e)]),t&&e){var a=t.id+"-"+e.id,o=new Vg(t,e,r);return o.hostGraph=this,this._directed&&(t.outEdges.push(o),e.inEdges.push(o)),t.edges.push(o),t!==e&&e.edges.push(o),this.edges.push(o),n[a]=o,o}},t.prototype.getEdgeByIndex=function(t){var e=this.edgeData.getRawIndex(t);return this.edges[e]},t.prototype.getEdge=function(t,e){t instanceof Hg&&(t=t.id),e instanceof Hg&&(e=e.id);var r=this._edgesMap;return this._directed?r[t+"-"+e]:r[t+"-"+e]||r[e+"-"+t]},t.prototype.eachNode=function(t,e){for(var r=this.nodes,i=r.length,n=0;n<i;n++)r[n].dataIndex>=0&&t.call(e,r[n],n)},t.prototype.eachEdge=function(t,e){for(var r=this.edges,i=r.length,n=0;n<i;n++)r[n].dataIndex>=0&&r[n].node1.dataIndex>=0&&r[n].node2.dataIndex>=0&&t.call(e,r[n],n)},t.prototype.breadthFirstTraverse=function(t,e,r,i){if(e instanceof Hg||(e=this._nodesMap[kg(e)]),e){for(var n="out"===r?"outEdges":"in"===r?"inEdges":"edges",a=0;a<this.nodes.length;a++)this.nodes[a].__visited=!1;if(!t.call(i,e,null))for(var o=[e];o.length;){var s=o.shift(),l=s[n];for(a=0;a<l.length;a++){var h=l[a],u=h.node1===s?h.node2:h.node1;if(!u.__visited){if(t.call(i,u,s))return;o.push(u),u.__visited=!0}}}}},t.prototype.update=function(){for(var t=this.data,e=this.edgeData,r=this.nodes,i=this.edges,n=0,a=r.length;n<a;n++)r[n].dataIndex=-1;for(n=0,a=t.count();n<a;n++)r[t.getRawIndex(n)].dataIndex=n;e.filterSelf(function(t){var r=i[e.getRawIndex(t)];return r.node1.dataIndex>=0&&r.node2.dataIndex>=0});for(n=0,a=i.length;n<a;n++)i[n].dataIndex=-1;for(n=0,a=e.count();n<a;n++)i[e.getRawIndex(n)].dataIndex=n},t.prototype.clone=function(){for(var e=new t(this._directed),r=this.nodes,i=this.edges,n=0;n<r.length;n++)e.addNode(r[n].id,r[n].dataIndex);for(n=0;n<i.length;n++){var a=i[n];e.addEdge(a.node1.id,a.node2.id,a.dataIndex)}return e},t}(),Hg=function(){function t(t,e){this.inEdges=[],this.outEdges=[],this.edges=[],this.dataIndex=-1,this.id=null==t?"":t,this.dataIndex=null==e?-1:e}return t.prototype.degree=function(){return this.edges.length},t.prototype.inDegree=function(){return this.inEdges.length},t.prototype.outDegree=function(){return this.outEdges.length},t.prototype.getModel=function(t){if(!(this.dataIndex<0))return this.hostGraph.data.getItemModel(this.dataIndex).getModel(t)},t.prototype.getAdjacentDataIndices=function(){for(var t={edge:[],node:[]},e=0;e<this.edges.length;e++){var r=this.edges[e];r.dataIndex<0||(t.edge.push(r.dataIndex),t.node.push(r.node1.dataIndex,r.node2.dataIndex))}return t},t}(),Vg=function(){function t(t,e,r){this.dataIndex=-1,this.node1=t,this.node2=e,this.dataIndex=null==r?-1:r}return t.prototype.getModel=function(t){if(!(this.dataIndex<0))return this.hostGraph.edgeData.getItemModel(this.dataIndex).getModel(t)},t.prototype.getAdjacentDataIndices=function(){return{edge:[this.dataIndex],node:[this.node1.dataIndex,this.node2.dataIndex]}},t}();function Wg(t,e){return{getValue:function(r){var i=this[t][e];return i.get(i.getDimension(r||"value"),this.dataIndex)},setVisual:function(r,i){this.dataIndex>=0&&this[t][e].setItemVisual(this.dataIndex,r,i)},getVisual:function(r){return this[t][e].getItemVisual(this.dataIndex,r)},setLayout:function(r,i){this.dataIndex>=0&&this[t][e].setItemLayout(this.dataIndex,r,i)},getLayout:function(){return this[t][e].getItemLayout(this.dataIndex)},getGraphicEl:function(){return this[t][e].getItemGraphicEl(this.dataIndex)},getRawIndex:function(){return this[t][e].getRawIndex(this.dataIndex)}}}Qn(Hg,Wg("hostGraph","data")),Qn(Vg,Wg("hostGraph","edgeData"));var Xg=Gg,jg=Zh();function qg(t,e){if(jg(i=this).mainData===i){var r=qn({},jg(this).datas);r[this.dataType]=e,Jg(e,r,t)}else $g(e,this.dataType,jg(this).mainData,t);var i;return e}function Zg(t,e){return t.struct&&t.struct.update(),e}function Yg(t,e){return $n(jg(e).datas,function(r,i){r!==e&&$g(r.cloneShallow(),i,e,t)}),e}function Kg(t){var e=jg(this).mainData;return null==t||null==e?e:jg(e).datas[t]}function Qg(){var t=jg(this).mainData;return null==t?[{data:t}]:ta(ra(jg(t).datas),function(e){return{type:e,data:jg(t).datas[e]}})}function Jg(t,e,r){jg(t).datas={},$n(e,function(e,i){$g(e,i,t,r)})}function $g(t,e,r,i){jg(r).datas[e]=t,jg(t).mainData=r,t.dataType=e,i.struct&&(t[i.structAttr]=i.struct,i.struct[i.datasAttr[e]]=t),t.getLinkedData=Kg,t.getLinkedDataAll=Qg}var t_=function(t){var e=t.mainData,r=t.datas;r||(r={main:e},t.datasAttr={main:"data"}),t.datas=t.mainData=null,Jg(e,r,t),$n(r,function(r){$n(e.TRANSFERABLE_METHODS,function(e){r.wrapMethod(e,ia(qg,t))})}),e.wrapMethod("cloneShallow",ia(Yg,t)),$n(e.CHANGABLE_METHODS,function(r){e.wrapMethod(r,ia(Zg,t))}),pa(r[e.dataType]===e)},e_=i.extendSeriesModel({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(t){e_.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(t){e_.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(t,e,r,i){var n=Zm.getFormattedLabel(this,t,e,r,i);if(null==n){var a=this.getData(),o=a.dimensions[a.dimensions.length-1];n=a.get(o,t)}return n},getInitialData:function(t,e){var r=t.edges||t.links||[],n=t.data||t.nodes||[],a=this;if(n&&r)return function(t,e,r,n,a){for(var o=new Xg(n),s=0;s<t.length;s++)o.addNode(qi.firstNotNull(t[s].id,t[s].name,s),s);var l,h=[],u=[],c=0;for(s=0;s<e.length;s++){var d=e[s],f=d.source,p=d.target;o.addEdge(f,p,c)&&(u.push(d),h.push(qi.firstNotNull(d.id,f+" > "+p)),c++)}var m=i.helper.createDimensions(["value"],t);(l=new i.List(m,r)).initData(t);var g=new i.List(["value"],r);return g.initData(u,h),a&&a(l,g),t_({mainData:l,struct:o,structAttr:"graph",datas:{node:l,edge:g},datasAttr:{node:"data",edge:"edgeData"}}),o.update(),o}(n,r,this,!0,function(t,r){t.wrapMethod("getItemModel",function(t){const e=a._categoriesModels,r=t.getShallow("category"),i=e[r];return i&&(i.parentModel=t.parentModel,t.parentModel=i),t});const i=e.getModel([]).getModel;function n(t,e){const r=i.call(this,t,e);return r.resolveParentPath=o,r}function o(t){if(t&&("label"===t[0]||"label"===t[1])){const e=t.slice();return"label"===t[0]?e[0]="edgeLabel":"label"===t[1]&&(e[1]="edgeLabel"),e}return t}r.wrapMethod("getItemModel",function(t){return t.resolveParentPath=o,t.getModel=n,t})}).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(t,e,r){if("edge"===r){var n=this.getData(),a=this.getDataParams(t,r),o=n.graph.getEdgeByIndex(t),s=n.getName(o.node1.dataIndex),l=n.getName(o.node2.dataIndex),h=[];return null!=s&&h.push(s),null!=l&&h.push(l),h=i.format.encodeHTML(h.join(" > ")),a.value&&(h+=" : "+i.format.encodeHTML(a.value)),h}return e_.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var t=(this.option.categories||[]).map(function(t){return null!=t.value?t:Object.assign({value:0},t)}),e=new i.List(["value"],this);e.initData(t),this._categoriesData=e,this._categoriesModels=e.mapArray(function(t){return e.getItemModel(t,!0)})},setView:function(t){null!=t.zoom&&(this.option.zoom=t.zoom),null!=t.offset&&(this.option.offset=t.offset)},setNodePosition:function(t){for(var e=0;e<t.length/2;e++){var r=t[2*e],i=t[2*e+1],n=this.getData().getRawDataItem(e);n.x=r,n.y=i}},isAnimationEnabled:function(){return e_.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}}),r_=lc.vec2,i_=[[0,0],[1,1]],n_=gr.extend(function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new gr.Attribute("position","float",2,"POSITION"),normal:new gr.Attribute("normal","float",2),offset:new gr.Attribute("offset","float",1),color:new gr.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(t){var e=this.attributes;this.vertexCount!==t&&(e.position.init(t),e.color.init(t),this.useNativeLine||(e.offset.init(t),e.normal.init(t)),t>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(t){this.triangleCount!==t&&(this.indices=0===t?null:this.vertexCount>65535?new Uint32Array(3*t):new Uint16Array(3*t))},_getCubicCurveApproxStep:function(t,e,r,i){return 1/(r_.dist(t,e)+r_.dist(r,e)+r_.dist(i,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(t,e,r,i){var n=this._getCubicCurveApproxStep(t,e,r,i),a=Math.ceil(1/n);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(t,e,r,i){var n=this._getCubicCurveApproxStep(t,e,r,i),a=Math.ceil(1/n);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(i_)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(i_)},getPolylineVertexCount:function(t){var e;"number"==typeof t?e=t:e="number"!=typeof t[0]?t.length:t.length/2;return this.useNativeLine?2*(e-1):2*(e-1)+2},getPolylineTriangleCount:function(t){var e;"number"==typeof t?e=t:e="number"!=typeof t[0]?t.length:t.length/2;return this.useNativeLine?0:2*(e-1)},addCubicCurve:function(t,e,r,i,n,a){null==a&&(a=1);var o=t[0],s=t[1],l=e[0],h=e[1],u=r[0],c=r[1],d=i[0],f=i[1],p=this._getCubicCurveApproxStep(t,e,r,i),m=p*p,g=m*p,_=3*p,v=3*m,y=6*m,x=6*g,T=o-2*l+u,b=s-2*h+c,w=3*(l-u)-o+d,S=3*(h-c)-s+f,E=o,A=s,M=(l-o)*_+T*v+w*g,C=(h-s)*_+b*v+S*g,D=T*y+w*x,L=b*y+S*x,P=w*x,N=S*x,R=0,I=0,O=Math.ceil(1/p),B=new Float32Array(3*(O+1)),F=(B=[],0);for(I=0;I<O+1;I++)B[F++]=E,B[F++]=A,E+=M,A+=C,M+=D,C+=L,D+=P,L+=N,(R+=p)>1&&(E=M>0?Math.min(E,d):Math.max(E,d),A=C>0?Math.min(A,f):Math.max(A,f));this.addPolyline(B,n,a)},addLine:function(t,e,r,i){this.addPolyline([t,e],r,i)},addPolyline:function(){var t=r_.create(),e=r_.create(),r=r_.create(),i=r_.create(),n=[],a=[],o=[];return function(s,l,h,u,c){if(s.length){var d="number"!=typeof s[0];if(null==c&&(c=d?s.length:s.length/2),!(c<2)){null==u&&(u=0),null==h&&(h=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,_=this.attributes.offset,v=this.attributes.normal,y=this.indices,x=this._vertexOffset,T=0;T<c;T++){if(d)n=s[T+u],f=p?l[T+u]:l;else{var b=2*T+u;if((n=n||[])[0]=s[b],n[1]=s[b+1],p){var w=4*T+u;(f=f||[])[0]=l[w],f[1]=l[w+1],f[2]=l[w+2],f[3]=l[w+3]}else f=l}if(this.useNativeLine)T>1&&(m.copy(x,x-1),g.copy(x,x-1),x++);else{var S;if(T<c-1){if(d)r_.copy(a,s[T+1]);else{b=2*(T+1)+u;(a=a||[])[0]=s[b],a[1]=s[b+1]}if(T>0){r_.sub(t,n,o),r_.sub(e,a,n),r_.normalize(t,t),r_.normalize(e,e),r_.add(i,t,e),r_.normalize(i,i);var E=h/2*Math.min(1/r_.dot(t,i),2);r[0]=-i[1],r[1]=i[0],S=E}else r_.sub(t,a,n),r_.normalize(t,t),r[0]=-t[1],r[1]=t[0],S=h/2}else r_.sub(t,n,o),r_.normalize(t,t),r[0]=-t[1],r[1]=t[0],S=h/2;v.set(x,r),v.set(x+1,r),_.set(x,S),_.set(x+1,-S),r_.copy(o,n),m.set(x,n),m.set(x+1,n),g.set(x,f),g.set(x+1,f),x+=2}if(this.useNativeLine)g.set(x,f),m.set(x,n),x++;else if(T>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(t,e){for(var r=this._itemVertexOffsets[t],i=t<this._itemVertexOffsets.length-1?this._itemVertexOffsets[t+1]:this._vertexOffset,n=r;n<i;n++)this.attributes.color.set(n,e);this.dirty("color")}});i.util.defaults(n_.prototype,sc);var a_=n_;Wa.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 o_={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function s_(t){var e={type:Wa.Texture.FLOAT,minFilter:Wa.Texture.NEAREST,magFilter:Wa.Texture.NEAREST};this._positionSourceTex=new Wa.Texture2D(e),this._positionSourceTex.flipY=!1,this._positionTex=new Wa.Texture2D(e),this._positionPrevTex=new Wa.Texture2D(e),this._forceTex=new Wa.Texture2D(e),this._forcePrevTex=new Wa.Texture2D(e),this._weightedSumTex=new Wa.Texture2D(e),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new Wa.Texture2D(e),this._globalSpeedPrevTex=new Wa.Texture2D(e),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new Bi({fragment:Wa.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new Bi({fragment:Wa.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new Bi({fragment:Wa.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new Bi({fragment:Wa.Shader.source("clay.compositor.output")});var r=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE)};this._edgeForceMesh=new Wa.Mesh({geometry:new Wa.Geometry({attributes:{node1:new Wa.Geometry.Attribute("node1","float",2),node2:new Wa.Geometry.Attribute("node2","float",2),weight:new Wa.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new Wa.Material({transparent:!0,shader:Wa.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:r,depthMask:!1,depthText:!1}),mode:Wa.Mesh.POINTS}),this._weightedSumMesh=new Wa.Mesh({geometry:new Wa.Geometry({attributes:{node:new Wa.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new Wa.Material({transparent:!0,shader:Wa.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:r,depthMask:!1,depthText:!1}),mode:Wa.Mesh.POINTS}),this._framebuffer=new ai({depthBuffer:!1}),this._dummyCamera=new Wa.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}s_.prototype.updateOption=function(t){for(var e in o_)this[e]=o_[e];var r=this._nodes.length;if(this.jitterTolerence=r>5e4?10:r>5e3?1:.1,this.scaling=r>100?2:10,t)for(var e in o_)null!=t[e]&&(this[e]=t[e]);if(this.repulsionByDegree)for(var i=this._positionSourceTex.pixels,n=0;n<this._nodes.length;n++)i[4*n+2]=(this._nodes[n].degree||0)+1},s_.prototype._updateGravityCenter=function(t){var e=this._nodes,r=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var i=[1/0,1/0],n=[-1/0,-1/0],a=0;a<e.length;a++)i[0]=Math.min(e[a].x,i[0]),i[1]=Math.min(e[a].y,i[1]),n[0]=Math.max(e[a].x,n[0]),n[1]=Math.max(e[a].y,n[1]);this._gravityCenter=[.5*(i[0]+n[0]),.5*(i[1]+n[1])]}for(a=0;a<r.length;a++){var o=r[a].node1,s=r[a].node2;e[o].degree=(e[o].degree||0)+1,e[s].degree=(e[s].degree||0)+1}},s_.prototype.initData=function(t,e){this._nodes=t,this._edges=e,this._updateGravityCenter();var r=Math.ceil(Math.sqrt(t.length)),i=r,n=new Float32Array(r*i*4);this._resize(r,i);for(var a=0,o=0;o<t.length;o++){var s=t[o];n[a++]=s.x||0,n[a++]=s.y||0,n[a++]=s.mass||1,n[a++]=s.size||1}this._positionSourceTex.pixels=n;var l=this._edgeForceMesh.geometry,h=e.length;l.attributes.node1.init(2*h),l.attributes.node2.init(2*h),l.attributes.weight.init(2*h);var u=[];for(o=0;o<e.length;o++){var c=l.attributes,d=e[o].weight;null==d&&(d=1),c.node1.set(o,this.getNodeUV(e[o].node1,u)),c.node2.set(o,this.getNodeUV(e[o].node2,u)),c.weight.set(o,d),c.node1.set(o+h,this.getNodeUV(e[o].node2,u)),c.node2.set(o+h,this.getNodeUV(e[o].node1,u)),c.weight.set(o+h,d)}var f=this._weightedSumMesh.geometry;f.attributes.node.init(t.length);for(o=0;o<t.length;o++)f.attributes.node.set(o,this.getNodeUV(o,u));l.dirty(),f.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",t.length),this._nodeRepulsionPass.material.setUniform("textureSize",[r,i]),this._inited=!1,this._frame=0},s_.prototype.getNodes=function(){return this._nodes},s_.prototype.getEdges=function(){return this._edges},s_.prototype.step=function(t){this._inited||(this._initFromSource(t),this._inited=!0),this._frame++,this._framebuffer.attach(this._forceTex),this._framebuffer.bind(t);var e=this._nodeRepulsionPass;e.setUniform("strongGravityMode",this.strongGravityMode),e.setUniform("gravity",this.gravity),e.setUniform("gravityCenter",this._gravityCenter),e.setUniform("scaling",this.scaling),e.setUniform("preventOverlap",this.preventOverlap),e.setUniform("positionTex",this._positionPrevTex),e.render(t);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),t.gl.enable(t.gl.BLEND),t.renderPass([r],this._dummyCamera),this._framebuffer.attach(this._weightedSumTex),t.gl.clearColor(0,0,0,0),t.gl.clear(t.gl.COLOR_BUFFER_BIT),t.gl.enable(t.gl.BLEND);var i=this._weightedSumMesh;i.material.set("positionTex",this._positionPrevTex),i.material.set("forceTex",this._forceTex),i.material.set("forcePrevTex",this._forcePrevTex),t.renderPass([i],this._dummyCamera),this._framebuffer.attach(this._globalSpeedTex);var n=this._globalSpeedPass;n.setUniform("globalSpeedPrevTex",this._globalSpeedPrevTex),n.setUniform("weightedSumTex",this._weightedSumTex),n.setUniform("jitterTolerence",this.jitterTolerence),t.gl.disable(t.gl.BLEND),n.render(t);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(t),this._framebuffer.unbind(t),this._swapTexture()},s_.prototype.update=function(t,e,r){null==e&&(e=1),e=Math.max(e,1);for(var i=0;i<e;i++)this.step(t);r&&r()},s_.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},s_.prototype.getNodeUV=function(t,e){e=e||[];var r=this._positionTex.width,i=this._positionTex.height;return e[0]=t%r/(r-1),e[1]=Math.floor(t/r)/(i-1)||0,e},s_.prototype.getNodePosition=function(t,e){var r=this._positionArr,i=this._positionTex.width,n=this._positionTex.height,a=i*n;r&&r.length===4*a||(r=this._positionArr=new Float32Array(4*a)),this._framebuffer.bind(t),this._framebuffer.attach(this._positionPrevTex),t.gl.readPixels(0,0,i,n,t.gl.RGBA,t.gl.FLOAT,r),this._framebuffer.unbind(t),e||(e=new Float32Array(2*this._nodes.length));for(var o=0;o<this._nodes.length;o++)e[2*o]=r[4*o],e[2*o+1]=r[4*o+1];return e},s_.prototype.getTextureData=function(t,e){var r=this["_"+e+"Tex"],i=r.width,n=r.height;this._framebuffer.bind(t),this._framebuffer.attach(r);var a=new Float32Array(i*n*4);return t.gl.readPixels(0,0,i,n,t.gl.RGBA,t.gl.FLOAT,a),this._framebuffer.unbind(t),a},s_.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},s_.prototype.isFinished=function(t){return this._frame>t},s_.prototype._swapTexture=function(){var t=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=t;t=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=t;t=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=t},s_.prototype._initFromSource=function(t){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(t),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(t),t.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),t.gl.clear(t.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),t.gl.clear(t.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(t)},s_.prototype._resize=function(t,e){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach(function(r){this[r].width=t,this[r].height=e,this[r].dirty()},this)},s_.prototype.dispose=function(t){this._framebuffer.dispose(t),this._copyPass.dispose(t),this._nodeRepulsionPass.dispose(t),this._positionPass.dispose(t),this._globalSpeedPass.dispose(t),this._edgeForceMesh.geometry.dispose(t),this._weightedSumMesh.geometry.dispose(t),this._positionSourceTex.dispose(t),this._positionTex.dispose(t),this._positionPrevTex.dispose(t),this._forceTex.dispose(t),this._forcePrevTex.dispose(t),this._weightedSumTex.dispose(t),this._globalSpeedTex.dispose(t),this._globalSpeedPrevTex.dispose(t)},i.ForceAtlas2GPU=s_;var l_=s_;var h_=function(){var t={create:function(){return new Float32Array(2)},dist:function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)},len:function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},scaleAndAdd:function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},scale:function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},sub:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},normalize:function(t,e){var r=e[0],i=e[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},set:function(t,e,r){return t[0]=e,t[1]=r,t}};function e(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var r=e.prototype;function i(){this.position=new Float32Array(2),this.force=t.create(),this.forcePrev=t.create(),this.mass=1,this.inDegree=0,this.outDegree=0}function n(t,e){this.source=t,this.target=e,this.weight=1}function a(){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 e,this.rootRegion.centerOfMass=t.create(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}r.beforeUpdate=function(){for(var t=0;t<this.nSubRegions;t++)this.subRegions[t].beforeUpdate();this.mass=0,this.centerOfMass&&(this.centerOfMass[0]=0,this.centerOfMass[1]=0),this.nSubRegions=0,this.node=null},r.afterUpdate=function(){this.subRegions.length=this.nSubRegions;for(var t=0;t<this.nSubRegions;t++)this.subRegions[t].afterUpdate()},r.addNode=function(t){if(0===this.nSubRegions){if(null==this.node)return void(this.node=t);this._addNodeToSubRegion(this.node),this.node=null}this._addNodeToSubRegion(t),this._updateCenterOfMass(t)},r.findSubRegion=function(t,e){for(var r=0;r<this.nSubRegions;r++){var i=this.subRegions[r];if(i.contain(t,e))return i}},r.contain=function(t,e){return this.bbox[0]<=t&&this.bbox[2]>=t&&this.bbox[1]<=e&&this.bbox[3]>=e},r.setBBox=function(t,e,r,i){this.bbox[0]=t,this.bbox[1]=e,this.bbox[2]=r,this.bbox[3]=i,this.size=(r-t+i-e)/2},r._newSubRegion=function(){var t=this.subRegions[this.nSubRegions];return t||(t=new e,this.subRegions[this.nSubRegions]=t),this.nSubRegions++,t},r._addNodeToSubRegion=function(t){var e=this.findSubRegion(t.position[0],t.position[1]),r=this.bbox;if(!e){var i=(r[0]+r[2])/2,n=(r[1]+r[3])/2,a=(r[2]-r[0])/2,o=(r[3]-r[1])/2,s=t.position[0]>=i?1:0,l=t.position[1]>=n?1:0;(e=this._newSubRegion()).setBBox(s*a+r[0],l*o+r[1],(s+1)*a+r[0],(l+1)*o+r[1])}e.addNode(t)},r._updateCenterOfMass=function(t){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var e=this.centerOfMass[0]*this.mass,r=this.centerOfMass[1]*this.mass;e+=t.position[0]*t.mass,r+=t.position[1]*t.mass,this.mass+=t.mass,this.centerOfMass[0]=e/this.mass,this.centerOfMass[1]=r/this.mass};var o,s=a.prototype;s.initNodes=function(t,e,r){var n=e.length;this.nodes.length=0;for(var a=void 0!==r,o=0;o<n;o++){var s=new i;s.position[0]=t[2*o],s.position[1]=t[2*o+1],s.mass=e[o],a&&(s.size=r[o]),this.nodes.push(s)}this._massArr=e,this._swingingArr=new Float32Array(n),a&&(this._sizeArr=r)},s.initEdges=function(t,e){var r=t.length/2;this.edges.length=0;for(var i=0;i<r;i++){var a=t[2*i],o=t[2*i+1],s=this.nodes[a],l=this.nodes[o];if(!s||!l)return void console.error("Node not exists, try initNodes before initEdges");s.outDegree++,l.inDegree++;var h=new n(s,l);e&&(h.weight=e[i]),this.edges.push(h)}},s.updateSettings=function(){if(this.repulsionByDegree)for(var t=0;t<this.nodes.length;t++)(e=this.nodes[t]).mass=e.inDegree+e.outDegree+1;else for(t=0;t<this.nodes.length;t++){var e;(e=this.nodes[t]).mass=this._massArr[t]}},s.update=function(){var e=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 r=0;r<e;r++)this.rootRegion.addNode(this.nodes[r]);this.rootRegion.afterUpdate()}for(r=0;r<e;r++){var i=this.nodes[r];t.copy(i.forcePrev,i.force),t.set(i.force,0,0)}for(r=0;r<e;r++){var n=this.nodes[r];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,n);else for(var a=r+1;a<e;a++){var o=this.nodes[a];this.applyNodeToNodeRepulsion(n,o,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(n):this.applyNodeGravity(n))}for(r=0;r<this.edges.length;r++)this.applyEdgeAttraction(this.edges[r]);var s=0,l=0,h=t.create();for(r=0;r<e;r++)i=this.nodes[r],s+=(c=t.dist(i.force,i.forcePrev))*i.mass,t.add(h,i.force,i.forcePrev),l+=.5*t.len(h)*i.mass,this._swingingArr[r]=c;var u=this.jitterTolerence*this.jitterTolerence*l/s;for(this._globalSpeed>0&&(u=Math.min(u/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=u,r=0;r<e;r++){i=this.nodes[r];var c=this._swingingArr[r],d=.1*u/(1+u*Math.sqrt(c)),f=t.len(i.force);f>0&&(d=Math.min(f*d,10)/f,t.scaleAndAdd(i.position,i.position,i.force,d))}},s.applyRegionToNodeRepulsion=(o=t.create(),function(e,r){if(e.node)this.applyNodeToNodeRepulsion(e.node,r,!0);else{t.sub(o,r.position,e.centerOfMass);var i=o[0]*o[0]+o[1]*o[1];if(i>this.barnesHutTheta*e.size*e.size){var n=this.scaling*r.mass*e.mass/i;t.scaleAndAdd(r.force,r.force,o,n)}else for(var a=0;a<e.nSubRegions;a++)this.applyRegionToNodeRepulsion(e.subRegions[a],r)}}),s.applyNodeToNodeRepulsion=function(){var e=t.create();return function(r,i,n){if(r!=i){t.sub(e,r.position,i.position);var a=e[0]*e[0]+e[1]*e[1];if(0!==a){var o;if(this.preventOverlap){var s=Math.sqrt(a);if((s=s-r.size-i.size)>0)o=this.scaling*r.mass*i.mass/(s*s);else{if(!(s<0))return;o=100*this.scaling*r.mass*i.mass}}else o=this.scaling*r.mass*i.mass/a;t.scaleAndAdd(r.force,r.force,e,o),t.scaleAndAdd(i.force,i.force,e,-o)}}}}(),s.applyEdgeAttraction=function(){var e=t.create();return function(r){var i=r.source,n=r.target;t.sub(e,i.position,n.position);var a,o,s=t.len(e);a=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?r.weight:Math.pow(r.weight,this.edgeWeightInfluence),this.preventOverlap&&(s=s-i.size-n.size)<=0||(o=this.linLogMode?-a*Math.log(s+1)/(s+1):-a,t.scaleAndAdd(i.force,i.force,e,o),t.scaleAndAdd(n.force,n.force,e,-o))}}(),s.applyNodeGravity=function(){var e=t.create();return function(r){t.sub(e,this.gravityCenter,r.position);var i=t.len(e);t.scaleAndAdd(r.force,r.force,e,this.gravity*r.mass/(i+1))}}(),s.applyNodeStrongGravity=function(){var e=t.create();return function(r){t.sub(e,this.gravityCenter,r.position),t.scaleAndAdd(r.force,r.force,e,this.gravity*r.mass)}}(),s.updateBBox=function(){for(var t=1/0,e=1/0,r=-1/0,i=-1/0,n=0;n<this.nodes.length;n++){var a=this.nodes[n].position;t=Math.min(t,a[0]),e=Math.min(e,a[1]),r=Math.max(r,a[0]),i=Math.max(i,a[1])}this.bbox[0]=t,this.bbox[1]=e,this.bbox[2]=r,this.bbox[3]=i},s.getGlobalSpeed=function(){return this._globalSpeed};var l=null;self.onmessage=function(t){switch(t.data.cmd){case"init":(l=new a).initNodes(t.data.nodesPosition,t.data.nodesMass,t.data.nodesSize),l.initEdges(t.data.edges,t.data.edgesWeight);break;case"updateConfig":if(l)for(var e in t.data.config)l[e]=t.data.config[e];break;case"update":var r=t.data.steps;if(l){for(var i=0;i<r;i++)l.update();var n=l.nodes.length,o=new Float32Array(2*n);for(i=0;i<n;i++){var s=l.nodes[i];o[2*i]=s.position[0],o[2*i+1]=s.position[1]}self.postMessage({buffer:o.buffer,globalSpeed:l.getGlobalSpeed()},[o.buffer])}else{var h=new Float32Array;self.postMessage({buffer:h.buffer,globalSpeed:l.getGlobalSpeed()},[h.buffer])}}}}.toString();h_=h_.slice(h_.indexOf("{")+1,h_.lastIndexOf("}"));var u_={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},c_=function(t){for(var e in u_)this[e]=u_[e];if(t)for(var e in t)this[e]=t[e];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new ir({type:Ye.FLOAT,flipY:!1,minFilter:Ye.NEAREST,magFilter:Ye.NEAREST})};c_.prototype.initData=function(t,e){var r=new Blob([h_]),i=window.URL.createObjectURL(r);this._worker=new Worker(i),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=t,this._edges=e,this._frame=0;for(var n=t.length,a=e.length,o=new Float32Array(2*n),s=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(2*a),u=new Float32Array(a),c=0;c<t.length;c++){var d=t[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<e.length;c++){var f=e[c],p=f.node1,m=f.node2;h[2*c]=p,h[2*c+1]=m,u[c]=null==f.weight?1:f.weight}var g=Math.ceil(Math.sqrt(t.length)),_=g,v=new Float32Array(g*_*4),y=this._positionTex;y.width=g,y.height=_,y.pixels=v,this._worker.postMessage({cmd:"init",nodesPosition:o,nodesMass:s,nodesSize:l,edges:h,edgesWeight:u}),this._globalSpeed=1/0},c_.prototype.updateOption=function(t){var e={};for(var r in u_)e[r]=u_[r];var i=this._nodes,n=this._edges,a=i.length;if(e.jitterTolerence=a>5e4?10:a>5e3?1:.1,e.scaling=a>100?2:10,e.barnesHutOptimize=a>1e3,t)for(var r in u_)null!=t[r]&&(e[r]=t[r]);if(!e.gravityCenter){for(var o=[1/0,1/0],s=[-1/0,-1/0],l=0;l<i.length;l++)o[0]=Math.min(i[l].x,o[0]),o[1]=Math.min(i[l].y,o[1]),s[0]=Math.max(i[l].x,s[0]),s[1]=Math.max(i[l].y,s[1]);e.gravityCenter=[.5*(o[0]+s[0]),.5*(o[1]+s[1])]}for(l=0;l<n.length;l++){var h=n[l].node1,u=n[l].node2;i[h].degree=(i[h].degree||0)+1,i[u].degree=(i[u].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:e})},c_.prototype.update=function(t,e,r){null==e&&(e=1),e=Math.max(e,1),this._frame+=e,this._onupdate=r,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(e)})},c_.prototype._$onupdate=function(t){if(!this._disposed){var e=new Float32Array(t.data.buffer);this._globalSpeed=t.data.globalSpeed,this._positionArr=e,this._updateTexture(e),this._onupdate&&this._onupdate()}},c_.prototype.getNodePositionTexture=function(){return this._positionTex},c_.prototype.getNodeUV=function(t,e){e=e||[];var r=this._positionTex.width,i=this._positionTex.height;return e[0]=t%r/(r-1),e[1]=Math.floor(t/r)/(i-1),e},c_.prototype.getNodes=function(){return this._nodes},c_.prototype.getEdges=function(){return this._edges},c_.prototype.isFinished=function(t){return this._frame>t},c_.prototype.getNodePosition=function(t,e){if(e||(e=new Float32Array(2*this._nodes.length)),this._positionArr)for(var r=0;r<this._positionArr.length;r++)e[r]=this._positionArr[r];return e},c_.prototype._updateTexture=function(t){for(var e=this._positionTex.pixels,r=0,i=0;i<t.length;)e[r++]=t[i++],e[r++]=t[i++],e[r++]=1,e[r++]=1;this._positionTex.dirty()},c_.prototype.dispose=function(t){this._disposed=!0,this._worker=null};var d_=c_,f_=f.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 t=this.zr;t.on("mousedown",this._mouseDownHandler),t.on("mousewheel",this._mouseWheelHandler),t.on("globalout",this._mouseUpHandler),t.animation.on("frame",this._update)},setTarget:function(t){this._target=t},setZoom:function(t){this._zoom=Math.max(Math.min(t,this.maxZoom),this.minZoom),this._needsUpdate=!0},setOffset:function(t){this._dx=t[0],this._dy=t[1],this._needsUpdate=!0},getZoom:function(){return this._zoom},getOffset:function(){return[this._dx,this._dy]},_update:function(){if(this._target&&this._needsUpdate){var t=this._target,e=this._zoom;t.position.x=this._dx,t.position.y=this._dy,t.scale.set(e,e,e),this.zr.refresh(),this._needsUpdate=!1,this.trigger("update")}},_mouseDownHandler:function(t){if(!t.target){var e=t.offsetX,r=t.offsetY;if(!this.viewGL||this.viewGL.containPoint(e,r)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var i=this._convertPos(e,r);this._x=i.x,this._y=i.y}}},_convertPos:function(t,e){var r=this.viewGL.camera,i=this.viewGL.viewport;return{x:(t-i.x)/i.width*(r.right-r.left)+r.left,y:(e-i.y)/i.height*(r.bottom-r.top)+r.top}},_mouseMoveHandler:function(t){var e=this._convertPos(t.offsetX,t.offsetY);this._dx+=e.x-this._x,this._dy+=e.y-this._y,this._x=e.x,this._y=e.y,this._needsUpdate=!0},_mouseUpHandler:function(t){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_mouseWheelHandler:function(t){var e=(t=t.event).wheelDelta||-t.detail;if(0!==e){var r=t.offsetX,i=t.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,i)){var n=e>0?1.1:.9,a=Math.max(Math.min(this._zoom*n,this.maxZoom),this.minZoom);n=a/this._zoom;var o=this._convertPos(r,i),s=(o.x-this._dx)*(n-1),l=(o.y-this._dy)*(n-1);this._dx-=s,this._dy-=l,this._zoom=a,this._needsUpdate=!0}}},dispose:function(){var t=this.zr;t.off("mousedown",this._mouseDownHandler),t.off("mousemove",this._mouseMoveHandler),t.off("mouseup",this._mouseUpHandler),t.off("mousewheel",this._mouseWheelHandler),t.off("globalout",this._mouseUpHandler),t.animation.off("frame",this._update)}}),p_=lc.vec2;Wa.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 m_,g_=1;function __(t){return t instanceof Array||(t=[t,t]),t}function v_(){}i.extendChartView({type:"graphGL",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this.viewGL=new Bf("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new dg(!0,e),this._forceEdgesMesh=new Wa.Mesh({material:new Wa.Material({shader:Wa.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new Wa.Geometry({attributes:{node:new Wa.Geometry.Attribute("node","float",2),color:new Wa.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:Wa.Mesh.LINES}),this._edgesMesh=new Wa.Mesh({material:new Wa.Material({shader:Wa.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new a_({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new f_({zr:e.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(t,e,r){this.groupGL.add(this._pointsBuilder.rootNode),this._model=t,this._api=r,this._initLayout(t,e,r),this._pointsBuilder.update(t,e,r),this._forceLayoutInstance instanceof l_||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(t,r),this._control.off("update"),this._control.on("update",function(){r.dispatchAction({type:"graphGLRoam",seriesId:t.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)},this),this._control.setZoom(qi.firstNotNull(t.get("zoom"),1)),this._control.setOffset(t.get("offset")||[0,0]);var i=this._pointsBuilder.getPointsMesh();if(i.off("mousemove",this._mousemoveHandler),i.off("mouseout",this._mouseOutHandler,this),r.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,t.get("focusNodeAdjacency")){var n=t.get("focusNodeAdjacencyOn");"click"===n?r.getZr().on("click",this._clickHandler):"mouseover"===n&&(i.on("mousemove",this._mousemoveHandler,this),i.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1)}this._lastMouseOverDataIndex=-1},_clickHandler:function(t){if(!this._layouting){var e=this._pointsBuilder.getPointsMesh().dataIndex;e>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:e}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(t){if(!this._layouting){var e=this._pointsBuilder.getPointsMesh().dataIndex;e>=0?e!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:e}):this._mouseOutHandler(t),this._lastMouseOverDataIndex=e}},_mouseOutHandler:function(t){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(t,e){var r=this._forceEdgesMesh.geometry,i=e.getEdgeData(),n=0,a=this._forceLayoutInstance,o=2*i.count();r.attributes.node.init(o),r.attributes.color.init(o),i.each(function(e){var o=t[e];r.attributes.node.set(n,a.getNodeUV(o.node1)),r.attributes.node.set(n+1,a.getNodeUV(o.node2));var s=wp(i,o.dataIndex),l=Wa.parseColor(s);l[3]*=qi.firstNotNull(Sp(i,o.dataIndex),1),r.attributes.color.set(n,l),r.attributes.color.set(n+1,l),n+=2}),r.dirty()},_updateMeshLinesGeometry:function(){var t=this._model.getEdgeData(),e=this._edgesMesh.geometry,r=(t=this._model.getEdgeData(),this._model.getData().getLayout("points"));e.resetOffset(),e.setVertexCount(t.count()*e.getLineVertexCount()),e.setTriangleCount(t.count()*e.getLineTriangleCount());var i=[],n=[],a=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*t.count()),this._edgeIndicesMap=new Float32Array(t.count()),t.each(function(o){var s=t.graph.getEdgeByIndex(o),l=2*s.node1.dataIndex,h=2*s.node2.dataIndex;i[0]=r[l],i[1]=r[l+1],n[0]=r[h],n[1]=r[h+1];var u=wp(t,s.dataIndex),c=Wa.parseColor(u);c[3]*=qi.firstNotNull(Sp(t,s.dataIndex),1);var d=t.getItemModel(s.dataIndex),f=qi.firstNotNull(d.get(a),1)*this._api.getDevicePixelRatio();e.addLine(i,n,c,f);for(var p=0;p<4;p++)this._originalEdgeColors[4*s.dataIndex+p]=c[p];this._edgeIndicesMap[s.dataIndex]=o},this),e.dirty()},_updateForceNodesGeometry:function(t){for(var e=this._pointsBuilder.getPointsMesh(),r=[],i=0;i<t.count();i++)this._forceLayoutInstance.getNodeUV(i,r),e.geometry.attributes.position.set(i,r);e.geometry.dirty("position")},_initLayout:function(t,e,r){var n=t.get("layout"),a=t.getGraph(),o=xd(t.getBoxLayoutParams(),{width:r.getWidth(),height:r.getHeight()});"force"===n&&(n="forceAtlas2"),this.stopLayout(t,e,r,{beforeLayout:!0});var s=t.getData(),l=t.getData();if("forceAtlas2"===n){var h=t.getModel("forceAtlas2"),u=this._forceLayoutInstance,c=[],d=[],f=s.getDataExtent("value"),p=l.getDataExtent("value"),m=qi.firstNotNull(h.get("edgeWeight"),1),g=qi.firstNotNull(h.get("nodeWeight"),1);"number"==typeof m&&(m=[m,m]),"number"==typeof g&&(g=[g,g]);var _=0,v={},y=new Float32Array(2*s.count());if(a.eachNode(function(t){var e,r,n=t.dataIndex,a=s.get("value",n);if(s.hasItemOption){var l=s.getItemModel(n);e=l.get("x"),r=l.get("y")}null==e&&(e=o.x+Math.random()*o.width,r=o.y+Math.random()*o.height),y[2*_]=e,y[2*_+1]=r,v[t.id]=_++;var h=i.number.linearMap(a,f,g);isNaN(h)&&(h=isNaN(g[0])?1:g[0]),c.push({x:e,y:r,mass:h,size:s.getItemVisual(n,"symbolSize")})}),s.setLayout("points",y),a.eachEdge(function(t){var e=t.dataIndex,r=s.get("value",e),n=i.number.linearMap(r,p,m);isNaN(n)&&(n=isNaN(m[0])?1:m[0]),d.push({node1:v[t.node1.id],node2:v[t.node2.id],weight:n,dataIndex:e})}),!u){var x=h.get("GPU");this._forceLayoutInstance&&((!x||this._forceLayoutInstance instanceof l_)&&(x||this._forceLayoutInstance instanceof d_)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),u=this._forceLayoutInstance=x?new l_:new d_}u.initData(c,d),u.updateOption(h.option),this._updateForceEdgesGeometry(u.getEdges(),t),this._updatePositionTexture(),r.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else{y=new Float32Array(2*s.count()),_=0;a.eachNode(function(t){var e,r,i=t.dataIndex;if(s.hasItemOption){var n=s.getItemModel(i);e=n.get("x"),r=n.get("y")}y[_++]=e,y[_++]=r}),s.setLayout("points",y),this._updateAfterLayout(t,e,r)}},_updatePositionTexture:function(){var t=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(t),this._forceEdgesMesh.material.set("positionTex",t)},startLayout:function(t,e,r,i){if(!i||null==i.from||i.from===this.uid){var n=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(t.getData()),this._pointsBuilder.hideLabels();var l=this,h=this._layoutId=g_++,u=s.getShallow("maxSteps"),c=s.getShallow("steps"),d=0,f=Math.max(2*c,20),p=function(e){if(e===l._layoutId)return a.isFinished(u)?(r.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void r.dispatchAction({type:"graphGLFinishLayout",points:o.getLayout("points"),from:l.uid})):void a.update(n.layer.renderer,c,function(){l._updatePositionTexture(),(d+=c)>=f&&(l._syncNodePosition(t),d=0),r.getZr().refresh(),Xa(function(){p(e)})})};Xa(function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(n.layer.renderer),l._forceLayoutInstanceToDispose=null),p(h)}),this._layouting=!0}}},stopLayout:function(t,e,r,i){i&&null!=i.from&&i.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(i&&i.beforeLayout||(this._syncNodePosition(t),this._updateAfterLayout(t,e,r)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(t){var e=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);t.getData().setLayout("points",e),t.setNodePosition(e)},_updateAfterLayout:function(t,e,r){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(t,e,r),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(t,e,r,i){var n=this._model.getData();this._downplayAll();var a=i.dataIndex,o=[],s=n.graph.getNodeByIndex(a);o.push(s),s.edges.forEach(function(t){t.dataIndex<0||(t.node1!==s&&o.push(t.node1),t.node2!==s&&o.push(t.node2))},this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),o.forEach(function(t){this._pointsBuilder.highlight(n,t.dataIndex)},this),this._pointsBuilder.updateLabels(o.map(function(t){return t.dataIndex}));var l=[];s.edges.forEach(function(t){t.dataIndex>=0&&(this._highlightEdge(t.dataIndex),l.push(t))},this),this._focusNodes=o,this._focusEdges=l},unfocusNodeAdjacency:function(t,e,r,i){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(t){var e=this._model.getEdgeData().getItemModel(t),r=Wa.parseColor(e.get("emphasis.lineStyle.color")||e.get("lineStyle.color")),i=qi.firstNotNull(e.get("emphasis.lineStyle.opacity"),e.get("lineStyle.opacity"),1);r[3]*=i,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],r)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach(function(t){this._pointsBuilder.downplay(this._model.getData(),t.dataIndex)},this),this._focusEdges&&this._focusEdges.forEach(function(t){this._downplayEdge(t.dataIndex)},this)},_downplayEdge:function(t){var e=this._getColor(t,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)},_setEdgeFade:(m_=[],function(t,e){this._getColor(t,m_),m_[3]*=e,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],m_)}),_getColor:function(t,e){for(var r=0;r<4;r++)e[r]=this._originalEdgeColors[4*t+r];return e},_fadeOutEdgesAll:function(t){this._model.getData().graph.eachEdge(function(e){this._setEdgeFade(e.dataIndex,t)},this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(t,e){this.viewGL.setViewport(0,0,e.getWidth(),e.getHeight(),e.getDevicePixelRatio());for(var r=this.viewGL.camera,i=t.getData().getLayout("points"),n=p_.create(1/0,1/0),a=p_.create(-1/0,-1/0),o=[],s=0;s<i.length;)o[0]=i[s++],o[1]=i[s++],p_.min(n,n,o),p_.max(a,a,o);var l=(a[1]+n[1])/2,h=(a[0]+n[0])/2;if(!(h>r.left&&h<r.right&&l<r.bottom&&l>r.top)){var u=Math.max(a[0]-n[0],10),c=u/e.getWidth()*e.getHeight();u*=1.4,c*=1.4,n[0]-=.2*u,r.left=n[0],r.top=l-c/2,r.bottom=l+c/2,r.right=u+n[0],r.near=0,r.far=100}},dispose:function(){var t=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(t),this.groupGL.removeAll(),this._layoutId=-1},remove:function(){this.groupGL.removeAll(),this._control.dispose()}}),i.registerVisual(function(t){const e={};t.eachSeriesByType("graphGL",function(t){var r=t.getCategoriesData(),n=t.getData(),a={};r.each(function(i){var n=r.getName(i);a["ec-"+n]=i;var o=r.getItemModel(i),s=o.getModel("itemStyle").getItemStyle();s.fill||(s.fill=t.getColorFromPalette(n,e)),r.setItemVisual(i,"style",s);var l=["symbol","symbolSize","symbolKeepAspect"];for(let t=0;t<l.length;t++){var h=o.getShallow(l[t],!0);null!=h&&r.setItemVisual(i,l[t],h)}}),r.count()&&n.each(function(t){let e=n.getItemModel(t).getShallow("category");if(null!=e){"string"==typeof e&&(e=a["ec-"+e]);var o=r.getItemVisual(e,"style"),s=n.ensureUniqueItemVisual(t,"style");i.util.extend(s,o);var l=["symbol","symbolSize","symbolKeepAspect"];for(let i=0;i<l.length;i++)n.setItemVisual(t,l[i],r.getItemVisual(e,l[i]))}})})}),i.registerVisual(function(t){t.eachSeriesByType("graphGL",function(t){var e=t.getGraph(),r=t.getEdgeData(),n=__(t.get("edgeSymbol")),a=__(t.get("edgeSymbolSize"));r.setVisual("drawType","stroke"),r.setVisual("fromSymbol",n&&n[0]),r.setVisual("toSymbol",n&&n[1]),r.setVisual("fromSymbolSize",a&&a[0]),r.setVisual("toSymbolSize",a&&a[1]),r.setVisual("style",t.getModel("lineStyle").getLineStyle()),r.each(function(t){var n=r.getItemModel(t),a=e.getEdgeByIndex(t),o=__(n.getShallow("symbol",!0)),s=__(n.getShallow("symbolSize",!0)),l=n.getModel("lineStyle").getLineStyle(),h=r.ensureUniqueItemVisual(t,"style");switch(i.util.extend(h,l),h.stroke){case"source":var u=a.node1.getVisual("style");h.stroke=u&&u.fill;break;case"target":u=a.node2.getVisual("style");h.stroke=u&&u.fill}o[0]&&a.setVisual("fromSymbol",o[0]),o[1]&&a.setVisual("toSymbol",o[1]),s[0]&&a.setVisual("fromSymbolSize",s[0]),s[1]&&a.setVisual("toSymbolSize",s[1])})})}),i.registerAction({type:"graphGLRoam",event:"graphglroam",update:"series.graphGL:roam"},function(t,e){e.eachComponent({mainType:"series",query:t},function(e){e.setView(t)})}),i.registerAction({type:"graphGLStartLayout",event:"graphgllayoutstarted",update:"series.graphGL:startLayout"},v_),i.registerAction({type:"graphGLStopLayout",event:"graphgllayoutstopped",update:"series.graphGL:stopLayout"},v_),i.registerAction({type:"graphGLFocusNodeAdjacency",event:"graphGLFocusNodeAdjacency",update:"series.graphGL:focusNodeAdjacency"},v_),i.registerAction({type:"graphGLUnfocusNodeAdjacency",event:"graphGLUnfocusNodeAdjacency",update:"series.graphGL:unfocusNodeAdjacency"},v_);var y_=gr.extend(function(){return{dynamic:!0,attributes:{position:new gr.Attribute("position","float",3,"POSITION")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(t){var e=this.attributes,r=4*t,i=2*t;this.vertexCount!==r&&e.position.init(r),this.triangleCount!==i&&(this.indices=0===i?null:this.vertexCount>65535?new Uint32Array(3*i):new Uint16Array(3*i))},addLine:function(t){var e=this._vertexOffset;this.attributes.position.set(e,[t[0],t[1],1]),this.attributes.position.set(e+1,[t[0],t[1],-1]),this.attributes.position.set(e+2,[t[0],t[1],2]),this.attributes.position.set(e+3,[t[0],t[1],-2]),this.setTriangleIndices(this._faceOffset++,[e,e+1,e+2]),this.setTriangleIndices(this._faceOffset++,[e+1,e+2,e+3]),this._vertexOffset+=4}});bt.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 x_=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new ir({type:Ye.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()};x_.prototype={constructor:x_,init:function(){var t={type:Ye.FLOAT,minFilter:Ye.NEAREST,magFilter:Ye.NEAREST,useMipmap:!1};this._spawnTexture=new ir(t),this._particleTexture0=new ir(t),this._particleTexture1=new ir(t),this._frameBuffer=new ai({depthBuffer:!1}),this._particlePass=new Bi({fragment:bt.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new Bi({fragment:bt.source("clay.compositor.downsample")});var e=new Qe({renderOrder:10,material:new G({shader:new bt(bt.source("ecgl.vfParticle.renderPoints.vertex"),bt.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:Qe.POINTS,geometry:new gr({dynamic:!0,mainAttribute:"texcoord0"})}),r=new Qe({renderOrder:10,material:new G({shader:new bt(bt.source("ecgl.vfParticle.renderLines.vertex"),bt.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new y_,culling:!1}),i=new Qe({material:new G({shader:new bt(bt.source("ecgl.color.vertex"),bt.source("ecgl.color.fragment"))}),geometry:new li});i.material.enableTexture("diffuseMap"),this._particlePointsMesh=e,this._particleLinesMesh=r,this._lastFrameFullQuadMesh=i,this._camera=new Ni,this._thisFrameTexture=new ir,this._lastFrameTexture=new ir},setParticleDensity:function(t,e){for(var r=new Float32Array(4*(t*e)),i=0,n=this.particleLife,a=0;a<t;a++)for(var o=0;o<e;o++,i++){r[4*i]=Math.random(),r[4*i+1]=Math.random(),r[4*i+2]=Math.random();var s=(n[1]-n[0])*Math.random()+n[0];r[4*i+3]=s}"line"===this._particleType?this._setLineGeometry(t,e):this._setPointsGeometry(t,e),this._spawnTexture.width=t,this._spawnTexture.height=e,this._spawnTexture.pixels=r,this._particleTexture0.width=this._particleTexture1.width=t,this._particleTexture0.height=this._particleTexture1.height=e,this._particlePass.setUniform("textureSize",[t,e])},_setPointsGeometry:function(t,e){var r=t*e,i=this._particlePointsMesh.geometry,n=i.attributes;n.texcoord0.init(r);for(var a=0,o=0;o<t;o++)for(var s=0;s<e;s++,a++)n.texcoord0.value[2*a]=o/t,n.texcoord0.value[2*a+1]=s/e;i.dirty()},_setLineGeometry:function(t,e){var r=t*e,i=this._getParticleMesh().geometry;i.setLineCount(r),i.resetOffset();for(var n=0;n<t;n++)for(var a=0;a<e;a++)i.addLine([n/t,a/e]);i.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(t,e,r,i){var n=this._getParticleMesh(),a=this._frameBuffer,o=this._particlePass;i&&this._updateDownsampleTextures(t,e),n.material.set("size",this._particleSize*this._supersampling),n.material.set("color",this.particleColor),o.setUniform("speedScaling",this.particleSpeedScaling),a.attach(this._particleTexture1),o.setUniform("firstFrameTime",i?(this.particleLife[1]+this.particleLife[0])/2:0),o.setUniform("particleTexture",this._particleTexture0),o.setUniform("deltaTime",r),o.setUniform("elapsedTime",this._elapsedTime),o.render(t,a),n.material.set("particleTexture",this._particleTexture1),n.material.set("prevParticleTexture",this._particleTexture0),a.attach(this._thisFrameTexture),a.bind(t),t.gl.clear(t.gl.DEPTH_BUFFER_BIT|t.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),t.renderPass([s,n],this._camera),a.unbind(t),this._downsample(t),this._swapTexture(),this._elapsedTime+=r},_downsample:function(t){var e=this._downsampleTextures;if(0!==e.length)for(var r=0,i=this._thisFrameTexture,n=e[r];n;)this._frameBuffer.attach(n),this._downsamplePass.setUniform("texture",i),this._downsamplePass.setUniform("textureSize",[i.width,i.height]),this._downsamplePass.render(t,this._frameBuffer),i=n,n=e[++r]},getSurfaceTexture:function(){var t=this._downsampleTextures;return t.length>0?t[t.length-1]:this._lastFrameTexture},setRegion:function(t){this._particlePass.setUniform("region",t)},resize:function(t,e){this._lastFrameTexture.width=t*this._supersampling,this._lastFrameTexture.height=e*this._supersampling,this._thisFrameTexture.width=t*this._supersampling,this._thisFrameTexture.height=e*this._supersampling,this._width=t,this._height=e},setParticleSize:function(t){var e=this._getParticleMesh();if(t<=2)return e.material.disableTexture("spriteTexture"),void(e.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new ir),this._spriteTexture.image&&this._spriteTexture.image.width===t||(this._spriteTexture.image=function(t){var e=document.createElement("canvas");e.width=e.height=t;var r=e.getContext("2d");return r.fillStyle="#fff",r.arc(t/2,t/2,t/2,0,2*Math.PI),r.fill(),e}(t),this._spriteTexture.dirty()),e.material.transparent=!0,e.material.enableTexture("spriteTexture"),e.material.set("spriteTexture",this._spriteTexture),this._particleSize=t},setGradientTexture:function(t){var e=this._getParticleMesh().material;e[t?"enableTexture":"disableTexture"]("gradientTexture"),e.setUniform("gradientTexture",t)},setColorTextureImage:function(t,e){this._getParticleMesh().material.setTextureImage("colorTexture",t,e,{flipY:!0})},setParticleType:function(t){this._particleType=t},clearFrame:function(t){var e=this._frameBuffer;e.attach(this._lastFrameTexture),e.bind(t),t.gl.clear(t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT),e.unbind(t)},setSupersampling:function(t){this._supersampling=t,this.resize(this._width,this._height)},_updateDownsampleTextures:function(t,e){for(var r=this._downsampleTextures,i=Math.max(Math.floor(Math.log(this._supersampling/e.getDevicePixelRatio())/Math.log(2)),0),n=2,a=this._width*this._supersampling,o=this._height*this._supersampling,s=0;s<i;s++)r[s]=r[s]||new ir,r[s].width=a/n,r[s].height=o/n,n*=2;for(;s<r.length;s++)r[s].dispose(t);r.length=i},_swapTexture:function(){var t=this._particleTexture0;this._particleTexture0=this._particleTexture1,this._particleTexture1=t;t=this._thisFrameTexture;this._thisFrameTexture=this._lastFrameTexture,this._lastFrameTexture=t},dispose:function(t){t.disposeFrameBuffer(this._frameBuffer),t.disposeTexture(this.vectorFieldTexture),t.disposeTexture(this._spawnTexture),t.disposeTexture(this._particleTexture0),t.disposeTexture(this._particleTexture1),t.disposeTexture(this._thisFrameTexture),t.disposeTexture(this._lastFrameTexture),t.disposeGeometry(this._particleLinesMesh.geometry),t.disposeGeometry(this._particlePointsMesh.geometry),t.disposeGeometry(this._lastFrameFullQuadMesh.geometry),this._spriteTexture&&t.disposeTexture(this._spriteTexture),this._particlePass.dispose(t),this._downsamplePass.dispose(t),this._downsampleTextures.forEach(function(e){e.dispose(t)})}};var T_=x_;i.extendChartView({type:"flowGL",__ecgl__:!0,init:function(t,e){this.viewGL=new Bf("orthographic"),this.groupGL=new Wa.Node,this.viewGL.add(this.groupGL),this._particleSurface=new T_;var r=new Wa.Mesh({geometry:new Wa.PlaneGeometry,material:new Wa.Material({shader:new Wa.Shader({vertex:Wa.Shader.source("ecgl.color.vertex"),fragment:Wa.Shader.source("ecgl.color.fragment")}),transparent:!0})});r.material.enableTexture("diffuseMap"),this.groupGL.add(r),this._planeMesh=r},render:function(t,e,r){var i=this._particleSurface;i.setParticleType(t.get("particleType")),i.setSupersampling(t.get("supersampling")),this._updateData(t,r),this._updateCamera(r.getWidth(),r.getHeight(),r.getDevicePixelRatio());var n=qi.firstNotNull(t.get("particleDensity"),128);i.setParticleDensity(n,n);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 t=+new Date,e=Math.min(t-o,20);o+=e,s._renderer&&(i.update(s._renderer,r,e/1e3,l),a.material.set("diffuseMap",i.getSurfaceTexture())),l=!1}).start();var h=t.getModel("itemStyle"),u=Wa.parseColor(h.get("color"));u[3]*=qi.firstNotNull(h.get("opacity"),1),a.material.set("color",u),i.setColorTextureImage(t.get("colorTexture"),r),i.setParticleSize(t.get("particleSize")),i.particleSpeedScaling=t.get("particleSpeed"),i.motionBlurFactor=1-Math.pow(.1,t.get("particleTrail"))},updateTransform:function(t,e,r){this._updateData(t,r)},afterRender:function(t,e,r,i){var n=i.renderer;this._renderer=n},_updateData:function(t,e){var r=t.coordinateSystem,i=r.dimensions.map(function(e){return t.coordDimToDataDim(e)[0]}),n=t.getData(),a=n.getDataExtent(i[0]),o=n.getDataExtent(i[1]),s=t.get("gridWidth"),l=t.get("gridHeight");if(null==s||"auto"===s){var h=(a[1]-a[0])/(o[1]-o[0]);s=Math.round(Math.sqrt(h*n.count()))}null!=l&&"auto"!==l||(l=Math.ceil(n.count()/s));var u=this._particleSurface.vectorFieldTexture,c=u.pixels;if(c&&c.length===l*s*4)for(var d=0;d<c.length;d++)c[d]=0;else c=u.pixels=new Float32Array(s*l*4);var f=0,p=1/0,m=new Float32Array(2*n.count()),g=0,_=[[1/0,1/0],[-1/0,-1/0]];n.each([i[0],i[1],"vx","vy"],function(t,e,i,n){var a=r.dataToPoint([t,e]);m[g++]=a[0],m[g++]=a[1],_[0][0]=Math.min(a[0],_[0][0]),_[0][1]=Math.min(a[1],_[0][1]),_[1][0]=Math.max(a[0],_[1][0]),_[1][1]=Math.max(a[1],_[1][1]);var o=Math.sqrt(i*i+n*n);f=Math.max(f,o),p=Math.min(p,o)}),n.each(["vx","vy"],function(t,e,r){var i=Math.round((m[2*r]-_[0][0])/(_[1][0]-_[0][0])*(s-1)),n=4*((l-1-Math.round((m[2*r+1]-_[0][1])/(_[1][1]-_[0][1])*(l-1)))*s+i);c[n]=t/f*.5+.5,c[n+1]=e/f*.5+.5,c[n+3]=1}),u.width=s,u.height=l,"bmap"===t.get("coordinateSystem")&&this._fillEmptyPixels(u),u.dirty(),this._updatePlanePosition(_[0],_[1],t,e),this._updateGradientTexture(n.getVisual("visualMeta"),[p,f])},_fillEmptyPixels:function(t){var e=t.pixels,r=t.width,i=t.height;function n(t,n,a){t=Math.max(Math.min(t,r-1),0);var o=4*((n=Math.max(Math.min(n,i-1),0))*(r-1)+t);return 0!==e[o+3]&&(a[0]=e[o],a[1]=e[o+1],!0)}function a(t,e,r){r[0]=t[0]+e[0],r[1]=t[1]+e[1]}for(var o=[],s=[],l=[],h=[],u=[],c=0,d=0;d<i;d++)for(var f=0;f<r;f++){var p=4*(d*(r-1)+f);0===e[p+3]&&(c=o[0]=o[1]=0,n(f-1,d,s)&&(c++,a(s,o,o)),n(f+1,d,l)&&(c++,a(l,o,o)),n(f,d-1,h)&&(c++,a(h,o,o)),n(f,d+1,u)&&(c++,a(u,o,o)),o[0]/=c,o[1]/=c,e[p]=o[0],e[p+1]=o[1]),e[p+3]=1}},_updateGradientTexture:function(t,e){if(t&&t.length){this._gradientTexture=this._gradientTexture||new Wa.Texture2D({image:document.createElement("canvas")});var r=this._gradientTexture,i=r.image;i.width=200,i.height=1;var n=i.getContext("2d"),a=n.createLinearGradient(0,.5,i.width,.5);t[0].stops.forEach(function(t){var r;e[1]===e[0]?r=0:(r=t.value/e[1],r=Math.min(Math.max(r,0),1)),a.addColorStop(r,t.color)}),n.fillStyle=a,n.fillRect(0,0,i.width,i.height),r.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(t,e,r,i){var n=this._limitInViewportAndFullFill(t,e,r,i);t=n.leftTop,e=n.rightBottom,this._particleSurface.setRegion(n.region),this._planeMesh.position.set((t[0]+e[0])/2,i.getHeight()-(t[1]+e[1])/2,0);var a=e[0]-t[0],o=e[1]-t[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(t,e,r,i){var n=[Math.max(t[0],0),Math.max(t[1],0)],a=[Math.min(e[0],i.getWidth()),Math.min(e[1],i.getHeight())];if("bmap"===r.get("coordinateSystem")){var o=r.getData().getDataExtent(r.coordDimToDataDim("lng")[0]);Math.floor(o[1]-o[0])>=359&&(n[0]>0&&(n[0]=0),a[0]<i.getWidth()&&(a[0]=i.getWidth()))}var s=e[0]-t[0],l=e[1]-t[1],h=a[0]-n[0],u=a[1]-n[1];return{leftTop:n,rightBottom:a,region:[(n[0]-t[0])/s,1-u/l-(n[1]-t[1])/l,h/s,u/l]}},_updateCamera:function(t,e,r){this.viewGL.setViewport(0,0,t,e,r);var i=this.viewGL.camera;i.left=i.bottom=0,i.top=e,i.right=t,i.near=0,i.far=100,i.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}}),i.extendSeriesModel({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(t,e){var r=i.getCoordinateSystemDimensions(this.get("coordinateSystem"))||["x","y"];r.push("vx","vy");var n=i.helper.createDimensions(r,this.getSource(),{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),a=new i.List(n,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}}});var b_=i.extendSeriesModel({type:"series.linesGL",dependencies:["grid","geo"],visualStyleAccessPath:"lineStyle",streamEnabled:!0,init:function(t){var e=this._processFlatCoordsArray(t.data);this._flatCoords=e.flatCoords,this._flatCoordsOffset=e.flatCoordsOffset,e.flatCoords&&(t.data=new Float32Array(e.count)),b_.superApply(this,"init",arguments)},mergeOption:function(t){var e=this._processFlatCoordsArray(t.data);this._flatCoords=e.flatCoords,this._flatCoordsOffset=e.flatCoordsOffset,e.flatCoords&&(t.data=new Float32Array(e.count)),b_.superApply(this,"mergeOption",arguments)},appendData:function(t){var e=this._processFlatCoordsArray(t.data);e.flatCoords&&(this._flatCoords?(this._flatCoords=xa(this._flatCoords,e.flatCoords),this._flatCoordsOffset=xa(this._flatCoordsOffset,e.flatCoordsOffset)):(this._flatCoords=e.flatCoords,this._flatCoordsOffset=e.flatCoordsOffset),t.data=new Float32Array(e.count)),this.getRawData().appendData(t.data)},_getCoordsFromItemModel:function(t){var e=this.getData().getItemModel(t);return e.option instanceof Array?e.option:e.getShallow("coords")},getLineCoordsCount:function(t){return this._flatCoordsOffset?this._flatCoordsOffset[2*t+1]:this._getCoordsFromItemModel(t).length},getLineCoords:function(t,e){if(this._flatCoordsOffset){for(var r=this._flatCoordsOffset[2*t],i=this._flatCoordsOffset[2*t+1],n=0;n<i;n++)e[n]=e[n]||[],e[n][0]=this._flatCoords[r+2*n],e[n][1]=this._flatCoords[r+2*n+1];return i}var a=this._getCoordsFromItemModel(t);for(n=0;n<a.length;n++)e[n]=e[n]||[],e[n][0]=a[n][0],e[n][1]=a[n][1];return a.length},_processFlatCoordsArray:function(t){var e=0;if(this._flatCoords&&(e=this._flatCoords.length),"number"==typeof t[0]){for(var r=t.length,i=new Uint32Array(r),n=new Float64Array(r),a=0,o=0,s=0,l=0;l<r;){s++;var h=t[l++];i[o++]=a+e,i[o++]=h;for(var u=0;u<h;u++){var c=t[l++],d=t[l++];n[a++]=c,n[a++]=d}}return{flatCoordsOffset:new Uint32Array(i.buffer,0,o),flatCoords:n,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:t.length}},getInitialData:function(t,e){var r=new i.List(["value"],this);return r.hasItemOption=!1,r.initData(t.data,[],function(t,e,i,n){if(t instanceof Array)return NaN;r.hasItemOption=!0;var a=t.value;return null!=a?a instanceof Array?a[n]: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}}}});i.extendChartView({type:"linesGL",__ecgl__:!0,init:function(t,e){this.groupGL=new Wa.Node,this.viewGL=new Bf("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new Ug(this.viewGL),this._nativeLinesShader=Wa.createShader("ecgl.lines3D"),this._meshLinesShader=Wa.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(t,e,r){this.groupGL.removeAll(),this._glViewHelper.reset(t,r);var i=this._linesMeshes[0];i||(i=this._linesMeshes[0]=this._createLinesMesh(t)),this._linesMeshes.length=1,this.groupGL.add(i),this._updateLinesMesh(t,i,0,t.getData().count()),this.viewGL.setPostEffect(t.getModel("postEffect"),r)},incrementalPrepareRender:function(t,e,r){this.groupGL.removeAll(),this._glViewHelper.reset(t,r),this._currentStep=0,this.viewGL.setPostEffect(t.getModel("postEffect"),r)},incrementalRender:function(t,e,r,i){var n=this._linesMeshes[this._currentStep];n||(n=this._createLinesMesh(e),this._linesMeshes[this._currentStep]=n),this._updateLinesMesh(e,n,t.start,t.end),this.groupGL.add(n),i.getZr().refresh(),this._currentStep++},updateTransform:function(t,e,r){t.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(t,r)},_createLinesMesh:function(t){return new Wa.Mesh({$ignorePicking:!0,material:new Wa.Material({shader:Wa.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new a_({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:Wa.Mesh.LINES,culling:!1})},_updateLinesMesh:function(t,e,r,i){var n=t.getData();e.material.blend="lighter"===t.get("blendMode")?Wa.additiveBlend:null;var a=t.get("lineStyle.curveness")||0,o=t.get("polyline"),s=e.geometry,l=t.coordinateSystem,h=qi.firstNotNull(t.get("lineStyle.width"),1);h>1?(e.material.shader!==this._meshLinesShader&&e.material.attachShader(this._meshLinesShader),e.mode=Wa.Mesh.TRIANGLES):(e.material.shader!==this._nativeLinesShader&&e.material.attachShader(this._nativeLinesShader),e.mode=Wa.Mesh.LINES),r=r||0,i=i||n.count(),s.resetOffset();var u=0,c=0,d=[],f=[],p=[],m=[],g=[],_=.3,v=.7;function y(){f[0]=d[0]*v+m[0]*_-(d[1]-m[1])*a,f[1]=d[1]*v+m[1]*_-(m[0]-d[0])*a,p[0]=d[0]*_+m[0]*v-(d[1]-m[1])*a,p[1]=d[1]*_+m[1]*v-(m[0]-d[0])*a}if(o||0!==a)for(var x=r;x<i;x++)if(o){var T=t.getLineCoordsCount(x);u+=s.getPolylineVertexCount(T),c+=s.getPolylineTriangleCount(T)}else t.getLineCoords(x,g),this._glViewHelper.dataToPoint(l,g[0],d),this._glViewHelper.dataToPoint(l,g[1],m),y(),u+=s.getCubicCurveVertexCount(d,f,p,m),c+=s.getCubicCurveTriangleCount(d,f,p,m);else{var b=i-r;u+=b*s.getLineVertexCount(),c+=b*s.getLineVertexCount()}s.setVertexCount(u),s.setTriangleCount(c);var w=r,S=[];for(x=r;x<i;x++){Wa.parseColor(wp(n,w),S);var E=qi.firstNotNull(Sp(n,w),1);S[3]*=E;T=t.getLineCoords(x,g);for(var A=0;A<T;A++)this._glViewHelper.dataToPoint(l,g[A],g[A]);o?s.addPolyline(g,S,h,0,T):0!==a?(d=g[0],m=g[1],y(),s.addCubicCurve(d,f,p,m,S,h)):s.addPolyline(g,S,h,0,2),w++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}})},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.a={get:function(t){var e=new XMLHttpRequest;e.open("get",t.url),e.responseType=t.responseType||"text",t.onprogress&&(e.onprogress=function(e){if(e.lengthComputable){var r=e.loaded/e.total;t.onprogress(r,e.loaded,e.total)}else t.onprogress(null)}),e.onload=function(r){e.status>=400?t.onerror&&t.onerror():t.onload&&t.onload(e.response)},t.onerror&&(e.onerror=t.onerror),e.send(null)}}}])});

Callers 2

lFunction · 0.70
fFunction · 0.70

Calls 1

xdFunction · 0.70

Tested by

no test coverage detected