/*! For license information please see echarts-gl.min.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],e):"object"==typeof exports?exports["echarts-gl"]=e(require("echarts")):t["echarts-gl"]=e(t.echarts)}(self,(function(t){return(()=>{"use strict";var e={583:(t,e,r)=>{r.r(e);var i=r(83);function n(t,e,r){"object"==typeof e&&(r=e,e=null);var i,n=this;if(!(t instanceof Function))for(var s in i=[],t)t.hasOwnProperty(s)&&i.push(s);var l=function(e){if(n.apply(this,arguments),t instanceof Function?a(this,t.call(this,e)):o(this,t,i),this.constructor===l)for(var r=l.__initializers__,s=0;s=400?t.onerror&&t.onerror():t.onload&&t.onload(e.response)},t.onerror&&(e.onerror=t.onerror),e.send(null)}};var F,z={supportWebGL:function(){if(null==F)try{var t=document.createElement("canvas");if(!t.getContext("webgl")&&!t.getContext("experimental-webgl"))throw new Error}catch(t){F=!1}return F}};z.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,z.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,z.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,z.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,z.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,z.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,z.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var k={};"undefined"!=typeof window?k=window:void 0!==r.g&&(k=r.g),z.requestAnimationFrame=k.requestAnimationFrame||k.msRequestAnimationFrame||k.mozRequestAnimationFrame||k.webkitRequestAnimationFrame||function(t){setTimeout(t,16)},z.createCanvas=function(){return document.createElement("canvas")},z.createImage=function(){return new k.Image},z.request={get:B.get},z.addEventListener=function(t,e,r,i){t.addEventListener(e,r,i)},z.removeEventListener=function(t,e,r){t.removeEventListener(e,r)};const G=z;var U=function(){this.head=null,this.tail=null,this._length=0};U.prototype.insert=function(t){var e=new U.Entry(t);return this.insertEntry(e),e},U.prototype.insertAt=function(t,e){if(!(t<0)){for(var r=this.head,i=0;r&&i!=t;)r=r.next,i++;if(r){var n=new U.Entry(e),a=r.prev;a?(a.next=n,n.prev=a):this.head=n,n.next=r,r.prev=n}else this.insert(e)}},U.prototype.insertBeforeEntry=function(t,e){var r=new U.Entry(t),i=e.prev;i?(i.next=r,r.prev=i):this.head=r,r.next=e,e.prev=r,this._length++},U.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._length++},U.prototype.remove=function(t){var e=t.prev,r=t.next;e?e.next=r:this.head=r,r?r.prev=e:this.tail=e,t.next=t.prev=null,this._length--},U.prototype.removeAt=function(t){if(!(t<0)){for(var e=this.head,r=0;e&&r!=t;)e=e.next,r++;return e?(this.remove(e),e.value):void 0}},U.prototype.getHead=function(){if(this.head)return this.head.value},U.prototype.getTail=function(){if(this.tail)return this.tail.value},U.prototype.getAt=function(t){if(!(t<0)){for(var e=this.head,r=0;e&&r!=t;)e=e.next,r++;return e.value}},U.prototype.indexOf=function(t){for(var e=this.head,r=0;e;){if(e.value===t)return r;e=e.next,r++}},U.prototype.length=function(){return this._length},U.prototype.isEmpty=function(){return 0===this._length},U.prototype.forEach=function(t,e){for(var r=this.head,i=0,n=void 0!==e;r;)n?t.call(e,r.value,i):t(r.value,i),r=r.next,i++},U.prototype.clear=function(){this.tail=this.head=null,this._length=0},U.Entry=function(t){this.value=t,this.next=null,this.prev=null};const H=U;var V=function(t){this._list=new H,this._map={},this._maxSize=t||10};V.prototype.setMaxSize=function(t){this._maxSize=t},V.prototype.put=function(t,e){if(!this._map.hasOwnProperty(t)){var r=this._list.length();if(r>=this._maxSize&&r>0){var i=this._list.head;this._list.remove(i),delete this._map[i.key]}var n=this._list.insert(e);n.key=t,this._map[t]=n}},V.prototype.get=function(t){var e=this._map[t];if(this._map.hasOwnProperty(t))return e!==this._list.tail&&(this._list.remove(e),this._list.insertEntry(e)),e.value},V.prototype.remove=function(t){var e=this._map[t];void 0!==e&&(delete this._map[t],this._list.remove(e))},V.prototype.clear=function(){this._list.clear(),this._map={}};const W=V;var j={},X={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function q(t){return(t=Math.round(t))<0?0:t>255?255:t}function Z(t){return t<0?0:t>1?1:t}function Y(t){return t.length&&"%"===t.charAt(t.length-1)?q(parseFloat(t)/100*255):q(parseInt(t,10))}function K(t){return t.length&&"%"===t.charAt(t.length-1)?Z(parseFloat(t)/100):Z(parseFloat(t))}function Q(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function J(t,e,r){return t+(e-t)*r}function $(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function tt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}var et=new W(20),rt=null;function it(t,e){rt&&tt(rt,e),rt=et.put(t,rt||e.slice())}function nt(t,e){var r=(parseFloat(t[0])%360+360)%360/360,i=K(t[1]),n=K(t[2]),a=n<=.5?n*(i+1):n+i-n*i,o=2*n-a;return $(e=e||[],q(255*Q(o,a,r+1/3)),q(255*Q(o,a,r)),q(255*Q(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}j.parse=function(t,e){if(t){e=e||[];var r=et.get(t);if(r)return tt(e,r);var i,n=(t+="").replace(/ /g,"").toLowerCase();if(n in X)return tt(e,X[n]),it(t,e),e;if("#"===n.charAt(0))return 4===n.length?(i=parseInt(n.substr(1),16))>=0&&i<=4095?($(e,(3840&i)>>4|(3840&i)>>8,240&i|(240&i)>>4,15&i|(15&i)<<4,1),it(t,e),e):void $(e,0,0,0,1):7===n.length?(i=parseInt(n.substr(1),16))>=0&&i<=16777215?($(e,(16711680&i)>>16,(65280&i)>>8,255&i,1),it(t,e),e):void $(e,0,0,0,1):void 0;var a=n.indexOf("("),o=n.indexOf(")");if(-1!==a&&o+1===n.length){var s=n.substr(0,a),l=n.substr(a+1,o-(a+1)).split(","),h=1;switch(s){case"rgba":if(4!==l.length)return void $(e,0,0,0,1);h=K(l.pop());case"rgb":return 3!==l.length?void $(e,0,0,0,1):($(e,Y(l[0]),Y(l[1]),Y(l[2]),h),it(t,e),e);case"hsla":return 4!==l.length?void $(e,0,0,0,1):(l[3]=K(l[3]),nt(l,e),it(t,e),e);case"hsl":return 3!==l.length?void $(e,0,0,0,1):(nt(l,e),it(t,e),e);default:return}}$(e,0,0,0,1)}},j.parseToFloat=function(t,e){if(e=j.parse(t,e))return e[0]/=255,e[1]/=255,e[2]/=255,e},j.lift=function(t,e){var r=j.parse(t);if(r){for(var i=0;i<3;i++)r[i]=e<0?r[i]*(1-e)|0:(255-r[i])*e+r[i]|0;return j.stringify(r,4===r.length?"rgba":"rgb")}},j.toHex=function(t){var e=j.parse(t);if(e)return((1<<24)+(e[0]<<16)+(e[1]<<8)+ +e[2]).toString(16).slice(1)},j.fastLerp=function(t,e,r){if(e&&e.length&&t>=0&&t<=1){r=r||[];var i=t*(e.length-1),n=Math.floor(i),a=Math.ceil(i),o=e[n],s=e[a],l=i-n;return r[0]=q(J(o[0],s[0],l)),r[1]=q(J(o[1],s[1],l)),r[2]=q(J(o[2],s[2],l)),r[3]=Z(J(o[3],s[3],l)),r}},j.fastMapToColor=j.fastLerp,j.lerp=function(t,e,r){if(e&&e.length&&t>=0&&t<=1){var i=t*(e.length-1),n=Math.floor(i),a=Math.ceil(i),o=j.parse(e[n]),s=j.parse(e[a]),l=i-n,h=j.stringify([q(J(o[0],s[0],l)),q(J(o[1],s[1],l)),q(J(o[2],s[2],l)),Z(J(o[3],s[3],l))],"rgba");return r?{color:h,leftIndex:n,rightIndex:a,value:i}:h}},j.mapToColor=j.lerp,j.modifyHSL=function(t,e,r,i){if(t=j.parse(t))return t=function(t){if(t){var e,r,i=t[0]/255,n=t[1]/255,a=t[2]/255,o=Math.min(i,n,a),s=Math.max(i,n,a),l=s-o,h=(s+o)/2;if(0===l)e=0,r=0;else{r=h<.5?l/(s+o):l/(2-s-o);var u=((s-i)/6+l/2)/l,c=((s-n)/6+l/2)/l,d=((s-a)/6+l/2)/l;i===s?e=d-c:n===s?e=1/3+u-d:a===s&&(e=2/3+c-u),e<0&&(e+=1),e>1&&(e-=1)}var f=[360*e,r,h];return null!=t[3]&&f.push(t[3]),f}}(t),null!=e&&(t[0]=(n=e,(n=Math.round(n))<0?0:n>360?360:n)),null!=r&&(t[1]=K(r)),null!=i&&(t[2]=K(i)),j.stringify(nt(t),"rgba");var n},j.modifyAlpha=function(t,e){if((t=j.parse(t))&&null!=e)return t[3]=Z(e),j.stringify(t,"rgba")},j.stringify=function(t,e){if(t&&t.length){var r=t[0]+","+t[1]+","+t[2];return"rgba"!==e&&"hsva"!==e&&"hsla"!==e||(r+=","+t[3]),e+"("+r+")"}};var at=j.parseToFloat,ot={};function st(t){var e=Object.keys(t);e.sort();for(var r=[],i=0;i=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(t,e){if("object"==typeof t)for(var r in t){var i=t[r];this.setUniform(r,i)}else this.setUniform(t,e)},get:function(t){var e=this.uniforms[t];if(e)return e.value},attachShader:function(t,e){var r=this.uniforms;this.uniforms=t.createUniforms(),this.shader=t;var i=this.uniforms;this._enabledUniforms=Object.keys(i),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter((function(t){var e=this.uniforms[t].type;return"t"===e||"tv"===e}),this);var n=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=f.clone(t.vertexDefines),this.fragmentDefines=f.clone(t.fragmentDefines),e){for(var o in r)i[o]&&(i[o].value=r[o].value);f.defaults(this.vertexDefines,n),f.defaults(this.fragmentDefines,a)}var s={};for(var l in t.textures)s[l]={shaderType:t.textures[l].shaderType,type:t.textures[l].type,enabled:!(!e||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var t=new this.constructor({name:this.name,shader:this.shader});for(var e in this.uniforms)t.uniforms[e].value=this.uniforms[e].value;return t.depthTest=this.depthTest,t.depthMask=this.depthMask,t.transparent=this.transparent,t.blend=this.blend,t.vertexDefines=f.clone(this.vertexDefines),t.fragmentDefines=f.clone(this.fragmentDefines),t.enableTexture(this.getEnabledTextures()),t.precision=this.precision,t},define:function(t,e,r){var i=this.vertexDefines,n=this.fragmentDefines;"vertex"!==t&&"fragment"!==t&&"both"!==t&&arguments.length<3&&(r=e,e=t,t="both"),r=null!=r?r:null,"vertex"!==t&&"both"!==t||i[e]!==r&&(i[e]=r,this._programKey=""),"fragment"!==t&&"both"!==t||n[e]!==r&&(n[e]=r,"both"!==t&&(this._programKey=""))},undefine:function(t,e){"vertex"!==t&&"fragment"!==t&&"both"!==t&&arguments.length<2&&(e=t,t="both"),"vertex"!==t&&"both"!==t||this.isDefined("vertex",e)&&(delete this.vertexDefines[e],this._programKey=""),"fragment"!==t&&"both"!==t||this.isDefined("fragment",e)&&(delete this.fragmentDefines[e],"both"!==t&&(this._programKey=""))},isDefined:function(t,e){switch(t){case"vertex":return void 0!==this.vertexDefines[e];case"fragment":return void 0!==this.fragmentDefines[e]}},getDefine:function(t,e){switch(t){case"vertex":return this.vertexDefines[e];case"fragment":return this.fragmentDefines[e]}},enableTexture:function(t){if(Array.isArray(t))for(var e=0;e0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},ft.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},ft.cross=function(t,e,r){var i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t},ft.lerp=function(t,e,r,i){var n=e[0],a=e[1];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t},ft.random=function(t,e){e=e||1;var r=2*GLMAT_RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},ft.transformMat2=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n,t[1]=r[1]*i+r[3]*n,t},ft.transformMat2d=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t},ft.transformMat3=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[3]*n+r[6],t[1]=r[1]*i+r[4]*n+r[7],t},ft.transformMat4=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[4]*n+r[12],t[1]=r[1]*i+r[5]*n+r[13],t},ft.forEach=(ht=ft.create(),function(t,e,r,i,n,a){var o,s;for(e||(e=2),r||(r=0),s=i?Math.min(i*e+r,t.length):t.length,o=r;o0&&i.push("#define "+n.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;ol.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),c+="\n"+Mt(d)+"\n"}a&&(c+="\n#define INSTANCING\n");var f=c+Mt(e.vertexDefines,s,u),p=c+Mt(e.fragmentDefines,s,u),m=f+"\n"+e.shader.vertex,g=["OES_standard_derivatives","EXT_shader_texture_lod"].filter((function(t){return null!=l.getGLExtension(t)}));g.indexOf("EXT_shader_texture_lod")>=0&&(p+="\n#define SUPPORT_TEXTURE_LOD"),g.indexOf("OES_standard_derivatives")>=0&&(p+="\n#define SUPPORT_STANDARD_DERIVATIVES");var _,v,y=function(t){for(var e=[],r=0;r=0){if(1!==s&&4!==s){Ut();break}s=2,h=[]}else if(1!==s)if(4!==s)u(c),s=0;else{var d=c;It.indexOf(d)>=0||Rt.indexOf(d)>=0||Bt.indexOf(d)>=0?l[o].semantic=d:"ignore"===d||"unconfigurable"===d?l[o].ignore=!0:l[o].value="bool"===t?"true"===d:parseFloat(d)}else l[o].value="bool"===t?"true"===c:parseFloat(c),h=null;else{if(2!==s){Ut();break}if(!(h instanceof Array)){Ut();break}h.push(+i[++a])}else l[o].value=new G.Float32Array(h),h=null,s=5;else if(2===s){if(!(h instanceof Array)){Ut();break}h.push(+i[++a])}else s=5;else s=4;else{if(0!==s&&3!==s){Ut();break}s=1}}return l}function Vt(t,e){"object"==typeof t&&(e=t.fragment,t=t.vertex),t=Gt(t),e=Gt(e),this._shaderID=function(t,e){var r="vertex:"+t+"fragment:"+e;if(zt[r])return zt[r];var i=f.genGUID();return zt[r]=i,kt[i]={vertex:t,fragment:e},i}(t,e),this._vertexCode=Vt.parseImport(t),this._fragmentCode=Vt.parseImport(e),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}Vt.prototype={constructor:Vt,createUniforms:function(){var t={};for(var e in this.uniformTemplates){var r=this.uniformTemplates[e];t[e]={type:r.type,value:r.value()}}return t},_parseImport:function(){this._vertexCode=Vt.parseImport(this.vertex),this._fragmentCode=Vt.parseImport(this.fragment)},_addSemanticUniform:function(t,e,r){if(It.indexOf(r)>=0)this.attributeSemantics[r]={symbol:t,type:e};else if(Bt.indexOf(r)>=0){var i=!1,n=r;r.match(/TRANSPOSE$/)&&(i=!0,n=r.slice(0,-9)),this.matrixSemantics[r]={symbol:t,type:e,isTranspose:i,semanticNoTranspose:n}}else Rt.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:t,type:e})},_addMaterialUniform:function(t,e,r,i,n,a){a[t]={type:r,value:n?Nt.array:i||Nt[e],semantic:null}},_parseUniforms:function(){var t={},e=this;function r(t){return null!=t?function(){return t}:null}function i(i,n,a){var o=Ht(n,a),s=[];for(var l in o){var h=o[l],u=h.semantic,c=l,d=Pt[n],f=r(o[l].value);o[l].isArray&&(c+="["+o[l].arraySize+"]",d+="v"),s.push(c),e._uniformList.push(l),h.ignore||("sampler2D"!==n&&"samplerCube"!==n||(e.textures[l]={shaderType:"fragment",type:n}),u?e._addSemanticUniform(l,d,u):e._addMaterialUniform(l,n,d,f,o[l].isArray,t))}return s.length>0?"uniform "+n+" "+s.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(Et,i),this._fragmentCode=this._fragmentCode.replace(Et,i),e.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseAttributes:function(){var t={},e=this;this._vertexCode=this._vertexCode.replace(Dt,(function(r,i,n){var a=Ht(i,n),o=Ft[i]||1,s=[];for(var l in a){var h=a[l].semantic;if(t[l]={type:"float",size:o,semantic:h||null},h){if(It.indexOf(h)<0)throw new Error('Unkown semantic "'+h+'"');e.attributeSemantics[h]={symbol:l,type:i}}s.push(l)}return"attribute "+i+" "+s.join(",")+";\n"})),this.attributes=t},_parseDefines:function(){var t=this;function e(e,r,i){var n=t.fragmentDefines;return n[r]||(n[r]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(Lt,e),this._fragmentCode=this._fragmentCode.replace(Lt,e)},clone:function(){var t=kt[this._shaderID];return new Vt(t.vertex,t.fragment)}},Object.defineProperty&&(Object.defineProperty(Vt.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(Vt.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(Vt.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(Vt.prototype,"uniforms",{get:function(){return this._uniformList}}));var Wt=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;Vt.parseImport=function(t){return t.replace(Wt,(function(t,e,r){return(t=Vt.source(r))?Vt.parseImport(t):(console.error('Shader chunk "'+r+'" not existed in library'),"")}))};var jt=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;Vt.import=function(t){t.replace(jt,(function(t,e,r,i){if(i=i.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var n,a=r.split("."),o=Vt.codes,s=0;s 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end";var Zt={create:function(){var t=new ct(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},clone:function(t){var e=new ct(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},transpose:function(t,e){if(t===e){var r=e[1],i=e[2],n=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=a,t[11]=e[14],t[12]=n,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15],v=r*s-i*o,y=r*l-n*o,x=r*h-a*o,b=i*l-n*s,w=i*h-a*s,T=n*h-a*l,S=u*m-c*p,M=u*g-d*p,A=u*_-f*p,C=c*g-d*m,E=c*_-f*m,D=d*_-f*g,L=v*D-y*E+x*C+b*A-w*M+T*S;return L?(L=1/L,t[0]=(s*D-l*E+h*C)*L,t[1]=(n*E-i*D-a*C)*L,t[2]=(m*T-g*w+_*b)*L,t[3]=(d*w-c*T-f*b)*L,t[4]=(l*A-o*D-h*M)*L,t[5]=(r*D-n*A+a*M)*L,t[6]=(g*x-p*T-_*y)*L,t[7]=(u*T-d*x+f*y)*L,t[8]=(o*E-s*A+h*S)*L,t[9]=(i*A-r*E-a*S)*L,t[10]=(p*w-m*x+_*v)*L,t[11]=(c*x-u*w-f*v)*L,t[12]=(s*M-o*C-l*S)*L,t[13]=(r*C-i*M+n*S)*L,t[14]=(m*y-p*b-g*v)*L,t[15]=(u*b-c*y+d*v)*L,t):null},adjoint:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15];return t[0]=s*(d*_-f*g)-c*(l*_-h*g)+m*(l*f-h*d),t[1]=-(i*(d*_-f*g)-c*(n*_-a*g)+m*(n*f-a*d)),t[2]=i*(l*_-h*g)-s*(n*_-a*g)+m*(n*h-a*l),t[3]=-(i*(l*f-h*d)-s*(n*f-a*d)+c*(n*h-a*l)),t[4]=-(o*(d*_-f*g)-u*(l*_-h*g)+p*(l*f-h*d)),t[5]=r*(d*_-f*g)-u*(n*_-a*g)+p*(n*f-a*d),t[6]=-(r*(l*_-h*g)-o*(n*_-a*g)+p*(n*h-a*l)),t[7]=r*(l*f-h*d)-o*(n*f-a*d)+u*(n*h-a*l),t[8]=o*(c*_-f*m)-u*(s*_-h*m)+p*(s*f-h*c),t[9]=-(r*(c*_-f*m)-u*(i*_-a*m)+p*(i*f-a*c)),t[10]=r*(s*_-h*m)-o*(i*_-a*m)+p*(i*h-a*s),t[11]=-(r*(s*f-h*c)-o*(i*f-a*c)+u*(i*h-a*s)),t[12]=-(o*(c*g-d*m)-u*(s*g-l*m)+p*(s*d-l*c)),t[13]=r*(c*g-d*m)-u*(i*g-n*m)+p*(i*d-n*c),t[14]=-(r*(s*g-l*m)-o*(i*g-n*m)+p*(i*l-n*s)),t[15]=r*(s*d-l*c)-o*(i*d-n*c)+u*(i*l-n*s),t},determinant:function(t){var e=t[0],r=t[1],i=t[2],n=t[3],a=t[4],o=t[5],s=t[6],l=t[7],h=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],m=t[14],g=t[15];return(e*o-r*a)*(c*g-d*m)-(e*s-i*a)*(u*g-d*p)+(e*l-n*a)*(u*m-c*p)+(r*s-i*o)*(h*g-d*f)-(r*l-n*o)*(h*m-c*f)+(i*l-n*s)*(h*p-u*f)},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],m=e[12],g=e[13],_=e[14],v=e[15],y=r[0],x=r[1],b=r[2],w=r[3];return t[0]=y*i+x*s+b*c+w*m,t[1]=y*n+x*l+b*d+w*g,t[2]=y*a+x*h+b*f+w*_,t[3]=y*o+x*u+b*p+w*v,y=r[4],x=r[5],b=r[6],w=r[7],t[4]=y*i+x*s+b*c+w*m,t[5]=y*n+x*l+b*d+w*g,t[6]=y*a+x*h+b*f+w*_,t[7]=y*o+x*u+b*p+w*v,y=r[8],x=r[9],b=r[10],w=r[11],t[8]=y*i+x*s+b*c+w*m,t[9]=y*n+x*l+b*d+w*g,t[10]=y*a+x*h+b*f+w*_,t[11]=y*o+x*u+b*p+w*v,y=r[12],x=r[13],b=r[14],w=r[15],t[12]=y*i+x*s+b*c+w*m,t[13]=y*n+x*l+b*d+w*g,t[14]=y*a+x*h+b*f+w*_,t[15]=y*o+x*u+b*p+w*v,t},multiplyAffine:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[4],s=e[5],l=e[6],h=e[8],u=e[9],c=e[10],d=e[12],f=e[13],p=e[14],m=r[0],g=r[1],_=r[2];return t[0]=m*i+g*o+_*h,t[1]=m*n+g*s+_*u,t[2]=m*a+g*l+_*c,m=r[4],g=r[5],_=r[6],t[4]=m*i+g*o+_*h,t[5]=m*n+g*s+_*u,t[6]=m*a+g*l+_*c,m=r[8],g=r[9],_=r[10],t[8]=m*i+g*o+_*h,t[9]=m*n+g*s+_*u,t[10]=m*a+g*l+_*c,m=r[12],g=r[13],_=r[14],t[12]=m*i+g*o+_*h+d,t[13]=m*n+g*s+_*u+f,t[14]=m*a+g*l+_*c+p,t}};Zt.mul=Zt.multiply,Zt.mulAffine=Zt.multiplyAffine,Zt.translate=function(t,e,r){var i,n,a,o,s,l,h,u,c,d,f,p,m=r[0],g=r[1],_=r[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=d,t[10]=f,t[11]=p,t[12]=i*m+s*g+c*_+e[12],t[13]=n*m+l*g+d*_+e[13],t[14]=a*m+h*g+f*_+e[14],t[15]=o*m+u*g+p*_+e[15]),t},Zt.scale=function(t,e,r){var i=r[0],n=r[1],a=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},Zt.rotate=function(t,e,r,i){var n,a,o,s,l,h,u,c,d,f,p,m,g,_,v,y,x,b,w,T,S,M,A,C,E=i[0],D=i[1],L=i[2],P=Math.sqrt(E*E+D*D+L*L);return Math.abs(P)0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},Kt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},Kt.cross=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=n*l-a*s,t[1]=a*o-i*l,t[2]=i*s-n*o,t},Kt.lerp=function(t,e,r,i){var n=e[0],a=e[1],o=e[2];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t[2]=o+i*(r[2]-o),t},Kt.random=function(t,e){e=e||1;var r=2*dt()*Math.PI,i=2*dt()-1,n=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=i*e,t},Kt.transformMat4=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[3]*i+r[7]*n+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/o,t[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/o,t[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/o,t},Kt.transformMat3=function(t,e,r){var i=e[0],n=e[1],a=e[2];return t[0]=i*r[0]+n*r[3]+a*r[6],t[1]=i*r[1]+n*r[4]+a*r[7],t[2]=i*r[2]+n*r[5]+a*r[8],t},Kt.transformQuat=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2],h=r[3],u=h*i+s*a-l*n,c=h*n+l*i-o*a,d=h*a+o*n-s*i,f=-o*i-s*n-l*a;return t[0]=u*h+f*-o+c*-l-d*-s,t[1]=c*h+f*-s+d*-o-u*-l,t[2]=d*h+f*-l+u*-s-c*-o,t},Kt.rotateX=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[0],a[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),a[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Kt.rotateY=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),a[1]=n[1],a[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Kt.rotateZ=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),a[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),a[2]=n[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Kt.forEach=function(){var t=Kt.create();return function(e,r,i,n,a,o){var s,l;for(r||(r=3),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,s=i;s1?0:Math.acos(n)};const Qt=Kt;Xt.import(qt);var Jt=Yt.create,$t={};function te(t){return t.material}function ee(t,e,r){return e.uniforms[r].value}function re(t,e,r,i){return r!==i}function ie(t){return!0}function ne(){}var ae={float:S,byte:5120,ubyte:T,short:5122,ushort:5123};function oe(t,e,r){this.availableAttributes=t,this.availableAttributeSymbols=e,this.indicesBuffer=r,this.vao=null}function se(t){var e,r;this.bind=function(t){e||((e=G.createCanvas()).width=e.height=1,e.getContext("2d"));var i=t.gl,n=!r;n&&(r=i.createTexture()),i.bindTexture(i.TEXTURE_2D,r),n&&i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e)},this.unbind=function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var le=m.extend((function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}}),(function(){this.canvas||(this.canvas=G.createCanvas());var t=this.canvas;try{var e={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!this.gl)throw new Error;this._glinfo=new v(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(t){throw"Error creating WebGL Context "+t}this._programMgr=new Ct(this),this._placeholderTexture=new se(this)}),{resize:function(t,e){var r=this.canvas,i=this.devicePixelRatio;null!=t?(r.style&&(r.style.width=t+"px",r.style.height=e+"px"),r.width=t*i,r.height=e*i,this._width=t,this._height=e):(this._width=r.width/i,this._height=r.height/i),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var t=this.viewport;return t.width/t.height},setDevicePixelRatio:function(t){this.devicePixelRatio=t,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(t){return this._glinfo.getExtension(t)},getGLParameter:function(t){return this._glinfo.getParameter(t)},setViewport:function(t,e,r,i,n){if("object"==typeof t){var a=t;t=a.x,e=a.y,r=a.width,i=a.height,n=a.devicePixelRatio}n=n||this.devicePixelRatio,this.gl.viewport(t*n,e*n,r*n,i*n),this.viewport={x:t,y:e,width:r,height:i,devicePixelRatio:n}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var t=this._clearStack.pop();this.clearColor=t.clearColor,this.clearBit=t.clearBit}},bindSceneRendering:function(t){this._sceneRendering=t},render:function(t,e,r,i){var n=this.gl,a=this.clearColor;if(this.clearBit){n.colorMask(!0,!0,!0,!0),n.depthMask(!0);var o=this.viewport,s=!1,l=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||l&&l!==this.devicePixelRatio||o.x||o.y)&&(s=!0,n.enable(n.SCISSOR_TEST),n.scissor(o.x*l,o.y*l,o.width*l,o.height*l)),n.clearColor(a[0],a[1],a[2],a[3]),n.clear(this.clearBit),s&&n.disable(n.SCISSOR_TEST)}if(r||t.update(!1),t.updateLights(),e=e||t.getMainCamera()){e.update();var h=t.updateRenderList(e,!0);this._sceneRendering=t;var u=h.opaque,c=h.transparent,d=t.material;t.trigger("beforerender",this,t,e,h),i?(this.renderPreZ(u,t,e),n.depthFunc(n.LEQUAL)):n.depthFunc(n.LESS);for(var f=Jt(),p=Qt.create(),m=0;m0){var s=t[n-1],l=s.joints?s.joints.length:0;if((a.joints?a.joints.length:0)===l&&a.material===s.material&&a.lightGroup===s.lightGroup){a.__program=s.__program;continue}}var h=this._programMgr.getProgram(a,o,e);this.validateProgram(h),a.__program=h}},renderPass:function(t,e,r){this.trigger("beforerenderpass",this,t,e,r),(r=r||{}).getMaterial=r.getMaterial||te,r.getUniform=r.getUniform||ee,r.isMaterialChanged=r.isMaterialChanged||re,r.beforeRender=r.beforeRender||ne,r.afterRender=r.afterRender||ne;var i=r.ifRender||ie;this.updatePrograms(t,this._sceneRendering,r),r.sortCompare&&t.sort(r.sortCompare);var n=this.viewport,a=n.devicePixelRatio,o=[n.x*a,n.y*a,n.width*a,n.height*a],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],h=[o[2],o[3]],u=Date.now();e?(Yt.copy(he.VIEW,e.viewMatrix.array),Yt.copy(he.PROJECTION,e.projectionMatrix.array),Yt.copy(he.VIEWINVERSE,e.worldTransform.array)):(Yt.identity(he.VIEW),Yt.identity(he.PROJECTION),Yt.identity(he.VIEWINVERSE)),Yt.multiply(he.VIEWPROJECTION,he.PROJECTION,he.VIEW),Yt.invert(he.PROJECTIONINVERSE,he.PROJECTION),Yt.invert(he.VIEWPROJECTIONINVERSE,he.VIEWPROJECTION);for(var c,d,f,p,m,g,_,v,y,x,b,w,T=this.gl,S=this._sceneRendering,M=0;Mthis.getMaxJointNumber()){var a=n.getSubSkinMatricesTexture(t.__uid__,t.joints);e.useTextureSlot(this,a,r),e.setUniform(i,"1i","skinMatricesTexture",r),e.setUniform(i,"1f","skinMatricesTextureSize",a.width)}else{var o=n.getSubSkinMatrices(t.__uid__,t.joints);e.setUniformOfSemantic(i,"SKIN_MATRIX",o)}},_renderObject:function(t,e,r){var i=this.gl,n=t.geometry,a=t.mode;null==a&&(a=4);var o=null,s=t.isInstancedMesh&&t.isInstancedMesh();if(!s||(o=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(t,r,o)),e.indicesBuffer){var h=this.getGLExtension("OES_element_index_uint")&&n.indices instanceof Uint32Array?i.UNSIGNED_INT:i.UNSIGNED_SHORT;s?o.drawElementsInstancedANGLE(a,e.indicesBuffer.count,h,0,t.getInstanceCount()):i.drawElements(a,e.indicesBuffer.count,h,0)}else s?o.drawArraysInstancedANGLE(a,0,n.vertexCount,t.getInstanceCount()):i.drawArrays(a,0,n.vertexCount);if(s)for(var u=0;ur?r:t}ce.add=function(t,e,r){return Qt.add(t.array,e.array,r.array),t._dirty=!0,t},ce.set=function(t,e,r,i){Qt.set(t.array,e,r,i),t._dirty=!0},ce.copy=function(t,e){return Qt.copy(t.array,e.array),t._dirty=!0,t},ce.cross=function(t,e,r){return Qt.cross(t.array,e.array,r.array),t._dirty=!0,t},ce.distance=ce.dist=function(t,e){return Qt.distance(t.array,e.array)},ce.divide=ce.div=function(t,e,r){return Qt.divide(t.array,e.array,r.array),t._dirty=!0,t},ce.dot=function(t,e){return Qt.dot(t.array,e.array)},ce.len=function(t){return Qt.length(t.array)},ce.lerp=function(t,e,r,i){return Qt.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},ce.min=function(t,e,r){return Qt.min(t.array,e.array,r.array),t._dirty=!0,t},ce.max=function(t,e,r){return Qt.max(t.array,e.array,r.array),t._dirty=!0,t},ce.multiply=ce.mul=function(t,e,r){return Qt.multiply(t.array,e.array,r.array),t._dirty=!0,t},ce.negate=function(t,e){return Qt.negate(t.array,e.array),t._dirty=!0,t},ce.normalize=function(t,e){return Qt.normalize(t.array,e.array),t._dirty=!0,t},ce.random=function(t,e){return Qt.random(t.array,e),t._dirty=!0,t},ce.scale=function(t,e,r){return Qt.scale(t.array,e.array,r),t._dirty=!0,t},ce.scaleAndAdd=function(t,e,r,i){return Qt.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},ce.squaredDistance=ce.sqrDist=function(t,e){return Qt.sqrDist(t.array,e.array)},ce.squaredLength=ce.sqrLen=function(t){return Qt.sqrLen(t.array)},ce.subtract=ce.sub=function(t,e,r){return Qt.subtract(t.array,e.array,r.array),t._dirty=!0,t},ce.transformMat3=function(t,e,r){return Qt.transformMat3(t.array,e.array,r.array),t._dirty=!0,t},ce.transformMat4=function(t,e,r){return Qt.transformMat4(t.array,e.array,r.array),t._dirty=!0,t},ce.transformQuat=function(t,e,r){return Qt.transformQuat(t.array,e.array,r.array),t._dirty=!0,t};var me=Math.atan2,ge=Math.asin,_e=Math.abs;ce.eulerFromQuat=function(t,e,r){t._dirty=!0,e=e.array;var i=t.array,n=e[0],a=e[1],o=e[2],s=e[3],l=n*n,h=a*a,u=o*o,c=s*s;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":i[0]=me(2*(n*s-a*o),c-l-h+u),i[1]=ge(pe(2*(n*o+a*s),-1,1)),i[2]=me(2*(o*s-n*a),c+l-h-u);break;case"YXZ":i[0]=ge(pe(2*(n*s-a*o),-1,1)),i[1]=me(2*(n*o+a*s),c-l-h+u),i[2]=me(2*(n*a+o*s),c-l+h-u);break;case"ZXY":i[0]=ge(pe(2*(n*s+a*o),-1,1)),i[1]=me(2*(a*s-o*n),c-l-h+u),i[2]=me(2*(o*s-n*a),c-l+h-u);break;case"ZYX":i[0]=me(2*(n*s+o*a),c-l-h+u),i[1]=ge(pe(2*(a*s-n*o),-1,1)),i[2]=me(2*(n*a+o*s),c+l-h-u);break;case"YZX":i[0]=me(2*(n*s-o*a),c-l+h-u),i[1]=me(2*(a*s-n*o),c+l-h-u),i[2]=ge(pe(2*(n*a+o*s),-1,1));break;case"XZY":i[0]=me(2*(n*s+a*o),c-l+h-u),i[1]=me(2*(n*o+a*s),c+l-h-u),i[2]=ge(pe(2*(o*s-n*a),-1,1));break;default:console.warn("Unkown order: "+r)}return t},ce.eulerFromMat3=function(t,e,r){var i=e.array,n=i[0],a=i[3],o=i[6],s=i[1],l=i[4],h=i[7],u=i[2],c=i[5],d=i[8],f=t.array;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":f[1]=ge(pe(o,-1,1)),_e(o)<.99999?(f[0]=me(-h,d),f[2]=me(-a,n)):(f[0]=me(c,l),f[2]=0);break;case"YXZ":f[0]=ge(-pe(h,-1,1)),_e(h)<.99999?(f[1]=me(o,d),f[2]=me(s,l)):(f[1]=me(-u,n),f[2]=0);break;case"ZXY":f[0]=ge(pe(c,-1,1)),_e(c)<.99999?(f[1]=me(-u,d),f[2]=me(-a,l)):(f[1]=0,f[2]=me(s,n));break;case"ZYX":f[1]=ge(-pe(u,-1,1)),_e(u)<.99999?(f[0]=me(c,d),f[2]=me(s,n)):(f[0]=0,f[2]=me(-a,l));break;case"YZX":f[2]=ge(pe(s,-1,1)),_e(s)<.99999?(f[0]=me(-h,l),f[1]=me(-u,n)):(f[0]=0,f[1]=me(o,d));break;case"XZY":f[2]=ge(-pe(a,-1,1)),_e(a)<.99999?(f[0]=me(c,l),f[1]=me(o,n)):(f[0]=me(-h,d),f[1]=0);break;default:console.warn("Unkown order: "+r)}return t._dirty=!0,t},Object.defineProperties(ce,{POSITIVE_X:{get:function(){return new ce(1,0,0)}},NEGATIVE_X:{get:function(){return new ce(-1,0,0)}},POSITIVE_Y:{get:function(){return new ce(0,1,0)}},NEGATIVE_Y:{get:function(){return new ce(0,-1,0)}},POSITIVE_Z:{get:function(){return new ce(0,0,1)}},NEGATIVE_Z:{get:function(){return new ce(0,0,-1)}},UP:{get:function(){return new ce(0,1,0)}},ZERO:{get:function(){return new ce}}});const ve=ce;var ye,xe,be,we,Te,Se=function(t,e){this.origin=t||new ve,this.direction=e||new ve};Se.prototype={constructor:Se,intersectPlane:function(t,e){var r=t.normal.array,i=t.distance,n=this.origin.array,a=this.direction.array,o=Qt.dot(r,a);if(0===o)return null;e||(e=new ve);var s=(Qt.dot(r,n)-i)/o;return Qt.scaleAndAdd(e.array,n,a,-s),e._dirty=!0,e},mirrorAgainstPlane:function(t){var e=Qt.dot(t.normal.array,this.direction.array);Qt.scaleAndAdd(this.direction.array,this.direction.array,t.normal.array,2*-e),this.direction._dirty=!0},distanceToPoint:(Te=Qt.create(),function(t){Qt.sub(Te,t,this.origin.array);var e=Qt.dot(Te,this.direction.array);if(e<0)return Qt.distance(this.origin.array,t);var r=Qt.lenSquared(Te);return Math.sqrt(r-e*e)}),intersectSphere:function(){var t=Qt.create();return function(e,r,i){var n=this.origin.array,a=this.direction.array;e=e.array,Qt.sub(t,e,n);var o=Qt.dot(t,a),s=Qt.squaredLength(t)-o*o,l=r*r;if(!(s>l)){var h=Math.sqrt(l-s),u=o-h,c=o+h;return i||(i=new ve),u<0?c<0?null:(Qt.scaleAndAdd(i.array,n,a,c),i):(Qt.scaleAndAdd(i.array,n,a,u),i)}}}(),intersectBoundingBox:function(t,e){var r,i,n,a,o,s,l=this.direction.array,h=this.origin.array,u=t.min.array,c=t.max.array,d=1/l[0],f=1/l[1],p=1/l[2];if(d>=0?(r=(u[0]-h[0])*d,i=(c[0]-h[0])*d):(i=(u[0]-h[0])*d,r=(c[0]-h[0])*d),f>=0?(n=(u[1]-h[1])*f,a=(c[1]-h[1])*f):(a=(u[1]-h[1])*f,n=(c[1]-h[1])*f),r>a||n>i)return null;if((n>r||r!=r)&&(r=n),(a=0?(o=(u[2]-h[2])*p,s=(c[2]-h[2])*p):(s=(u[2]-h[2])*p,o=(c[2]-h[2])*p),r>s||o>i)return null;if((o>r||r!=r)&&(r=o),(s=0?r:i;return e||(e=new ve),Qt.scaleAndAdd(e.array,h,l,m),e},intersectTriangle:(ye=Qt.create(),xe=Qt.create(),be=Qt.create(),we=Qt.create(),function(t,e,r,i,n,a){var o=this.direction.array,s=this.origin.array;t=t.array,e=e.array,r=r.array,Qt.sub(ye,e,t),Qt.sub(xe,r,t),Qt.cross(we,xe,o);var l=Qt.dot(ye,we);if(i){if(l>-1e-5)return null}else if(l>-1e-5&&l<1e-5)return null;Qt.sub(be,s,t);var h=Qt.dot(we,be)/l;if(h<0||h>1)return null;Qt.cross(we,ye,be);var u=Qt.dot(o,we)/l;if(u<0||u>1||h+u>1)return null;Qt.cross(we,ye,xe);var c=-Qt.dot(be,we)/l;return c<0?null:(n||(n=new ve),a&&ve.set(a,1-h-u,h,u),Qt.scaleAndAdd(n.array,s,o,c),n)}),applyTransform:function(t){ve.add(this.direction,this.direction,this.origin),ve.transformMat4(this.origin,this.origin,t),ve.transformMat4(this.direction,this.direction,t),ve.sub(this.direction,this.direction,this.origin),ve.normalize(this.direction,this.direction)},copy:function(t){ve.copy(this.origin,t.origin),ve.copy(this.direction,t.direction)},clone:function(){var t=new Se;return t.copy(this),t}};const Me=Se;var Ae={create:function(){var t=new ct(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},clone:function(t){var e=new ct(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},fromValues:function(t,e,r,i){var n=new ct(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=i,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},set:function(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},subtract:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}};Ae.sub=Ae.subtract,Ae.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},Ae.mul=Ae.multiply,Ae.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t},Ae.div=Ae.divide,Ae.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},Ae.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},Ae.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},Ae.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},Ae.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+i*i+n*n+a*a)},Ae.dist=Ae.distance,Ae.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],a=e[3]-t[3];return r*r+i*i+n*n+a*a},Ae.sqrDist=Ae.squaredDistance,Ae.length=function(t){var e=t[0],r=t[1],i=t[2],n=t[3];return Math.sqrt(e*e+r*r+i*i+n*n)},Ae.len=Ae.length,Ae.squaredLength=function(t){var e=t[0],r=t[1],i=t[2],n=t[3];return e*e+r*r+i*i+n*n},Ae.sqrLen=Ae.squaredLength,Ae.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},Ae.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},Ae.normalize=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*r+i*i+n*n+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o),t},Ae.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},Ae.lerp=function(t,e,r,i){var n=e[0],a=e[1],o=e[2],s=e[3];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t[2]=o+i*(r[2]-o),t[3]=s+i*(r[3]-s),t},Ae.random=function(t,e){return e=e||1,t[0]=dt(),t[1]=dt(),t[2]=dt(),t[3]=dt(),Ae.normalize(t,t),Ae.scale(t,t,e),t},Ae.transformMat4=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*o,t[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*o,t[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*o,t[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*o,t},Ae.transformQuat=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2],h=r[3],u=h*i+s*a-l*n,c=h*n+l*i-o*a,d=h*a+o*n-s*i,f=-o*i-s*n-l*a;return t[0]=u*h+f*-o+c*-l-d*-s,t[1]=c*h+f*-s+d*-o-u*-l,t[2]=d*h+f*-l+u*-s-c*-o,t},Ae.forEach=function(){var t=Ae.create();return function(e,r,i,n,a,o){var s,l;for(r||(r=4),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,s=i;s.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(Qt.cross(Le,e,r),t[0]=Le[0],t[1]=Le[1],t[2]=Le[2],t[3]=1+i,Ie.normalize(t,t))}),Ie.setAxes=(Ne=De.create(),function(t,e,r,i){return Ne[0]=r[0],Ne[3]=r[1],Ne[6]=r[2],Ne[1]=i[0],Ne[4]=i[1],Ne[7]=i[2],Ne[2]=-e[0],Ne[5]=-e[1],Ne[8]=-e[2],Ie.normalize(t,Ie.fromMat3(t,Ne))}),Ie.clone=Ce.clone,Ie.fromValues=Ce.fromValues,Ie.copy=Ce.copy,Ie.set=Ce.set,Ie.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},Ie.setAxisAngle=function(t,e,r){r*=.5;var i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t},Ie.add=Ce.add,Ie.multiply=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],h=r[2],u=r[3];return t[0]=i*u+o*s+n*h-a*l,t[1]=n*u+o*l+a*s-i*h,t[2]=a*u+o*h+i*l-n*s,t[3]=o*u-i*s-n*l-a*h,t},Ie.mul=Ie.multiply,Ie.scale=Ce.scale,Ie.rotateX=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+o*s,t[1]=n*l+a*s,t[2]=a*l-n*s,t[3]=o*l-i*s,t},Ie.rotateY=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l-a*s,t[1]=n*l+o*s,t[2]=a*l+i*s,t[3]=o*l-n*s,t},Ie.rotateZ=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+n*s,t[1]=n*l-i*s,t[2]=a*l+o*s,t[3]=o*l-a*s,t},Ie.calculateW=function(t,e){var r=e[0],i=e[1],n=e[2];return t[0]=r,t[1]=i,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),t},Ie.dot=Ce.dot,Ie.lerp=Ce.lerp,Ie.slerp=function(t,e,r,i){var n,a,o,s,l,h=e[0],u=e[1],c=e[2],d=e[3],f=r[0],p=r[1],m=r[2],g=r[3];return(a=h*f+u*p+c*m+d*g)<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>1e-6?(n=Math.acos(a),o=Math.sin(n),s=Math.sin((1-i)*n)/o,l=Math.sin(i*n)/o):(s=1-i,l=i),t[0]=s*h+l*f,t[1]=s*u+l*p,t[2]=s*c+l*m,t[3]=s*d+l*g,t},Ie.invert=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*r+i*i+n*n+a*a,s=o?1/o:0;return t[0]=-r*s,t[1]=-i*s,t[2]=-n*s,t[3]=a*s,t},Ie.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Ie.length=Ce.length,Ie.len=Ie.length,Ie.squaredLength=Ce.squaredLength,Ie.sqrLen=Ie.squaredLength,Ie.normalize=Ce.normalize,Ie.fromMat3=function(t,e){var r,i=e[0]+e[4]+e[8];if(i>0)r=Math.sqrt(i+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var n=0;e[4]>e[0]&&(n=1),e[8]>e[3*n+n]&&(n=2);var a=(n+1)%3,o=(n+2)%3;r=Math.sqrt(e[3*n+n]-e[3*a+a]-e[3*o+o]+1),t[n]=.5*r,r=.5/r,t[3]=(e[3*a+o]-e[3*o+a])*r,t[a]=(e[3*a+n]+e[3*n+a])*r,t[o]=(e[3*o+n]+e[3*n+o])*r}return t};const Re=Ie;var Be,Fe,ze,ke,Ge=function(){this._axisX=new ve,this._axisY=new ve,this._axisZ=new ve,this.array=Yt.create(),this._dirty=!0};Ge.prototype={constructor:Ge,setArray:function(t){for(var e=0;e0){var e=this.min,r=this.max,i=e.array,n=r.array;er(i,t[0]),er(n,t[0]);for(var a=1;an[0]&&(n[0]=o[0]),o[1]>n[1]&&(n[1]=o[1]),o[2]>n[2]&&(n[2]=o[2])}e._dirty=!0,r._dirty=!0}},union:function(t){var e=this.min,r=this.max;return Qt.min(e.array,e.array,t.min.array),Qt.max(r.array,r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},intersection:function(t){var e=this.min,r=this.max;return Qt.max(e.array,e.array,t.min.array),Qt.min(r.array,r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(t){var e=this.min.array,r=this.max.array,i=t.min.array,n=t.max.array;return!(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]||r[0]=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},containPoint:function(t){var e=this.min.array,r=this.max.array,i=t.array;return e[0]<=i[0]&&e[1]<=i[1]&&e[2]<=i[2]&&r[0]>=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},isFinite:function(){var t=this.min.array,e=this.max.array;return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])},applyTransform:function(t){this.transformFrom(this,t)},transformFrom:(Ze=Qt.create(),Ye=Qt.create(),Ke=Qt.create(),Qe=Qt.create(),Je=Qt.create(),$e=Qt.create(),function(t,e){var r=t.min.array,i=t.max.array,n=e.array;return Ze[0]=n[0]*r[0],Ze[1]=n[1]*r[0],Ze[2]=n[2]*r[0],Ye[0]=n[0]*i[0],Ye[1]=n[1]*i[0],Ye[2]=n[2]*i[0],Ke[0]=n[4]*r[1],Ke[1]=n[5]*r[1],Ke[2]=n[6]*r[1],Qe[0]=n[4]*i[1],Qe[1]=n[5]*i[1],Qe[2]=n[6]*i[1],Je[0]=n[8]*r[2],Je[1]=n[9]*r[2],Je[2]=n[10]*r[2],$e[0]=n[8]*i[2],$e[1]=n[9]*i[2],$e[2]=n[10]*i[2],r=this.min.array,i=this.max.array,r[0]=Math.min(Ze[0],Ye[0])+Math.min(Ke[0],Qe[0])+Math.min(Je[0],$e[0])+n[12],r[1]=Math.min(Ze[1],Ye[1])+Math.min(Ke[1],Qe[1])+Math.min(Je[1],$e[1])+n[13],r[2]=Math.min(Ze[2],Ye[2])+Math.min(Ke[2],Qe[2])+Math.min(Je[2],$e[2])+n[14],i[0]=Math.max(Ze[0],Ye[0])+Math.max(Ke[0],Qe[0])+Math.max(Je[0],$e[0])+n[12],i[1]=Math.max(Ze[1],Ye[1])+Math.max(Ke[1],Qe[1])+Math.max(Je[1],$e[1])+n[13],i[2]=Math.max(Ze[2],Ye[2])+Math.max(Ke[2],Qe[2])+Math.max(Je[2],$e[2])+n[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(t){var e=this.min.array,r=this.max.array,i=t.array,n=e[0],a=e[1],o=e[2],s=r[0],l=r[1],h=e[2],u=r[0],c=r[1],d=r[2];if(1===i[15])e[0]=i[0]*n+i[12],e[1]=i[5]*a+i[13],r[2]=i[10]*o+i[14],r[0]=i[0]*u+i[12],r[1]=i[5]*c+i[13],e[2]=i[10]*d+i[14];else{var f=-1/o;e[0]=i[0]*n*f,e[1]=i[5]*a*f,r[2]=(i[10]*o+i[14])*f,f=-1/h,r[0]=i[0]*s*f,r[1]=i[5]*l*f,f=-1/d,e[2]=(i[10]*d+i[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var t=this.vertices;if(!t){t=[];for(var e=0;e<8;e++)t[e]=Qt.fromValues(0,0,0);this.vertices=t}var r=this.min.array,i=this.max.array;return tr(t[0],r[0],r[1],r[2]),tr(t[1],r[0],i[1],r[2]),tr(t[2],i[0],r[1],r[2]),tr(t[3],i[0],i[1],r[2]),tr(t[4],r[0],r[1],i[2]),tr(t[5],r[0],i[1],i[2]),tr(t[6],i[0],r[1],i[2]),tr(t[7],i[0],i[1],i[2]),this},copy:function(t){var e=this.min,r=this.max;return er(e.array,t.min.array),er(r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},clone:function(){var t=new rr;return t.copy(this),t}};const ir=rr;var nr,ar=0;const or=m.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},(function(){this.name||(this.name=(this.type||"NODE")+"_"+ar++),this.position||(this.position=new ve),this.rotation||(this.rotation=new qe),this.scale||(this.scale=new ve(1,1,1)),this.worldTransform=new Ve,this.localTransform=new Ve,this._children=[]}),{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(t){var e=this._scene;if(e){var r=e._nodeRepository;delete r[this.name],r[t]=this}this.name=t},add:function(t){var e=t._parent;if(e!==this){e&&e.remove(t),t._parent=this,this._children.push(t);var r=this._scene;r&&r!==t.scene&&t.traverse(this._addSelfToScene,this),t._needsUpdateWorldTransform=!0}},remove:function(t){var e=this._children,r=e.indexOf(t);r<0||(e.splice(r,1),t._parent=null,this._scene&&t.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var t=this._children,e=0;e0},beforeRender:function(t){},afterRender:function(t,e){},getBoundingBox:function(t,e){return e=or.prototype.getBoundingBox.call(this,t,e),this.geometry&&this.geometry.boundingBox&&e.union(this.geometry.boundingBox),e},clone:(sr=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var t=or.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var e=0;e=0&&g[p]>1e-4&&(Qt.transformMat4(T,m,d[_[p]]),Qt.scaleAndAdd(v,v,T,g[p]));S.set(f,v)}}for(f=0;f>e;return t+1},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("webgl_texture");r&&t.gl.deleteTexture(r),e.deleteContext(t.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(xr.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(xr.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),xr.BYTE=5120,xr.UNSIGNED_BYTE=T,xr.SHORT=5122,xr.UNSIGNED_SHORT=5123,xr.INT=5124,xr.UNSIGNED_INT=5125,xr.FLOAT=S,xr.HALF_FLOAT=36193,xr.UNSIGNED_INT_24_8_WEBGL=34042,xr.DEPTH_COMPONENT=M,xr.DEPTH_STENCIL=34041,xr.ALPHA=6406,xr.RGB=6407,xr.RGBA=A,xr.LUMINANCE=6409,xr.LUMINANCE_ALPHA=6410,xr.SRGB=35904,xr.SRGB_ALPHA=35906,xr.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,xr.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,xr.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,xr.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,xr.NEAREST=C,xr.LINEAR=E,xr.NEAREST_MIPMAP_NEAREST=D,xr.LINEAR_MIPMAP_NEAREST=L,xr.NEAREST_MIPMAP_LINEAR=P,xr.LINEAR_MIPMAP_LINEAR=O,xr.REPEAT=N,xr.CLAMP_TO_EDGE=I,xr.MIRRORED_REPEAT=33648;const br=xr;var wr=hr.extend({skeleton:null,joints:null},(function(){this.joints||(this.joints=[])}),{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var t=hr.prototype.clone.call(this);return t.skeleton=this.skeleton,this.joints&&(t.joints=this.joints.slice()),t}});wr.POINTS=0,wr.LINES=1,wr.LINE_LOOP=2,wr.LINE_STRIP=3,wr.TRIANGLES=4,wr.TRIANGLE_STRIP=5,wr.TRIANGLE_FAN=6,wr.BACK=x,wr.FRONT=y,wr.FRONT_AND_BACK=1032,wr.CW=b,wr.CCW=w;const Tr=wr;const Sr={isPowerOfTwo:function(t){return 0==(t&t-1)},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}};var Mr=Sr.isPowerOfTwo;function Ar(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}var Cr=br.extend((function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}}),{textureType:"texture2D",update:function(t){var e=t.gl;e.bindTexture(e.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(t);var r=this.format,i=this.type,n=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==br.REPEAT&&this.wrapT!==br.REPEAT||!this.NPOT);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,n?this.wrapS:this.getAvailableWrapS()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,n?this.wrapT:this.getAvailableWrapT()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,n?this.magFilter:this.getAvailableMagFilter()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n?this.minFilter:this.getAvailableMinFilter());var a=t.getGLExtension("EXT_texture_filter_anisotropic");if(a&&this.anisotropic>1&&e.texParameterf(e.TEXTURE_2D,a.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===i&&(t.getGLExtension("OES_texture_half_float")||(i=S)),this.mipmaps.length)for(var o=this.width,s=this.height,l=0;l=br.COMPRESSED_RGB_S3TC_DXT1_EXT?t.compressedTexImage2D(t.TEXTURE_2D,r,a,i,n,0,e.pixels):t.texImage2D(t.TEXTURE_2D,r,a,i,n,0,a,o,e.pixels)},generateMipmap:function(t){var e=t.gl;this.useMipmap&&!this.NPOT&&(e.bindTexture(e.TEXTURE_2D,this._cache.get("webgl_texture")),e.generateMipmap(e.TEXTURE_2D))},isPowerOfTwo:function(){return Mr(this.width)&&Mr(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,this.getWebGLTexture(t))},unbind:function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},load:function(t,e){var r=G.createImage();e&&(r.crossOrigin=e);var i=this;return r.onload=function(){i.dirty(),i.trigger("success",i)},r.onerror=function(){i.trigger("error",i)},r.src=t,this.image=r,this}});Object.defineProperty(Cr.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(t){this.image?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(Cr.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(t){this.image?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}});const Er=Cr;function Dr(t){return{byte:G.Int8Array,ubyte:G.Uint8Array,short:G.Int16Array,ushort:G.Uint16Array}[t]||G.Float32Array}function Lr(t){return"attr_"+t}function Pr(t,e,r,i){switch(this.name=t,this.type=e,this.size=r,this.semantic=i||"",this.value=null,r){case 1:this.get=function(t){return this.value[t]},this.set=function(t,e){this.value[t]=e},this.copy=function(t,e){this.value[t]=this.value[t]};break;case 2:this.get=function(t,e){var r=this.value;return e[0]=r[2*t],e[1]=r[2*t+1],e},this.set=function(t,e){var r=this.value;r[2*t]=e[0],r[2*t+1]=e[1]},this.copy=function(t,e){var r=this.value;e*=2,r[t*=2]=r[e],r[t+1]=r[e+1]};break;case 3:this.get=function(t,e){var r=3*t,i=this.value;return e[0]=i[r],e[1]=i[r+1],e[2]=i[r+2],e},this.set=function(t,e){var r=3*t,i=this.value;i[r]=e[0],i[r+1]=e[1],i[r+2]=e[2]},this.copy=function(t,e){var r=this.value;e*=3,r[t*=3]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2]};break;case 4:this.get=function(t,e){var r=this.value,i=4*t;return e[0]=r[i],e[1]=r[i+1],e[2]=r[i+2],e[3]=r[i+3],e},this.set=function(t,e){var r=this.value,i=4*t;r[i]=e[0],r[i+1]=e[1],r[i+2]=e[2],r[i+3]=e[3]},this.copy=function(t,e){var r=this.value;e*=4,r[t*=4]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2],r[t+3]=r[e+3]}}}function Or(t,e,r,i,n){this.name=t,this.type=e,this.buffer=r,this.size=i,this.semantic=n,this.symbol="",this.needsRemove=!1}function Nr(t){this.buffer=t,this.count=0}Pr.prototype.init=function(t){if(!this.value||this.value.length!==t*this.size){var e=Dr(this.type);this.value=new e(t*this.size)}},Pr.prototype.fromArray=function(t){var e,r=Dr(this.type);if(t[0]&&t[0].length){var i=0,n=this.size;e=new r(t.length*n);for(var a=0;a=0){e||(e=[]);var r=this.indices;return e[0]=r[3*t],e[1]=r[3*t+1],e[2]=r[3*t+2],e}},setTriangleIndices:function(t,e){var r=this.indices;r[3*t]=e[0],r[3*t+1]=e[1],r[3*t+2]=e[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(t){var e,r=this.vertexCount>65535?G.Uint32Array:G.Uint16Array;if(t[0]&&t[0].length){var i=0;e=new r(3*t.length);for(var n=0;n=0&&(e.splice(r,1),delete this.attributes[t],!0)},getAttribute:function(t){return this.attributes[t]},getEnabledAttributes:function(){var t=this._enabledAttributes,e=this._attributeList;if(t)return t;for(var r=[],i=this.vertexCount,n=0;na[0]&&(a[0]=s),l>a[1]&&(a[1]=l),h>a[2]&&(a[2]=h)}r._dirty=!0,i._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var t=this.indices,e=this.attributes,r=e.position.value,i=e.normal.value;if(i&&i.length===r.length)for(var n=0;n65535&&(this.indices=new G.Uint32Array(this.indices));for(var t=this.attributes,e=this.indices,r=this.getEnabledAttributes(),i={},n=0;nthis.distance,n=1;n<8;n++)if(Qt.dot(e[n].array,r)>this.distance!=i)return!0},intersectLine:(Kr=Qt.create(),function(t,e,r){var i=this.distanceToPoint(t),n=this.distanceToPoint(e);if(i>0&&n>0||i<0&&n<0)return null;var a=this.normal.array,o=this.distance,s=t.array;Qt.sub(Kr,e.array,t.array),Qt.normalize(Kr,Kr);var l=Qt.dot(a,Kr);if(0===l)return null;r||(r=new ve);var h=(Qt.dot(a,s)-o)/l;return Qt.scaleAndAdd(r.array,s,Kr,-h),r._dirty=!0,r}),applyTransform:(qr=Yt.create(),Zr=Ce.create(),Yr=Ce.create(),Yr[3]=1,function(t){t=t.array,Qt.scale(Yr,this.normal.array,this.distance),Ce.transformMat4(Yr,Yr,t),this.distance=Qt.dot(Yr,this.normal.array),Yt.invert(qr,t),Yt.transpose(qr,qr),Zr[3]=0,Qt.copy(Zr,this.normal.array),Ce.transformMat4(Zr,Zr,qr),Qt.copy(this.normal.array,Zr)}),copy:function(t){Qt.copy(this.normal.array,t.normal.array),this.normal._dirty=!0,this.distance=t.distance},clone:function(){var t=new Qr;return t.copy(this),t}};const Jr=Qr;var $r,ti=Qt.set,ei=Qt.copy,ri=Qt.transformMat4,ii=Math.min,ni=Math.max,ai=function(){this.planes=[];for(var t=0;t<6;t++)this.planes.push(new Jr);for(this.boundingBox=new ir,this.vertices=[],t=0;t<8;t++)this.vertices[t]=Qt.fromValues(0,0,0)};ai.prototype={setFromProjection:function(t){var e=this.planes,r=t.array,i=r[0],n=r[1],a=r[2],o=r[3],s=r[4],l=r[5],h=r[6],u=r[7],c=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],_=r[14],v=r[15];ti(e[0].normal.array,o-i,u-s,p-c),e[0].distance=-(v-m),e[0].normalize(),ti(e[1].normal.array,o+i,u+s,p+c),e[1].distance=-(v+m),e[1].normalize(),ti(e[2].normal.array,o+n,u+l,p+d),e[2].distance=-(v+g),e[2].normalize(),ti(e[3].normal.array,o-n,u-l,p-d),e[3].distance=-(v-g),e[3].normalize(),ti(e[4].normal.array,o-a,u-h,p-f),e[4].distance=-(v-_),e[4].normalize(),ti(e[5].normal.array,o+a,u+h,p+f),e[5].distance=-(v+_),e[5].normalize();var y=this.boundingBox,x=this.vertices;if(0===v){var b=l/i,w=-_/(f-1),T=-_/(f+1),S=-T/l,M=-w/l;y.min.set(-S*b,-S,T),y.max.set(S*b,S,w),ti(x[0],-S*b,-S,T),ti(x[1],-S*b,S,T),ti(x[2],S*b,-S,T),ti(x[3],S*b,S,T),ti(x[4],-M*b,-M,w),ti(x[5],-M*b,M,w),ti(x[6],M*b,-M,w),ti(x[7],M*b,M,w)}else{var A=(-1-m)/i,C=(1-m)/i,E=(1-g)/l,D=(-1-g)/l,L=(-1-_)/f,P=(1-_)/f;y.min.set(Math.min(A,C),Math.min(D,E),Math.min(P,L)),y.max.set(Math.max(C,A),Math.max(E,D),Math.max(L,P));var O=y.min.array,N=y.max.array;ti(x[0],O[0],O[1],O[2]),ti(x[1],O[0],N[1],O[2]),ti(x[2],N[0],O[1],O[2]),ti(x[3],N[0],N[1],O[2]),ti(x[4],O[0],O[1],N[2]),ti(x[5],O[0],N[1],N[2]),ti(x[6],N[0],O[1],N[2]),ti(x[7],N[0],N[1],N[2])}},getTransformedBoundingBox:($r=Qt.create(),function(t,e){var r=this.vertices,i=e.array,n=t.min,a=t.max,o=n.array,s=a.array,l=r[0];ri($r,l,i),ei(o,$r),ei(s,$r);for(var h=1;h<8;h++)l=r[h],ri($r,l,i),o[0]=ii($r[0],o[0]),o[1]=ii($r[1],o[1]),o[2]=ii($r[2],o[2]),s[0]=ni($r[0],s[0]),s[1]=ni($r[1],s[1]),s[2]=ni($r[2],s[2]);return n._dirty=!0,a._dirty=!0,t})};const oi=ai;var si;const li=or.extend((function(){return{projectionMatrix:new Ve,invProjectionMatrix:new Ve,viewMatrix:new Ve,frustum:new oi}}),(function(){this.update(!0)}),{update:function(t){or.prototype.update.call(this,t),Ve.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),Ve.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(t){Ve.copy(this.viewMatrix,t),Ve.invert(this.worldTransform,t),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(t){Ve.copy(this.projectionMatrix,t),Ve.invert(this.invProjectionMatrix,t),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(si=Ce.create(),function(t,e){var r=void 0!==e?e:new Me,i=t.array[0],n=t.array[1];return Ce.set(si,i,n,-1,1),Ce.transformMat4(si,si,this.invProjectionMatrix.array),Ce.transformMat4(si,si,this.worldTransform.array),Qt.scale(r.origin.array,si,1/si[3]),Ce.set(si,i,n,1,1),Ce.transformMat4(si,si,this.invProjectionMatrix.array),Ce.transformMat4(si,si,this.worldTransform.array),Qt.scale(si,si,1/si[3]),Qt.sub(r.direction.array,si,r.origin.array),Qt.normalize(r.direction.array,r.direction.array),r.direction._dirty=!0,r.origin._dirty=!0,r})});var hi,ui,ci=Yt.create(),di=Yt.create(),fi={};function pi(t){var e=[],r=Object.keys(t);r.sort();for(var i=0;i0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(t)):t instanceof Xr&&this.lights.push(t),t.name&&(this._nodeRepository[t.name]=t)},removeFromScene:function(t){var e;t instanceof li?(e=this._cameraList.indexOf(t))>=0&&this._cameraList.splice(e,1):t instanceof Xr&&(e=this.lights.indexOf(t))>=0&&this.lights.splice(e,1),t.name&&delete this._nodeRepository[t.name]},getNode:function(t){return this._nodeRepository[t]},setMainCamera:function(t){var e=this._cameraList.indexOf(t);e>=0&&this._cameraList.splice(e,1),this._cameraList.unshift(t)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var t=this.lights;this._previousLightNumber=this._lightNumber;for(var e={},r=0;r0&&this._doUpdateRenderList(o,e,r,i,n)}},isFrustumCulled:(hi=new ir,ui=new Ve,function(t,e,r){var i=t.boundingBox;if(i||(i=t.skeleton&&t.skeleton.boundingBox?t.skeleton.boundingBox:t.geometry.boundingBox),!i)return!1;if(ui.array=r,hi.transformFrom(i,ui),t.castShadow&&this.viewBoundingBoxLastFrame.union(hi),t.frustumCulling){if(!hi.intersectBoundingBox(e.frustum.boundingBox))return!0;ui.array=e.projectionMatrix.array,hi.max.array[2]>0&&hi.min.array[2]<0&&(hi.max.array[2]=-1e-20),hi.applyProjection(ui);var n=hi.min.array,a=hi.max.array;if(a[0]<-1||n[0]>1||a[1]<-1||n[1]>1||a[2]<-1||n[2]>1)return!0}return!1}),_updateLightUniforms:function(){var t=this.lights;t.sort(gi);var e=this._lightUniforms;for(var r in e)for(var i in e[r])e[r][i].value.length=0;for(var n=0;n=this._maxSize&&a>0){var s=r.head;r.remove(s),delete i[s.key],n=s.value,this._lastRemovedEntry=s}o?o.value=e:o=new vi(e),o.key=t,r.insertEntry(o),i[t]=o}return n},t.prototype.get=function(t){var e=this._map[t],r=this._list;if(null!=e)return e!==r.tail&&(r.remove(e),r.insertEntry(e)),e.value},t.prototype.clear=function(){this._list.clear(),this._map={}},t.prototype.len=function(){return this._list.len()},t}();var bi=Sr.isPowerOfTwo,wi=["px","nx","py","ny","pz","nz"],Ti=br.extend((function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}}),{textureType:"textureCube",update:function(t){var e=t.gl;e.bindTexture(e.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(t);var r=this.format,i=this.type;e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,this.getAvailableWrapS()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,this.getAvailableWrapT()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var n=t.getGLExtension("EXT_texture_filter_anisotropic");if(n&&this.anisotropic>1&&e.texParameterf(e.TEXTURE_CUBE_MAP,n.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===i&&(t.getGLExtension("OES_texture_half_float")||(i=S)),this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s0&&t.height>0}Object.defineProperty(Ti.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(t){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(Ti.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(t){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}});const Mi=Ti,Ai=li.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var t=this.fov/180*Math.PI;this.projectionMatrix.perspective(t,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix.array,e=2*Math.atan(1/t[5]);this.fov=e/Math.PI*180,this.aspect=t[5]/t[0],this.near=t[14]/(t[10]-1),this.far=t[14]/(t[10]+1)},clone:function(){var t=li.prototype.clone.call(this);return t.fov=this.fov,t.aspect=this.aspect,t.near=this.near,t.far=this.far,t}});var Ci="framebuffer",Ei="renderbuffer",Di="renderbuffer_width",Li="renderbuffer_height",Pi="renderbuffer_attached",Oi="depthtexture_attached",Ni=36160,Ii=36161,Ri=36096,Bi=m.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},(function(){this._cache=new yr,this._textures={}}),{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(t){if(t.__currentFrameBuffer){if(t.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}t.__currentFrameBuffer=this;var e=t.gl;e.bindFramebuffer(Ni,this._getFrameBufferGL(t)),this._boundRenderer=t;var r=this._cache;r.put("viewport",t.viewport);var i,n,a=!1;for(var o in this._textures){a=!0;var s=this._textures[o];s&&(i=s.texture.width,n=s.texture.height,this._doAttach(t,s.texture,o,s.target))}this._width=i,this._height=n,!a&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?t.setViewport(this.viewport):t.setViewport(0,0,i,n,1);var l=r.get("attached_textures");if(l)for(var o in l)if(!this._textures[o]){var h=l[o];this._doDetach(e,o,h)}if(!r.get(Oi)&&this.depthBuffer){r.miss(Ei)&&r.put(Ei,e.createRenderbuffer());var u=r.get(Ei);i===r.get(Di)&&n===r.get(Li)||(e.bindRenderbuffer(Ii,u),e.renderbufferStorage(Ii,e.DEPTH_COMPONENT16,i,n),r.put(Di,i),r.put(Li,n),e.bindRenderbuffer(Ii,null)),r.get(Pi)||(e.framebufferRenderbuffer(Ni,Ri,Ii,u),r.put(Pi,!0))}},unbind:function(t){t.__currentFrameBuffer=null,t.gl.bindFramebuffer(Ni,null),this._boundRenderer=null,this._cache.use(t.__uid__);var e=this._cache.get("viewport");e&&t.setViewport(e),this.updateMipmap(t)},updateMipmap:function(t){var e=t.gl;for(var r in this._textures){var i=this._textures[r];if(i){var n=i.texture;if(!n.NPOT&&n.useMipmap&&n.minFilter===br.LINEAR_MIPMAP_LINEAR){var a="textureCube"===n.textureType?34067:3553;e.bindTexture(a,n.getWebGLTexture(t)),e.generateMipmap(a),e.bindTexture(a,null)}}}},checkStatus:function(t){return t.checkFramebufferStatus(Ni)},_getFrameBufferGL:function(t){var e=this._cache;return e.use(t.__uid__),e.miss(Ci)&&e.put(Ci,t.gl.createFramebuffer()),e.get(Ci)},attach:function(t,e,r){if(!t.width)throw new Error("The texture attached to color buffer is not a valid.");e=e||36064,r=r||3553;var i,n=this._boundRenderer;if(n&&n.gl){var a=this._cache;a.use(n.__uid__),i=a.get("attached_textures")}var o=this._textures[e];if(!o||o.target!==r||o.texture!==t||!i||null==i[e]){var s=!0;n&&(s=this._doAttach(n,t,e,r),this.viewport||n.setViewport(0,0,t.width,t.height,1)),s&&(this._textures[e]=this._textures[e]||{},this._textures[e].texture=t,this._textures[e].target=r)}},_doAttach:function(t,e,r,i){var n=t.gl,a=e.getWebGLTexture(t),o=this._cache.get("attached_textures");if(o&&o[r]){var s=o[r];if(s.texture===e&&s.target===i)return}var l=!0;if(((r=+r)===Ri||r===R)&&(t.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),e.format!==M&&34041!==e.format&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var h=this._cache.get(Ei);h&&(n.framebufferRenderbuffer(Ni,Ri,Ii,null),n.deleteRenderbuffer(h),this._cache.put(Ei,!1)),this._cache.put(Pi,!1),this._cache.put(Oi,!0)}return n.framebufferTexture2D(Ni,r,i,a,0),o||(o={},this._cache.put("attached_textures",o)),o[r]=o[r]||{},o[r].texture=e,o[r].target=i,l},_doDetach:function(t,e,r){t.framebufferTexture2D(Ni,e,r,null,0);var i=this._cache.get("attached_textures");i&&i[e]&&(i[e]=null),e!==Ri&&e!==R||this._cache.put(Oi,!1)},detach:function(t,e){this._textures[t]=null,this._boundRenderer&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,t,e))},dispose:function(t){var e=t.gl,r=this._cache;r.use(t.__uid__);var i=r.get(Ei);i&&e.deleteRenderbuffer(i);var n=r.get(Ci);n&&e.deleteFramebuffer(n),r.deleteContext(t.__uid__),this._textures={}}});Bi.DEPTH_ATTACHMENT=Ri,Bi.COLOR_ATTACHMENT0=36064,Bi.STENCIL_ATTACHMENT=36128,Bi.DEPTH_STENCIL_ATTACHMENT=R;const Fi=Bi;var zi=["px","nx","py","ny","pz","nz"];const ki=m.extend((function(){var t={position:new ve,far:1e3,near:.1,texture:null,shadowMapPass:null},e=t._cameras={px:new Ai({fov:90}),nx:new Ai({fov:90}),py:new Ai({fov:90}),ny:new Ai({fov:90}),pz:new Ai({fov:90}),nz:new Ai({fov:90})};return e.px.lookAt(ve.POSITIVE_X,ve.NEGATIVE_Y),e.nx.lookAt(ve.NEGATIVE_X,ve.NEGATIVE_Y),e.py.lookAt(ve.POSITIVE_Y,ve.POSITIVE_Z),e.ny.lookAt(ve.NEGATIVE_Y,ve.NEGATIVE_Z),e.pz.lookAt(ve.POSITIVE_Z,ve.NEGATIVE_Y),e.nz.lookAt(ve.NEGATIVE_Z,ve.NEGATIVE_Y),t._frameBuffer=new Fi,t}),{getCamera:function(t){return this._cameras[t]},render:function(t,e,r){var i=t.gl;r||e.update();for(var n=this.texture.width,a=2*Math.atan(n/(n-.5))/Math.PI*180,o=0;o<6;o++){var s=zi[o],l=this._cameras[s];if(ve.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=a,this.shadowMapPass){l.update();var h=e.getBoundingBox();h.applyTransform(l.viewMatrix),e.viewBoundingBoxLastFrame.copy(h),this.shadowMapPass.render(t,e,l,!0)}this._frameBuffer.attach(this.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._frameBuffer.bind(t),t.render(e,l,!0),this._frameBuffer.unbind(t)}},dispose:function(t){this._frameBuffer.dispose(t)}}),Gi=Ur.extend({dynamic:!1,widthSegments:1,heightSegments:1},(function(){this.build()}),{build:function(){for(var t=this.heightSegments,e=this.widthSegments,r=this.attributes,i=[],n=[],a=[],o=[],s=0;s<=t;s++)for(var l=s/t,h=0;h<=e;h++){var u=h/e;if(i.push([2*u-1,2*l-1,0]),n&&n.push([u,l]),a&&a.push([0,0,1]),h0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),t.renderPass([this],r)}}),ji=Wi;function Xi(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var qi=Xi("DXT1"),Zi=Xi("DXT3"),Yi=Xi("DXT5");const Ki=function(t,e){var r=new Int32Array(t,0,31);if(542327876!==r[0])return null;if(4&!r(20))return null;var i,n,a=r(21),o=r[4],s=r[3],l=512&r[28],h=131072&r[2];switch(a){case qi:i=8,n=br.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case Zi:i=16,n=br.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case Yi:i=16,n=br.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var u=r[1]+4,c=l?6:1,d=1;h&&(d=Math.max(1,r[7]));for(var f=[],p=0;p0){var n=Math.pow(2,t[3]-128-8+i);e[r+0]=t[0]*n,e[r+1]=t[1]*n,e[r+2]=t[2]*n}else e[r+0]=0,e[r+1]=0,e[r+2]=0;return e[r+3]=1,e}function $i(t,e,r,i){for(var n,a,o=0,s=0,l=i;l>0;)if(t[s][0]=e[r++],t[s][1]=e[r++],t[s][2]=e[r++],t[s][3]=e[r++],1===t[s][0]&&1===t[s][1]&&1===t[s][2]){for(var h=t[s][3]<>>0;h>0;h--)n=t[s-1],(a=t[s])[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],s++,l--;o+=8}else s++,l--,o=0;return r}function tn(t,e,r,i){if(i<8|i>32767)return $i(t,e,r,i);if(2!=(n=e[r++]))return $i(t,e,r-1,i);if(t[0][1]=e[r++],t[0][2]=e[r++],n=e[r++],(t[0][2]<<8>>>0|n)>>>0!==i)return null;for(var n=0;n<4;n++)for(var a=0;a128){o=(127&o)>>>0;for(var s=e[r++];o--;)t[a++][n]=s}else for(;o--;)t[a++][n]=e[r++]}return r}const en=function(t,e,r){null==r&&(r=0);var i=new Uint8Array(t),n=i.length;if("#?"===function(t,e,r){for(var i="",n=0;n<2;n++)i+=Qi(t[n]);return i}(i)){for(var a=2;a=n)){a+=2;for(var o="";a20)return console.warn("Given image is not a height map"),t}var d,f,p,m;l%(4*i)==0?(d=o.data[l],p=o.data[l+4]):l%(4*i)==4*(i-1)?(d=o.data[l-4],p=o.data[l]):(d=o.data[l-4],p=o.data[l+4]),l<4*i?(f=o.data[l],m=o.data[l+4*i]):l>i*(n-1)*4?(f=o.data[l-4*i],m=o.data[l]):(f=o.data[l-4*i],m=o.data[l+4*i]),s.data[l]=d-p+127,s.data[l+1]=f-m+127,s.data[l+2]=255,s.data[l+3]=255}return a.putImageData(s,0,0),r},isHeightImage:function(t,e,r){if(!t||!t.width||!t.height)return!1;var i=document.createElement("canvas"),n=i.getContext("2d"),a=e||32;r=r||20,i.width=i.height=a,n.drawImage(t,0,0,a,a);for(var o=n.getImageData(0,0,a,a),s=0;sr)return!1}return!0},_fetchTexture:function(t,e,r){G.request.get({url:t,responseType:"arraybuffer",onload:e,onerror:r})},createChessboard:function(t,e,r,i){t=t||512,e=e||64,r=r||"black",i=i||"white";var n=Math.ceil(t/e),a=document.createElement("canvas");a.width=t,a.height=t;var o=a.getContext("2d");o.fillStyle=i,o.fillRect(0,0,t,t),o.fillStyle=r;for(var s=0;s=0||(an.forEach((function(e){t.on(e,this[on(e)],this)}),this),this._meshes.push(t))},detachFromMesh:function(t){var e=this._meshes.indexOf(t);e>=0&&this._meshes.splice(e,1),an.forEach((function(e){t.off(e,this[on(e)])}),this)},dispose:function(){this._meshes.forEach((function(t){this.detachFromMesh(t)}),this)}};const ln=sn,hn=li.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix.array;this.left=(-1-t[12])/t[0],this.right=(1-t[12])/t[0],this.top=(1-t[13])/t[5],this.bottom=(-1-t[13])/t[5],this.near=-(-1-t[14])/t[10],this.far=-(1-t[14])/t[10]},clone:function(){var t=li.prototype.clone.call(this);return t.left=this.left,t.right=this.right,t.near=this.near,t.far=this.far,t.top=this.top,t.bottom=this.bottom,t}});Xt.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var un=new Gi,cn=new Tr({geometry:un,frustumCulling:!1}),dn=new hn;const fn=m.extend((function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}}),(function(){var t=new Xt(Xt.source("clay.compositor.vertex"),this.fragment),e=new lt({shader:t});e.enableTexturesAll(),this.material=e}),{setUniform:function(t,e){this.material.setUniform(t,e)},getUniform:function(t){var e=this.material.uniforms[t];if(e)return e.value},attachOutput:function(t,e){this.outputs||(this.outputs={}),e=e||36064,this.outputs[e]=t},detachOutput:function(t){for(var e in this.outputs)this.outputs[e]===t&&(this.outputs[e]=null)},bind:function(t,e){if(this.outputs)for(var r in this.outputs){var i=this.outputs[r];i&&e.attach(i,r)}e&&e.bind(t)},unbind:function(t,e){e.unbind(t)},render:function(t,e){var r=t.gl;if(e){this.bind(t,e);var i=t.getGLExtension("EXT_draw_buffers");if(i&&this.outputs){var n=[];for(var a in this.outputs)(a=+a)>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&n.push(a);i.drawBuffersEXT(n)}}this.trigger("beforerender",this,t);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(t),this.trigger("afterrender",this,t),e&&this.unbind(t,e)},renderQuad:function(t){cn.material=this.material,t.renderPass([cn],dn)},dispose:function(t){}});var pn={},mn=["px","nx","py","ny","pz","nz"];pn.prefilterEnvironmentMap=function(t,e,r,i,n){n&&i||(i=pn.generateNormalDistribution(),n=pn.integrateBRDF(t,i));var a=(r=r||{}).width||64,o=r.height||64,s=r.type||e.type,l=new Mi({width:a,height:o,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var h=Math.min(a,o),u=Math.log(h)/Math.log(2)+1,c=new lt({shader:new Xt({vertex:Xt.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});c.set("normalDistribution",i),r.encodeRGBM&&c.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&c.define("fragment","RGBM_DECODE");var d,f=new _i;if("texture2D"===e.textureType){var p=new Mi({width:a,height:o,type:s===br.FLOAT?br.HALF_FLOAT:s});nn.panoramaToCubeMap(t,e,p,{encodeRGBM:r.decodeRGBM}),e=p}(d=new Wi({scene:f,material:c})).material.set("environmentMap",e);var m=new ki({texture:l});r.encodeRGBM&&(s=l.type=br.UNSIGNED_BYTE);for(var g=new Er({width:a,height:o,type:s}),_=new Fi({depthBuffer:!1}),v=G[s===br.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],y=0;y 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),n=new Er({width:512,height:256,type:br.HALF_FLOAT,wrapS:br.CLAMP_TO_EDGE,wrapT:br.CLAMP_TO_EDGE,minFilter:br.NEAREST,magFilter:br.NEAREST,useMipmap:!1});return i.setUniform("normalDistribution",e),i.setUniform("viewportSize",[512,256]),i.attachOutput(n),i.render(t,r),r.dispose(t),n},pn.generateNormalDistribution=function(t,e){for(var r=new Er({width:t=t||256,height:e=e||1024,type:br.FLOAT,minFilter:br.NEAREST,magFilter:br.NEAREST,wrapS:br.CLAMP_TO_EDGE,wrapT:br.CLAMP_TO_EDGE,useMipmap:!1}),i=new Float32Array(e*t*4),n=[],a=0;a>>16)>>>0;h=(((16711935&(h=((252645135&(h=((858993459&(h=((1431655765&h)<<1|(2863311530&h)>>>1)>>>0))<<2|(3435973836&h)>>>2)>>>0))<<4|(4042322160&h)>>>4)>>>0))<<8|(4278255360&h)>>>8)>>>0)/4294967296;var u=Math.sqrt((1-h)/(1+(s*s-1)*h));n[l]=u}for(l=0;l65535?Uint32Array:Uint16Array,v=this.indices=new _(e*t*6),y=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,T=this.thetaLength,S=[],M=[],A=0,C=1/(y=this.radius);for(d=0;d<=t;d++)for(c=0;c<=e;c++)h=c/e,u=d/t,o=-y*Math.cos(x+h*b)*Math.sin(w+u*T),s=y*Math.cos(w+u*T),l=y*Math.sin(x+h*b)*Math.sin(w+u*T),S[0]=o,S[1]=s,S[2]=l,M[0]=h,M[1]=u,r.set(A,S),i.set(A,M),S[0]*=C,S[1]*=C,S[2]*=C,n.set(A,S),A++;var E=e+1,D=0;for(d=0;d255?255:t}function Kn(t){return t<0?0:t>1?1:t}function Qn(t){var e=t;return e.length&&"%"===e.charAt(e.length-1)?Yn(parseFloat(e)/100*255):Yn(parseInt(e,10))}function Jn(t){var e=t;return e.length&&"%"===e.charAt(e.length-1)?Kn(parseFloat(e)/100):Kn(parseFloat(e))}function $n(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function ta(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function ea(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}var ra=new xi(20),ia=null;function na(t,e){ia&&ea(ia,e),ia=ra.put(t,ia||e.slice())}function aa(t,e){if(t){e=e||[];var r=ra.get(t);if(r)return ea(e,r);var i=(t+="").replace(/ /g,"").toLowerCase();if(i in Zn)return ea(e,Zn[i]),na(t,e),e;var n,a=i.length;if("#"===i.charAt(0))return 4===a||5===a?(n=parseInt(i.slice(1,4),16))>=0&&n<=4095?(ta(e,(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,5===a?parseInt(i.slice(4),16)/15:1),na(t,e),e):void ta(e,0,0,0,1):7===a||9===a?(n=parseInt(i.slice(1,7),16))>=0&&n<=16777215?(ta(e,(16711680&n)>>16,(65280&n)>>8,255&n,9===a?parseInt(i.slice(7),16)/255:1),na(t,e),e):void ta(e,0,0,0,1):void 0;var o=i.indexOf("("),s=i.indexOf(")");if(-1!==o&&s+1===a){var l=i.substr(0,o),h=i.substr(o+1,s-(o+1)).split(","),u=1;switch(l){case"rgba":if(4!==h.length)return 3===h.length?ta(e,+h[0],+h[1],+h[2],1):ta(e,0,0,0,1);u=Jn(h.pop());case"rgb":return 3!==h.length?void ta(e,0,0,0,1):(ta(e,Qn(h[0]),Qn(h[1]),Qn(h[2]),u),na(t,e),e);case"hsla":return 4!==h.length?void ta(e,0,0,0,1):(h[3]=Jn(h[3]),oa(h,e),na(t,e),e);case"hsl":return 3!==h.length?void ta(e,0,0,0,1):(oa(h,e),na(t,e),e);default:return}}ta(e,0,0,0,1)}}function oa(t,e){var r=(parseFloat(t[0])%360+360)%360/360,i=Jn(t[1]),n=Jn(t[2]),a=n<=.5?n*(i+1):n+i-n*i,o=2*n-a;return ta(e=e||[],Yn(255*$n(o,a,r+1/3)),Yn(255*$n(o,a,r)),Yn(255*$n(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}function sa(t,e){var r=aa(t);return r?(.299*r[0]+.587*r[1]+.114*r[2])*r[3]/255+(1-r[3])*e:0}var la={"[object Function]":!0,"[object RegExp]":!0,"[object Date]":!0,"[object Error]":!0,"[object CanvasGradient]":!0,"[object CanvasPattern]":!0,"[object Image]":!0,"[object Canvas]":!0},ha={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0},ua=Object.prototype.toString,ca=Array.prototype,da=ca.forEach,fa=ca.filter,pa=ca.slice,ma=ca.map,ga=function(){}.constructor,_a=ga?ga.prototype:null,va={},ya=2311;function xa(){for(var t=[],e=0;eo)i.length=o;else for(var s=a;s=2&&this.interpolable},t.prototype.getAdditiveTrack=function(){return this._additiveTrack},t.prototype.addKeyframe=function(t,e){t>=this.maxTime?this.maxTime=t:this._needsSort=!0;var r=this.keyframes,i=r.length;if(this.interpolable)if(Ca(e)){var n=function(t){return Ca(t&&t[0])?2:1}(e);if(i>0&&this.arrDim!==n)return void(this.interpolable=!1);if(1===n&&"number"!=typeof e[0]||2===n&&"number"!=typeof e[0][0])return void(this.interpolable=!1);if(i>0){var a=r[i-1];this._isAllValueEqual&&(1===n&&Ja(e,a.value)||(this._isAllValueEqual=!1))}this.arrDim=n}else{if(this.arrDim>0)return void(this.interpolable=!1);if("string"==typeof e){var o=aa(e);o?(e=o,this.isValueColor=!0):this.interpolable=!1}else if("number"!=typeof e)return void(this.interpolable=!1);this._isAllValueEqual&&i>0&&(a=r[i-1],(this.isValueColor&&!Ja(a.value,e)||a.value!==e)&&(this._isAllValueEqual=!1))}var s={time:t,value:e,percent:0};return this.keyframes.push(s),s},t.prototype.prepare=function(t){var e=this.keyframes;this._needsSort&&e.sort((function(t,e){return t.time-e.time}));for(var r=this.arrDim,i=e.length,n=e[i-1],a=0;a0&&a!==i-1&&Qa(e[a].value,n.value,r);if(t&&this.needsAnimate()&&t.needsAnimate()&&r===t.arrDim&&this.isValueColor===t.isValueColor&&!t._finished){this._additiveTrack=t;var o=e[0].value;for(a=0;a=0&&!(a[r].percent<=e);r--);r=Math.min(r,o-2)}else{for(r=this._lastFrame;re);r++);r=Math.min(r-1,o-2)}var u=a[r+1],c=a[r];if(c&&u){this._lastFrame=r,this._lastFramePercent=e;var d=u.percent-c.percent;if(0!==d){var f=(e-c.percent)/d,p=i?this._additiveValue:h?io:t[s];if((l>0||h)&&!p&&(p=this._additiveValue=[]),this.useSpline){var m=a[r][n],g=a[0===r?r:r-1][n],_=a[r>o-2?o-1:r+1][n],v=a[r>o-3?o-1:r+2][n];if(l>0)1===l?to(p,g,m,_,v,f,f*f,f*f*f):function(t,e,r,i,n,a,o,s){for(var l=e.length,h=e[0].length,u=0;u0?1===l?Za(p,c[n],u[n],f):function(t,e,r,i){for(var n=e.length,a=n&&e[0].length,o=0;o.5?e:t}(c[n],u[n],f),i?this._additiveValue=y:t[s]=y);i&&this._addToTarget(t)}}}},t.prototype._addToTarget=function(t){var e=this.arrDim,r=this.propName,i=this._additiveValue;0===e?this.isValueColor?(aa(t[r],io),Ya(io,io,i,1),t[r]=ro(io)):t[r]=t[r]+i:1===e?Ya(t[r],t[r],i,1):2===e&&Ka(t[r],t[r],i,1)},t}();const ao=function(){function t(t,e,r){this._tracks={},this._trackKeys=[],this._delay=0,this._maxTime=0,this._paused=!1,this._started=0,this._clip=null,this._target=t,this._loop=e,e&&r?xa("Can' use additive animation on looped animation."):this._additiveAnimators=r}return t.prototype.getTarget=function(){return this._target},t.prototype.changeTarget=function(t){this._target=t},t.prototype.when=function(t,e){return this.whenWithKeys(t,e,La(e))},t.prototype.whenWithKeys=function(t,e,r){for(var i=this._tracks,n=0;n0)){this._started=1;for(var r=this,i=[],n=0;n1){var o=a.pop();n.addKeyframe(o.time,t[i]),n.prepare(n.getAdditiveTrack())}}}},t}(),oo={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(t,e){var r;if(this._animators=this._animators||[],t){for(var i=t.split("."),n=this,a=0,o=i.length;a=0&&s.splice(t,1)})),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(t){this._animators=this._animators||[];for(var e=this._animators,r=e.length,i=0;i 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"),Xt.import(qt),Xt.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),Xt.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),Xt.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),Xt.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),Xt.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),Xt.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var lo=_i.prototype.addToScene,ho=_i.prototype.removeFromScene;_i.prototype.addToScene=function(t){if(lo.call(this,t),this.__zr){var e=this.__zr;t.traverse((function(t){t.__zr=e,t.addAnimatorsToZr&&t.addAnimatorsToZr(e)}))}},_i.prototype.removeFromScene=function(t){ho.call(this,t),t.traverse((function(t){var e=t.__zr;t.__zr=null,e&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(e)}))},lt.prototype.setTextureImage=function(t,e,r,i){if(this.shader){var n,a=r.getZr(),o=this;return o.autoUpdateTextureStatus=!1,o.disableTexture(t),!(s=e)||"none"===s||(n=uo.loadTexture(e,r,i,(function(e){o.enableTexture(t),a&&a.refresh()})),o.set(t,n)),n}var s};var uo={};uo.Renderer=ue,uo.Node=or,uo.Mesh=Tr,uo.Shader=Xt,uo.Material=lt,uo.Texture=br,uo.Texture2D=Er,uo.Geometry=Ur,uo.SphereGeometry=An,uo.PlaneGeometry=Gi,uo.CubeGeometry=Vi,uo.AmbientLight=Cn,uo.DirectionalLight=En,uo.PointLight=Dn,uo.SpotLight=Ln,uo.PerspectiveCamera=Ai,uo.OrthographicCamera=hn,uo.Vector2=_t,uo.Vector3=ve,uo.Vector4=In,uo.Quaternion=qe,uo.Matrix2=zn,uo.Matrix2d=Hn,uo.Matrix3=Wn,uo.Matrix4=Ve,uo.Plane=Jr,uo.Ray=Me,uo.BoundingBox=ir,uo.Frustum=oi;var co=nn.createBlank("rgba(255,255,255,0)").image;function fo(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function po(t){if((t.wrapS===br.REPEAT||t.wrapT===br.REPEAT)&&t.image){var e=fo(t.width),r=fo(t.height);if(e!==t.width||r!==t.height){var i=document.createElement("canvas");i.width=e,i.height=r,i.getContext("2d").drawImage(t.image,0,0,e,r),t.image=i}}}uo.loadTexture=function(t,e,r,i){"function"==typeof r&&(i=r,r={}),r=r||{};for(var n=Object.keys(r).sort(),a="",o=0;o3?e[3]=t[3]:e[3]=1,e):((e=i.color.parse(t||"#000",e)||[0,0,0,0])[0]/=255,e[1]/=255,e[2]/=255,e)},uo.directionFromAlphaBeta=function(t,e){var r=t/180*Math.PI+Math.PI/2,i=-e/180*Math.PI+Math.PI/2,n=[],a=Math.sin(r);return n[0]=a*Math.cos(i),n[1]=-Math.cos(r),n[2]=a*Math.sin(i),n},uo.getShadowResolution=function(t){var e=1024;switch(t){case"low":e=512;break;case"medium":break;case"high":e=2048;break;case"ultra":e=4096}return e},uo.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],uo.createShader=function(t){"ecgl.shadow"===t&&(t="ecgl.displayShadow");var e=Xt.source(t+".vertex"),r=Xt.source(t+".fragment");e||console.error("Vertex shader of '%s' not exits",t),r||console.error("Fragment shader of '%s' not exits",t);var i=new Xt(e,r);return i.name=t,i},uo.createMaterial=function(t,e){e instanceof Array||(e=[e]);var r=uo.createShader(t),i=new lt({shader:r});return e.forEach((function(t){"string"==typeof t&&i.define(t)})),i},uo.setMaterialFromModel=function(t,e,r,i){e.autoUpdateTextureStatus=!1;var n=r.getModel(t+"Material"),a=n.get("detailTexture"),o=Sn(n.get("textureTiling"),1),s=Sn(n.get("textureOffset"),0);"number"==typeof o&&(o=[o,o]),"number"==typeof s&&(s=[s,s]);var l=o[0]>1||o[1]>1?uo.Texture.REPEAT:uo.Texture.CLAMP_TO_EDGE,h={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===t){var u=n.get("roughness"),c=n.get("metalness");null!=c?isNaN(c)&&(e.setTextureImage("metalnessMap",c,i,h),c=Sn(n.get("metalnessAdjust"),.5)):c=0,null!=u?isNaN(u)&&(e.setTextureImage("roughnessMap",u,i,h),u=Sn(n.get("roughnessAdjust"),.5)):u=.5;var d=n.get("normalTexture");e.setTextureImage("detailMap",a,i,h),e.setTextureImage("normalMap",d,i,h),e.set({roughness:u,metalness:c,detailUvRepeat:o,detailUvOffset:s})}else if("lambert"===t)e.setTextureImage("detailMap",a,i,h),e.set({detailUvRepeat:o,detailUvOffset:s});else if("color"===t)e.setTextureImage("detailMap",a,i,h),e.set({detailUvRepeat:o,detailUvOffset:s});else if("hatching"===t){var f=n.get("hatchingTextures")||[];f.length;for(var p=0;p<6;p++)e.setTextureImage("hatch"+(p+1),f[p],i,{anisotropic:8,wrapS:uo.Texture.REPEAT,wrapT:uo.Texture.REPEAT});e.set({detailUvRepeat:o,detailUvOffset:s})}},uo.updateVertexAnimation=function(t,e,r,i){var n=i.get("animation"),a=i.get("animationDurationUpdate"),o=i.get("animationEasingUpdate"),s=r.shadowDepthMaterial;if(n&&e&&a>0&&e.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l=0&&this._viewsToDispose.splice(e,1),this.views.push(t),t.layer=this;var r=this.zr;t.scene.traverse((function(t){t.__zr=r,t.addAnimatorsToZr&&t.addAnimatorsToZr(r)}))}},_o.prototype.removeView=function(t){if(t.layer===this){var e=this.views.indexOf(t);e>=0&&(this.views.splice(e,1),t.scene.traverse(vo,this),t.layer=null,this._viewsToDispose.push(t))}},_o.prototype.removeViewsAll=function(){this.views.forEach((function(t){t.scene.traverse(vo,this),t.layer=null,this._viewsToDispose.push(t)}),this),this.views.length=0},_o.prototype.resize=function(t,e){this.renderer.resize(t,e)},_o.prototype.clear=function(){var t=this.renderer.gl,e=this._backgroundColor||[0,0,0,0];t.clearColor(e[0],e[1],e[2],e[3]),t.depthMask(!0),t.colorMask(!0,!0,!0,!0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT)},_o.prototype.clearDepth=function(){var t=this.renderer.gl;t.clear(t.DEPTH_BUFFER_BIT)},_o.prototype.clearColor=function(){var t=this.renderer.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},_o.prototype.needsRefresh=function(){this.zr.refresh()},_o.prototype.refresh=function(t){this._backgroundColor=t?mo.parseColor(t):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var e=0;e20)){t=t.event;var i=this.pickObject(t.offsetX,t.offsetY);i&&(this._dispatchEvent(t.type,t,i),this._dispatchDataEvent(t.type,t,i));var n=this._clickToSetFocusPoint(t);n&&n.view.setDOFFocusOnPoint(n.distance)&&this.zr.refresh()}}},_o.prototype._clickToSetFocusPoint=function(t){for(var e=this.renderer,r=e.viewport,i=this.views.length-1;i>=0;i--){var n=this.views[i];if(n.hasDOF()&&n.containPoint(t.offsetX,t.offsetY)){this._picking.scene=n.scene,this._picking.camera=n.camera,e.viewport=n.viewport;var a=this._picking.pick(t.offsetX,t.offsetY,!0);if(a)return a.view=n,a}}e.viewport=r},_o.prototype.onglobalout=function(t){var e=this._hovered;e&&this._dispatchEvent("mouseout",t,{target:e.target})},_o.prototype.pickObject=function(t,e){for(var r=[],i=this.renderer,n=i.viewport,a=0;a=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",e)),l=!0):null!=s&&s!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",e)),l=!0),this._lastEventData=s,this._lastDataIndex=a,this._lastSeriesIndex=o),c.eventData=s,c.dataIndex=a,c.seriesIndex=o,(null!=s||parseInt(a,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,t,e),l&&this.zr.handler.dispatchToElement(u,"mouseover",e))},_o.prototype._dispatchToView=function(t,e){for(var r=0;rt&&o=0&&(function(t){Ao(t,"itemStyle"),Ao(t,"lineStyle"),Ao(t,"areaStyle"),Ao(t,"label")}(e),"mapbox"===e.coordinateSystem&&(e.coordinateSystem="mapbox3D",t.mapbox3D=t.mapbox))})),Co(t.xAxis3D),Co(t.yAxis3D),Co(t.zAxis3D),Co(t.grid3D),Ao(t.geo3D)}));var Do={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},Lo=i.util.merge({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},Do),Po=i.util.merge({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},Do),Oo=i.util.defaults({scale:!0,min:"dataMin",max:"dataMax"},Po),No=i.util.defaults({logBase:10},Po);No.scale=!0;const Io={categoryAxis3D:Lo,valueAxis3D:Po,timeAxis3D:Oo,logAxis3D:No};function Ro(t){return Ia(t)&&null!=t.value?t.value:t+""}const Bo=function(){function t(t){this.categories=t.categories||[],this._needCollect=t.needCollect,this._deduplication=t.deduplication}return t.createByAxisModel=function(e){var r=e.option,i=r.data,n=i&&Da(i,Ro);return new t({categories:n,needCollect:!n,deduplication:!1!==r.dedplication})},t.prototype.getOrdinal=function(t){return this._getOrCreateMap().get(t)},t.prototype.parseAndCollect=function(t){var e,r=this._needCollect;if("string"!=typeof t&&!r)return t;if(r&&!this._deduplication)return e=this.categories.length,this.categories[e]=t,e;var i=this._getOrCreateMap();return null==(e=i.get(t))&&(r?(e=this.categories.length,this.categories[e]=t,i.set(t,e)):e=NaN),e},t.prototype._getOrCreateMap=function(){return this._map||(this._map=(t=this.categories,new Va(t)));var t},t}();var Fo=["value","category","time","log"];function zo(t,e,r,n){i.util.each(Fo,(function(a){e.extend({type:t+"Axis3D."+a,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){var o=n.getTheme();i.util.merge(e,o.get(a+"Axis3D")),i.util.merge(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=Bo.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:i.util.merge(i.util.clone(Io[a+"Axis3D"]),n||{},!0)})})),e.superClass.registerSubTypeDefaulter(t+"Axis3D",i.util.curry(r,t))}var ko=i.extendComponentModel({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});function Go(t,e){return e.type||(e.data?"category":"value")}i.helper.mixinAxisModelCommonMethods(ko),zo("x",ko,Go,{name:"X"}),zo("y",ko,Go,{name:"Y"}),zo("z",ko,Go,{name:"Z"});const Uo={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(t){t=t||{},this.option.viewControl=this.option.viewControl||{},null!=t.alpha&&(this.option.viewControl.alpha=t.alpha),null!=t.beta&&(this.option.viewControl.beta=t.beta),null!=t.distance&&(this.option.viewControl.distance=t.distance),null!=t.center&&(this.option.viewControl.center=t.center)}},Ho={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},Vo={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}};var Wo=i.extendComponentModel({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});i.util.merge(Wo.prototype,Uo),i.util.merge(Wo.prototype,Ho),i.util.merge(Wo.prototype,Vo);var jo=function(t,e){return(jo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function Xo(t,e){function r(){this.constructor=t}jo(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function qo(){for(var t=0,e=0,r=arguments.length;ep&&(p=y,mp&&(p=x,_=r.x&&t<=r.x+r.width&&e>=r.y&&e<=r.y+r.height},t.prototype.clone=function(){return new t(this.x,this.y,this.width,this.height)},t.prototype.copy=function(e){t.copy(this,e)},t.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},t.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},t.prototype.isZero=function(){return 0===this.width||0===this.height},t.create=function(e){return new t(e.x,e.y,e.width,e.height)},t.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},t.applyTransform=function(e,r,i){if(i){if(i[1]<1e-5&&i[1]>-1e-5&&i[2]<1e-5&&i[2]>-1e-5){var n=i[0],a=i[3],o=i[4],s=i[5];return e.x=r.x*n+o,e.y=r.y*a+s,e.width=r.width*n,e.height=r.height*a,e.width<0&&(e.x+=e.width,e.width=-e.width),void(e.height<0&&(e.y+=e.height,e.height=-e.height))}is.x=as.x=r.x,is.y=os.y=r.y,ns.x=os.x=r.x+r.width,ns.y=as.y=r.y+r.height,is.transform(i),os.transform(i),ns.transform(i),as.transform(i),e.x=es(is.x,ns.x,as.x,os.x),e.y=es(is.y,ns.y,as.y,os.y);var l=rs(is.x,ns.x,as.x,os.x),h=rs(is.y,ns.y,as.y,os.y);e.width=l-e.x,e.height=h-e.y}else e!==r&&t.copy(e,r)},t}();var us,cs,ds={},fs="12px sans-serif",ps=function(t,e){return us||(us=va.createCanvas().getContext("2d")),cs!==e&&(cs=us.font=e||fs),us.measureText(t)};function ms(t,e){var r=ds[e=e||fs];r||(r=ds[e]=new xi(500));var i=r.get(t);return null==i&&(i=ps(t,e).width,r.put(t,i)),i}function gs(t,e,r,i){var n=ms(t,e),a=ys(e),o=_s(0,n,r),s=vs(0,a,i);return new hs(o,s,n,a)}function _s(t,e,r){return"right"===r?t-=e:"center"===r&&(t-=e/2),t}function vs(t,e,r){return"middle"===r?t-=e/2:"bottom"===r&&(t-=e),t}function ys(t){return ms("国",t)}function xs(t,e){return"string"==typeof t?t.lastIndexOf("%")>=0?parseFloat(t)/100*e:parseFloat(t):t}var bs=/\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;function ws(t,e,r,i,n){if(!e)return"";var a=(t+"").split("\n");n=Ts(e,r,i,n);for(var o=0,s=a.length;o=o;l++)s-=o;var h=ms(r,e);return h>s&&(r="",h=0),s=t-h,n.ellipsis=r,n.ellipsisWidth=h,n.contentWidth=s,n.containerWidth=t,n}function Ss(t,e){var r=e.containerWidth,i=e.font,n=e.contentWidth;if(!r)return"";var a=ms(t,i);if(a<=r)return t;for(var o=0;;o++){if(a<=n||o>=e.maxIterations){t+=e.ellipsis;break}var s=0===o?Ms(t,n,e.ascCharWidth,e.cnCharWidth):a>0?Math.floor(t.length*n/a):0;a=ms(t=t.substr(0,s),i)}return""===t&&(t=e.placeholder),t}function Ms(t,e,r,i){for(var n=0,a=0,o=t.length;a=0?parseFloat(s)/100*l:parseFloat(s):s)+m);c.length>0&&g+i.accumWidth>i.width&&(a=e.split("\n"),f=!0),i.accumWidth=g}else{var _=Os(e,d,i.width,i.breakAll,i.accumWidth);i.accumWidth=_.accumWidth+m,o=_.linesWidths,a=_.lines}}else a=e.split("\n");for(var v=0;v=33&&e<=255}(t)||!!Ls[t]}function Os(t,e,r,i,n){for(var a=[],o=[],s="",l="",h=0,u=0,c=0;cr:n+u+f>r)?u?(s||l)&&(p?(s||(s=l,l="",u=h=0),a.push(s),o.push(u-h),l+=d,s="",u=h+=f):(l&&(s+=l,u+=h,l="",h=0),a.push(s),o.push(u),s=d,u=f)):p?(a.push(l),o.push(h),l=d,h=f):(a.push(d),o.push(f)):(u+=f,p?(l+=d,h+=f):(l&&(s+=l,l="",h=0),s+=d))}else l&&(s+=l,u+=h),a.push(s),o.push(u),s="",l="",h=0,u=0}return a.length||s||(s=t,l="",h=0),l&&(s+=l),s&&(a.push(s),o.push(u)),1===a.length&&(u+=n),{accumWidth:u,lines:a,linesWidths:o}}function Ns(t,e){return null==t&&(t=0),null==e&&(e=0),[t,e]}function Is(t){return[t[0],t[1]]}function Rs(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function Bs(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Fs(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function zs(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}var ks=function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])};function Gs(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t}function Us(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Hs(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}var Vs=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t};function Ws(t){return t>5e-5||t<-5e-5}var js=[],Xs=[],qs=[1,0,0,1,0,0],Zs=Math.abs;const Ys=function(){function t(){}return t.prototype.setPosition=function(t){this.x=t[0],this.y=t[1]},t.prototype.setScale=function(t){this.scaleX=t[0],this.scaleY=t[1]},t.prototype.setOrigin=function(t){this.originX=t[0],this.originY=t[1]},t.prototype.needLocalTransform=function(){return Ws(this.rotation)||Ws(this.x)||Ws(this.y)||Ws(this.scaleX-1)||Ws(this.scaleY-1)},t.prototype.updateTransform=function(){var t=this.parent,e=t&&t.transform,r=this.needLocalTransform(),i=this.transform;r||e?(i=i||[1,0,0,1,0,0],r?this.getLocalTransform(i):Vs(i),e&&(r?Qo(i,t.transform,i):Ko(i,t.transform)),this.transform=i,this._resolveGlobalScaleRatio(i)):i&&Vs(i)},t.prototype._resolveGlobalScaleRatio=function(t){var e=this.globalScaleRatio;if(null!=e&&1!==e){this.getGlobalScale(js);var r=js[0]<0?-1:1,i=js[1]<0?-1:1,n=((js[0]-r)*e+r)/js[0]||0,a=((js[1]-i)*e+i)/js[1]||0;t[0]*=n,t[1]*=n,t[2]*=a,t[3]*=a}this.invTransform=this.invTransform||[1,0,0,1,0,0],$o(this.invTransform,t)},t.prototype.getLocalTransform=function(e){return t.getLocalTransform(this,e)},t.prototype.getComputedTransform=function(){for(var t=this,e=[];t;)e.push(t),t=t.parent;for(;t=e.pop();)t.updateTransform();return this.transform},t.prototype.setLocalTransform=function(t){if(t){var e=t[0]*t[0]+t[1]*t[1],r=t[2]*t[2]+t[3]*t[3];Ws(e-1)&&(e=Math.sqrt(e)),Ws(r-1)&&(r=Math.sqrt(r)),t[0]<0&&(e=-e),t[3]<0&&(r=-r),this.rotation=Math.atan2(-t[1]/r,t[0]/e),e<0&&r<0&&(this.rotation+=Math.PI,e=-e,r=-r),this.x=t[4],this.y=t[5],this.scaleX=e,this.scaleY=r}},t.prototype.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(Qo(Xs,t.invTransform,e),e=Xs);var r=this.originX,i=this.originY;(r||i)&&(qs[4]=r,qs[5]=i,Qo(Xs,e,qs),Xs[4]-=r,Xs[5]-=i,e=Xs),this.setLocalTransform(e)}},t.prototype.getGlobalScale=function(t){var e=this.transform;return t=t||[],e?(t[0]=Math.sqrt(e[0]*e[0]+e[1]*e[1]),t[1]=Math.sqrt(e[2]*e[2]+e[3]*e[3]),e[0]<0&&(t[0]=-t[0]),e[3]<0&&(t[1]=-t[1]),t):(t[0]=1,t[1]=1,t)},t.prototype.transformCoordToLocal=function(t,e){var r=[t,e],i=this.invTransform;return i&&Gs(r,r,i),r},t.prototype.transformCoordToGlobal=function(t,e){var r=[t,e],i=this.transform;return i&&Gs(r,r,i),r},t.prototype.getLineScale=function(){var t=this.transform;return t&&Zs(t[0]-1)>1e-10&&Zs(t[3]-1)>1e-10?Math.sqrt(Zs(t[0]*t[3]-t[2]*t[1])):1},t.getLocalTransform=function(t,e){Vs(e=e||[]);var r=t.originX||0,i=t.originY||0,n=t.scaleX,a=t.scaleY,o=t.rotation||0,s=t.x,l=t.y;return e[4]-=r,e[5]-=i,e[0]*=n,e[1]*=a,e[2]*=n,e[3]*=a,e[4]*=n,e[5]*=a,o&&function(t,e,r){var i=e[0],n=e[2],a=e[4],o=e[1],s=e[3],l=e[5],h=Math.sin(r),u=Math.cos(r);t[0]=i*u+o*h,t[1]=-i*h+o*u,t[2]=n*u+s*h,t[3]=-n*h+u*s,t[4]=u*a+h*l,t[5]=u*l-h*a}(e,e,o),e[4]+=r,e[5]+=i,e[4]+=s,e[5]+=l,e},t.initDefaultProps=function(){var e=t.prototype;e.x=0,e.y=0,e.scaleX=1,e.scaleY=1,e.originX=0,e.originY=0,e.rotation=0,e.globalScaleRatio=1}(),t}(),Ks=function(){function t(t){t&&(this._$eventProcessor=t)}return t.prototype.on=function(t,e,r,i){this._$handlers||(this._$handlers={});var n=this._$handlers;if("function"==typeof e&&(i=r,r=e,e=null),!r||!t)return this;var a=this._$eventProcessor;null!=e&&a&&a.normalizeQuery&&(e=a.normalizeQuery(e)),n[t]||(n[t]=[]);for(var o=0;o=11),$s.domSupported="undefined"!=typeof document);const ul=hl;var cl="__zr_normal__",dl=["x","y","scaleX","scaleY","originX","originY","rotation","ignore"],fl={x:!0,y:!0,scaleX:!0,scaleY:!0,originX:!0,originY:!0,rotation:!0,ignore:!1},pl={},ml=new hs(0,0,0,0),gl=function(){function t(t){this.id=ya++,this.animators=[],this.currentStates=[],this.states={},this._init(t)}return t.prototype._init=function(t){this.attr(t)},t.prototype.drift=function(t,e,r){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0}var i=this.transform;i||(i=this.transform=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.markRedraw()},t.prototype.beforeUpdate=function(){},t.prototype.afterUpdate=function(){},t.prototype.update=function(){this.updateTransform(),this.__dirty&&this.updateInnerText()},t.prototype.updateInnerText=function(t){var e=this._textContent;if(e&&(!e.ignore||t)){this.textConfig||(this.textConfig={});var r=this.textConfig,i=r.local,n=e.attachedTransform,a=void 0,o=void 0,s=!1;n.parent=i?this:null;var l=!1;if(n.x=e.x,n.y=e.y,n.originX=e.originX,n.originY=e.originY,n.rotation=e.rotation,n.scaleX=e.scaleX,n.scaleY=e.scaleY,null!=r.position){var h=ml;r.layoutRect?h.copy(r.layoutRect):h.copy(this.getBoundingRect()),i||h.applyTransform(this.transform),this.calculateTextPosition?this.calculateTextPosition(pl,r,h):function(t,e,r){var i=e.position||"inside",n=null!=e.distance?e.distance:5,a=r.height,o=r.width,s=a/2,l=r.x,h=r.y,u="left",c="top";if(i instanceof Array)l+=xs(i[0],r.width),h+=xs(i[1],r.height),u=null,c=null;else switch(i){case"left":l-=n,h+=s,u="right",c="middle";break;case"right":l+=n+o,h+=s,c="middle";break;case"top":l+=o/2,h-=n,u="center",c="bottom";break;case"bottom":l+=o/2,h+=a+n,u="center";break;case"inside":l+=o/2,h+=s,u="center",c="middle";break;case"insideLeft":l+=n,h+=s,c="middle";break;case"insideRight":l+=o-n,h+=s,u="right",c="middle";break;case"insideTop":l+=o/2,h+=n,u="center";break;case"insideBottom":l+=o/2,h+=a-n,u="center",c="bottom";break;case"insideTopLeft":l+=n,h+=n;break;case"insideTopRight":l+=o-n,h+=n,u="right";break;case"insideBottomLeft":l+=n,h+=a-n,c="bottom";break;case"insideBottomRight":l+=o-n,h+=a-n,u="right",c="bottom"}(t=t||{}).x=l,t.y=h,t.align=u,t.verticalAlign=c}(pl,r,h),n.x=pl.x,n.y=pl.y,a=pl.align,o=pl.verticalAlign;var u=r.origin;if(u&&null!=r.rotation){var c=void 0,d=void 0;"center"===u?(c=.5*h.width,d=.5*h.height):(c=xs(u[0],h.width),d=xs(u[1],h.height)),l=!0,n.originX=-n.x+c+(i?0:h.x),n.originY=-n.y+d+(i?0:h.y)}}null!=r.rotation&&(n.rotation=r.rotation);var f=r.offset;f&&(n.x+=f[0],n.y+=f[1],l||(n.originX=-f[0],n.originY=-f[1]));var p=null==r.inside?"string"==typeof r.position&&r.position.indexOf("inside")>=0:r.inside,m=this._innerTextDefaultStyle||(this._innerTextDefaultStyle={}),g=void 0,_=void 0,v=void 0;p&&this.canBeInsideText()?(g=r.insideFill,_=r.insideStroke,null!=g&&"auto"!==g||(g=this.getInsideTextFill()),null!=_&&"auto"!==_||(_=this.getInsideTextStroke(g),v=!0)):(g=r.outsideFill,_=r.outsideStroke,null!=g&&"auto"!==g||(g=this.getOutsideFill()),null!=_&&"auto"!==_||(_=this.getOutsideStroke(g),v=!0)),(g=g||"#000")===m.fill&&_===m.stroke&&v===m.autoStroke&&a===m.align&&o===m.verticalAlign||(s=!0,m.fill=g,m.stroke=_,m.autoStroke=v,m.align=a,m.verticalAlign=o,e.setDefaultTextStyle(m)),s&&e.dirtyStyle(),e.markRedraw()}},t.prototype.canBeInsideText=function(){return!0},t.prototype.getInsideTextFill=function(){return"#fff"},t.prototype.getInsideTextStroke=function(t){return"#000"},t.prototype.getOutsideFill=function(){return this.__zr&&this.__zr.isDarkMode()?sl:ol},t.prototype.getOutsideStroke=function(t){var e=this.__zr&&this.__zr.getBackgroundColor(),r="string"==typeof e&&aa(e);r||(r=[255,255,255,1]);for(var i=r[3],n=this.__zr.isDarkMode(),a=0;a<3;a++)r[a]=r[a]*i+(n?0:255)*(1-i);return r[3]=1,function(t,e){if(t&&t.length){var r=t[0]+","+t[1]+","+t[2];return"rgba"!==e&&"hsva"!==e&&"hsla"!==e||(r+=","+t[3]),e+"("+r+")"}}(r,"rgba")},t.prototype.traverse=function(t,e){},t.prototype.attrKV=function(t,e){"textConfig"===t?this.setTextConfig(e):"textContent"===t?this.setTextContent(e):"clipPath"===t?this.setClipPath(e):"extra"===t?(this.extra=this.extra||{},Ta(this.extra,e)):this[t]=e},t.prototype.hide=function(){this.ignore=!0,this.markRedraw()},t.prototype.show=function(){this.ignore=!1,this.markRedraw()},t.prototype.attr=function(t,e){if("string"==typeof t)this.attrKV(t,e);else if(Ia(t))for(var r=La(t),i=0;i0},t.prototype.getState=function(t){return this.states[t]},t.prototype.ensureState=function(t){var e=this.states;return e[t]||(e[t]={}),e[t]},t.prototype.clearStates=function(t){this.useState(cl,!1,t)},t.prototype.useState=function(e,r,i){var n=e===cl;if(this.hasState()||!n){var a=this.currentStates,o=this.stateTransition;if(!(Ma(a,e)>=0)||!r&&1!==a.length){var s;if(this.stateProxy&&!n&&(s=this.stateProxy(e)),s||(s=this.states&&this.states[e]),s||n){n||this.saveCurrentToNormalState(s);var l=!(!s||!s.hoverLayer);return l&&this._toggleHoverLayerFlag(!0),this._applyStateObj(e,s,this._normalState,r,!i&&!this.__inHover&&o&&o.duration>0,o),this._textContent&&this._textContent.useState(e,r),this._textGuide&&this._textGuide.useState(e,r),n?(this.currentStates=[],this._normalState={}):r?this.currentStates.push(e):this.currentStates=[e],this._updateAnimationTargets(),this.markRedraw(),!l&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~t.REDARAW_BIT),s}xa("State "+e+" not exists.")}}},t.prototype.useStates=function(e,r){if(e.length){var i=[],n=this.currentStates,a=e.length,o=a===n.length;if(o)for(var s=0;s0,d),this._textContent&&this._textContent.useStates(e),this._textGuide&&this._textGuide.useStates(e),this._updateAnimationTargets(),this.currentStates=e.slice(),this.markRedraw(),!u&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~t.REDARAW_BIT)}else this.clearStates()},t.prototype._updateAnimationTargets=function(){for(var t=0;t=0){var r=this.currentStates.slice();r.splice(e,1),this.useStates(r)}},t.prototype.replaceState=function(t,e,r){var i=this.currentStates.slice(),n=Ma(i,t),a=Ma(i,e)>=0;n>=0?a?i.splice(n,1):i[n]=e:r&&!a&&i.push(e),this.useStates(i)},t.prototype.toggleState=function(t,e){e?this.useState(t,!0):this.removeState(t)},t.prototype._mergeStates=function(t){for(var e,r={},i=0;i=0&&e.splice(r,1)})),this.animators.push(t),r&&r.animation.addAnimator(t),r&&r.wakeUp()},t.prototype.updateDuringAnimation=function(t){this.markRedraw()},t.prototype.stopAnimation=function(t,e){for(var r=this.animators,i=r.length,n=[],a=0;a8)&&(n("position","_legacyPos","x","y"),n("scale","_legacyScale","scaleX","scaleY"),n("origin","_legacyOrigin","originX","originY"))}(),t}();function _l(t,e,r,i,n){var a=[];xl(t,"",t,e,r=r||{},i,a,n);var o=a.length,s=!1,l=r.done,h=r.aborted,u=function(){s=!0,--o<=0&&(s?l&&l():h&&h())},c=function(){--o<=0&&(s?l&&l():h&&h())};o||l&&l(),a.length>0&&r.during&&a[0].during((function(t,e){r.during(e)}));for(var d=0;d0||n.force&&!o.length){for(var v=t.animators,y=[],x=0;x-1e-8&&t<1e-8}function kl(t){return t>1e-8||t<-1e-8}function Gl(t,e,r,i,n){var a=1-n;return a*a*(a*t+3*n*e)+n*n*(n*i+3*a*r)}function Ul(t,e,r,i,n){var a=1-n;return 3*(((e-t)*a+2*(r-e)*n)*a+(i-r)*n*n)}function Hl(t,e,r,i,n){var a=6*r-12*e+6*t,o=9*e+3*i-3*t-9*r,s=3*e-3*t,l=0;if(zl(o))kl(a)&&(u=-s/a)>=0&&u<=1&&(n[l++]=u);else{var h=a*a-4*o*s;if(zl(h))n[0]=-a/(2*o);else if(h>0){var u,c=Pl(h),d=(-a-c)/(2*o);(u=(-a+c)/(2*o))>=0&&u<=1&&(n[l++]=u),d>=0&&d<=1&&(n[l++]=d)}}return l}function Vl(t,e,r,i,n,a){var o=(e-t)*n+t,s=(r-e)*n+e,l=(i-r)*n+r,h=(s-o)*n+o,u=(l-s)*n+s,c=(u-h)*n+h;a[0]=t,a[1]=o,a[2]=h,a[3]=c,a[4]=c,a[5]=u,a[6]=l,a[7]=i}function Wl(t,e,r,i,n,a,o,s,l){for(var h=t,u=e,c=0,d=1/l,f=1;f<=l;f++){var p=f*d,m=Gl(t,r,n,o,p),g=Gl(e,i,a,s,p),_=m-h,v=g-u;c+=Math.sqrt(_*_+v*v),h=m,u=g}return c}function jl(t,e,r,i){var n=1-i;return n*(n*t+2*i*e)+i*i*r}function Xl(t,e,r,i){return 2*((1-i)*(e-t)+i*(r-e))}function ql(t,e,r){var i=t+r-2*e;return 0===i?.5:(t-e)/i}function Zl(t,e,r,i,n){var a=(e-t)*i+t,o=(r-e)*i+e,s=(o-a)*i+a;n[0]=t,n[1]=a,n[2]=s,n[3]=s,n[4]=o,n[5]=r}function Yl(t,e,r,i,n,a,o){for(var s=t,l=e,h=0,u=1/o,c=1;c<=o;c++){var d=c*u,f=jl(t,r,n,d),p=jl(e,i,a,d),m=f-s,g=p-l;h+=Math.sqrt(m*m+g*g),s=f,l=p}return h}var Kl=Math.min,Ql=Math.max,Jl=Math.sin,$l=Math.cos,th=2*Math.PI,eh=Ns(),rh=Ns(),ih=Ns();function nh(t,e,r,i,n,a){n[0]=Kl(t,r),n[1]=Kl(e,i),a[0]=Ql(t,r),a[1]=Ql(e,i)}var ah=[],oh=[];function sh(t,e,r,i,n,a,o,s,l,h){var u=Hl,c=Gl,d=u(t,r,n,o,ah);l[0]=1/0,l[1]=1/0,h[0]=-1/0,h[1]=-1/0;for(var f=0;f1e-4)return s[0]=t-r,s[1]=e-i,l[0]=t+r,void(l[1]=e+i);if(eh[0]=$l(n)*r+t,eh[1]=Jl(n)*i+e,rh[0]=$l(a)*r+t,rh[1]=Jl(a)*i+e,h(s,eh,rh),u(l,eh,rh),(n%=th)<0&&(n+=th),(a%=th)<0&&(a+=th),n>a&&!o?a+=th:nn&&(ih[0]=$l(f)*r+t,ih[1]=Jl(f)*i+e,h(s,ih,s),u(l,ih,l))}var uh={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},ch=[],dh=[],fh=[],ph=[],mh=[],gh=[],_h=Math.min,vh=Math.max,yh=Math.cos,xh=Math.sin,bh=Math.sqrt,wh=Math.abs,Th=Math.PI,Sh=2*Th,Mh="undefined"!=typeof Float32Array,Ah=[];function Ch(t){return Math.round(t/Th*1e8)/1e8%2*Th}function Eh(t,e){var r=Ch(t[0]);r<0&&(r+=Sh);var i=r-t[0],n=t[1];n+=i,!e&&n-r>=Sh?n=r+Sh:e&&r-n>=Sh?n=r-Sh:!e&&r>n?n=r+(Sh-Ch(r-n)):e&&r0&&(this._ux=wh(r/al/t)||0,this._uy=wh(r/al/e)||0)},t.prototype.setDPR=function(t){this.dpr=t},t.prototype.setContext=function(t){this._ctx=t},t.prototype.getContext=function(){return this._ctx},t.prototype.beginPath=function(){return this._ctx&&this._ctx.beginPath(),this.reset(),this},t.prototype.reset=function(){this._saveData&&(this._len=0),this._lineDash&&(this._lineDash=null,this._dashOffset=0),this._pathSegLen&&(this._pathSegLen=null,this._pathLen=0),this._version++},t.prototype.moveTo=function(t,e){return this.addData(uh.M,t,e),this._ctx&&this._ctx.moveTo(t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},t.prototype.lineTo=function(t,e){var r=wh(t-this._xi)>this._ux||wh(e-this._yi)>this._uy||this._len<5;return this.addData(uh.L,t,e),this._ctx&&r&&(this._needsDash?this._dashedLineTo(t,e):this._ctx.lineTo(t,e)),r&&(this._xi=t,this._yi=e),this},t.prototype.bezierCurveTo=function(t,e,r,i,n,a){return this.addData(uh.C,t,e,r,i,n,a),this._ctx&&(this._needsDash?this._dashedBezierTo(t,e,r,i,n,a):this._ctx.bezierCurveTo(t,e,r,i,n,a)),this._xi=n,this._yi=a,this},t.prototype.quadraticCurveTo=function(t,e,r,i){return this.addData(uh.Q,t,e,r,i),this._ctx&&(this._needsDash?this._dashedQuadraticTo(t,e,r,i):this._ctx.quadraticCurveTo(t,e,r,i)),this._xi=r,this._yi=i,this},t.prototype.arc=function(t,e,r,i,n,a){Ah[0]=i,Ah[1]=n,Eh(Ah,a),i=Ah[0];var o=(n=Ah[1])-i;return this.addData(uh.A,t,e,r,r,i,o,0,a?0:1),this._ctx&&this._ctx.arc(t,e,r,i,n,a),this._xi=yh(n)*r+t,this._yi=xh(n)*r+e,this},t.prototype.arcTo=function(t,e,r,i,n){return this._ctx&&this._ctx.arcTo(t,e,r,i,n),this},t.prototype.rect=function(t,e,r,i){return this._ctx&&this._ctx.rect(t,e,r,i),this.addData(uh.R,t,e,r,i),this},t.prototype.closePath=function(){this.addData(uh.Z);var t=this._ctx,e=this._x0,r=this._y0;return t&&(this._needsDash&&this._dashedLineTo(e,r),t.closePath()),this._xi=e,this._yi=r,this},t.prototype.fill=function(t){t&&t.fill(),this.toStatic()},t.prototype.stroke=function(t){t&&t.stroke(),this.toStatic()},t.prototype.setLineDash=function(t){if(t instanceof Array){this._lineDash=t,this._dashIdx=0;for(var e=0,r=0;rh.length&&(this._expandData(),h=this.data);for(var u=0;u0&&f<=t||u<0&&f>=t||0===u&&(c>0&&p<=e||c<0&&p>=e);)f+=u*(r=a[i=this._dashIdx]),p+=c*r,this._dashIdx=(i+1)%m,u>0&&fl||c>0&&ph||o[i%2?"moveTo":"lineTo"](u>=0?_h(f,t):vh(f,t),c>=0?_h(p,e):vh(p,e));u=f-t,c=p-e,this._dashOffset=-bh(u*u+c*c)},t.prototype._dashedBezierTo=function(t,e,r,i,n,a){var o,s,l,h,u,c=this._ctx,d=this._dashSum,f=this._dashOffset,p=this._lineDash,m=this._xi,g=this._yi,_=0,v=this._dashIdx,y=p.length,x=0;for(f<0&&(f=d+f),f%=d,o=0;o<1;o+=.1)s=Gl(m,t,r,n,o+.1)-Gl(m,t,r,n,o),l=Gl(g,e,i,a,o+.1)-Gl(g,e,i,a,o),_+=bh(s*s+l*l);for(;vf);v++);for(o=(x-f)/_;o<=1;)h=Gl(m,t,r,n,o),u=Gl(g,e,i,a,o),v%2?c.moveTo(h,u):c.lineTo(h,u),o+=p[v]/_,v=(v+1)%y;v%2!=0&&c.lineTo(n,a),s=n-h,l=a-u,this._dashOffset=-bh(s*s+l*l)},t.prototype._dashedQuadraticTo=function(t,e,r,i){var n=r,a=i;r=(r+2*t)/3,i=(i+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,r,i,n,a)},t.prototype.toStatic=function(){if(this._saveData){var t=this.data;t instanceof Array&&(t.length=this._len,Mh&&this._len>11&&(this.data=new Float32Array(t)))}},t.prototype.getBoundingRect=function(){fh[0]=fh[1]=mh[0]=mh[1]=Number.MAX_VALUE,ph[0]=ph[1]=gh[0]=gh[1]=-Number.MAX_VALUE;var t,e=this.data,r=0,i=0,n=0,a=0;for(t=0;tr||wh(g)>i||c===e-1)&&(p=Math.sqrt(D*D+g*g),n=m,a=y);break;case uh.C:var _=t[c++],v=t[c++],y=(m=t[c++],t[c++]),x=t[c++],b=t[c++];p=Wl(n,a,_,v,m,y,x,b,10),n=x,a=b;break;case uh.Q:p=Yl(n,a,_=t[c++],v=t[c++],m=t[c++],y=t[c++],10),n=m,a=y;break;case uh.A:var w=t[c++],T=t[c++],S=t[c++],M=t[c++],A=t[c++],C=t[c++],E=C+A;c+=1,t[c++],f&&(o=yh(A)*S+w,s=xh(A)*M+T),p=vh(S,M)*_h(Sh,Math.abs(C)),n=yh(E)*S+w,a=xh(E)*M+T;break;case uh.R:o=n=t[c++],s=a=t[c++],p=2*t[c++]+2*t[c++];break;case uh.Z:var D=o-n;g=s-a,p=Math.sqrt(D*D+g*g),n=o,a=s}p>=0&&(l[u++]=p,h+=p)}return this._pathLen=h,h},t.prototype.rebuildPath=function(t,e){var r,i,n,a,o,s,l,h,u=this.data,c=this._ux,d=this._uy,f=this._len,p=e<1,m=0,g=0;if(!p||(this._pathSegLen||this._calculateLength(),l=this._pathSegLen,h=e*this._pathLen))t:for(var _=0;_c||wh(s-a)>d||_===f-1){if(p){if(m+(H=l[g++])>h){var x=(h-m)/H;t.lineTo(n*(1-x)+o*x,a*(1-x)+s*x);break t}m+=H}t.lineTo(o,s),n=o,a=s}break;case uh.C:var b=u[_++],w=u[_++],T=u[_++],S=u[_++],M=u[_++],A=u[_++];if(p){if(m+(H=l[g++])>h){Vl(n,b,T,M,x=(h-m)/H,ch),Vl(a,w,S,A,x,dh),t.bezierCurveTo(ch[1],dh[1],ch[2],dh[2],ch[3],dh[3]);break t}m+=H}t.bezierCurveTo(b,w,T,S,M,A),n=M,a=A;break;case uh.Q:if(b=u[_++],w=u[_++],T=u[_++],S=u[_++],p){if(m+(H=l[g++])>h){Zl(n,b,T,x=(h-m)/H,ch),Zl(a,w,S,x,dh),t.quadraticCurveTo(ch[1],dh[1],ch[2],dh[2]);break t}m+=H}t.quadraticCurveTo(b,w,T,S),n=T,a=S;break;case uh.A:var C=u[_++],E=u[_++],D=u[_++],L=u[_++],P=u[_++],O=u[_++],N=u[_++],I=!u[_++],R=D>L?D:L,B=wh(D-L)>.001,F=P+O,z=!1;if(p&&(m+(H=l[g++])>h&&(F=P+O*(h-m)/H,z=!0),m+=H),B&&t.ellipse?t.ellipse(C,E,D,L,N,P,F,I):t.arc(C,E,R,P,F,I),z)break t;y&&(r=yh(P)*D+C,i=xh(P)*L+E),n=yh(F)*D+C,a=xh(F)*L+E;break;case uh.R:r=n=u[_],i=a=u[_+1],o=u[_++],s=u[_++];var k=u[_++],G=u[_++];if(p){if(m+(H=l[g++])>h){var U=h-m;t.moveTo(o,s),t.lineTo(o+_h(U,k),s),(U-=k)>0&&t.lineTo(o+k,s+_h(U,G)),(U-=G)>0&&t.lineTo(o+vh(k-U,0),s+G),(U-=k)>0&&t.lineTo(o,s+vh(G-U,0));break t}m+=H}t.rect(o,s,k,G);break;case uh.Z:if(p){var H;if(m+(H=l[g++])>h){x=(h-m)/H,t.lineTo(n*(1-x)+r*x,a*(1-x)+i*x);break t}m+=H}t.closePath(),n=r,a=i}}},t.CMD=uh,t.initDefaultProps=function(){var e=t.prototype;e._saveData=!0,e._needsDash=!1,e._dashOffset=0,e._dashIdx=0,e._dashSum=0,e._ux=0,e._uy=0}(),t}();function Lh(t,e,r,i,n,a,o){if(0===n)return!1;var s,l=n;if(o>e+l&&o>i+l||ot+l&&a>r+l||ae+c&&u>i+c&&u>a+c&&u>s+c||ut+c&&h>r+c&&h>n+c&&h>o+c||h=0&&p<_?(c=d,_=p):(Fl[0]=Gl(t,r,n,o,f),Fl[1]=Gl(e,i,a,s,f),m=ks(Fl,Rl),f<=1&&m<_?(c=f,_=m):g*=.5);return Pl(_)}(t,e,r,i,n,a,o,s,h,u)<=c/2}function Oh(t,e,r,i,n,a,o,s,l){if(0===o)return!1;var h=o;return!(l>e+h&&l>i+h&&l>a+h||lt+h&&s>r+h&&s>n+h||s=0&&gr||u+hn&&(n+=Rh);var d=Math.atan2(l,s);return d<0&&(d+=Rh),d>=i&&d<=n||d+Rh>=i&&d+Rh<=n}function Fh(t,e,r,i,n,a){if(a>e&&a>i||an?s:0}var zh=Dh.CMD,kh=2*Math.PI,Gh=[-1,-1,-1],Uh=[-1,-1];function Hh(){var t=Uh[0];Uh[0]=Uh[1],Uh[1]=t}function Vh(t,e,r,i,n,a,o,s,l,h){if(h>e&&h>i&&h>a&&h>s||h=0&&S<=1&&(a[f++]=S);else{var p=c*c-4*u*d;if(zl(p)){var m=c/u,g=-m/2;(S=-s/o+m)>=0&&S<=1&&(a[f++]=S),g>=0&&g<=1&&(a[f++]=g)}else if(p>0){var _=Pl(p),v=u*s+1.5*o*(-c+_),y=u*s+1.5*o*(-c-_);(S=(-s-((v=v<0?-Ll(-v,Il):Ll(v,Il))+(y=y<0?-Ll(-y,Il):Ll(y,Il))))/(3*o))>=0&&S<=1&&(a[f++]=S)}else{var x=(2*u*s-3*o*c)/(2*Pl(u*u*u)),b=Math.acos(x)/3,w=Pl(u),T=Math.cos(b),S=(-s-2*w*T)/(3*o),M=(g=(-s+w*(T+Nl*Math.sin(b)))/(3*o),(-s+w*(T-Nl*Math.sin(b)))/(3*o));S>=0&&S<=1&&(a[f++]=S),g>=0&&g<=1&&(a[f++]=g),M>=0&&M<=1&&(a[f++]=M)}}return f}(e,i,a,s,h,Gh);if(0===u)return 0;for(var c=0,d=-1,f=void 0,p=void 0,m=0;m1&&Hh(),f=Gl(e,i,a,s,Uh[0]),d>1&&(p=Gl(e,i,a,s,Uh[1]))),2===d?ge&&s>i&&s>a||s=0&&u<=1&&(n[l++]=u);else{var h=o*o-4*a*s;if(zl(h))(u=-o/(2*a))>=0&&u<=1&&(n[l++]=u);else if(h>0){var u,c=Pl(h),d=(-o-c)/(2*a);(u=(-o+c)/(2*a))>=0&&u<=1&&(n[l++]=u),d>=0&&d<=1&&(n[l++]=d)}}return l}(e,i,a,s,Gh);if(0===l)return 0;var h=ql(e,i,a);if(h>=0&&h<=1){for(var u=0,c=jl(e,i,a,h),d=0;dr||s<-r)return 0;var l=Math.sqrt(r*r-s*s);Gh[0]=-l,Gh[1]=l;var h=Math.abs(i-n);if(h<1e-4)return 0;if(h>=kh-1e-4){i=0,n=kh;var u=a?1:-1;return o>=Gh[0]+t&&o<=Gh[1]+t?u:0}if(i>n){var c=i;i=n,n=c}i<0&&(i+=kh,n+=kh);for(var d=0,f=0;f<2;f++){var p=Gh[f];if(p+t>o){var m=Math.atan2(s,p);u=a?1:-1,m<0&&(m=kh+m),(m>=i&&m<=n||m+kh>=i&&m+kh<=n)&&(m>Math.PI/2&&m<1.5*Math.PI&&(u=-u),d+=u)}}return d}function Xh(t,e,r,i,n){for(var a,o,s,l,h=t.data,u=t.len(),c=0,d=0,f=0,p=0,m=0,g=0;g1&&(r||(c+=Fh(d,f,p,m,i,n))),v&&(p=d=h[g],m=f=h[g+1]),_){case zh.M:d=p=h[g++],f=m=h[g++];break;case zh.L:if(r){if(Lh(d,f,h[g],h[g+1],e,i,n))return!0}else c+=Fh(d,f,h[g],h[g+1],i,n)||0;d=h[g++],f=h[g++];break;case zh.C:if(r){if(Ph(d,f,h[g++],h[g++],h[g++],h[g++],h[g],h[g+1],e,i,n))return!0}else c+=Vh(d,f,h[g++],h[g++],h[g++],h[g++],h[g],h[g+1],i,n)||0;d=h[g++],f=h[g++];break;case zh.Q:if(r){if(Oh(d,f,h[g++],h[g++],h[g],h[g+1],e,i,n))return!0}else c+=Wh(d,f,h[g++],h[g++],h[g],h[g+1],i,n)||0;d=h[g++],f=h[g++];break;case zh.A:var y=h[g++],x=h[g++],b=h[g++],w=h[g++],T=h[g++],S=h[g++];g+=1;var M=!!(1-h[g++]);a=Math.cos(T)*b+y,o=Math.sin(T)*w+x,v?(p=a,m=o):c+=Fh(d,f,a,o,i,n);var A=(i-y)*w/b+y;if(r){if(Bh(y,x,w,T,T+S,M,e,A,n))return!0}else c+=jh(y,x,w,T,T+S,M,A,n);d=Math.cos(T+S)*b+y,f=Math.sin(T+S)*w+x;break;case zh.R:if(p=d=h[g++],m=f=h[g++],a=p+h[g++],o=m+h[g++],r){if(Lh(p,m,a,m,e,i,n)||Lh(a,m,a,o,e,i,n)||Lh(a,o,p,o,e,i,n)||Lh(p,o,p,m,e,i,n))return!0}else c+=Fh(a,m,a,o,i,n),c+=Fh(p,o,p,m,i,n);break;case zh.Z:if(r){if(Lh(d,f,p,m,e,i,n))return!0}else c+=Fh(d,f,p,m,i,n);d=p,f=m}}return r||(s=f,l=m,Math.abs(s-l)<1e-4)||(c+=Fh(d,f,p,m,i,n)||0),0!==c}var qh=Sa({fill:"#000",stroke:null,strokePercent:1,fillOpacity:1,strokeOpacity:1,lineDashOffset:0,lineWidth:1,lineCap:"butt",miterLimit:10,strokeNoScale:!1,strokeFirst:!1},Tl),Zh={style:Sa({fill:!0,stroke:!0,strokePercent:!0,fillOpacity:!0,strokeOpacity:!0,lineDashOffset:!0,lineWidth:!0,miterLimit:!0},Sl.style)},Yh=["x","y","rotation","scaleX","scaleY","originX","originY","invisible","culling","z","z2","zlevel","parent"];const Kh=function(t){function e(e){return t.call(this,e)||this}var r;return Xo(e,t),e.prototype.update=function(){var r=this;t.prototype.update.call(this);var i=this.style;if(i.decal){var n=this._decalEl=this._decalEl||new e;n.buildPath===e.prototype.buildPath&&(n.buildPath=function(t){r.buildPath(t,r.shape)}),n.silent=!0;var a=n.style;for(var o in i)a[o]!==i[o]&&(a[o]=i[o]);a.fill=i.fill?i.decal:null,a.decal=null,a.shadowColor=null,i.strokeFirst&&(a.stroke=null);for(var s=0;s.5?ol:e>.2?"#eee":sl}if(t)return sl}return ol},e.prototype.getInsideTextStroke=function(t){var e=this.style.fill;if(Na(e)){var r=this.__zr;if(!(!r||!r.isDarkMode())==sa(t,0)<.4)return e}},e.prototype.buildPath=function(t,e,r){},e.prototype.pathUpdated=function(){this.__dirty&=~e.SHAPE_CHANGED_BIT},e.prototype.createPathProxy=function(){this.path=new Dh(!1)},e.prototype.hasStroke=function(){var t=this.style,e=t.stroke;return!(null==e||"none"===e||!(t.lineWidth>0))},e.prototype.hasFill=function(){var t=this.style.fill;return null!=t&&"none"!==t},e.prototype.getBoundingRect=function(){var t=this._rect,r=this.style,i=!t;if(i){var n=!1;this.path||(n=!0,this.createPathProxy());var a=this.path;(n||this.__dirty&e.SHAPE_CHANGED_BIT)&&(a.beginPath(),this.buildPath(a,this.shape,!1),this.pathUpdated()),t=a.getBoundingRect()}if(this._rect=t,this.hasStroke()&&this.path&&this.path.len()>0){var o=this._rectWithStroke||(this._rectWithStroke=t.clone());if(this.__dirty||i){o.copy(t);var s=r.strokeNoScale?this.getLineScale():1,l=r.lineWidth;if(!this.hasFill()){var h=this.strokeContainThreshold;l=Math.max(l,null==h?4:h)}s>1e-10&&(o.width+=l/s,o.height+=l/s,o.x-=l/s/2,o.y-=l/s/2)}return o}return t},e.prototype.contain=function(t,e){var r=this.transformCoordToLocal(t,e),i=this.getBoundingRect(),n=this.style;if(t=r[0],e=r[1],i.contain(t,e)){var a=this.path;if(this.hasStroke()){var o=n.lineWidth,s=n.strokeNoScale?this.getLineScale():1;if(s>1e-10&&(this.hasFill()||(o=Math.max(o,this.strokeContainThreshold)),function(t,e,r,i){return Xh(t,e,!0,r,i)}(a,o/s,t,e)))return!0}if(this.hasFill())return function(t,e,r){return Xh(t,0,!1,e,r)}(a,t,e)}return!1},e.prototype.dirtyShape=function(){this.__dirty|=e.SHAPE_CHANGED_BIT,this._rect&&(this._rect=null),this._decalEl&&this._decalEl.dirtyShape(),this.markRedraw()},e.prototype.dirty=function(){this.dirtyStyle(),this.dirtyShape()},e.prototype.animateShape=function(t){return this.animate("shape",t)},e.prototype.updateDuringAnimation=function(t){"style"===t?this.dirtyStyle():"shape"===t?this.dirtyShape():this.markRedraw()},e.prototype.attrKV=function(e,r){"shape"===e?this.setShape(r):t.prototype.attrKV.call(this,e,r)},e.prototype.setShape=function(t,e){var r=this.shape;return r||(r=this.shape={}),"string"==typeof t?r[t]=e:Ta(r,t),this.dirtyShape(),this},e.prototype.shapeChanged=function(){return!!(this.__dirty&e.SHAPE_CHANGED_BIT)},e.prototype.createStyle=function(t){return ja(qh,t)},e.prototype._innerSaveToNormal=function(e){t.prototype._innerSaveToNormal.call(this,e);var r=this._normalState;e.shape&&!r.shape&&(r.shape=Ta({},this.shape))},e.prototype._applyStateObj=function(e,r,i,n,a,o){t.prototype._applyStateObj.call(this,e,r,i,n,a,o);var s,l=!(r&&n);if(r&&r.shape?a?n?s=r.shape:(s=Ta({},i.shape),Ta(s,r.shape)):(s=Ta({},n?this.shape:i.shape),Ta(s,r.shape)):l&&(s=i.shape),s)if(a){this.shape=Ta({},this.shape);for(var h={},u=La(s),c=0;c0},e.prototype.hasFill=function(){var t=this.style.fill;return null!=t&&"none"!==t},e.prototype.createStyle=function(t){return ja(Qh,t)},e.prototype.setBoundingRect=function(t){this._rect=t},e.prototype.getBoundingRect=function(){var t=this.style;if(!this._rect){var e=t.text;null!=e?e+="":e="";var r=function(t,e,r,i){var n=((t||"")+"").split("\n");if(1===n.length)return gs(n[0],e,r,i);for(var a=new hs(0,0,0,0),o=0;oh&&(r*=h/(o=r+i),i*=h/o),n+a>h&&(n*=h/(o=n+a),a*=h/o),i+n>u&&(i*=u/(o=i+n),n*=u/o),r+a>u&&(r*=u/(o=r+a),a*=u/o),t.moveTo(s+r,l),t.lineTo(s+h-i,l),0!==i&&t.arc(s+h-i,l+i,i,-Math.PI/2,0),t.lineTo(s+h,l+u-n),0!==n&&t.arc(s+h-n,l+u-n,n,0,Math.PI/2),t.lineTo(s+a,l+u),0!==a&&t.arc(s+a,l+u-a,a,Math.PI/2,Math.PI),t.lineTo(s,l+r),0!==r&&t.arc(s+r,l+r,r,Math.PI,1.5*Math.PI)}(t,e):t.rect(r,i,n,a)},e.prototype.isZeroArea=function(){return!this.shape.width||!this.shape.height},e}(Kh);lu.prototype.type="rect";const hu=lu;var uu={fill:"#000"},cu={style:Sa({fill:!0,stroke:!0,fillOpacity:!0,strokeOpacity:!0,lineWidth:!0,fontSize:!0,lineHeight:!0,width:!0,height:!0,textShadowColor:!0,textShadowBlur:!0,textShadowOffsetX:!0,textShadowOffsetY:!0,backgroundColor:!0,padding:!0,borderColor:!0,borderWidth:!0,borderRadius:!0},Sl.style)},du=function(t){function e(e){var r=t.call(this)||this;return r.type="text",r._children=[],r._defaultStyle=uu,r.attr(e),r}return Xo(e,t),e.prototype.childrenRef=function(){return this._children},e.prototype.update=function(){this.styleChanged()&&this._updateSubTexts();for(var e=0;ed&&h){var f=Math.floor(d/l);r=r.slice(0,f)}var p=d,m=u;if(n&&(p+=n[0]+n[2],null!=m&&(m+=n[1]+n[3])),t&&o&&null!=m)for(var g=Ts(u,a,e.ellipsis,{minChar:e.truncateMinChar,placeholder:e.placeholder}),_=0;_0,M=null!=t.width&&("truncate"===t.overflow||"break"===t.overflow||"breakAll"===t.overflow),A=i.calculatedLineHeight,C=0;Cl&&Ds(r,t.substring(l,h),e,s),Ds(r,i[2],e,s,i[1]),l=bs.lastIndex}la){w>0?(y.tokens=y.tokens.slice(0,w),_(y,b,x),r.lines=r.lines.slice(0,v+1)):r.lines=r.lines.slice(0,v);break t}var E=T.width,D=null==E||"auto"===E;if("string"==typeof E&&"%"===E.charAt(E.length-1))N.percentWidth=E,c.push(N),N.contentWidth=ms(N.text,A);else{if(D){var L=T.backgroundColor,P=L&&L.image;P&&((u=P=Yo(P))&&u.width&&u.height)&&(N.width=Math.max(N.width,P.width*C/P.height))}var O=m&&null!=n?n-b:null;null!=O&&O=0&&"right"===(C=y[A]).align;)this._placeToken(C,t,b,p,M,"right",g),w-=C.width,M-=C.width,A--;for(S+=(r-(S-f)-(m-M)-w)/2;T<=A;)C=y[T],this._placeToken(C,t,b,p,S+C.width/2,"center",g),S+=C.width,T++;p+=b}},e.prototype._placeToken=function(t,e,r,i,n,a,o){var s=e.rich[t.styleName]||{};s.text=t.text;var l=t.verticalAlign,h=i+r/2;"top"===l?h=i+t.height/2:"bottom"===l&&(h=i+r-t.height/2),!t.isLineHolder&&yu(s)&&this._renderBackground(s,e,"right"===a?n-t.width:"center"===a?n-t.width/2:n,h-t.height/2,t.width,t.height);var u=!!s.backgroundColor,c=t.textPadding;c&&(n=_u(n,a,c),h-=t.height/2-c[0]-t.innerHeight/2);var d=this._getOrCreateChild($h),f=d.createStyle();d.useStyle(f);var p=this._defaultStyle,m=!1,g=0,_=gu("fill"in s?s.fill:"fill"in e?e.fill:(m=!0,p.fill)),v=gu("stroke"in s?s.stroke:"stroke"in e?e.stroke:u||o||p.autoStroke&&!m?null:(g=2,p.stroke)),y=s.textShadowBlur>0||e.textShadowBlur>0;f.text=t.text,f.x=n,f.y=h,y&&(f.shadowBlur=s.textShadowBlur||e.textShadowBlur||0,f.shadowColor=s.textShadowColor||e.textShadowColor||"transparent",f.shadowOffsetX=s.textShadowOffsetX||e.textShadowOffsetX||0,f.shadowOffsetY=s.textShadowOffsetY||e.textShadowOffsetY||0),f.textAlign=a,f.textBaseline="middle",f.font=t.font||fs,f.opacity=za(s.opacity,e.opacity,1),v&&(f.lineWidth=za(s.lineWidth,e.lineWidth,g),f.lineDash=Fa(s.lineDash,e.lineDash),f.lineDashOffset=e.lineDashOffset||0,f.stroke=v),_&&(f.fill=_);var x=t.contentWidth,b=t.contentHeight;d.setBoundingRect(new hs(_s(f.x,x,f.textAlign),vs(f.y,b,f.textBaseline),x,b))},e.prototype._renderBackground=function(t,e,r,i,n,a){var o,s,l,h=t.backgroundColor,u=t.borderWidth,c=t.borderColor,d=Na(h),f=t.borderRadius,p=this;if(d||u&&c){(o=this._getOrCreateChild(hu)).useStyle(o.createStyle()),o.style.fill=null;var m=o.shape;m.x=r,m.y=i,m.width=n,m.height=a,m.r=f,o.dirtyShape()}if(d)(l=o.style).fill=h||null,l.fillOpacity=Fa(t.fillOpacity,1);else if(h&&h.image){(s=this._getOrCreateChild(iu)).onload=function(){p.dirtyStyle()};var g=s.style;g.image=h.image,g.x=r,g.y=i,g.width=n,g.height=a}u&&c&&((l=o.style).lineWidth=u,l.stroke=c,l.strokeOpacity=Fa(t.strokeOpacity,1),l.lineDash=t.borderDash,l.lineDashOffset=t.borderDashOffset||0,o.strokeContainThreshold=0,o.hasFill()&&o.hasStroke()&&(l.strokeFirst=!0,l.lineWidth*=2));var _=(o||s).style;_.shadowBlur=t.shadowBlur||0,_.shadowColor=t.shadowColor||"transparent",_.shadowOffsetX=t.shadowOffsetX||0,_.shadowOffsetY=t.shadowOffsetY||0,_.opacity=za(t.opacity,e.opacity,1)},e.makeFont=function(t){var e="";if(t.fontSize||t.fontFamily||t.fontWeight){var r="";r="string"!=typeof t.fontSize||-1===t.fontSize.indexOf("px")&&-1===t.fontSize.indexOf("rem")&&-1===t.fontSize.indexOf("em")?isNaN(+t.fontSize)?"12px":t.fontSize+"px":t.fontSize,e=[t.fontStyle,t.fontWeight,r,t.fontFamily||"sans-serif"].join(" ")}return e&&Ua(e)||t.textFont||t.font},e}(Dl),fu={left:!0,right:1,center:1},pu={top:1,bottom:1,middle:1};function mu(t){if(t){t.font=du.makeFont(t);var e=t.align;"middle"===e&&(e="center"),t.align=null==e||fu[e]?e:"left";var r=t.verticalAlign;"center"===r&&(r="middle"),t.verticalAlign=null==r||pu[r]?r:"top",t.padding&&(t.padding=Ga(t.padding))}}function gu(t,e){return null==t||e<=0||"transparent"===t||"none"===t?null:t.image||t.colorStops?"#000":t}function _u(t,e,r){return"right"===e?t-r[1]:"center"===e?t+r[3]/2-r[1]/2:t+r[3]}function vu(t){var e=t.text;return null!=e&&(e+=""),e}function yu(t){return!!(t.backgroundColor||t.borderWidth&&t.borderColor)}const xu=du;function bu(t,e){switch(t){case"center":case"middle":t="50%";break;case"left":case"top":t="0%";break;case"right":case"bottom":t="100%"}return"string"==typeof t?(r=t,r.replace(/^\s+|\s+$/g,"")).match(/%$/)?parseFloat(t)/100*e:parseFloat(t):null==t?NaN:+t;var r}function wu(){var t="__ec_inner_"+Tu++;return function(e){return e[t]||(e[t]={})}}"undefined"!=typeof console&&console.warn&&console.log;var Tu=Math.round(9*Math.random());wu(),wu(),new xi(100),Dh.CMD,Math.sqrt,Math.atan2,Math.sqrt,Math.sin,Math.cos,Math.PI,function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Xo(e,t),e.prototype.applyTransform=function(t){}}(Kh),function(t){function e(e){var r=t.call(this)||this;return r.isGroup=!0,r._children=[],r.attr(e),r}return Xo(e,t),e.prototype.childrenRef=function(){return this._children},e.prototype.children=function(){return this._children.slice()},e.prototype.childAt=function(t){return this._children[t]},e.prototype.childOfName=function(t){for(var e=this._children,r=0;r=0&&(r.splice(i,0,t),this._doAdd(t))}return this},e.prototype.replaceAt=function(t,e){var r=this._children,i=r[e];if(t&&t!==this&&t.parent!==this&&t!==i){r[e]=t,i.parent=null;var n=this.__zr;n&&i.removeSelfFromZr(n),this._doAdd(t)}return this},e.prototype._doAdd=function(t){t.parent&&t.parent.remove(t),t.parent=this;var e=this.__zr;e&&e!==t.__zr&&t.addSelfToZr(e),e&&e.refresh()},e.prototype.remove=function(t){var e=this.__zr,r=this._children,i=Ma(r,t);return i<0||(r.splice(i,1),t.parent=null,e&&t.removeSelfFromZr(e),e&&e.refresh()),this},e.prototype.removeAll=function(){for(var t=this._children,e=this.__zr,r=0;rL*L+P*P&&(S=A,M=C),{cx:S,cy:M,x01:-u,y01:-c,x11:S*(n/b-1),y11:M*(n/b-1)}}var Hu=function(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=2*Math.PI,this.clockwise=!0,this.cornerRadius=0,this.innerCornerRadius=0},Vu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new Hu},e.prototype.buildPath=function(t,e){!function(t,e){var r=zu(e.r,0),i=zu(e.r0||0,0),n=r>0;if(n||i>0){if(n||(r=i,i=0),i>r){var a=r;r=i,i=a}var o=!!e.clockwise,s=e.startAngle,l=e.endAngle,h=[s,l];Eh(h,!o);var u=Bu(h[0]-h[1]),c=e.cx,d=e.cy,f=e.cornerRadius||0,p=e.innerCornerRadius||0;if(r>Gu)if(u>Pu-Gu)t.moveTo(c+r*Nu(s),d+r*Ou(s)),t.arc(c,d,r,s,l,!o),i>Gu&&(t.moveTo(c+i*Nu(l),d+i*Ou(l)),t.arc(c,d,i,l,s,o));else{var m=Bu(r-i)/2,g=ku(m,f),_=ku(m,p),v=_,y=g,x=r*Nu(s),b=r*Ou(s),w=i*Nu(l),T=i*Ou(l),S=void 0,M=void 0,A=void 0,C=void 0;if((g>Gu||_>Gu)&&(S=r*Nu(l),M=r*Ou(l),A=i*Nu(s),C=i*Ou(s),uGu)if(y>Gu){var R=Uu(A,C,x,b,r,y,o),B=Uu(S,M,w,T,r,y,o);t.moveTo(c+R.cx+R.x01,d+R.cy+R.y01),yGu&&u>Gu?v>Gu?(R=Uu(w,T,S,M,i,-v,o),B=Uu(x,b,A,C,i,-v,o),t.lineTo(c+R.cx+R.x01,d+R.cy+R.y01),v<_?t.arc(c+R.cx,d+R.cy,v,Ru(R.y01,R.x01),Ru(B.y01,B.x01),!o):(t.arc(c+R.cx,d+R.cy,v,Ru(R.y01,R.x01),Ru(R.y11,R.x11),!o),t.arc(c,d,i,Ru(R.cy+R.y11,R.cx+R.x11),Ru(B.cy+B.y11,B.cx+B.x11),o),t.arc(c+B.cx,d+B.cy,v,Ru(B.y11,B.x11),Ru(B.y01,B.x01),!o))):(t.lineTo(c+w,d+T),t.arc(c,d,i,l,s,o)):t.lineTo(c+w,d+T)}else t.moveTo(c,d);t.closePath()}}(t,e)},e.prototype.isZeroArea=function(){return this.shape.startAngle===this.shape.endAngle||this.shape.r===this.shape.r0},e}(Kh);Vu.prototype.type="sector";const Wu=Vu;var ju=function(){this.cx=0,this.cy=0,this.r=0,this.r0=0},Xu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new ju},e.prototype.buildPath=function(t,e){var r=e.cx,i=e.cy,n=2*Math.PI;t.moveTo(r+e.r,i),t.arc(r,i,e.r,0,n,!1),t.moveTo(r+e.r0,i),t.arc(r,i,e.r0,0,n,!0)},e}(Kh);Xu.prototype.type="ring";const qu=Xu;function Zu(t,e,r,i,n,a,o){var s=.5*(r-t),l=.5*(i-e);return(2*(e-r)+s+l)*o+(-3*(e-r)-2*s-l)*a+s*n+e}function Yu(t,e,r){var i=e.smooth,n=e.points;if(n&&n.length>=2){if(i&&"spline"!==i){var a=function(t,e,r,i){var n,a,o,s,l=[],h=[],u=[],c=[];if(i){o=[1/0,1/0],s=[-1/0,-1/0];for(var d=0,f=t.length;dr-2?r-1:l+1],f=t[l>r-3?r-1:l+2]);var p=h*h,m=h*p;i.push([Zu(u[0],c[0],d[0],f[0],h,p,m),Zu(u[1],c[1],d[1],f[1],h,p,m)])}return i}(n,r)),t.moveTo(n[0][0],n[0][1]),s=1;for(var c=n.length;s_c[1]){if(o=!1,n)return o;var h=Math.abs(_c[0]-gc[1]),u=Math.abs(gc[0]-_c[1]);Math.min(h,u)>i.len()&&(h0&&this._notFirst?this.animateTo({alpha:h,beta:u,center:c,distance:a,orthographicSize:o,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(h),this.setBeta(u),this.setCenter(c),this.setOrthographicSize(o)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(t){var e=this.zr,r=this,i={},n={};return null!=t.distance&&(i.distance=this.getDistance(),n.distance=t.distance),null!=t.orthographicSize&&(i.orthographicSize=this.getOrthographicSize(),n.orthographicSize=t.orthographicSize),null!=t.alpha&&(i.alpha=this.getAlpha(),n.alpha=t.alpha),null!=t.beta&&(i.beta=this.getBeta(),n.beta=t.beta),null!=t.center&&(i.center=this.getCenter(),n.center=t.center),this._addAnimator(e.animation.animate(i).when(t.duration||1e3,n).during((function(){null!=i.alpha&&r.setAlpha(i.alpha),null!=i.beta&&r.setBeta(i.beta),null!=i.distance&&r.setDistance(i.distance),null!=i.center&&r.setCenter(i.center),null!=i.orthographicSize&&r.setOrthographicSize(i.orthographicSize),r._needsUpdate=!0}))).start(t.easing||"linear")},stopAllAnimation:function(){for(var t=0;t0},_update:function(t){if(this._rotating){var e=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=e*t/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(t=Math.min(t,50),this._updateDistanceOrSize(t),this._updatePan(t),this._updateRotate(t),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(t){var e=this._rotateVelocity;this._phi=e.y*t/20+this._phi,this._theta=e.x*t/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(e,Math.pow(this.damping,t/16))},_updateDistanceOrSize:function(t){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*t/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*t/20),this._zoomSpeed*=Math.pow(this.damping,t/16)},_setDistance:function(t){this._distance=Math.max(Math.min(t,this.maxDistance),this.minDistance)},_setOrthoSize:function(t){this._orthoSize=Math.max(Math.min(t,this.maxOrthographicSize),this.minOrthographicSize);var e=this.getCamera(),r=this._orthoSize,i=r/this.viewGL.viewport.height*this.viewGL.viewport.width;e.left=-i/2,e.right=i/2,e.top=r/2,e.bottom=-r/2},_updatePan:function(t){var e=this._panVelocity,r=this._distance,i=this.getCamera(),n=i.worldTransform.y,a=i.worldTransform.x;this._center.scaleAndAdd(a,-e.x*r/200).scaleAndAdd(n,-e.y*r/200),this._vectorDamping(e,0)},_updateTransform:function(){var t=this.getCamera(),e=new ve,r=this._theta+Math.PI/2,i=this._phi+Math.PI/2,n=Math.sin(r);e.x=n*Math.cos(i),e.y=-Math.cos(r),e.z=n*Math.sin(i),t.position.copy(this._center).scaleAndAdd(e,this._distance),t.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var t=this.autoRotateAfterStill,e=this;!isNaN(t)&&t>0&&(this._stillTimeout=setTimeout((function(){e._rotating=!0}),1e3*t))},_vectorDamping:function(t,e){var r=t.len();(r*=e)<1e-4&&(r=0),t.normalize().scale(r)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var t=this.getCamera().worldTransform.z,e=Math.asin(t.y),r=Math.atan2(t.x,t.z);this._theta=e,this._phi=-r,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(t){if(!t.target&&!this._isAnimating()){var e=t.offsetX,r=t.offsetY;this.viewGL&&!this.viewGL.containPoint(e,r)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),t.event.targetTouches?1===t.event.targetTouches.length&&(this._mode="rotate"):t.event.button===Lc[this.rotateMouseButton]?this._mode="rotate":t.event.button===Lc[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t.offsetX,this._mouseY=t.offsetY)}},_mouseMoveHandler:function(t){if(!(t.target&&t.target.__isGLToZRProxy||this._isAnimating())){var e=Pc(this.panSensitivity),r=Pc(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(t.offsetX-this._mouseX)/this.zr.getHeight()*2*r[0],this._rotateVelocity.x=(t.offsetY-this._mouseY)/this.zr.getWidth()*2*r[1]):"pan"===this._mode&&(this._panVelocity.x=(t.offsetX-this._mouseX)/this.zr.getWidth()*e[0]*400,this._panVelocity.y=(-t.offsetY+this._mouseY)/this.zr.getHeight()*e[1]*400),this._mouseX=t.offsetX,this._mouseY=t.offsetY,t.event.preventDefault()}},_mouseWheelHandler:function(t){if(!this._isAnimating()){var e=t.event.wheelDelta||-t.event.detail;this._zoomHandler(t,e)}},_pinchHandler:function(t){this._isAnimating()||(this._zoomHandler(t,t.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(t,e){if(0!==e){var r,i=t.offsetX,n=t.offsetY;this.viewGL&&!this.viewGL.containPoint(i,n)||(r="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(e>0?-1:1)*r*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),t.event.preventDefault())}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(t){this._isRightMouseButtonUsed()&&t.preventDefault()},_addAnimator:function(t){var e=this._animators;return e.push(t),t.done((function(){var r=e.indexOf(t);r>=0&&e.splice(r,1)})),t}});Object.defineProperty(Oc.prototype,"autoRotate",{get:function(t){return this._autoRotate},set:function(t){this._autoRotate=t,this._rotating=t}});const Nc=Oc,Ic={convertToDynamicArray:function(t){t&&this.resetOffset();var e=this.attributes;for(var r in e)t||!e[r].value?e[r].value=[]:e[r].value=Array.prototype.slice.call(e[r].value);t||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var t=this.attributes;for(var e in t)t[e].value&&t[e].value.length>0?t[e].value=new Float32Array(t[e].value):t[e].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},Rc={vec2:pt,vec3:Qt,vec4:Ce,mat2:Bn,mat2d:Gn,mat3:De,mat4:Yt,quat:Re};var Bc=Rc.vec3,Fc=[[0,0],[1,1]],zc=Ur.extend((function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new Ur.Attribute("position","float",3,"POSITION"),positionPrev:new Ur.Attribute("positionPrev","float",3),positionNext:new Ur.Attribute("positionNext","float",3),prevPositionPrev:new Ur.Attribute("prevPositionPrev","float",3),prevPosition:new Ur.Attribute("prevPosition","float",3),prevPositionNext:new Ur.Attribute("prevPositionNext","float",3),offset:new Ur.Attribute("offset","float",1),color:new Ur.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(t){var e=this.attributes;this.vertexCount!==t&&(e.position.init(t),e.color.init(t),this.useNativeLine||(e.positionPrev.init(t),e.positionNext.init(t),e.offset.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/(Bc.dist(t,e)+Bc.dist(r,e)+Bc.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(Fc)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Fc)},getPolylineVertexCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/3,this.useNativeLine?2*(e-1):2*(e-1)+2},getPolylineTriangleCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/3,this.useNativeLine?0:2*Math.max(e-1,0)},addCubicCurve:function(t,e,r,i,n,a){null==a&&(a=1);var o=t[0],s=t[1],l=t[2],h=e[0],u=e[1],c=e[2],d=r[0],f=r[1],p=r[2],m=i[0],g=i[1],_=i[2],v=this._getCubicCurveApproxStep(t,e,r,i),y=v*v,x=y*v,b=3*v,w=3*y,T=6*y,S=6*x,M=o-2*h+d,A=s-2*u+f,C=l-2*c+p,E=3*(h-d)-o+m,D=3*(u-f)-s+g,L=3*(c-p)-l+_,P=o,O=s,N=l,I=(h-o)*b+M*w+E*x,R=(u-s)*b+A*w+D*x,B=(c-l)*b+C*w+L*x,F=M*T+E*S,z=A*T+D*S,k=C*T+L*S,G=E*S,U=D*S,H=L*S,V=0,W=0,j=Math.ceil(1/v),X=new Float32Array(3*(j+1)),q=(X=[],0);for(W=0;W1&&(P=I>0?Math.min(P,m):Math.max(P,m),O=R>0?Math.min(O,g):Math.max(O,g),N=B>0?Math.min(N,_):Math.max(N,_));return this.addPolyline(X,n,a)},addLine:function(t,e,r,i){return this.addPolyline([t,e],r,i)},addPolyline:function(t,e,r,i,n){if(t.length){var a="number"!=typeof t[0];if(null==n&&(n=a?t.length:t.length/3),!(n<2)){null==i&&(i=0),null==r&&(r=1),this._itemVertexOffsets.push(this._vertexOffset);var o,s,l=(a="number"!=typeof t[0])?"number"!=typeof e[0]:e.length/4===n,h=this.attributes.position,u=this.attributes.positionPrev,c=this.attributes.positionNext,d=this.attributes.color,f=this.attributes.offset,p=this.indices,m=this._vertexOffset;r=Math.max(r,.01);for(var g=i;g1&&(h.copy(m,m-1),d.copy(m,m-1),m++):(g0&&(c.set(m-2,o),c.set(m-1,o)),h.set(m,o),h.set(m+1,o),d.set(m,s),d.set(m+1,s),f.set(m,r/2),f.set(m+1,-r/2),m+=2),this.useNativeLine)d.set(m,s),h.set(m,o),m++;else if(g>0){var y=3*this._triangleOffset;(p=this.indices)[y]=m-4,p[y+1]=m-3,p[y+2]=m-2,p[y+3]=m-3,p[y+4]=m-1,p[y+5]=m-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*n;u.copy(x,x+2),u.copy(x+1,x+3),c.copy(b-1,b-3),c.copy(b-2,b-4)}return this._vertexOffset=m,this._vertexOffset}}},setItemColor:function(t,e){for(var r=this._itemVertexOffsets[t],i=to&&(n=this._x=0,a+=this._rowHeight+l,this._y=a,this._rowHeight=0),this._x+=e+l,this._rowHeight=Math.max(this._rowHeight,r),a+r+l>s)return null;t.x+=this.offsetX*this.dpr+n,t.y+=this.offsetY*this.dpr+a,this._zr.add(t);var h=[this.offsetX/this.width,this.offsetY/this.height];return[[n/o+h[0],a/s+h[1]],[(n+e)/o+h[0],(a+r)/s+h[1]]]},_fitElement:function(t,e,r){var i=t.getBoundingRect(),n=e/i.width,a=r/i.height;t.x=-i.x*n,t.y=-i.y*a,t.scaleX=n,t.scaleY=a,t.update()}},Uc.prototype={clear:function(){for(var t=0;t=t)){var n=(r+this._nodeWidth)*this._dpr,a=(i+this._nodeHeight)*this._dpr;try{this._zr.resize({width:n,height:a})}catch(t){this._canvas.width=n,this._canvas.height=a}var o=new Gc(this._zr,r,i,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(o),o}},add:function(t,e,r){if(this._coords[t.id])return this._coords[t.id];var i=this._getCurrentNode().add(t,e,r);if(!i){var n=this._expand();if(!n)return;i=n.add(t,e,r)}return this._coords[t.id]=i,i},getCoordsScale:function(){var t=this._dpr;return[this._nodeWidth/this._canvas.width*t,this._nodeHeight/this._canvas.height*t]},getCoords:function(t){return this._coords[t]}};const Hc=Uc;function Vc(){}Vc.prototype={constructor:Vc,setScene:function(t){this._scene=t,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(t){this._lightRoot=t,this.mainLight=new mo.DirectionalLight({shadowBias:.005}),this.ambientLight=new mo.AmbientLight,t.add(this.mainLight),t.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(t){var e=this.mainLight,r=this.ambientLight,i=t.getModel("light"),n=i.getModel("main"),a=i.getModel("ambient");e.intensity=n.get("intensity"),r.intensity=a.get("intensity"),e.color=mo.parseColor(n.get("color")).slice(0,3),r.color=mo.parseColor(a.get("color")).slice(0,3);var o=n.get("alpha")||0,s=n.get("beta")||0;e.position.setArray(mo.directionFromAlphaBeta(o,s)),e.lookAt(mo.Vector3.ZERO),e.castShadow=n.get("shadow"),e.shadowResolution=mo.getShadowResolution(n.get("shadowQuality"))},updateAmbientCubemap:function(t,e,r){var i=e.getModel("light.ambientCubemap"),n=i.get("texture");if(n){this._cubemapLightsCache=this._cubemapLightsCache||{};var a=this._cubemapLightsCache[n];if(!a){var o=this;a=this._cubemapLightsCache[n]=mo.createAmbientCubemap(i.option,t,r,(function(){o._isSkyboxFromAmbientCubemap&&o._skybox.setEnvironmentMap(a.specular.cubemap),r.getZr().refresh()}))}this._lightRoot.add(a.diffuse),this._lightRoot.add(a.specular),this._currentCubemapLights=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(t,e,r){var n=e.get("environment"),a=this,o=(a._skybox=a._skybox||new Wi,a._skybox);if(n&&"none"!==n)if("auto"===n)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var s=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(s),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"==typeof n&&n.colorStops||"string"==typeof n&&i.color.parse(n)){this._isSkyboxFromAmbientCubemap=!1;var l=new mo.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(l);var h=l.image=document.createElement("canvas");h.width=h.height=16;var u=h.getContext("2d"),c=new i.graphic.Rect({shape:{x:0,y:0,width:16,height:16},style:{fill:n}});i.innerDrawElementOnCanvas(u,c),o.attachScene(this._scene)}else this._isSkyboxFromAmbientCubemap=!1,l=mo.loadTexture(n,r,{anisotropic:8,flipY:!1}),o.setEnvironmentMap(l),o.attachScene(this._scene);else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var d=e.coordinateSystem;if(this._skybox)if(!d||!d.viewGL||"auto"===n||n.match&&n.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var f=d.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[f]("fragment","SRGB_DECODE")}}};const Wc=Vc;var jc=Rc.vec3,Xc=Ur.extend((function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new Ur.Attribute("position","float",3,"POSITION"),normal:new Ur.Attribute("normal","float",3,"NORMAL"),color:new Ur.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(t){var e=this.attributes,r=this.getQuadVertexCount()*t,i=this.getQuadTriangleCount()*t;this.vertexCount!==r&&(e.position.init(r),e.normal.init(r),e.color.init(r)),this.triangleCount!==i&&(this.indices=r>65535?new Uint32Array(3*i):new Uint16Array(3*i))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var t=jc.create(),e=jc.create(),r=jc.create(),i=[0,3,1,3,2,1];return function(n,a){var o=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;jc.sub(t,n[1],n[0]),jc.sub(e,n[2],n[1]),jc.cross(r,t,e),jc.normalize(r,r);for(var h=0;h<4;h++)o.set(this._vertexOffset+h,n[h]),l.set(this._vertexOffset+h,a),s.set(this._vertexOffset+h,r);var u=3*this._faceOffset;for(h=0;h<6;h++)this.indices[u+h]=i[h]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});i.util.defaults(Xc.prototype,Ic);const qc=Xc;var Zc=Sn,Yc={x:0,y:2,z:1};function Kc(t,e,r){this.rootNode=new mo.Node;var i=new mo.Mesh({geometry:new kc({useNativeLine:!1}),material:e,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),n=new mo.Mesh({geometry:new qc,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(n),this.rootNode.add(i),this.faceInfo=t,this.plane=new mo.Plane,this.linesMesh=i,this.quadsMesh=n}Kc.prototype.update=function(t,e,r){var i=t.coordinateSystem,n=[i.getAxis(this.faceInfo[0]),i.getAxis(this.faceInfo[1])],a=this.linesMesh.geometry,o=this.quadsMesh.geometry;a.convertToDynamicArray(!0),o.convertToDynamicArray(!0),this._updateSplitLines(a,n,t,r),this._udpateSplitAreas(o,n,t,r),a.convertToTypedArray(),o.convertToTypedArray();var s=i.getAxis(this.faceInfo[2]);!function(t,e,r,i){var n=[0,0,0],a=i<0?r.getExtentMin():r.getExtentMax();n[Yc[r.dim]]=a,t.position.setArray(n),t.rotation.identity(),e.distance=-Math.abs(a),e.normal.set(0,0,0),"x"===r.dim?(t.rotation.rotateY(i*Math.PI/2),e.normal.x=-i):"z"===r.dim?(t.rotation.rotateX(-i*Math.PI/2),e.normal.y=-i):(i>0&&t.rotation.rotateY(Math.PI),e.normal.z=-i)}(this.rootNode,this.plane,s,this.faceInfo[3])},Kc.prototype._updateSplitLines=function(t,e,r,n){var a=n.getDevicePixelRatio();e.forEach((function(n,o){var s=n.model,l=e[1-o].getExtent();if(!n.scale.isBlank()){var h=s.getModel("splitLine",r.getModel("splitLine"));if(h.get("show")){var u=h.getModel("lineStyle"),c=u.get("color"),d=Zc(u.get("opacity"),1),f=Zc(u.get("width"),1);c=i.util.isArray(c)?c:[c];for(var p=n.getTicksCoords({tickModel:h}),m=0,g=0;g65535?new Uint32Array(3*r):new Uint16Array(3*r))},setSpriteAlign:function(t,e,r,i,n){var a,o,s,l;switch(null==r&&(r="left"),null==i&&(i="top"),n=n||0,r){case"left":a=n,s=e[0]+n;break;case"center":case"middle":a=-e[0]/2,s=e[0]/2;break;case"right":a=-e[0]-n,s=-n}switch(i){case"bottom":o=n,l=e[1]+n;break;case"middle":o=-e[1]/2,l=e[1]/2;break;case"top":o=-e[1]-n,l=-n}var h=4*t,u=this.attributes.offset;u.set(h,[a,l]),u.set(h+1,[s,l]),u.set(h+2,[s,o]),u.set(h+3,[a,o])},addSprite:function(t,e,r,i,n,a){var o=this._vertexOffset;this.setSprite(this._vertexOffset/4,t,e,r,i,n,a);for(var s=0;s 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end";var ld=Sn;mo.Shader.import(sd),["x","y","z"].forEach((function(t){i.extendComponentView({type:t+"Axis3D"})}));var hd={x:0,y:2,z:1};i.extendComponentView({type:"grid3D",__ecgl__:!0,init:function(t,e){var r=new mo.Material({shader:mo.createShader("ecgl.color"),depthMask:!1,transparent:!0}),i=new mo.Material({shader:mo.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});r.define("fragment","DOUBLE_SIDED"),r.define("both","VERTEX_COLOR"),this.groupGL=new mo.Node,this._control=new Nc({zr:e.getZr()}),this._control.init(),this._faces=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]].map((function(t){var e=new Qc(t,i,r);return this.groupGL.add(e.rootNode),e}),this),this._axes=["x","y","z"].map((function(t){var e=new od(t,i);return this.groupGL.add(e.rootNode),e}),this);var n=e.getDevicePixelRatio();this._axisLabelSurface=new Hc({width:256,height:256,devicePixelRatio:n}),this._axisLabelSurface.onupdate=function(){e.getZr().refresh()},this._axisPointerLineMesh=new mo.Mesh({geometry:new kc({useNativeLine:!1}),material:i,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new Hc({width:128,height:128,devicePixelRatio:n}),this._axisPointerLabelsMesh=new ed({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new mo.Node,this._sceneHelper=new Wc,this._sceneHelper.initLight(this._lightRoot)},render:function(t,e,r){this._model=t,this._api=r;var i=t.coordinateSystem;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._axisLabelSurface.clear(),n.off("update"),t.get("show")&&(this._faces.forEach((function(i){i.update(t,e,r)}),this),this._axes.forEach((function(e){e.update(t,this._axisLabelSurface,r)}),this)),n.on("update",this._onCameraChange.bind(this,t,r),this),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(t),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._initMouseHandler(t)},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r)},showAxisPointer:function(t,e,r,i){this._doShowAxisPointer(),this._updateAxisPointer(i.value)},hideAxisPointer:function(t,e,r,i){this._doHideAxisPointer()},_initMouseHandler:function(t){var e=t.coordinateSystem.viewGL;t.get("show")&&t.get("axisPointer.show")?e.on("mousemove",this._updateAxisPointerOnMousePosition,this):e.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(t){if(!t.target){for(var e,r=this._model.coordinateSystem,i=r.viewGL,n=i.castRay(t.offsetX,t.offsetY,new mo.Ray),a=0;ai[1]?0:1,o=this._faces[2*r+a],s=this._faces[2*r+1-a];o.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var t=this._model.coordinateSystem,e=t.getAxis("x"),r=t.getAxis("y"),i=t.getAxis("z"),n=i.getExtentMax(),a=i.getExtentMin(),o=e.getExtentMin(),s=e.getExtentMax(),l=r.getExtentMax(),h=r.getExtentMin(),u=this._axes[0].rootNode,c=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,p=f[4].rootNode.invisible?h:l,m=f[2].rootNode.invisible?n:a,g=f[0].rootNode.invisible?o:s,_=f[2].rootNode.invisible?n:a,v=f[0].rootNode.invisible?s:o,y=f[4].rootNode.invisible?h:l;u.rotation.identity(),c.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,u.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,c.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),u.position.set(0,m,p),c.position.set(g,_,0),d.position.set(v,0,y),u.update(),c.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var t=this._control.getCamera(),e=[new mo.Vector4,new mo.Vector4],r=new mo.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(t.viewMatrix).transformMat4(t.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach((function(i){for(var n=i.axisLineCoords,a=(i.labelsMesh.geometry,0);ar.y?"bottom":"top"):(s="middle",o=u>r.x?"left":"right"),i.setSpriteAlign(o,s,this._api)}),this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(t){var e=this._model.coordinateSystem,r=e.dataToPoint(t),i=this._axisPointerLineMesh.geometry,n=this._model.getModel("axisPointer"),a=this._api.getDevicePixelRatio();function o(t){return Sn(t.model.get("axisPointer.show"),n.get("show"))}function s(t){var e=t.model.getModel("axisPointer",n).getModel("lineStyle"),r=mo.parseColor(e.get("color")),i=ld(e.get("width"),1),a=ld(e.get("opacity"),1);return r[3]*=a,{color:r,lineWidth:i}}i.convertToDynamicArray(!0);for(var l=0;l=0||n&&Ma(n,s)<0)){var l=r.getShallow(s,e);null!=l&&(a[t[o][0]]=l)}}return a}}var xd=yd([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]]),bd=function(){function t(){}return t.prototype.getAreaStyle=function(t,e){return xd(this,t,e)},t}(),wd=["textStyle","color"],Td=new xu;const Sd=function(){function t(){}return t.prototype.getTextColor=function(t){var e=this.ecModel;return this.getShallow("color")||(!t&&e?e.get(wd):null)},t.prototype.getFont=function(){return t={fontStyle:this.getShallow("fontStyle"),fontWeight:this.getShallow("fontWeight"),fontSize:this.getShallow("fontSize"),fontFamily:this.getShallow("fontFamily")},r=(e=this.ecModel)&&e.getModel("textStyle"),Ua([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 Td.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")}),Td.update(),Td.getBoundingRect()},t}();var Md,Ad,Cd,Ed=yd([["lineWidth","width"],["stroke","color"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"],["lineDash","type"],["lineDashOffset","dashOffset"],["lineCap","cap"],["lineJoin","join"],["miterLimit"]]),Dd=function(){function t(){}return t.prototype.getLineStyle=function(t){return Ed(this,t)},t}(),Ld=yd([["fill","color"],["stroke","borderColor"],["lineWidth","borderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"],["lineDash","borderType"],["lineDashOffset","borderDashOffset"],["lineCap","borderCap"],["lineJoin","borderJoin"],["miterLimit","borderMiterLimit"]]),Pd=function(){function t(){}return t.prototype.getItemStyle=function(t,e){return Ld(this,t,e)},t}(),Od=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;ni||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)}))}function kd(t,e,r){r=Fd(r||0);var i=e.width,n=e.height,a=bu(t.left,i),o=bu(t.top,n),s=bu(t.right,i),l=bu(t.bottom,n),h=bu(t.width,i),u=bu(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 hs(a+r[3],o+r[0],h,u);return p.margin=r,p}Pa(zd,"vertical"),Pa(zd,"horizontal");var Gd=function(){this._pool={},this._allocatedTextures=[]};Gd.prototype={constructor:Gd,get:function(t){var e=Vd(t);this._pool.hasOwnProperty(e)||(this._pool[e]=[]);var r=this._pool[e];if(!r.length){var i=new Er(t);return this._allocatedTextures.push(i),i}return r.pop()},put:function(t){var e=Vd(t);this._pool.hasOwnProperty(e)||(this._pool[e]=[]),this._pool[e].push(t)},clear:function(t){for(var e=0;e 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 Zd,Yd,Kd,Qd,Jd,$d,tf,ef=m.extend((function(){return{softShadow:ef.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 Fi,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new Wd}}),(function(){this._gaussianPassH=new fn({fragment:Xt.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new fn({fragment:Xt.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 fn({fragment:Xt.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===ef.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===ef.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;i4){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;f0?v.define("fragment",_,g):v.isDefined("fragment",_)&&v.undefine("fragment",_))}for(f=0;f0){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 b=c.slice(),w=c.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),u.reverse(),y.shadowCascadeClipsNear={value:b,type:"1fv"},y.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var T=s.map(S);(y=e.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},y.spotLightMatrices={value:l,type:"m4v"},y.spotLightShadowMapSizes={value:T,type:"1fv"}}d.length>0&&(y.pointLightShadowMaps={value:d,type:"tv"})}function S(t){return t.height}},renderDirectionalLightShadow:(Zd=new oi,Yd=new Ve,Kd=new ir,Qd=new Ve,Jd=new Ve,$d=new Ve,tf=new Ve,function(t,e,r,i,n,a,o){var s=this._getDepthMaterial(i),l={getMaterial:function(t){return t.shadowDepthMaterial||s},isMaterialChanged:qd,getUniform:Xd,ifRender:function(t){return t.castShadow},sortCompare:ue.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=$d.array;tf.copy(d.projectionMatrix),Yt.invert(Jd.array,d.worldTransform.array),Yt.multiply(Jd.array,Jd.array,r.worldTransform.array),Yt.multiply(f,tf.array,Jd.array);for(var p=[],m=r instanceof Ai,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,b=y*i.cascadeSplitLogFactor+x*(1-i.cascadeSplitLogFactor);p.push(b),n.push(-(-b*g+_)/-b)}var w=this._getTexture(i,i.shadowCascade);o.push(w);var T=t.viewport,S=t.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(t),S.clear(S.COLOR_BUFFER_BIT|S.DEPTH_BUFFER_BIT),v=0;vd?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;r0&&(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]))}}),af=m.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=r.COLOR_ATTACHMENT0&&u<=r.COLOR_ATTACHMENT0+8&&h.push(u);l.drawBuffersEXT(h)}t.saveClear(),t.clearBit=16640,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}}),lf=nf.extend((function(){return{texture:null,outputs:{color:{}}}}),(function(){}),{getOutput:function(t,e){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),hf=nf.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 fn({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(){nf.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),uf="@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",cf="\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",df="@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",ff="@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",pf="@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",mf="\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",gf="@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",_f="@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",vf="@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";!function(t){t.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),t.import(uf),t.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),t.import(cf),t.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),t.import(df),t.import(ff),t.import(pf),t.import(mf),t.import(gf),t.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),t.import(_f),t.import(vf)}(Xt);var yf=/^#source\((.*?)\)/;function xf(t,e,r){var i,n,a,o,s=t.type||"filter";if("filter"===s){var l=t.shader.trim(),h=yf.exec(l);if(h?i=Xt.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=Tf(c.parameters))}if(o="scene"===s?new sf({name:t.name,scene:r.scene,camera:r.camera,outputs:a}):"texture"===s?new lf({name:t.name,outputs:a}):new hf({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",Sf(u,Mf(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 bf(t,e){return t}function wf(t,e){return e}function Tf(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=br[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=Mf(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=bf),e.height||(e.height=wf),null!=t.useMipmap&&(e.useMipmap=t.useMipmap),e}function Sf(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 Mf(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.")}}const Af=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 Cf(t){for(var e=new Uint8Array(t*t*4),r=0,i=new ve,n=0;n 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"),Lf.prototype.setDepthTexture=function(t){this._depthTex=t},Lf.prototype.setNormalTexture=function(t){this._normalTex=t,this._ssaoPass.material[t?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},Lf.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 Ve;Ve.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])},Lf.prototype.getTargetTexture=function(){return this._blurTexture2},Lf.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)},Lf.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]=Df(t,e*t,!!this._normalTex)},Lf.prototype.setNoiseSize=function(t){var e=this._ssaoPass.getUniform("noiseTex");e?(e.data=Cf(t),e.width=e.height=t,e.dirty()):(e=Ef(t),this._ssaoPass.setUniform("noiseTex",Ef(t))),this._ssaoPass.setUniform("noiseTexSize",[t,t])},Lf.prototype.dispose=function(t){this._blurTexture.dispose(t),this._ssaoTexture.dispose(t),this._blurTexture2.dispose(t)};const Pf=Lf;function Of(t){t=t||{},this._ssrPass=new fn({fragment:Xt.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new fn({fragment:Xt.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new fn({fragment:Xt.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new fn({fragment:Xt.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 Er({type:br.HALF_FLOAT}),this._texture2=new Er({type:br.HALF_FLOAT}),this._texture3=new Er({type:br.HALF_FLOAT}),this._prevTexture=new Er({type:br.HALF_FLOAT}),this._currentTexture=new Er({type:br.HALF_FLOAT}),this._frameBuffer=new Fi({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}Xt.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"),Of.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")},Of.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 Ve,m=new Ve;Ve.transpose(p,e.worldTransform),Ve.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=_}},Of.prototype.getTargetTexture=function(){return this._texture3},Of.prototype.setParameter=function(t,e){"maxIteration"===t?this._ssrPass.material.define("fragment","MAX_ITERATION",e):this._ssrPass.setUniform(t,e)},Of.prototype.setPhysicallyCorrect=function(t){t?(this._normalDistribution||(this._normalDistribution=gn.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},Of.prototype.setSSAOTexture=function(t){var e=this._blurPass2;t?(e.material.enableTexture("ssaoTex"),e.material.set("ssaoTex",t)):e.material.disableTexture("ssaoTex")},Of.prototype.isFinished=function(t){return!this._physicallyCorrect||t>this._totalSamples/this._samplePerFrame},Of.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)};const Nf=Of,If=[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 Rf(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 Bf(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"),b=d.get("detailUvOffset"),w=!!_&&d.isTextureEnabled("bumpMap"),T=!!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",w),u.set("useRoughnessMap",T),u.set("doubleSide",S),null!=v&&u.set("uvRepeat",v),null!=y&&u.set("uvOffset",y),null!=x&&u.set("detailUvRepeat",x),null!=b&&u.set("detailUvOffset",b),u.set("roughness",p)):(f.setUniform(h,"1f","roughness",p),a!==m&&Rf(t,f,"normalMap",m,0),o!==_&&_&&Rf(t,f,"bumpMap",_,1),s!==g&&g&&Rf(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!=b&&f.setUniform(h,"2f","detailUvOffset",b),f.setUniform(h,"1i","useBumpMap",+w),f.setUniform(h,"1i","useRoughnessMap",+T),f.setUniform(h,"1i","doubleSide",+S)),a=m,o=_,s=g,l=n}}}function Ff(t){t=t||{},this._depthTex=new Er({format:br.DEPTH_COMPONENT,type:br.UNSIGNED_INT}),this._normalTex=new Er({type:br.HALF_FLOAT}),this._framebuffer=new Fi,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,Fi.DEPTH_ATTACHMENT),this._normalMaterial=new lt({shader:new Xt(Xt.source("ecgl.normal.vertex"),Xt.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=nn.createBlank("#000"),this._defaultBumpMap=nn.createBlank("#000"),this._defaultRoughessMap=nn.createBlank("#000"),this._debugPass=new fn({fragment:Xt.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}Xt.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"),Ff.prototype.getDepthTexture=function(){return this._depthTex},Ff.prototype.getNormalTexture=function(){return this._normalTex},Ff.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:Bf(t,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:t.opaqueSortCompare}),this._framebuffer.unbind(t)},Ff.prototype.renderDebug=function(t){this._debugPass.render(t)},Ff.prototype.dispose=function(t){this._depthTex.dispose(t),this._normalTex.dispose(t)};const zf=Ff;function kf(t){t=t||{},this._edgePass=new fn({fragment:Xt.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",t.normalTexture),this._edgePass.setUniform("depthTexture",t.depthTexture),this._targetTexture=new Er({type:br.HALF_FLOAT}),this._frameBuffer=new Fi,this._frameBuffer.attach(this._targetTexture)}kf.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)},kf.prototype.getTargetTexture=function(){return this._targetTexture},kf.prototype.setParameter=function(t,e){this._edgePass.setUniform(t,e)},kf.prototype.dispose=function(t){this._targetTexture.dispose(t),this._frameBuffer.dispose(t)};const Gf=kf,Uf={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 Hf(t,e){return{color:{parameters:{width:t,height:e}}}}Xt.import(uf),Xt.import(cf),Xt.import(df),Xt.import(ff),Xt.import(pf),Xt.import(mf),Xt.import(gf),Xt.import(_f),Xt.import(vf),Xt.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"),Xt.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 Vf=["composite","FXAA"];function Wf(){this._width,this._height,this._dpr,this._sourceTexture=new Er({type:br.HALF_FLOAT}),this._depthTexture=new Er({format:br.DEPTH_COMPONENT,type:br.UNSIGNED_INT}),this._framebuffer=new Fi,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,Fi.DEPTH_ATTACHMENT),this._normalPass=new zf,this._compositor=function(t,e){var r=new of;e=e||{};var i={textures:{},parameters:{}};for(var n in t.parameters){var a=t.parameters[n];i.parameters[n]=Tf(a)}return function(t,e,r,i){if(t.textures){var n={},a=0,o=!1,s=r.textureRootPath;f.each(t.textures,(function(t,e){var r,l=t.path,h=Tf(t.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map((function(t){return f.relative2absolute(t,s)}))),r=new Mi(h);else{if("string"!=typeof l)return;s&&(l=f.relative2absolute(l,s)),r=new Er(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=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)}};const qf=Xf;function Zf(t){t=t||"perspective",this.layer=null,this.scene=new _i,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(t),this._compositor=new jf,this._temporalSS=new qf,this._shadowMapPass=new rf;for(var e=[],r=0,i=0;i<30;i++){for(var n=[],a=0;a<6;a++)n.push(4*Af(r,2)-2),n.push(4*Af(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)}Zf.prototype.setProjection=function(t){var e=this.camera;e&&e.update(),"perspective"===t?this.camera instanceof Ai||(this.camera=new Ai,e&&this.camera.setLocalTransform(e.localTransform)):this.camera instanceof hn||(this.camera=new hn,e&&this.camera.setLocalTransform(e.localTransform)),this.camera.near=.1,this.camera.far=2e3},Zf.prototype.setViewport=function(t,e,r,i,n){this.camera instanceof Ai&&(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)},Zf.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 Yf=new _t;Zf.prototype.castRay=function(t,e,r){var i=this.layer.renderer,n=i.viewport;return i.viewport=this.viewport,i.screenToNDC(t,e,Yf),this.camera.castRay(Yf,r),i.viewport=n,r},Zf.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;e30},Zf.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))},Zf.prototype._updateTransparent=function(t,e,r,i){for(var n=new ve,a=new Ve,o=r.getWorldPosition(),s=e.getRenderList(r).transparent,l=0;lthis.camera.far||t80*r){i=a=t[0],n=o=t[1];for(var p=r;pa&&(a=s),l>o&&(o=l);h=Math.max(a-i,o-n)}return sp(d,f,r,i,n,h),f}function ap(t,e,r,i,n){var a,o;if(n===Ap(t,e,r,i)>0)for(a=e;a=e;a-=i)o=Tp(a,t[a],t[a+1],o);return o&&yp(o,o.next)&&(Sp(o),o=o.next),o}function op(t,e){if(!t)return t;e||(e=t);var r,i=t;do{if(r=!1,i.steiner||!yp(i,i.next)&&0!==vp(i.prev,i,i.next))i=i.next;else{if(Sp(i),(i=e=i.prev)===i.next)return null;r=!0}}while(r||i!==e);return e}function sp(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=pp(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;e0||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?hp(t,i,n,a):lp(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),Sp(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?sp(t=up(t,e,r),e,r,i,n,a,2):2===o&&cp(t,e,r,i,n,a):sp(op(t),e,r,i,n,a,1);break}}}function lp(t){var e=t.prev,r=t,i=t.next;if(vp(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(gp(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&vp(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function hp(t,e,r,i){var n=t.prev,a=t,o=t.next;if(vp(n,a,o)>=0)return!1;for(var s=n.xa.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=pp(s,l,e,r,i),d=pp(h,u,e,r,i),f=t.nextZ;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&gp(n.x,n.y,a.x,a.y,o.x,o.y,f.x,f.y)&&vp(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&&gp(n.x,n.y,a.x,a.y,o.x,o.y,f.x,f.y)&&vp(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function up(t,e,r){var i=t;do{var n=i.prev,a=i.next.next;!yp(n,a)&&xp(n,i,i.next,a)&&bp(n,a)&&bp(a,n)&&(e.push(n.i/r),e.push(i.i/r),e.push(a.i/r),Sp(i),Sp(i.next),i=t=a),i=i.next}while(i!==t);return i}function cp(t,e,r,i,n,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&_p(o,s)){var l=wp(o,s);return o=op(o,o.next),l=op(l,l.next),sp(o,e,r,i,n,a),void sp(l,e,r,i,n,a)}s=s.next}o=o.next}while(o!==t)}function dp(t,e){return t.x-e.x}function fp(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.x&&i.x>=u&&n!==i.x&&gp(ar.x)&&bp(i,t)&&(r=i,d=l),i=i.next;return r}(t,e)){var r=wp(e,t);op(r,r.next)}}function pp(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 mp(t){var e=t,r=t;do{e.x=0&&(t-o)*(i-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(n-o)*(i-s)>=0}function _p(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&&xp(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&bp(t,e)&&bp(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 vp(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function yp(t,e){return t.x===e.x&&t.y===e.y}function xp(t,e,r,i){return!!(yp(t,e)&&yp(r,i)||yp(t,i)&&yp(r,e))||vp(t,e,r)>0!=vp(t,e,i)>0&&vp(r,i,t)>0!=vp(r,i,e)>0}function bp(t,e){return vp(t.prev,t,t.next)<0?vp(t,e,t.next)>=0&&vp(t,t.prev,e)>=0:vp(t,e,t.prev)<0||vp(t,t.next,e)<0}function wp(t,e){var r=new Mp(t.i,t.x,t.y),i=new Mp(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 Tp(t,e,r,i){var n=new Mp(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 Sp(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 Mp(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 Ap(t,e,r,i){for(var n=0,a=e,o=r-i;ah&&s.push({pivot:Math.floor((l+h)/2),left:h,right:l}),h=a[o].pivot+1,(l=a[o].right)>h&&s.push({pivot:Math.floor((l+h)/2),left:h,right:l})}a=this._parts=s}else for(o=0;o=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;o0,r={},n=0;n65535?new Uint32Array(3*o):new Uint16Array(3*o),d.material.shader!==e&&d.material.attachShader(e,!0),mo.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;u0;w&&(b*=e.getDevicePixelRatio(),this._updateLinesGeometry(h.geometry,t,u,v,b,t.coordinateSystem.transform)),h.invisible=!w,h.material.set({color:g})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?mo.Mesh.CCW:mo.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=mo.parseColor(e.get("lineStyle.color")||"rgba(0,0,0,0.5)"),i=Sn(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),mo.setMaterialFromModel(n,a,i,r),a.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=a,this._groundMesh.material.set("color",mo.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;o1?i:0,L[G][g]=A.points[H+2],l.set(n+G,L[G]),s?(I[0]=(A.points[H]*_[0]-v[0])/x,I[1]=(A.points[H+2]*_[g]-v[g])/x):(I[0]=(U?R:R+k)/x,I[1]=(L[G][m]*_[m]-v[m])/x),u.set(n+G,I)}for(Up.sub(P,L[1],L[0]),Up.sub(O,L[3],L[0]),Up.cross(N,P,O),Up.normalize(N,N),G=0;G<4;G++)h.set(n+G,N),f&&c.set(n+G,o);for(G=0;G<6;G++)p[3*a+G]=D[G]+n;n+=4,a+=2,R+=k}}return e.dirty(),{vertexOffset:n,triangleOffset:a}},_getRegionLinesInfo:function(t,e,r){var i=0,n=0;return 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;othis._endIndex)){e-=this._startIndex;for(var i=this._vertexRangeOfDataIndex[2*e];i0},_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(im.prototype,Uo),i.util.merge(im.prototype,Ho),i.util.merge(im.prototype,Vo),i.util.merge(im.prototype,tp);var nm=Math.PI,am=Math.sin,om=Math.cos,sm=Math.tan,lm=Math.asin,hm=Math.atan2,um=nm/180,cm=23.4397*um;function dm(t,e){return hm(am(t)*om(cm)-sm(e)*am(cm),om(t))}function fm(t,e,r){return hm(am(t),om(t)*am(e)-sm(r)*om(e))}function pm(t,e,r){return lm(am(e)*am(r)+om(e)*om(r)*om(t))}var mm={};mm.getPosition=function(t,e,r){var i=um*-r,n=um*e,a=function(t){return function(t){return t.valueOf()/864e5-.5+2440588}(t)-2451545}(t),o=function(t){var e,r,i=(r=function(t){return um*(357.5291+.98560028*t)}(t))+um*(1.9148*am(r)+.02*am(2*r)+3e-4*am(3*r))+102.9372*um+nm;return{dec:(e=i,lm(am(0)*om(cm)+om(0)*am(cm)*am(e))),ra:dm(i,0)}}(a),s=function(t,e){return um*(280.16+360.9856235*t)-e}(a,i)-o.ra;return{azimuth:fm(s,n,o.dec),altitude:pm(s,n,o.dec)}};const gm=mm;mo.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 mo.Node,this._sphereGeometry=new mo.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new mo.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new mo.PlaneGeometry,this._earthMesh=new mo.Mesh({renderNormal:!0}),this._atmosphereMesh=new mo.Mesh,this._atmosphereGeometry=new mo.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.atmosphere.vertex"),mo.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=mo.Mesh.CW,this._lightRoot=new mo.Node,this._sceneHelper=new Wc,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new Nc({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=mo.createMaterial(o)),mo.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",mo.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=mo.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=Sn(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 mo.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===n.get("shading")?(m.material=m.__lambertMaterial||new mo.Material({autoUpdateTextureStatus:!1,shader:mo.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),m.__lambertMaterial=m.material):(m.material=m.__colorMaterial||new mo.Material({autoUpdateTextureStatus:!1,shader:mo.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=mo.createBlankTexture("rgba(255, 255, 255, 0)"));m.material.set("diffuseMap",v),mo.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=mo.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),f=Sn(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),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;l50&&(a=1e3);var o=[];Tm.perspective(o,Mm,this.width/this.height,1,a),this.viewGL.camera.projectionMatrix.setArray(o),this.viewGL.camera.decomposeProjectionMatrix(),o=Tm.identity([]);var s=this.dataToPoint(this.center);Tm.scale(o,o,[1,-1,1]),Tm.translate(o,o,[0,0,-t]),Tm.rotateX(o,o,e),Tm.rotateZ(o,o,-this.bearing/180*Math.PI),Tm.translate(o,o,[-s[0]*this.getScale()*Cm,-s[1]*this.getScale()*Cm,0]),this.viewGL.camera.viewMatrix.array=o;var l=[];Tm.invert(l,o),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var h,u=Sm*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var c=this.altitudeExtent[1]-this.altitudeExtent[0];h=this.boxHeight/c*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else h=u/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*Cm;this.viewGL.rootNode.scale.set(this.getScale()*Cm,this.getScale()*Cm,h)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(t,e){return this.projectOnTileWithScale(t,this.getScale()*Sm,e)},projectOnTileWithScale:function(t,e,r){var i=t[0],n=t[1]*Am/180,a=e*(i*Am/180+Am)/(2*Am),o=e*(Am-Math.log(Math.tan(Am/4+.5*n)))/(2*Am);return(r=r||[])[0]=a,r[1]=o,r},unprojectFromTile:function(t,e){return this.unprojectOnTileWithScale(t,this.getScale()*Sm,e)},unprojectOnTileWithScale:function(t,e,r){var i=t[0],n=t[1],a=i/e*(2*Am)-Am,o=2*(Math.atan(Math.exp(Am-n/e*(2*Am)))-Am/4);return(r=r||[])[0]=180*a/Am,r[1]=180*o/Am,r},dataToPoint:function(t,e){return(e=this.projectOnTileWithScale(t,Sm,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}};const Dm=Em;function Lm(){Dm.apply(this,arguments)}function Pm(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 Kf).setRootNode(new mo.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+' "'+Sn(e.get(t+"Index"),e.get(t+"Id"),0)+'" not found');e.coordinateSystem=r.coordinateSystem}})),r&&r(s,a,o),s}}}Lm.prototype=new Dm,Lm.prototype.constructor=Lm,Lm.prototype.type="mapbox3D";var Om=Pm("mapbox3D",Lm,(function(t){t.forEach((function(t){t.setCameraOption(t.model.getMapboxCameraOption())}))}));i.registerCoordinateSystem("mapbox3D",Om);var Nm=["zoom","center","pitch","bearing"],Im=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 Nm.reduce((function(e,r){return e[r]=t.get(r),e}),{})},setMapboxCameraOption:function(t){null!=t&&Nm.forEach((function(e){null!=t[e]&&(this.option[e]=t[e])}),this)},getMapbox:function(){return this._mapbox},setMapbox:function(t){this._mapbox=t}});function Rm(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()}i.util.merge(Im.prototype,Ho),i.util.merge(Im.prototype,Vo),Rm.prototype.resize=function(){this._mapbox.resize()},Rm.prototype.getMapbox=function(){return this._mapbox},Rm.prototype.clear=function(){},Rm.prototype.refresh=function(){this._mapbox.resize()};var Bm=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];Rm.prototype._initEvents=function(){var t=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(t){return t.preventDefault(),!1}},Bm.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)},Rm.prototype.dispose=function(){Bm.forEach((function(t){this.zr.dom.removeEventListener(t,this._handlers[t])}),this)};const Fm=Rm,zm="\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";function km(){Dm.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}mo.Shader.import(zm),i.extendComponentView({type:"mapbox3D",__ecgl__:!0,init:function(t,e){var r=e.getZr();this._zrLayer=new Fm("mapbox3D",r),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new mo.Node,this._sceneHelper=new Wc(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 mo.Mesh({geometry:new mo.PlaneGeometry,material:new mo.Material({shader:new mo.Shader({vertex:mo.Shader.source("ecgl.displayShadow.vertex"),fragment:mo.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 mo.Plane(new mo.Vector3(0,0,1),0),i=t.viewGL.camera.castRay(new mo.Vector2(-1,-1)),n=t.viewGL.camera.castRay(new mo.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)}}),i.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},(function(t,e){e.eachComponent({mainType:"mapbox3D",query:t},(function(e){e.setMapboxCameraOption(t)}))})),km.prototype=new Dm,km.prototype.constructor=km,km.prototype.type="maptalks3D";var Gm=Pm("maptalks3D",km,(function(t){t.forEach((function(t){t.setCameraOption(t.model.getMaptalksCameraOption())}))}));i.registerCoordinateSystem("maptalks3D",Gm);var Um=["zoom","center","pitch","bearing"],Hm=i.extendComponentModel({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'© OpenStreetMap contributors, © CARTO',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 Um.reduce((function(e,r){return e[r]=t.get(r),e}),{})},setMaptalksCameraOption:function(t){null!=t&&Um.forEach((function(e){null!=t[e]&&(this.option[e]=t[e])}),this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(t){this._maptalks=t}});function Vm(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()}i.util.merge(Hm.prototype,Ho),i.util.merge(Hm.prototype,Vo),Vm.prototype.resize=function(){this._maptalks.checkSize()},Vm.prototype.getMaptalks=function(){return this._maptalks},Vm.prototype.clear=function(){},Vm.prototype.refresh=function(){this._maptalks.checkSize()};var Wm=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];Vm.prototype._initEvents=function(){var t=this.dom;this._handlers=this._handlers||{contextmenu:function(t){return t.preventDefault(),!1}},Wm.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)},Vm.prototype.dispose=function(){Wm.forEach((function(t){this.zr.dom.removeEventListener(t,this._handlers[t])}),this),this._maptalks.remove()};const jm=Vm;mo.Shader.import(zm),i.extendComponentView({type:"maptalks3D",__ecgl__:!0,init:function(t,e){this._groundMesh=new mo.Mesh({geometry:new mo.PlaneGeometry,material:new mo.Material({shader:new mo.Shader({vertex:mo.Shader.source("ecgl.displayShadow.vertex"),fragment:mo.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 jm("maptalks3D",r,t.get("center"),t.get("zoom")),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new mo.Node,this._sceneHelper=new Wc(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/Xm)/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 mo.Plane(new mo.Vector3(0,0,1),0),i=t.viewGL.camera.castRay(new mo.Vector2(-1,-1)),n=t.viewGL.camera.castRay(new mo.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 Xm=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 qm=Rc.vec3,Zm=i.helper.dataStack.isDimensionStacked;function Ym(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;l0&&r>0||e<0&&r<0)}(u),d=["x","y","z"].map((function(e){return t.coordDimToDataDim(e)[0]})),f=Zm(r,d[2]),p=f?r.getCalculationInfo("stackResultDimension"):d[2];r.each(d,(function(t,i,a,o){var s=r.get(p,o),l=f?s-a:c?0:u[0],h=e.dataToPoint([t,i,l]),d=e.dataToPoint([t,i,s]),m=qm.dist(h,d),g=[0,d[1]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;n0&&this.bevelSegments>0)this._addBevelBar(t,c,m,g,this.bevelSize,this.bevelSegments,_);else{lg.copy(n,c),lg.normalize(n,n),lg.cross(a,m,n),lg.normalize(a,a),lg.cross(i,n,a),lg.normalize(a,a),lg.negate(o,i),lg.negate(s,n),lg.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 b=this._vertexOffset,w=0;w"+a.join("
")}(a):i.format.encodeHTML(i.format.addCommas(a)),s=n.getName(e),l=Fp(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?": ":"
"):"",r?h+u+o:u+h+(s?i.format.encodeHTML(s)+": "+o:o)}function pg(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}i.extendChartView({type:"bar3D",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this._api=e,this._labelsBuilder=new Gp(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 dg.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 mo.Mesh({geometry:new cg,shadowDepthMaterial:new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.sm.depth.vertex"),mo.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){mo.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=mo.createMaterial(s,["VERTEX_COLOR"])),mo.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=Fp(r,t),i=zp(r,t);null==i&&(i=1),mo.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=Fp(e,t);a=i.color.lift(s,-.4)}null==o&&(o=zp(e,t));var l=mo.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=Fp(e,t),n=zp(e,t),a=mo.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=Mn(o,a),l=this;null!=s?i.util.each($m.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 mg=i.extendSeriesModel({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(t,e){return pg(this)},getFormattedLabel:function(t,e,r,i){var n=$m.getFormattedLabel(this,t,e,r,i);return null==n&&(n=this.getData().get("z",t)),n},formatTooltip:function(t){return fg(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(mg.prototype,tp),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 pg(this)},formatTooltip:function(t){return fg(this,t)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}});var gg=Rc.vec3;function _g(t,e,r){(e=e||document.createElement("canvas")).width=t,e.height=t;var i=e.getContext("2d");return r&&r(i),e}mo.Shader.import(sd),i.extendChartView({type:"line3D",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.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 mo.Mesh({geometry:new kc({useNativeLine:!1,sortTriangles:!0}),material:new mo.Material({shader:mo.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=Fp(r,t),i=zp(r,t);null==i&&(i=1),mo.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,Sn(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",mo.parseColor(u.get("lineStyle.color")||"rgba(0,0,0,0.5)")),i.material.set("wireframeLineWidth",Sn(u.get("lineStyle.width"),1))):i.material.set("both","WIREFRAME_TRIANGLE"),this._points=n,this._initHandler(t,e)},_updateAnimation:function(t){mo.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 Ve,e=this._camera;Ve.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=0){var g=3*l,_=new ve(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()}}),i.registerLayout((function(t,e){t.eachSeriesByType("line3D",(function(t){var e=t.getData(),r=t.coordinateSystem;if(r){if("cartesian3D"!==r.type)return;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 pg(this)},getFormattedLabel:function(t,e,r,i){var n=$m.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 fg(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 vg={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=vg.getMarginByStyle(r,void 0),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=vg.getMarginByStyle(r);return{image:_g(a.__size,n,(function(t){i.innerDrawElementOnCanvas(t,a)})),margin:o}},createSDFFromCanvas:function(t,e,r,i){return _g(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=2e4},doSortVertices:function(t,e){var r=this.indices,i=xg.create();if(!r){r=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var n=0;n.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):Pp.sort(r,i,0,r.length-1)},_progressiveQuickSort:function(t){var e=this._zList,r=this.indices;this._quickSort=this._quickSort||new Pp,this._quickSort.step(r,(function(t,r){return e[r]-e[t]}),t)}};var wg=Rc.vec4;mo.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");const Tg=mo.Mesh.extend((function(){var t=new mo.Geometry({dynamic:!0,attributes:{color:new mo.Geometry.Attribute("color","float",4,"COLOR"),position:new mo.Geometry.Attribute("position","float",3,"POSITION"),size:new mo.Geometry.Attribute("size","float",1),prevPosition:new mo.Geometry.Attribute("prevPosition","float",3),prevSize:new mo.Geometry.Attribute("prevSize","float",1)}});Object.assign(t,bg);var e=new mo.Material({shader:mo.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});e.enableTexture("sprite"),e.define("both","VERTEX_COLOR"),e.define("both","VERTEX_SIZE");var r=new mo.Texture2D({image:document.createElement("canvas"),flipY:!1});return e.set("sprite",r),t.pick=this._pick.bind(this),{geometry:t,material:e,mode:mo.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&&tf-p*h&&e2?(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");mo.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;x1?(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&&(a=o,(n=this._symbolSize)&&a&&n[0]===a[0]&&n[1]===a[1])&&this._lineWidth===e.lineWidth||(yg.createSymbolSprite(r.type,o,{fill:"#fff",lineWidth:e.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(o[0]/2,10)},this._spriteImageCanvas),yg.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")?mo.additiveBlend:null,i=this._mesh.material;i.blend=r,i.set("lineWidth",e.lineWidth/20);var n=mo.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){mo.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;othis._endDataIndex||ethis._endDataIndex||e 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");const Wg=mo.Mesh.extend((function(){var t=new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.trail2.vertex"),mo.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),e=new kc({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,b=0;t.each((function(e){var i=t.getItemLayout(e),a=g?p:zp(t,e),s=Fp(t,e);null==a&&(a=1),(d=mo.parseColor(m?f:s,d))[3]*=a;for(var l=c?r.getPolylineVertexCount(i):r.getCubicCurveVertexCount(i[0],i[1],i[2],i[3]),w=0,T=[],S=[],M=x;Mx&&(w+=Vg.dist(T,S)),n.attributes.dist.set(M,w),Vg.copy(S,T);b=Math.max(b,w);var A=Math.random()*(u?w:h);for(M=x;M0?1:-1)*o/2),n.attributes.color.set(M,d);x+=l})),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",a.get("spotIntensity")),n.dirty()},setAnimationTime:function(t){this.material.set("time",t)}});function jg(t,e){for(var r=[],i=0;i0;this._updateSurfaceMesh(this._surfaceMesh,t,u,f);var p=this._surfaceMesh.material;f?(p.define("WIREFRAME_QUAD"),p.set("wireframeLineWidth",d),p.set("wireframeLineColor",mo.parseColor(c.get("lineStyle.color")))):p.undefine("WIREFRAME_QUAD"),this._initHandler(t,r),this._updateAnimation(t)},_updateAnimation:function(t){mo.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,t)},_createSurfaceMesh:function(){var t=new mo.Mesh({geometry:new mo.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.sm.depth.vertex"),mo.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=0){var s=[];i.geometry.attributes.position.get(o,s);for(var l=n.pointToData(s),h=1/0,u=-1,c=[],d=0;d65535?Uint32Array:Uint16Array)((p-1)*(m-1)*6),w=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},T=!1;if(l){var S=[],M=[],A=0;g?u.init(n.vertexCount):u.value=null;for(var C=[[],[],[]],E=[],D=[],L=Zg.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},O=new Float32Array(o.length),N=new Float32Array(o.length/3*4),I=0;I0;){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 Kg=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 fg(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=em.createGeo3D(this));for(var i=this._geo.getRegion(r),n=[],a=0;a=0&&t.call(e,r[n],n)},t.prototype.eachEdge=function(t,e){for(var r=this.edges,i=r.length,n=0;n=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 e_||(e=this._nodesMap[$g(e)]),e){for(var n="out"===r?"outEdges":"in"===r?"inEdges":"edges",a=0;a=0&&r.node2.dataIndex>=0})),n=0,a=i.length;n=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)}}}Aa(e_,i_("hostGraph","data")),Aa(r_,i_("hostGraph","edgeData"));const n_=t_;var a_=wu();function o_(t,e){if(a_(this).mainData===this){var r=Ta({},a_(this).datas);r[this.dataType]=e,c_(e,r,t)}else d_(e,this.dataType,a_(this).mainData,t);return e}function s_(t,e){return t.struct&&t.struct.update(),e}function l_(t,e){return Ea(a_(e).datas,(function(r,i){r!==e&&d_(r.cloneShallow(),i,e,t)})),e}function h_(t){var e=a_(this).mainData;return null==t||null==e?e:a_(e).datas[t]}function u_(){var t=a_(this).mainData;return null==t?[{data:t}]:Da(La(a_(t).datas),(function(e){return{type:e,data:a_(t).datas[e]}}))}function c_(t,e,r){a_(t).datas={},Ea(e,(function(e,i){d_(e,i,t,r)}))}function d_(t,e,r,i){a_(r).datas[e]=t,a_(t).mainData=r,t.dataType=e,i.struct&&(t[i.structAttr]=i.struct,i.struct[i.datasAttr[e]]=t),t.getLinkedData=h_,t.getLinkedDataAll=u_}var f_=i.extendSeriesModel({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(t){f_.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(t){f_.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(t,e,r,i){var n=$m.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 n_(!0),s=0;s "+p)),c++)}var m=i.helper.createDimensions(["value"],t);(l=new i.List(m,r)).initData(t);var g,_,v,y=new i.List(["value"],r);return y.initData(u,h),a&&a(l,y),_=(g={mainData:l,struct:o,structAttr:"graph",datas:{node:l,edge:y},datasAttr:{node:"data",edge:"edgeData"}}).mainData,(v=g.datas)||(v={main:_},g.datasAttr={main:"data"}),g.datas=g.mainData=null,c_(_,v,g),Ea(v,(function(t){Ea(_.TRANSFERABLE_METHODS,(function(e){t.wrapMethod(e,Pa(o_,g))}))})),_.wrapMethod("cloneShallow",Pa(l_,g)),Ea(_.CHANGABLE_METHODS,(function(t){_.wrapMethod(t,Pa(s_,g))})),function(t,e){if(!t)throw new Error(void 0)}(v[_.dataType]===_),o.update(),o}(n,r,this,0,(function(t,r){t.wrapMethod("getItemModel",(function(t){const e=a._categoriesModels[t.getShallow("category")];return e&&(e.parentModel=t.parentModel,t.parentModel=e),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 f_.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;e65535?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/(p_.dist(t,e)+p_.dist(r,e)+p_.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(m_)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(m_)},getPolylineVertexCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/2,this.useNativeLine?2*(e-1):2*(e-1)+2},getPolylineTriangleCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/2,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,b=o-2*l+u,w=s-2*h+c,T=3*(l-u)-o+d,S=3*(h-c)-s+f,M=o,A=s,C=(l-o)*_+b*v+T*g,E=(h-s)*_+w*v+S*g,D=b*y+T*x,L=w*y+S*x,P=T*x,O=S*x,N=0,I=0,R=Math.ceil(1/p),B=new Float32Array(3*(R+1)),F=(B=[],0);for(I=0;I1&&(M=C>0?Math.min(M,d):Math.max(M,d),A=E>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=p_.create(),e=p_.create(),r=p_.create(),i=p_.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,b=0;b1&&(m.copy(x,x-1),g.copy(x,x-1),x++);else{var S;if(b0){p_.sub(t,n,o),p_.sub(e,a,n),p_.normalize(t,t),p_.normalize(e,e),p_.add(i,t,e),p_.normalize(i,i);var M=h/2*Math.min(1/p_.dot(t,i),2);r[0]=-i[1],r[1]=i[0],S=M}else p_.sub(t,a,n),p_.normalize(t,t),r[0]=-t[1],r[1]=t[0],S=h/2;else p_.sub(t,n,o),p_.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),p_.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(b>0){var A=3*this._faceOffset;(y=this.indices)[A]=x-4,y[A+1]=x-3,y[A+2]=x-2,y[A+3]=x-3,y[A+4]=x-1,y[A+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(t,e){for(var r=this._itemVertexOffsets[t],i=t 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 v_={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function y_(t){var e={type:mo.Texture.FLOAT,minFilter:mo.Texture.NEAREST,magFilter:mo.Texture.NEAREST};this._positionSourceTex=new mo.Texture2D(e),this._positionSourceTex.flipY=!1,this._positionTex=new mo.Texture2D(e),this._positionPrevTex=new mo.Texture2D(e),this._forceTex=new mo.Texture2D(e),this._forcePrevTex=new mo.Texture2D(e),this._weightedSumTex=new mo.Texture2D(e),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new mo.Texture2D(e),this._globalSpeedPrevTex=new mo.Texture2D(e),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new fn({fragment:mo.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new fn({fragment:mo.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new fn({fragment:mo.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new fn({fragment:mo.Shader.source("clay.compositor.output")});var r=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE)};this._edgeForceMesh=new mo.Mesh({geometry:new mo.Geometry({attributes:{node1:new mo.Geometry.Attribute("node1","float",2),node2:new mo.Geometry.Attribute("node2","float",2),weight:new mo.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new mo.Material({transparent:!0,shader:mo.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:r,depthMask:!1,depthText:!1}),mode:mo.Mesh.POINTS}),this._weightedSumMesh=new mo.Mesh({geometry:new mo.Geometry({attributes:{node:new mo.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new mo.Material({transparent:!0,shader:mo.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:r,depthMask:!1,depthText:!1}),mode:mo.Mesh.POINTS}),this._framebuffer=new Fi({depthBuffer:!1}),this._dummyCamera=new mo.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}y_.prototype.updateOption=function(t){for(var e in v_)this[e]=v_[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 v_)null!=t[e]&&(this[e]=t[e]);if(this.repulsionByDegree)for(var i=this._positionSourceTex.pixels,n=0;nt},y_.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},y_.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)},y_.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)},y_.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)};const x_=y_;var b_=function(){var t=function(){return new Float32Array(2)},e=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)},r=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},i=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},n=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},a=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},o=function(t,e){return t[0]=e[0],t[1]=e[1],t},s=function(t,e,r){return t[0]=e,t[1]=r,t};function l(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var h=l.prototype;function u(){this.position=new Float32Array(2),this.force=t(),this.forcePrev=t(),this.mass=1,this.inDegree=0,this.outDegree=0}function c(t,e){this.source=t,this.target=e,this.weight=1}function d(){this.autoSettings=!0,this.barnesHutOptimize=!0,this.barnesHutTheta=1.5,this.repulsionByDegree=!0,this.linLogMode=!1,this.strongGravityMode=!1,this.gravity=1,this.scaling=1,this.edgeWeightInfluence=1,this.jitterTolerence=.1,this.preventOverlap=!1,this.dissuadeHubs=!1,this.rootRegion=new l,this.rootRegion.centerOfMass=t(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}h.beforeUpdate=function(){for(var t=0;t=t&&this.bbox[1]<=e&&this.bbox[3]>=e},h.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},h._newSubRegion=function(){var t=this.subRegions[this.nSubRegions];return t||(t=new l,this.subRegions[this.nSubRegions]=t),this.nSubRegions++,t},h._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)},h._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 f=d.prototype;f.initNodes=function(t,e,r){var i=e.length;this.nodes.length=0;for(var n=void 0!==r,a=0;a0&&(this.strongGravityMode?this.applyNodeStrongGravity(u):this.applyNodeGravity(u))}for(l=0;l0&&(g=Math.min(g/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=g,l=0;l0&&(v=Math.min(y*v,10)/y,i(h.position,h.position,h.force,v))}},f.applyRegionToNodeRepulsion=function(){var e=t();return function(t,r){if(t.node)this.applyNodeToNodeRepulsion(t.node,r,!0);else{a(e,r.position,t.centerOfMass);var n=e[0]*e[0]+e[1]*e[1];if(n>this.barnesHutTheta*t.size*t.size){var o=this.scaling*r.mass*t.mass/n;i(r.force,r.force,e,o)}else for(var s=0;s0)s=this.scaling*t.mass*r.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*t.mass*r.mass}}else s=this.scaling*t.mass*r.mass/o;i(t.force,t.force,e,s),i(r.force,r.force,e,-s)}}}}(),f.applyEdgeAttraction=function(){var e=t();return function(t){var n=t.source,o=t.target;a(e,n.position,o.position);var s,l,h=r(e);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?t.weight:Math.pow(t.weight,this.edgeWeightInfluence),this.preventOverlap&&(h=h-n.size-o.size)<=0||(l=this.linLogMode?-s*Math.log(h+1)/(h+1):-s,i(n.force,n.force,e,l),i(o.force,o.force,e,-l))}}(),f.applyNodeGravity=function(){var e=t();return function(t){a(e,this.gravityCenter,t.position);var n=r(e);i(t.force,t.force,e,this.gravity*t.mass/(n+1))}}(),f.applyNodeStrongGravity=function(){var e=t();return function(t){a(e,this.gravityCenter,t.position),i(t.force,t.force,e,this.gravity*t.mass)}}(),f.updateBBox=function(){for(var t=1/0,e=1/0,r=-1/0,i=-1/0,n=0;n5e4?10:a>5e3?1:.1,e.scaling=a>100?2:10,e.barnesHutOptimize=a>1e3,t)for(var r in w_)null!=t[r]&&(e[r]=t[r]);if(!e.gravityCenter){for(var o=[1/0,1/0],s=[-1/0,-1/0],l=0;lt},T_.prototype.getNodePosition=function(t,e){if(e||(e=new Float32Array(2*this._nodes.length)),this._positionArr)for(var r=0;r0?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)}});var A_=Rc.vec2;mo.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 C_,E_=1;function D_(t){return t instanceof Array||(t=[t,t]),t}function L_(){}i.extendChartView({type:"graphGL",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this.viewGL=new Kf("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new Mg(!0,e),this._forceEdgesMesh=new mo.Mesh({material:new mo.Material({shader:mo.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new mo.Geometry({attributes:{node:new mo.Geometry.Attribute("node","float",2),color:new mo.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:mo.Mesh.LINES}),this._edgesMesh=new mo.Mesh({material:new mo.Material({shader:mo.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new __({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new M_({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 x_||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(Sn(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=Fp(i,o.dataIndex),l=mo.parseColor(s);l[3]*=Sn(zp(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=Fp(t,s.dataIndex),c=mo.parseColor(u);c[3]*=Sn(zp(t,s.dataIndex),1);var d=t.getItemModel(s.dataIndex),f=Sn(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=f&&(l._syncNodePosition(t),d=0),r.getZr().refresh(),go((function(){p(e)}))}))};go((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=n.graph,s=[],l=o.getNodeByIndex(a);s.push(l),l.edges.forEach((function(t){t.dataIndex<0||(t.node1!==l&&s.push(t.node1),t.node2!==l&&s.push(t.node2))}),this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach((function(t){this._pointsBuilder.highlight(n,t.dataIndex)}),this),this._pointsBuilder.updateLabels(s.map((function(t){return t.dataIndex})));var h=[];l.edges.forEach((function(t){t.dataIndex>=0&&(this._highlightEdge(t.dataIndex),h.push(t))}),this),this._focusNodes=s,this._focusEdges=h},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=mo.parseColor(e.get("emphasis.lineStyle.color")||e.get("lineStyle.color")),i=Sn(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:(C_=[],function(t,e){this._getColor(t,C_),C_[3]*=e,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],C_)}),_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=A_.create(1/0,1/0),a=A_.create(-1/0,-1/0),o=[],s=0;sr.left&&hr.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;t65535?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}});Xt.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 O_=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new Er({type:br.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()};O_.prototype={constructor:O_,init:function(){var t={type:br.FLOAT,minFilter:br.NEAREST,magFilter:br.NEAREST,useMipmap:!1};this._spawnTexture=new Er(t),this._particleTexture0=new Er(t),this._particleTexture1=new Er(t),this._frameBuffer=new Fi({depthBuffer:!1}),this._particlePass=new fn({fragment:Xt.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new fn({fragment:Xt.source("clay.compositor.downsample")});var e=new Tr({renderOrder:10,material:new lt({shader:new Xt(Xt.source("ecgl.vfParticle.renderPoints.vertex"),Xt.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:Tr.POINTS,geometry:new Ur({dynamic:!0,mainAttribute:"texcoord0"})}),r=new Tr({renderOrder:10,material:new lt({shader:new Xt(Xt.source("ecgl.vfParticle.renderLines.vertex"),Xt.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new P_,culling:!1}),i=new Tr({material:new lt({shader:new Xt(Xt.source("ecgl.color.vertex"),Xt.source("ecgl.color.fragment"))}),geometry:new Gi});i.material.enableTexture("diffuseMap"),this._particlePointsMesh=e,this._particleLinesMesh=r,this._lastFrameFullQuadMesh=i,this._camera=new hn,this._thisFrameTexture=new Er,this._lastFrameTexture=new Er},setParticleDensity:function(t,e){for(var r=new Float32Array(t*e*4),i=0,n=this.particleLife,a=0;a0?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 Er),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=359&&(n[0]>0&&(n[0]=0),a[0]1?(e.material.shader!==this._meshLinesShader&&e.material.attachShader(this._meshLinesShader),e.mode=mo.Mesh.TRIANGLES):(e.material.shader!==this._nativeLinesShader&&e.material.attachShader(this._nativeLinesShader),e.mode=mo.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{e.exports=t}},r={};function i(t){if(r[t])return r[t].exports;var n=r[t]={exports:{}};return e[t](n,n.exports,i),n.exports}return i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i(583)})()}));