mirror of
git://soft.sys114.com/mainsail
synced 2026-02-04 15:50:36 +09:00
2 lines
437 KiB
JavaScript
2 lines
437 KiB
JavaScript
import{m as ct,B as ft,a as zi,b as jr,P as ze,W as ta,C as at,n as dt,_ as Dt,c as Qa,d as ra,e as Ja,f as es,g as ts,T as rs,R as is,h as ns,i as as,j as ss}from"./index-Bku7SJna.js";import{h as Gi,f as be,c as ut,i as et,o as ia,p as ki,d as Vi,m as Je,n as _e,x as os,j as Wt,V as ls,v as us,T as hs,q as Er,S as cs,t as fs}from"./vuetify-Ce4WN_Dg.js";import{m as an,j as ur,A as ds,L as vs,p as na,R as aa,k as ps,r as ms,l as hr,n as _s,o as gs,q as ys,s as xs,Z as Ts,C as sa,v as ht,w as xr,x as ws,y as Es,M as bs,z as Ei,B as bi,D as Ss,E as oa,F as la,G as ua,H as ha,I as As,J as Cs,K as Ms,N as Ps,O as Rs,P as Ls,Q as br,S as sn,T as Ns,U as Ds,V as Os,W as Is,X as Fs,Y as Bs,_ as Us,$ as Hs,a0 as Sr,a1 as zs,u as Gs,a2 as ks,a3 as Vs}from"./echarts-DzoUeqWp.js";import"./overlayscrollbars-CiKU261J.js";var Ws=Object.defineProperty,Xs=Object.getOwnPropertyDescriptor,qr=(e,t,r,i)=>{for(var n=i>1?void 0:i?Xs(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=(i?s(t,r,n):s(n))||n);return i&&n&&Ws(t,r,n),n};let qt=class extends ct(ft){constructor(){super(...arguments),this.mdiCloseThick=zi,this.mdiGrid=jr,this.isInvalidName=!1,this.newName="",this.rules=[t=>!!t||this.$t("Heightmap.InvalidNameEmpty"),t=>t!=="default"||this.$t("Heightmap.InvalidNameReserved"),t=>!this.profileNames.includes(t)||this.$t("Heightmap.InvalidNameAlreadyExists"),t=>t===t.replace(/[^\x00-\x7F]/g,"")||this.$t("Heightmap.InvalidNameAscii")]}get profileNames(){var t,r;return Object.keys((r=(t=this.$store.state.printer.bed_mesh)==null?void 0:t.profiles)!=null?r:{})}renameProfile(){const t='BED_MESH_PROFILE SAVE="'.concat(this.newName,'"\nBED_MESH_PROFILE REMOVE="').concat(this.name,'"');this.$store.dispatch("server/addEvent",{message:t,type:"command"}),this.$socket.emit("printer.gcode.script",{script:t},{loading:"bedMeshRename"}),this.closeDialog()}closeDialog(){this.$emit("close")}showChanged(){this.show&&(this.newName=this.name,this.$nextTick(()=>{setTimeout(()=>{var t;(t=this.$refs.input)==null||t.focus()},100)}))}};qr([ze({type:Boolean,required:!0})],qt.prototype,"show",2);qr([ze({type:String,required:!0})],qt.prototype,"name",2);qr([ta("show")],qt.prototype,"showChanged",1);qt=qr([at],qt);var js=function(){var t=this,r=t._self._c;return t._self._setupProxy,r(Gi,{attrs:{value:t.show,persistent:"","max-width":400},on:{keydown:function(i){return!i.type.indexOf("key")&&t._k(i.keyCode,"esc",27,i.key,["Esc","Escape"])?null:t.closeDialog.apply(null,arguments)}}},[r(Dt,{attrs:{title:t.$t("Heightmap.RenameBedMeshProfile"),icon:t.mdiGrid,"card-class":"heightmap-rename-dialog","margin-bottom":!1},scopedSlots:t._u([{key:"buttons",fn:function(){return[r(be,{attrs:{icon:"",tile:""},on:{click:t.closeDialog}},[r(ut,[t._v(t._s(t.mdiCloseThick))])],1)]},proxy:!0}])},[r(et,[r(ia,{ref:"input",attrs:{label:t.$t("Heightmap.Name"),required:"",rules:t.rules},on:{"update:error":i=>{t.isInvalidName=i},keyup:function(i){return!i.type.indexOf("key")&&t._k(i.keyCode,"enter",13,i.key,"Enter")?null:t.renameProfile.apply(null,arguments)}},model:{value:t.newName,callback:function(i){t.newName=i},expression:"newName"}})],1),r(ki,[r(Vi),r(be,{attrs:{text:""},on:{click:t.closeDialog}},[t._v(t._s(t.$t("Heightmap.Abort")))]),r(be,{attrs:{disabled:t.isInvalidName,color:"primary",text:""},on:{click:t.renameProfile}},[t._v(" "+t._s(t.$t("Heightmap.Rename"))+" ")])],1)],1)],1)},qs=[],Ys=dt(qt,js,qs,!1,null,null);const Wi=Ys.exports;var Zs=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,Xi=(e,t,r,i)=>{for(var n=i>1?void 0:i?$s(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=(i?s(t,r,n):s(n))||n);return i&&n&&Zs(t,r,n),n};let cr=class extends ct(ft){constructor(){super(...arguments),this.mdiCloseThick=zi,this.mdiGrid=jr}removeProfile(){const e='BED_MESH_PROFILE REMOVE="'.concat(this.name,'"');this.$store.dispatch("server/addEvent",{message:e,type:"command"}),this.$socket.emit("printer.gcode.script",{script:e},{loading:"bedMeshRemove"}),this.closeDialog()}closeDialog(){this.$emit("close")}};Xi([ze({type:Boolean,required:!0})],cr.prototype,"show",2);Xi([ze({type:String,required:!0})],cr.prototype,"name",2);cr=Xi([at],cr);var Ks=function(){var t=this,r=t._self._c;return t._self._setupProxy,r(Gi,{attrs:{value:t.show,persistent:"","max-width":400},on:{keydown:function(i){return!i.type.indexOf("key")&&t._k(i.keyCode,"esc",27,i.key,["Esc","Escape"])?null:t.closeDialog.apply(null,arguments)}}},[r(Dt,{attrs:{title:t.$t("Heightmap.BedMeshRemove"),icon:t.mdiGrid,"card-class":"heightmap-remove-dialog","margin-bottom":!1},scopedSlots:t._u([{key:"buttons",fn:function(){return[r(be,{attrs:{icon:"",tile:""},on:{click:t.closeDialog}},[r(ut,[t._v(t._s(t.mdiCloseThick))])],1)]},proxy:!0}])},[r(et,[r("p",{staticClass:"mb-0"},[t._v(t._s(t.$t("Heightmap.DoYouReallyWantToDelete",{name:t.name})))])]),r(ki,[r(Vi),r(be,{attrs:{text:""},on:{click:t.closeDialog}},[t._v(t._s(t.$t("Heightmap.Abort")))]),r(be,{attrs:{color:"error",text:""},on:{click:t.removeProfile}},[t._v(t._s(t.$t("Heightmap.Remove")))])],1)],1)],1)},Qs=[],Js=dt(cr,Ks,Qs,!1,null,null);const ca=Js.exports;var eo=Object.defineProperty,to=Object.getOwnPropertyDescriptor,ji=(e,t,r,i)=>{for(var n=i>1?void 0:i?to(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=(i?s(t,r,n):s(n))||n);return i&&n&&eo(t,r,n),n};let fr=class extends ct(ft){constructor(){super(...arguments),this.mdiDelete=Qa,this.mdiPencil=ra,this.mdiProgressUpload=Ja,this.showRemove=!1,this.showRename=!1}get points(){const e=[];for(let t=0;t<this.profile.points.length;t++)for(let r=0;r<this.profile.points[t].length;r++)e.push(this.profile.points[t][r]);return e}get min(){return Math.round(Math.min(...this.points)*1e3)/1e3}get max(){return Math.round(Math.max(...this.points)*1e3)/1e3}get variance(){return Math.abs(this.min-this.max).toFixed(3)}get is_active(){var t,r;return((r=(t=this.$store.state.printer.bed_mesh)==null?void 0:t.profile_name)!=null?r:"")===this.name}get loadingNameLoad(){return"bedMeshLoad_".concat(this.name)}get loadingNameRemove(){return"bedMeshRemove_".concat(this.name)}get isLoadingLoad(){return this.loadings.includes(this.loadingNameLoad)}get isLoadingRemove(){return this.loadings.includes(this.loadingNameRemove)}clickOnName(){if(this.is_active){this.showRename=!0;return}this.loadProfile()}loadProfile(){const e='BED_MESH_PROFILE LOAD="'.concat(this.name,'"');this.$store.dispatch("server/addEvent",{message:e,type:"command"}),this.$socket.emit("printer.gcode.script",{script:e},{loading:this.loadingNameLoad})}};ji([ze({type:String,required:!0})],fr.prototype,"name",2);ji([ze({type:Object,required:!0})],fr.prototype,"profile",2);fr=ji([at({components:{HeightmapRenameProfileDialog:Wi,HeightmapRemoveProfileDialog:ca}})],fr);var ro=function(){var t=this,r=t._self._c;return t._self._setupProxy,r(Je,{staticClass:"rowProfile"},[r(_e,{staticClass:"pl-6"},[r("span",{class:{"font-weight-bold":t.is_active,currentMeshName:t.is_active,"cursor-pointer":!0},on:{click:t.clickOnName}},[t._v(" "+t._s(t.name)+" ")])]),r(_e,{staticClass:"col-auto text-center d-flex align-center justify-center pr-6"},[r(os,{attrs:{top:"",color:"rgba(0,0,0,0.8)"},scopedSlots:t._u([{key:"activator",fn:function({on:i,attrs:n}){return[r("small",t._g(t._b({},"small",n,!1),i),[t._v(t._s(t.variance))])]}}])},[r("span",[t._v(" max: "+t._s(t.max)+" "),r("br"),t._v(" min: "+t._s(t.min)+" ")])])],1),r(_e,{staticClass:"col-auto py-0 d-flex flex-row align-center justify-end"},[t.is_active?r(be,{staticClass:"px-2 minwidth-0",staticStyle:{height:"48px",width:"48px"},attrs:{text:"",tile:"",loading:t.isLoadingLoad},on:{click:function(i){t.showRename=!0}}},[r(ut,[t._v(t._s(t.mdiPencil))])],1):r(be,{staticClass:"px-2 minwidth-0",staticStyle:{height:"48px",width:"48px"},attrs:{text:"",tile:"",loading:t.isLoadingLoad},on:{click:t.loadProfile}},[r(ut,[t._v(t._s(t.mdiProgressUpload))])],1),r(be,{staticClass:"px-2 minwidth-0",staticStyle:{height:"48px",width:"48px"},attrs:{text:"",tile:"",loading:t.isLoadingRemove,title:t.$t("Heightmap.DeleteBedMeshProfile")},on:{click:function(i){t.showRemove=!0}}},[r(ut,[t._v(t._s(t.mdiDelete))])],1)],1),r(ca,{attrs:{show:t.showRemove,name:t.name},on:{close:function(i){t.showRemove=!1}}}),r(Wi,{attrs:{show:t.showRename,name:t.name},on:{close:function(i){t.showRename=!1}}})],1)},io=[],no=dt(fr,ro,io,!1,null,"b0715bd0");const fa=no.exports;var ao=Object.getOwnPropertyDescriptor,so=(e,t,r,i)=>{for(var n=i>1?void 0:i?ao(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n};let Si=class extends ct(ft){constructor(){super(...arguments),this.mdiStackOverflow=es}get profiles(){var e,t;return(t=(e=this.$store.state.printer.bed_mesh)==null?void 0:e.profiles)!=null?t:{}}};Si=so([at({components:{HeightmapProfilesPanelRow:fa}})],Si);var oo=function(){var t=this,r=t._self._c;return t._self._setupProxy,r(Dt,{staticClass:"mt-6 mt-md-0",attrs:{title:t.$t("Heightmap.Profiles"),"card-class":"heightmap-profiles-panel",icon:t.mdiStackOverflow,collapsible:!0}},[Object.keys(t.profiles).length?r(et,{staticClass:"px-0 py-3"},[t._l(t.profiles,function(i,n,a){return[a?r(Wt,{key:"deliver_".concat(n),staticClass:"my-3"}):t._e(),r(fa,{key:"profile_".concat(n),attrs:{profile:i,name:n}})]})],2):r(et,[r("p",{staticClass:"mb-0"},[t._v(t._s(t.$t("Heightmap.NoProfile")))])])],1)},lo=[],uo=dt(Si,oo,lo,!1,null,null);const ho=uo.exports;var co=Object.getOwnPropertyDescriptor,fo=(e,t,r,i)=>{for(var n=i>1?void 0:i?co(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n};let dr=class extends ls{get bed_mesh(){var e;return(e=this.$store.state.printer.bed_mesh)!=null?e:{}}get profiles(){var e;return(e=this.bed_mesh.profiles)!=null?e:{}}get mesh_min(){var e;return(e=this.bed_mesh.mesh_min)!=null?e:[0,0]}get mesh_max(){var e;return(e=this.bed_mesh.mesh_max)!=null?e:[0,0]}get min(){return Math.min(...this.points)}get max(){return Math.max(...this.points)}get variance(){return Math.abs(this.min-this.max).toFixed(3)}get is_active(){return this.bed_mesh.profile_name!==""?!0:this.mesh_min[0]!==0||this.mesh_min[1]!==0||this.mesh_max[0]!==0||this.mesh_max[1]!==0}get name(){return this.bed_mesh.profile_name!==""?this.bed_mesh.profile_name:"Unknown"}get probed_matrix(){var e;return(e=this.bed_mesh.probed_matrix)!=null?e:[]}get points(){const e=[];for(let t=0;t<this.probed_matrix.length;t++)for(let r=0;r<this.probed_matrix[t].length;r++)e.push(this.probed_matrix[t][r]);return e}};dr=fo([at],dr);var vo=Object.getOwnPropertyDescriptor,po=(e,t,r,i)=>{for(var n=i>1?void 0:i?vo(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n};let Ai=class extends ct(ft,dr){constructor(){super(...arguments),this.mdiInformation=ts,this.mdiPencil=ra,this.showRename=!1}get x_count(){var e,t;return(t=(e=this.bed_mesh.probed_matrix[0])==null?void 0:e.length)!=null?t:0}get y_count(){var e,t;return(t=(e=this.bed_mesh.probed_matrix)==null?void 0:e.length)!=null?t:0}get x_step_size(){return this.x_count<1?0:(this.mesh_max[0]-this.mesh_min[0])/(this.x_count-1)}get y_step_size(){return this.y_count<1?0:(this.mesh_max[1]-this.mesh_min[1])/(this.y_count-1)}get index_max(){return this.points.indexOf(this.max)}get index_max_y(){return Math.trunc(this.index_max/this.x_count)}get index_max_x(){return this.index_max%this.y_count}get position_max_x(){return this.mesh_min[0]+this.index_max_x*this.x_step_size}get position_max_y(){return this.mesh_min[1]+this.index_max_y*this.y_step_size}get index_min(){return this.points.indexOf(this.min)}get index_min_y(){return Math.trunc(this.index_min/this.x_count)}get index_min_x(){return this.index_min%this.y_count}get position_min_x(){return this.mesh_min[0]+this.index_min_x*this.x_step_size}get position_min_y(){return this.mesh_min[1]+this.index_min_y*this.y_step_size}};Ai=po([at({components:{}})],Ai);var mo=function(){var t=this,r=t._self._c;return t._self._setupProxy,t.is_active?r(Dt,{staticClass:"mt-0",attrs:{title:t.$t("Heightmap.CurrentMesh.Headline"),"card-class":"heightmap-current-mesh-panel",icon:t.mdiInformation,collapsible:!0}},[r(et,{staticClass:"py-3 px-0"},[r(Je,{staticClass:"px-3"},[r(_e,[t._v(t._s(t.$t("Heightmap.CurrentMesh.Name")))]),r(_e,{staticClass:"text-right"},[t.name.startsWith("adaptive-")?r("span",{staticClass:"font-weight-bold"},[t._v(t._s(t.name))]):r("span",{staticClass:"currentMeshName cursor-pointer font-weight-bold",on:{click:function(i){t.showRename=!0}}},[r(ut,{attrs:{left:"",small:"",color:"primary"}},[t._v(t._s(t.mdiPencil))]),t._v(" "+t._s(t.name)+" ")],1)])],1),r(Wt,{staticClass:"my-3"}),r(Je,{staticClass:"px-3"},[r(_e,[t._v(t._s(t.$t("Heightmap.CurrentMesh.Size")))]),r(_e,{staticClass:"text-right"},[t._v(t._s(t.x_count)+"x"+t._s(t.y_count))])],1),r(Wt,{staticClass:"my-3"}),t.index_max>-1?r(Je,{staticClass:"px-3"},[r(_e,[t._v(" "+t._s(t.$t("Heightmap.CurrentMesh.Max"))+" ["+t._s(t.position_max_x.toFixed(1))+", "+t._s(t.position_max_y.toFixed(1))+"] ")]),r(_e,{staticClass:"text-right"},[t._v(t._s(t.max.toFixed(3))+" mm")])],1):t._e(),r(Wt,{staticClass:"my-3"}),r(Je,{staticClass:"px-3"},[r(_e,[t._v(" "+t._s(t.$t("Heightmap.CurrentMesh.Min"))+" ["+t._s(t.position_min_x.toFixed(1))+", "+t._s(t.position_min_y.toFixed(1))+"] ")]),r(_e,{staticClass:"text-right"},[t._v(t._s(t.min.toFixed(3))+" mm")])],1),r(Wt,{staticClass:"my-3"}),r(Je,{staticClass:"px-3"},[r(_e,[t._v(t._s(t.$t("Heightmap.CurrentMesh.Range")))]),r(_e,{staticClass:"text-right"},[t._v(t._s(t.variance)+" mm")])],1)],1),r(Wi,{attrs:{show:t.showRename,name:t.name},on:{close:function(i){t.showRename=!1}}})],1):t._e()},_o=[],go=dt(Ai,mo,_o,!1,null,"1001f9ee");const yo=go.exports;var xo=Object.defineProperty,To=Object.getOwnPropertyDescriptor,qi=(e,t,r,i)=>{for(var n=i>1?void 0:i?To(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=(i?s(t,r,n):s(n))||n);return i&&n&&xo(t,r,n),n};let vr=class extends ct(ft){constructor(){super(...arguments),this.mdiCloseThick=zi,this.mdiGrid=jr,this.isInvalidName=!1,this.name="",this.rules=[e=>!!e||this.$t("Heightmap.InvalidNameEmpty"),e=>e===e.replace(/[^\x00-\x7F]/g,"")||this.$t("Heightmap.InvalidNameAscii")]}calibrateMesh(){const e='BED_MESH_CALIBRATE PROFILE="'.concat(this.name,'"');this.$store.dispatch("server/addEvent",{message:e,type:"command"}),this.$socket.emit("printer.gcode.script",{script:e},{loading:"bedMeshCalibrate"}),this.closeDialog()}closeDialog(){this.$emit("close")}showChanged(){this.show&&(this.name="default",this.$nextTick(()=>{setTimeout(()=>{var e;(e=this.$refs.input)==null||e.focus()},100)}))}};qi([ze({type:Boolean,required:!0})],vr.prototype,"show",2);qi([ta("show")],vr.prototype,"showChanged",1);vr=qi([at],vr);var wo=function(){var t=this,r=t._self._c;return t._self._setupProxy,r(Gi,{attrs:{value:t.show,persistent:"","max-width":400},on:{keydown:function(i){return!i.type.indexOf("key")&&t._k(i.keyCode,"esc",27,i.key,["Esc","Escape"])?null:t.closeDialog.apply(null,arguments)}}},[r(Dt,{attrs:{title:t.$t("Heightmap.BedMeshCalibrate"),icon:t.mdiGrid,"card-class":"heightmap-calibrate-dialog","margin-bottom":!1},scopedSlots:t._u([{key:"buttons",fn:function(){return[r(be,{attrs:{icon:"",tile:""},on:{click:t.closeDialog}},[r(ut,[t._v(t._s(t.mdiCloseThick))])],1)]},proxy:!0}])},[r(et,[r(ia,{ref:"input",attrs:{label:t.$t("Heightmap.Name"),required:"",rules:t.rules},on:{"update:error":i=>{t.isInvalidName=i},keyup:function(i){return!i.type.indexOf("key")&&t._k(i.keyCode,"enter",13,i.key,"Enter")?null:t.calibrateMesh.apply(null,arguments)}},model:{value:t.name,callback:function(i){t.name=i},expression:"name"}})],1),r(ki,[r(Vi),r(be,{attrs:{text:""},on:{click:t.closeDialog}},[t._v(t._s(t.$t("Heightmap.Abort")))]),r(be,{attrs:{disabled:t.isInvalidName,color:"primary",text:""},on:{click:t.calibrateMesh}},[t._v(" "+t._s(t.$t("Heightmap.Calibrate"))+" ")])],1)],1)],1)},Eo=[],bo=dt(vr,wo,Eo,!1,null,null);const da=bo.exports;function on(e,t,r){typeof t=="object"&&(r=t,t=null);var i=this,n;if(!(e instanceof Function)){n=[];for(var a in e)e.hasOwnProperty(a)&&n.push(a)}var s=function(l){if(i.apply(this,arguments),e instanceof Function?ln(this,e.call(this,l)):So(this,e,n),this.constructor===s)for(var u=s.__initializers__,h=0;h<u.length;h++)u[h].apply(this,arguments)};s.__super__=i,i.__initializers__?s.__initializers__=i.__initializers__.slice():s.__initializers__=[],t&&s.__initializers__.push(t);var o=function(){};return o.prototype=i.prototype,s.prototype=new o,s.prototype.constructor=s,ln(s.prototype,r),s.extend=i.extend,s.derive=i.extend,s}function ln(e,t){if(t)for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])}function So(e,t,r){for(var i=0;i<r.length;i++){var n=r[i];e[n]=t[n]}}const Ao={extend:on,derive:on};function Co(e,t){this.action=e,this.context=t}var Yi={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],r=t.length,i=-1,n=arguments;switch(n.length){case 1:for(;++i<r;)t[i].action.call(t[i].context);return;case 2:for(;++i<r;)t[i].action.call(t[i].context,n[1]);return;case 3:for(;++i<r;)t[i].action.call(t[i].context,n[1],n[2]);return;case 4:for(;++i<r;)t[i].action.call(t[i].context,n[1],n[2],n[3]);return;case 5:for(;++i<r;)t[i].action.call(t[i].context,n[1],n[2],n[3],n[4]);return;default:for(;++i<r;)t[i].action.apply(t[i].context,Array.prototype.slice.call(n,1));return}}},on:function(e,t,r){if(!(!e||!t)){var i=this.__handlers__||(this.__handlers__={});if(!i[e])i[e]=[];else if(this.has(e,t))return;var n=new Co(t,r||this);return i[e].push(n),this}},once:function(e,t,r){if(!e||!t)return;var i=this;function n(){i.off(e,n),t.apply(this,arguments)}return this.on(e,n,r)},before:function(e,t,r){if(!(!e||!t))return e="before"+e,this.on(e,t,r)},after:function(e,t,r){if(!(!e||!t))return e="after"+e,this.on(e,t,r)},success:function(e,t){return this.once("success",e,t)},error:function(e,t){return this.once("error",e,t)},off:function(e,t){var r=this.__handlers__||(this.__handlers__={});if(!t){r[e]=[];return}if(r[e]){for(var i=r[e],n=[],a=0;a<i.length;a++)t&&i[a].action!==t&&n.push(i[a]);r[e]=n}return this},has:function(e,t){var r=this.__handlers__;if(!r||!r[e])return!1;for(var i=r[e],n=0;n<i.length;n++)if(i[n].action===t)return!0}},Mo=0,Po=Array.prototype,Ro=Po.forEach,me={genGUID:function(){return++Mo},relative2absolute:function(e,t){if(!t||e.match(/^\//))return e;for(var r=e.split("/"),i=t.split("/"),n=r[0];n==="."||n==="..";)n===".."&&i.pop(),r.shift(),n=r[0];return i.join("/")+"/"+r.join("/")},extend:function(e,t){if(t)for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},defaults:function(e,t){if(t)for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e},extendWithPropList:function(e,t,r){if(t)for(var i=0;i<r.length;i++){var n=r[i];e[n]=t[n]}return e},defaultsWithPropList:function(e,t,r){if(t)for(var i=0;i<r.length;i++){var n=r[i];e[n]==null&&(e[n]=t[n])}return e},each:function(e,t,r){if(e&&t)if(e.forEach&&e.forEach===Ro)e.forEach(t,r);else if(e.length===+e.length)for(var i=0,n=e.length;i<n;i++)t.call(r,e[i],i,e);else for(var a in e)e.hasOwnProperty(a)&&t.call(r,e[a],a,e)},isObject:function(e){return e===Object(e)},isArray:function(e){return Array.isArray(e)},isArrayLike:function(e){return e?e.length===+e.length:!1},clone:function(e){if(me.isObject(e)){if(me.isArray(e))return e.slice();if(me.isArrayLike(e)){for(var t=new e.constructor(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}else return me.extend({},e)}else return e}},Pe=function(){this.__uid__=me.genGUID()};Pe.__initializers__=[function(e){me.extend(this,e)}];me.extend(Pe,Ao);me.extend(Pe.prototype,Yi);var un=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],hn=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];function Lo(e){for(var t={},r={},i=0;i<un.length;i++){var n=un[i];s(n)}for(var i=0;i<hn.length;i++){var a=hn[i];r[a]=e.getParameter(e[a])}this.getExtension=function(o){return o in t||s(o),t[o]},this.getParameter=function(o){return r[o]};function s(o){if(e.getExtension){var l=e.getExtension(o);l||(l=e.getExtension("MOZ_"+o)),l||(l=e.getExtension("WEBKIT_"+o)),t[o]=l}}}const b={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CW:2304,CCW:2305,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_2D:3553,TEXTURE_CUBE_MAP:34067,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FRAMEBUFFER:36160,RENDERBUFFER:36161,DEPTH_STENCIL:34041,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306};function No(e){var t=new XMLHttpRequest;t.open("get",e.url),t.responseType=e.responseType||"text",e.onprogress&&(t.onprogress=function(r){if(r.lengthComputable){var i=r.loaded/r.total;e.onprogress(i,r.loaded,r.total)}else e.onprogress(null)}),t.onload=function(r){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}const Do={get:No};var ti,J={};J.supportWebGL=function(){if(ti==null)try{var e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)throw new Error}catch{ti=!1}return ti};J.Int8Array=typeof Int8Array>"u"?Array:Int8Array;J.Uint8Array=typeof Uint8Array>"u"?Array:Uint8Array;J.Uint16Array=typeof Uint16Array>"u"?Array:Uint16Array;J.Uint32Array=typeof Uint32Array>"u"?Array:Uint32Array;J.Int16Array=typeof Int16Array>"u"?Array:Int16Array;J.Float32Array=typeof Float32Array>"u"?Array:Float32Array;J.Float64Array=typeof Float64Array>"u"?Array:Float64Array;var Pt={};typeof window<"u"?Pt=window:typeof global<"u"&&(Pt=global);J.requestAnimationFrame=Pt.requestAnimationFrame||Pt.msRequestAnimationFrame||Pt.mozRequestAnimationFrame||Pt.webkitRequestAnimationFrame||function(e){setTimeout(e,16)};J.createCanvas=function(){return document.createElement("canvas")};J.createImage=function(){return new Pt.Image};J.request={get:Do.get};J.addEventListener=function(e,t,r,i){e.addEventListener(t,r,i)};J.removeEventListener=function(e,t,r){e.removeEventListener(t,r)};var we=function(){this.head=null,this.tail=null,this._length=0};we.prototype.insert=function(e){var t=new we.Entry(e);return this.insertEntry(t),t};we.prototype.insertAt=function(e,t){if(!(e<0)){for(var r=this.head,i=0;r&&i!=e;)r=r.next,i++;if(r){var n=new we.Entry(t),a=r.prev;a?(a.next=n,n.prev=a):this.head=n,n.next=r,r.prev=n}else this.insert(t)}};we.prototype.insertBeforeEntry=function(e,t){var r=new we.Entry(e),i=t.prev;i?(i.next=r,r.prev=i):this.head=r,r.next=t,t.prev=r,this._length++};we.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++};we.prototype.remove=function(e){var t=e.prev,r=e.next;t?t.next=r:this.head=r,r?r.prev=t:this.tail=t,e.next=e.prev=null,this._length--};we.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;if(t)return this.remove(t),t.value}};we.prototype.getHead=function(){if(this.head)return this.head.value};we.prototype.getTail=function(){if(this.tail)return this.tail.value};we.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t.value}};we.prototype.indexOf=function(e){for(var t=this.head,r=0;t;){if(t.value===e)return r;t=t.next,r++}};we.prototype.length=function(){return this._length};we.prototype.isEmpty=function(){return this._length===0};we.prototype.forEach=function(e,t){for(var r=this.head,i=0,n=typeof t<"u";r;)n?e.call(t,r.value,i):e(r.value,i),r=r.next,i++};we.prototype.clear=function(){this.tail=this.head=null,this._length=0};we.Entry=function(e){this.value=e,this.next=null,this.prev=null};var Ot=function(e){this._list=new we,this._map={},this._maxSize=e||10};Ot.prototype.setMaxSize=function(e){this._maxSize=e};Ot.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){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(t);n.key=e,this._map[e]=n}};Ot.prototype.get=function(e){var t=this._map[e];if(this._map.hasOwnProperty(e))return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value};Ot.prototype.remove=function(e){var t=this._map[e];typeof t<"u"&&(delete this._map[e],this._list.remove(t))};Ot.prototype.clear=function(){this._list.clear(),this._map={}};var ce={},cn={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 Ye(e){return e=Math.round(e),e<0?0:e>255?255:e}function Oo(e){return e=Math.round(e),e<0?0:e>360?360:e}function pr(e){return e<0?0:e>1?1:e}function ri(e){return e.length&&e.charAt(e.length-1)==="%"?Ye(parseFloat(e)/100*255):Ye(parseInt(e,10))}function Yt(e){return e.length&&e.charAt(e.length-1)==="%"?pr(parseFloat(e)/100):pr(parseFloat(e))}function ii(e,t,r){return r<0?r+=1:r>1&&(r-=1),r*6<1?e+(t-e)*r*6:r*2<1?t:r*3<2?e+(t-e)*(2/3-r)*6:e}function yt(e,t,r){return e+(t-e)*r}function qe(e,t,r,i,n){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e}function Ci(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var va=new Ot(20),Ar=null;function Ft(e,t){Ar&&Ci(Ar,t),Ar=va.put(e,Ar||t.slice())}ce.parse=function(e,t){if(e){t=t||[];var r=va.get(e);if(r)return Ci(t,r);e=e+"";var i=e.replace(/ /g,"").toLowerCase();if(i in cn)return Ci(t,cn[i]),Ft(e,t),t;if(i.charAt(0)==="#"){if(i.length===4){var n=parseInt(i.substr(1),16);if(!(n>=0&&n<=4095)){qe(t,0,0,0,1);return}return qe(t,(n&3840)>>4|(n&3840)>>8,n&240|(n&240)>>4,n&15|(n&15)<<4,1),Ft(e,t),t}else if(i.length===7){var n=parseInt(i.substr(1),16);if(!(n>=0&&n<=16777215)){qe(t,0,0,0,1);return}return qe(t,(n&16711680)>>16,(n&65280)>>8,n&255,1),Ft(e,t),t}return}var a=i.indexOf("("),s=i.indexOf(")");if(a!==-1&&s+1===i.length){var o=i.substr(0,a),l=i.substr(a+1,s-(a+1)).split(","),u=1;switch(o){case"rgba":if(l.length!==4){qe(t,0,0,0,1);return}u=Yt(l.pop());case"rgb":if(l.length!==3){qe(t,0,0,0,1);return}return qe(t,ri(l[0]),ri(l[1]),ri(l[2]),u),Ft(e,t),t;case"hsla":if(l.length!==4){qe(t,0,0,0,1);return}return l[3]=Yt(l[3]),Mi(l,t),Ft(e,t),t;case"hsl":if(l.length!==3){qe(t,0,0,0,1);return}return Mi(l,t),Ft(e,t),t;default:return}}qe(t,0,0,0,1)}};ce.parseToFloat=function(e,t){if(t=ce.parse(e,t),!!t)return t[0]/=255,t[1]/=255,t[2]/=255,t};function Mi(e,t){var r=(parseFloat(e[0])%360+360)%360/360,i=Yt(e[1]),n=Yt(e[2]),a=n<=.5?n*(i+1):n+i-n*i,s=n*2-a;return t=t||[],qe(t,Ye(ii(s,a,r+1/3)*255),Ye(ii(s,a,r)*255),Ye(ii(s,a,r-1/3)*255),1),e.length===4&&(t[3]=e[3]),t}function Io(e){if(e){var t=e[0]/255,r=e[1]/255,i=e[2]/255,n=Math.min(t,r,i),a=Math.max(t,r,i),s=a-n,o=(a+n)/2,l,u;if(s===0)l=0,u=0;else{o<.5?u=s/(a+n):u=s/(2-a-n);var h=((a-t)/6+s/2)/s,c=((a-r)/6+s/2)/s,d=((a-i)/6+s/2)/s;t===a?l=d-c:r===a?l=1/3+h-d:i===a&&(l=2/3+c-h),l<0&&(l+=1),l>1&&(l-=1)}var f=[l*360,u,o];return e[3]!=null&&f.push(e[3]),f}}ce.lift=function(e,t){var r=ce.parse(e);if(r){for(var i=0;i<3;i++)t<0?r[i]=r[i]*(1-t)|0:r[i]=(255-r[i])*t+r[i]|0;return ce.stringify(r,r.length===4?"rgba":"rgb")}};ce.toHex=function(e){var t=ce.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)};ce.fastLerp=function(e,t,r){if(!(!(t&&t.length)||!(e>=0&&e<=1))){r=r||[];var i=e*(t.length-1),n=Math.floor(i),a=Math.ceil(i),s=t[n],o=t[a],l=i-n;return r[0]=Ye(yt(s[0],o[0],l)),r[1]=Ye(yt(s[1],o[1],l)),r[2]=Ye(yt(s[2],o[2],l)),r[3]=pr(yt(s[3],o[3],l)),r}};ce.fastMapToColor=ce.fastLerp;ce.lerp=function(e,t,r){if(!(!(t&&t.length)||!(e>=0&&e<=1))){var i=e*(t.length-1),n=Math.floor(i),a=Math.ceil(i),s=ce.parse(t[n]),o=ce.parse(t[a]),l=i-n,u=ce.stringify([Ye(yt(s[0],o[0],l)),Ye(yt(s[1],o[1],l)),Ye(yt(s[2],o[2],l)),pr(yt(s[3],o[3],l))],"rgba");return r?{color:u,leftIndex:n,rightIndex:a,value:i}:u}};ce.mapToColor=ce.lerp;ce.modifyHSL=function(e,t,r,i){if(e=ce.parse(e),e)return e=Io(e),t!=null&&(e[0]=Oo(t)),r!=null&&(e[1]=Yt(r)),i!=null&&(e[2]=Yt(i)),ce.stringify(Mi(e),"rgba")};ce.modifyAlpha=function(e,t){if(e=ce.parse(e),e&&t!=null)return e[3]=pr(t),ce.stringify(e,"rgba")};ce.stringify=function(e,t){if(!(!e||!e.length)){var r=e[0]+","+e[1]+","+e[2];return(t==="rgba"||t==="hsva"||t==="hsla")&&(r+=","+e[3]),t+"("+r+")"}};var Fo=ce.parseToFloat,ni={};function fn(e){var t=Object.keys(e);t.sort();for(var r=[],i=0;i<t.length;i++){var n=t[i],a=e[n];a===null?r.push(n):r.push(n+" "+a.toString())}return r.join("\n")}function Bo(e,t,r){r.sort();for(var i=[],n=0;n<r.length;n++){var a=r[n];i.push(a)}var s=fn(e)+"\n"+fn(t)+"\n"+i.join("\n");if(ni[s])return ni[s];var o=me.genGUID();return ni[s]=o,o}var vt=Pe.extend(function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}},function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)},{precision:"highp",setUniform:function(e,t){t===void 0&&console.warn('Uniform value "'+e+'" is undefined');var r=this.uniforms[e];r&&(typeof t=="string"&&(t=Fo(t)||t),r.value=t,this.autoUpdateTextureStatus&&r.type==="t"&&(t?this.enableTexture(e):this.disableTexture(e)))},setUniforms:function(e){for(var t in e){var r=e[t];this.setUniform(t,r)}},isUniformEnabled:function(e){return this._enabledUniforms.indexOf(e)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if(typeof e=="object")for(var r in e){var i=e[r];this.setUniform(r,i)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var r=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var i=this.uniforms;this._enabledUniforms=Object.keys(i),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter(function(u){var h=this.uniforms[u].type;return h==="t"||h==="tv"},this);var n=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=me.clone(e.vertexDefines),this.fragmentDefines=me.clone(e.fragmentDefines),t){for(var s in r)i[s]&&(i[s].value=r[s].value);me.defaults(this.vertexDefines,n),me.defaults(this.fragmentDefines,a)}var o={};for(var l in e.textures)o[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:t&&this._textureStatus[l]?this._textureStatus[l].enabled:!1};this._textureStatus=o,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=me.clone(this.vertexDefines),e.fragmentDefines=me.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,r){var i=this.vertexDefines,n=this.fragmentDefines;e!=="vertex"&&e!=="fragment"&&e!=="both"&&arguments.length<3&&(r=t,t=e,e="both"),r=r!=null?r:null,(e==="vertex"||e==="both")&&i[t]!==r&&(i[t]=r,this._programKey=""),(e==="fragment"||e==="both")&&n[t]!==r&&(n[t]=r,e!=="both"&&(this._programKey=""))},undefine:function(e,t){e!=="vertex"&&e!=="fragment"&&e!=="both"&&arguments.length<2&&(t=e,e="both"),(e==="vertex"||e==="both")&&this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),(e==="fragment"||e==="both")&&this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],e!=="both"&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return this.vertexDefines[t]!==void 0;case"fragment":return this.fragmentDefines[t]!==void 0}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e)){for(var t=0;t<e.length;t++)this.enableTexture(e[t]);return}var r=this._textureStatus[e];if(r){var i=r.enabled;i||(r.enabled=!0,this._programKey="")}},enableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!0;this._programKey=""},disableTexture:function(e){if(Array.isArray(e)){for(var t=0;t<e.length;t++)this.disableTexture(e[t]);return}var r=this._textureStatus[e];if(r){var i=!r.enabled;i||(r.enabled=!1,this._programKey="")}},disableTexturesAll:function(){var e=this._textureStatus;for(var t in e)e[t].enabled=!1;this._programKey=""},isTextureEnabled:function(e){var t=this._textureStatus;return!!t[e]&&t[e].enabled},getEnabledTextures:function(){var e=[],t=this._textureStatus;for(var r in t)t[r].enabled&&e.push(r);return e},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=Bo(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}}),Br=1e-6,Ae=Array,Xt=Math.random,R={};R.create=function(){var e=new Ae(2);return e[0]=0,e[1]=0,e};R.clone=function(e){var t=new Ae(2);return t[0]=e[0],t[1]=e[1],t};R.fromValues=function(e,t){var r=new Ae(2);return r[0]=e,r[1]=t,r};R.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e};R.set=function(e,t,r){return e[0]=t,e[1]=r,e};R.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e};R.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e};R.sub=R.subtract;R.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e};R.mul=R.multiply;R.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e};R.div=R.divide;R.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e};R.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e};R.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e};R.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e};R.distance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(r*r+i*i)};R.dist=R.distance;R.squaredDistance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i};R.sqrDist=R.squaredDistance;R.length=function(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)};R.len=R.length;R.squaredLength=function(e){var t=e[0],r=e[1];return t*t+r*r};R.sqrLen=R.squaredLength;R.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e};R.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e};R.normalize=function(e,t){var r=t[0],i=t[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n),e[0]=t[0]*n,e[1]=t[1]*n),e};R.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]};R.cross=function(e,t,r){var i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e};R.lerp=function(e,t,r,i){var n=t[0],a=t[1];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e};R.random=function(e,t){t=t||1;var r=GLMAT_RANDOM()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e};R.transformMat2=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[2]*n,e[1]=r[1]*i+r[3]*n,e};R.transformMat2d=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[2]*n+r[4],e[1]=r[1]*i+r[3]*n+r[5],e};R.transformMat3=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[3]*n+r[6],e[1]=r[1]*i+r[4]*n+r[7],e};R.transformMat4=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e};R.forEach=function(){var e=R.create();return function(t,r,i,n,a,s){var o,l;for(r||(r=2),i||(i=0),n?l=Math.min(n*r+i,t.length):l=t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],a(e,e,s),t[o]=e[0],t[o+1]=e[1];return t}}();var q=function(e,t){e=e||0,t=t||0,this.array=R.fromValues(e,t),this._dirty=!0};q.prototype={constructor:q,add:function(e){return R.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t){return this.array[0]=e,this.array[1]=t,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this._dirty=!0,this},clone:function(){return new q(this.x,this.y)},copy:function(e){return R.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return R.cross(e.array,this.array,t.array),e._dirty=!0,this},dist:function(e){return R.dist(this.array,e.array)},distance:function(e){return R.distance(this.array,e.array)},div:function(e){return R.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return R.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return R.dot(this.array,e.array)},len:function(){return R.len(this.array)},length:function(){return R.length(this.array)},lerp:function(e,t,r){return R.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return R.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return R.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return R.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return R.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return R.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return R.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return R.random(this.array,e),this._dirty=!0,this},scale:function(e){return R.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return R.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return R.sqrDist(this.array,e.array)},squaredDistance:function(e){return R.squaredDistance(this.array,e.array)},sqrLen:function(){return R.sqrLen(this.array)},squaredLength:function(){return R.squaredLength(this.array)},sub:function(e){return R.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return R.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat2:function(e){return R.transformMat2(this.array,this.array,e.array),this._dirty=!0,this},transformMat2d:function(e){return R.transformMat2d(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return R.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return R.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};if(Object.defineProperty){var dn=q.prototype;Object.defineProperty(dn,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Object.defineProperty(dn,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}})}q.add=function(e,t,r){return R.add(e.array,t.array,r.array),e._dirty=!0,e};q.set=function(e,t,r){return R.set(e.array,t,r),e._dirty=!0,e};q.copy=function(e,t){return R.copy(e.array,t.array),e._dirty=!0,e};q.cross=function(e,t,r){return R.cross(e.array,t.array,r.array),e._dirty=!0,e};q.dist=function(e,t){return R.distance(e.array,t.array)};q.distance=q.dist;q.div=function(e,t,r){return R.divide(e.array,t.array,r.array),e._dirty=!0,e};q.divide=q.div;q.dot=function(e,t){return R.dot(e.array,t.array)};q.len=function(e){return R.length(e.array)};q.lerp=function(e,t,r,i){return R.lerp(e.array,t.array,r.array,i),e._dirty=!0,e};q.min=function(e,t,r){return R.min(e.array,t.array,r.array),e._dirty=!0,e};q.max=function(e,t,r){return R.max(e.array,t.array,r.array),e._dirty=!0,e};q.mul=function(e,t,r){return R.multiply(e.array,t.array,r.array),e._dirty=!0,e};q.multiply=q.mul;q.negate=function(e,t){return R.negate(e.array,t.array),e._dirty=!0,e};q.normalize=function(e,t){return R.normalize(e.array,t.array),e._dirty=!0,e};q.random=function(e,t){return R.random(e.array,t),e._dirty=!0,e};q.scale=function(e,t,r){return R.scale(e.array,t.array,r),e._dirty=!0,e};q.scaleAndAdd=function(e,t,r,i){return R.scaleAndAdd(e.array,t.array,r.array,i),e._dirty=!0,e};q.sqrDist=function(e,t){return R.sqrDist(e.array,t.array)};q.squaredDistance=q.sqrDist;q.sqrLen=function(e){return R.sqrLen(e.array)};q.squaredLength=q.sqrLen;q.sub=function(e,t,r){return R.subtract(e.array,t.array,r.array),e._dirty=!0,e};q.subtract=q.sub;q.transformMat2=function(e,t,r){return R.transformMat2(e.array,t.array,r.array),e._dirty=!0,e};q.transformMat2d=function(e,t,r){return R.transformMat2d(e.array,t.array,r.array),e._dirty=!0,e};q.transformMat3=function(e,t,r){return R.transformMat3(e.array,t.array,r.array),e._dirty=!0,e};q.transformMat4=function(e,t,r){return R.transformMat4(e.array,t.array,r.array),e._dirty=!0,e};var vn=1,pn=2,ai=3,mn={};function Uo(e){for(var t=e.split("\n"),r=0,i=t.length;r<i;r++)t[r]=r+1+": "+t[r];return t.join("\n")}function _n(e,t,r){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),Uo(r)].join("\n")}var gn=new J.Float32Array(16),Ho=Pe.extend({uniformSemantics:{},attributes:{}},function(){this._locations={},this._textureSlot=0,this._program=null},{bind:function(e){this._textureSlot=0,e.gl.useProgram(this._program)},hasUniform:function(e){var t=this._locations[e];return t!=null},useTextureSlot:function(e,t,r){t&&(e.gl.activeTexture(e.gl.TEXTURE0+r),t.isRenderable()?t.bind(e):t.unbind(e))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(e){this._textureSlot=e||0},takeCurrentTextureSlot:function(e,t){var r=this._textureSlot;return this.useTextureSlot(e,t,r),this._textureSlot++,r},setUniform:function(e,t,r,i){var n=this._locations,a=n[r];if(a==null)return!1;switch(t){case"m4":if(!(i instanceof Float32Array)){for(var s=0;s<i.length;s++)gn[s]=i[s];i=gn}e.uniformMatrix4fv(a,!1,i);break;case"2i":e.uniform2i(a,i[0],i[1]);break;case"2f":e.uniform2f(a,i[0],i[1]);break;case"3i":e.uniform3i(a,i[0],i[1],i[2]);break;case"3f":e.uniform3f(a,i[0],i[1],i[2]);break;case"4i":e.uniform4i(a,i[0],i[1],i[2],i[3]);break;case"4f":e.uniform4f(a,i[0],i[1],i[2],i[3]);break;case"1i":e.uniform1i(a,i);break;case"1f":e.uniform1f(a,i);break;case"1fv":e.uniform1fv(a,i);break;case"1iv":e.uniform1iv(a,i);break;case"2iv":e.uniform2iv(a,i);break;case"2fv":e.uniform2fv(a,i);break;case"3iv":e.uniform3iv(a,i);break;case"3fv":e.uniform3fv(a,i);break;case"4iv":e.uniform4iv(a,i);break;case"4fv":e.uniform4fv(a,i);break;case"m2":case"m2v":e.uniformMatrix2fv(a,!1,i);break;case"m3":case"m3v":e.uniformMatrix3fv(a,!1,i);break;case"m4v":if(Array.isArray(i)&&Array.isArray(i[0])){for(var o=new J.Float32Array(i.length*16),l=0,s=0;s<i.length;s++)for(var u=i[s],h=0;h<16;h++)o[l++]=u[h];e.uniformMatrix4fv(a,!1,o)}else e.uniformMatrix4fv(a,!1,i);break}return!0},setUniformOfSemantic:function(e,t,r){var i=this.uniformSemantics[t];return i?this.setUniform(e,i.type,i.symbol,r):!1},enableAttributes:function(e,t,r){var i=e.gl,n=this._program,a=this._locations,s;r?s=r.__enabledAttributeList:s=mn[e.__uid__],s||(r?s=r.__enabledAttributeList=[]:s=mn[e.__uid__]=[]);for(var o=[],l=0;l<t.length;l++){var u=t[l];if(!this.attributes[u]){o[l]=-1;continue}var h=a[u];if(h==null){if(h=i.getAttribLocation(n,u),h===-1){o[l]=-1;continue}a[u]=h}o[l]=h,s[h]?s[h]=pn:s[h]=vn}for(var l=0;l<s.length;l++)switch(s[l]){case vn:i.enableVertexAttribArray(l),s[l]=ai;break;case pn:s[l]=ai;break;case ai:i.disableVertexAttribArray(l),s[l]=0;break}return o},getAttribLocation:function(e,t){var r=this._locations,i=r[t];return i==null&&(i=e.getAttribLocation(this._program,t),r[t]=i),i},buildProgram:function(e,t,r,i){var n=e.createShader(e.VERTEX_SHADER),a=e.createProgram();e.shaderSource(n,r),e.compileShader(n);var s=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(s,i),e.compileShader(s);var o=_n(e,n,r);if(o||(o=_n(e,s,i),o))return o;if(e.attachShader(a,n),e.attachShader(a,s),t.attributeSemantics.POSITION)e.bindAttribLocation(a,0,t.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);e.bindAttribLocation(a,0,l[0])}if(e.linkProgram(a),e.deleteShader(n),e.deleteShader(s),this._program=a,this.vertexCode=r,this.fragmentCode=i,!e.getProgramParameter(a,e.LINK_STATUS))return"Could not link program\n"+e.getProgramInfoLog(a);for(var u=0;u<t.uniforms.length;u++){var h=t.uniforms[u];this._locations[h]=e.getUniformLocation(a,h)}}}),zo=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function yn(e,t,r){function i(s,o,l,u){var h="";isNaN(o)&&(o in t?o=t[o]:o=n[o]),isNaN(l)&&(l in t?l=t[l]:l=n[l]);for(var c=parseInt(o);c<parseInt(l);c++)h+="{"+u.replace(/float\s*\(\s*_idx_\s*\)/g,c.toFixed(1)).replace(/_idx_/g,c)+"}";return h}var n={};for(var a in r)n[a+"_COUNT"]=r[a];return e.replace(zo,i)}function si(e,t,r){var i=[];if(t)for(var n in t){var a=t[n];a>0&&i.push("#define "+n.toUpperCase()+"_COUNT "+a)}if(r)for(var s=0;s<r.length;s++){var o=r[s];i.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var l=e[o];l===null?i.push("#define "+o):i.push("#define "+o+" "+l.toString())}return i.join("\n")}function Go(e){for(var t=[],r=0;r<e.length;r++)t.push("#extension GL_"+e[r]+" : enable");return t.join("\n")}function ko(e){return["precision",e,"float"].join(" ")+";\n"+["precision",e,"int"].join(" ")+";\n"+["precision",e,"sampler2D"].join(" ")+";\n"}function pa(e){this._renderer=e,this._cache={}}pa.prototype.getProgram=function(e,t,r){var i=this._cache,n=e.isSkinnedMesh&&e.isSkinnedMesh(),a=e.isInstancedMesh&&e.isInstancedMesh(),s="s"+t.shader.shaderID+"m"+t.getProgramKey();r&&(s+="se"+r.getProgramKey(e.lightGroup)),n&&(s+=",sk"+e.joints.length),a&&(s+=",is");var x=i[s];if(x)return x;var o=r?r.getLightsNumbers(e.lightGroup):{},l=this._renderer,u=l.gl,h=t.getEnabledTextures(),c="";if(n){var d={SKINNING:null,JOINT_COUNT:e.joints.length};e.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),c+="\n"+si(d)+"\n"}a&&(c+="\n#define INSTANCING\n");var f=c+si(t.vertexDefines,o,h),v=c+si(t.fragmentDefines,o,h),p=f+"\n"+t.shader.vertex,m=["OES_standard_derivatives","EXT_shader_texture_lod"].filter(function(S){return l.getGLExtension(S)!=null});m.indexOf("EXT_shader_texture_lod")>=0&&(v+="\n#define SUPPORT_TEXTURE_LOD"),m.indexOf("OES_standard_derivatives")>=0&&(v+="\n#define SUPPORT_STANDARD_DERIVATIVES");var g=Go(m)+"\n"+ko(t.precision)+"\n"+v+"\n"+t.shader.fragment,T=yn(p,t.vertexDefines,o),y=yn(g,t.fragmentDefines,o),x=new Ho;x.uniformSemantics=t.shader.uniformSemantics,x.attributes=t.shader.attributes;var E=x.buildProgram(u,t.shader,T,y);return x.__error=E,i[s]=x,x};var xn=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,Vo=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,Tn=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,Wo={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"};function ot(e){for(var t=[],r=0;r<e;r++)t[r]=0;return t}var wn={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return ot(2)},vec3:function(){return ot(3)},vec4:function(){return ot(4)},ivec2:function(){return ot(2)},ivec3:function(){return ot(3)},ivec4:function(){return ot(4)},mat2:function(){return ot(4)},mat3:function(){return ot(9)},mat4:function(){return ot(16)},array:function(){return[]}},Pi=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],ma=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],_a=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],Xo={vec4:4,vec3:3,vec2:2,float:1},oi={},ga={};function jo(e,t){var r="vertex:"+e+"fragment:"+t;if(oi[r])return oi[r];var i=me.genGUID();return oi[r]=i,ga[i]={vertex:e,fragment:t},i}function En(e){return e.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function Bt(){console.error("Wrong uniform/attributes syntax")}function bn(e,t){for(var r=/[,=\(\):]/,i=t.replace(/:\s*\[\s*(.*)\s*\]/g,"="+e+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),n=[],a=0;a<i.length;a++)i[a].match(r)?n.push(i[a].charAt(0),i[a].slice(1)):n.push(i[a]);i=n;var s=0,o=1,l=2,u=3,h=4,c=5,d=s,f={},v=null,p;m(i[0]);function m(y){y||Bt();var x=y.match(/\[(.*?)\]/);p=y.replace(/\[(.*?)\]/,""),f[p]={},x&&(f[p].isArray=!0,f[p].arraySize=x[1])}for(var a=1;a<i.length;a++){var g=i[a];if(g){if(g==="="){if(d!==s&&d!==u){Bt();break}d=o;continue}else if(g===":"){d=h;continue}else if(g===","){if(d===l){if(!(v instanceof Array)){Bt();break}v.push(+i[++a])}else d=c;continue}else if(g===")"){f[p].value=new J.Float32Array(v),v=null,d=c;continue}else if(g==="("){if(d!==l){Bt();break}if(!(v instanceof Array)){Bt();break}v.push(+i[++a]);continue}else if(g.indexOf("vec")>=0){if(d!==o&&d!==h){Bt();break}d=l,v=[];continue}else if(d===o){e==="bool"?f[p].value=g==="true":f[p].value=parseFloat(g),v=null;continue}else if(d===h){var T=g;Pi.indexOf(T)>=0||ma.indexOf(T)>=0||_a.indexOf(T)>=0?f[p].semantic=T:T==="ignore"||T==="unconfigurable"?f[p].ignore=!0:e==="bool"?f[p].value=T==="true":f[p].value=parseFloat(T);continue}m(g),d=s}}return f}function F(e,t){typeof e=="object"&&(t=e.fragment,e=e.vertex),e=En(e),t=En(t),this._shaderID=jo(e,t),this._vertexCode=F.parseImport(e),this._fragmentCode=F.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}F.prototype={constructor:F,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var r=this.uniformTemplates[t];e[t]={type:r.type,value:r.value()}}return e},_parseImport:function(){this._vertexCode=F.parseImport(this.vertex),this._fragmentCode=F.parseImport(this.fragment)},_addSemanticUniform:function(e,t,r){if(Pi.indexOf(r)>=0)this.attributeSemantics[r]={symbol:e,type:t};else if(_a.indexOf(r)>=0){var i=!1,n=r;r.match(/TRANSPOSE$/)&&(i=!0,n=r.slice(0,-9)),this.matrixSemantics[r]={symbol:e,type:t,isTranspose:i,semanticNoTranspose:n}}else ma.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:e,type:t})},_addMaterialUniform:function(e,t,r,i,n,a){a[e]={type:r,value:n?wn.array:i||wn[t],semantic:null}},_parseUniforms:function(){var e={},t=this,r="vertex";this._uniformList=[],this._vertexCode=this._vertexCode.replace(xn,n),r="fragment",this._fragmentCode=this._fragmentCode.replace(xn,n),t.matrixSemanticKeys=Object.keys(this.matrixSemantics);function i(a){return a!=null?function(){return a}:null}function n(a,s,o){var l=bn(s,o),u=[];for(var h in l){var c=l[h],d=c.semantic,f=h,v=Wo[s],p=i(l[h].value);l[h].isArray&&(f+="["+l[h].arraySize+"]",v+="v"),u.push(f),t._uniformList.push(h),c.ignore||((s==="sampler2D"||s==="samplerCube")&&(t.textures[h]={shaderType:r,type:s}),d?t._addSemanticUniform(h,v,d):t._addMaterialUniform(h,s,v,p,l[h].isArray,e))}return u.length>0?"uniform "+s+" "+u.join(",")+";\n":""}this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(Vo,r);function r(i,n,a){var s=bn(n,a),o=Xo[n]||1,l=[];for(var u in s){var h=s[u].semantic;if(e[u]={type:"float",size:o,semantic:h||null},h){if(Pi.indexOf(h)<0)throw new Error('Unkown semantic "'+h+'"');t.attributeSemantics[h]={symbol:u,type:n}}l.push(u)}return"attribute "+n+" "+l.join(",")+";\n"}this.attributes=e},_parseDefines:function(){var e=this,t="vertex";this._vertexCode=this._vertexCode.replace(Tn,r),t="fragment",this._fragmentCode=this._fragmentCode.replace(Tn,r);function r(i,n,a){var s=t==="vertex"?e.vertexDefines:e.fragmentDefines;return s[n]||(a==="false"?s[n]=!1:a==="true"?s[n]=!0:s[n]=a?isNaN(parseFloat(a))?a.trim():parseFloat(a):null),""}},clone:function(){var e=ga[this._shaderID],t=new F(e.vertex,e.fragment);return t}};Object.defineProperty&&(Object.defineProperty(F.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(F.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(F.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(F.prototype,"uniforms",{get:function(){return this._uniformList}}));var qo=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;F.parseImport=function(e){return e=e.replace(qo,function(n,r,i){var n=F.source(i);return n?F.parseImport(n):(console.error('Shader chunk "'+i+'" not existed in library'),"")}),e};var Yo=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;F.import=function(e){e.replace(Yo,function(t,r,i,a){var a=a.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"");if(a){for(var s=i.split("."),o=F.codes,l=0,u;l<s.length-1;)u=s[l++],o[u]||(o[u]={}),o=o[u];u=s[l],o[u]=a}return a})};F.codes={};F.source=function(e){for(var t=e.split("."),r=F.codes,i=0;r&&i<t.length;){var n=t[i++];r=r[n]}return typeof r!="string"?(console.error('Shader "'+e+'" not existed in library'),""):r};const ya="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end";var C={};C.create=function(){var e=new Ae(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e};C.clone=function(e){var t=new Ae(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t};C.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e};C.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e};C.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[3],a=t[6],s=t[7],o=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=a,e[11]=t[14],e[12]=n,e[13]=s,e[14]=o}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e};C.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],f=t[11],v=t[12],p=t[13],m=t[14],g=t[15],T=r*o-i*s,y=r*l-n*s,x=r*u-a*s,E=i*l-n*o,S=i*u-a*o,O=n*u-a*l,P=h*p-c*v,B=h*m-d*v,k=h*g-f*v,N=c*m-d*p,V=c*g-f*p,z=d*g-f*m,U=T*z-y*V+x*N+E*k-S*B+O*P;return U?(U=1/U,e[0]=(o*z-l*V+u*N)*U,e[1]=(n*V-i*z-a*N)*U,e[2]=(p*O-m*S+g*E)*U,e[3]=(d*S-c*O-f*E)*U,e[4]=(l*k-s*z-u*B)*U,e[5]=(r*z-n*k+a*B)*U,e[6]=(m*x-v*O-g*y)*U,e[7]=(h*O-d*x+f*y)*U,e[8]=(s*V-o*k+u*P)*U,e[9]=(i*k-r*V-a*P)*U,e[10]=(v*S-p*x+g*T)*U,e[11]=(c*x-h*S-f*T)*U,e[12]=(o*B-s*N-l*P)*U,e[13]=(r*N-i*B+n*P)*U,e[14]=(p*y-v*E-m*T)*U,e[15]=(h*E-c*y+d*T)*U,e):null};C.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],f=t[11],v=t[12],p=t[13],m=t[14],g=t[15];return e[0]=o*(d*g-f*m)-c*(l*g-u*m)+p*(l*f-u*d),e[1]=-(i*(d*g-f*m)-c*(n*g-a*m)+p*(n*f-a*d)),e[2]=i*(l*g-u*m)-o*(n*g-a*m)+p*(n*u-a*l),e[3]=-(i*(l*f-u*d)-o*(n*f-a*d)+c*(n*u-a*l)),e[4]=-(s*(d*g-f*m)-h*(l*g-u*m)+v*(l*f-u*d)),e[5]=r*(d*g-f*m)-h*(n*g-a*m)+v*(n*f-a*d),e[6]=-(r*(l*g-u*m)-s*(n*g-a*m)+v*(n*u-a*l)),e[7]=r*(l*f-u*d)-s*(n*f-a*d)+h*(n*u-a*l),e[8]=s*(c*g-f*p)-h*(o*g-u*p)+v*(o*f-u*c),e[9]=-(r*(c*g-f*p)-h*(i*g-a*p)+v*(i*f-a*c)),e[10]=r*(o*g-u*p)-s*(i*g-a*p)+v*(i*u-a*o),e[11]=-(r*(o*f-u*c)-s*(i*f-a*c)+h*(i*u-a*o)),e[12]=-(s*(c*m-d*p)-h*(o*m-l*p)+v*(o*d-l*c)),e[13]=r*(c*m-d*p)-h*(i*m-n*p)+v*(i*d-n*c),e[14]=-(r*(o*m-l*p)-s*(i*m-n*p)+v*(i*l-n*o)),e[15]=r*(o*d-l*c)-s*(i*d-n*c)+h*(i*l-n*o),e};C.determinant=function(e){var t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],h=e[9],c=e[10],d=e[11],f=e[12],v=e[13],p=e[14],m=e[15],g=t*s-r*a,T=t*o-i*a,y=t*l-n*a,x=r*o-i*s,E=r*l-n*s,S=i*l-n*o,O=u*v-h*f,P=u*p-c*f,B=u*m-d*f,k=h*p-c*v,N=h*m-d*v,V=c*m-d*p;return g*V-T*N+y*k+x*B-E*P+S*O};C.multiply=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],f=t[10],v=t[11],p=t[12],m=t[13],g=t[14],T=t[15],y=r[0],x=r[1],E=r[2],S=r[3];return e[0]=y*i+x*o+E*c+S*p,e[1]=y*n+x*l+E*d+S*m,e[2]=y*a+x*u+E*f+S*g,e[3]=y*s+x*h+E*v+S*T,y=r[4],x=r[5],E=r[6],S=r[7],e[4]=y*i+x*o+E*c+S*p,e[5]=y*n+x*l+E*d+S*m,e[6]=y*a+x*u+E*f+S*g,e[7]=y*s+x*h+E*v+S*T,y=r[8],x=r[9],E=r[10],S=r[11],e[8]=y*i+x*o+E*c+S*p,e[9]=y*n+x*l+E*d+S*m,e[10]=y*a+x*u+E*f+S*g,e[11]=y*s+x*h+E*v+S*T,y=r[12],x=r[13],E=r[14],S=r[15],e[12]=y*i+x*o+E*c+S*p,e[13]=y*n+x*l+E*d+S*m,e[14]=y*a+x*u+E*f+S*g,e[15]=y*s+x*h+E*v+S*T,e};C.multiplyAffine=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[4],o=t[5],l=t[6],u=t[8],h=t[9],c=t[10],d=t[12],f=t[13],v=t[14],p=r[0],m=r[1],g=r[2];return e[0]=p*i+m*s+g*u,e[1]=p*n+m*o+g*h,e[2]=p*a+m*l+g*c,p=r[4],m=r[5],g=r[6],e[4]=p*i+m*s+g*u,e[5]=p*n+m*o+g*h,e[6]=p*a+m*l+g*c,p=r[8],m=r[9],g=r[10],e[8]=p*i+m*s+g*u,e[9]=p*n+m*o+g*h,e[10]=p*a+m*l+g*c,p=r[12],m=r[13],g=r[14],e[12]=p*i+m*s+g*u+d,e[13]=p*n+m*o+g*h+f,e[14]=p*a+m*l+g*c+v,e};C.mul=C.multiply;C.mulAffine=C.multiplyAffine;C.translate=function(e,t,r){var i=r[0],n=r[1],a=r[2],s,o,l,u,h,c,d,f,v,p,m,g;return t===e?(e[12]=t[0]*i+t[4]*n+t[8]*a+t[12],e[13]=t[1]*i+t[5]*n+t[9]*a+t[13],e[14]=t[2]*i+t[6]*n+t[10]*a+t[14],e[15]=t[3]*i+t[7]*n+t[11]*a+t[15]):(s=t[0],o=t[1],l=t[2],u=t[3],h=t[4],c=t[5],d=t[6],f=t[7],v=t[8],p=t[9],m=t[10],g=t[11],e[0]=s,e[1]=o,e[2]=l,e[3]=u,e[4]=h,e[5]=c,e[6]=d,e[7]=f,e[8]=v,e[9]=p,e[10]=m,e[11]=g,e[12]=s*i+h*n+v*a+t[12],e[13]=o*i+c*n+p*a+t[13],e[14]=l*i+d*n+m*a+t[14],e[15]=u*i+f*n+g*a+t[15]),e};C.scale=function(e,t,r){var i=r[0],n=r[1],a=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e};C.rotate=function(e,t,r,i){var n=i[0],a=i[1],s=i[2],o=Math.sqrt(n*n+a*a+s*s),l,u,h,c,d,f,v,p,m,g,T,y,x,E,S,O,P,B,k,N,V,z,U,X;return Math.abs(o)<Br?null:(o=1/o,n*=o,a*=o,s*=o,l=Math.sin(r),u=Math.cos(r),h=1-u,c=t[0],d=t[1],f=t[2],v=t[3],p=t[4],m=t[5],g=t[6],T=t[7],y=t[8],x=t[9],E=t[10],S=t[11],O=n*n*h+u,P=a*n*h+s*l,B=s*n*h-a*l,k=n*a*h-s*l,N=a*a*h+u,V=s*a*h+n*l,z=n*s*h+a*l,U=a*s*h-n*l,X=s*s*h+u,e[0]=c*O+p*P+y*B,e[1]=d*O+m*P+x*B,e[2]=f*O+g*P+E*B,e[3]=v*O+T*P+S*B,e[4]=c*k+p*N+y*V,e[5]=d*k+m*N+x*V,e[6]=f*k+g*N+E*V,e[7]=v*k+T*N+S*V,e[8]=c*z+p*U+y*X,e[9]=d*z+m*U+x*X,e[10]=f*z+g*U+E*X,e[11]=v*z+T*U+S*X,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)};C.rotateX=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),a=t[4],s=t[5],o=t[6],l=t[7],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*n+u*i,e[5]=s*n+h*i,e[6]=o*n+c*i,e[7]=l*n+d*i,e[8]=u*n-a*i,e[9]=h*n-s*i,e[10]=c*n-o*i,e[11]=d*n-l*i,e};C.rotateY=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),a=t[0],s=t[1],o=t[2],l=t[3],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*n-u*i,e[1]=s*n-h*i,e[2]=o*n-c*i,e[3]=l*n-d*i,e[8]=a*i+u*n,e[9]=s*i+h*n,e[10]=o*i+c*n,e[11]=l*i+d*n,e};C.rotateZ=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),a=t[0],s=t[1],o=t[2],l=t[3],u=t[4],h=t[5],c=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*n+u*i,e[1]=s*n+h*i,e[2]=o*n+c*i,e[3]=l*n+d*i,e[4]=u*n-a*i,e[5]=h*n-s*i,e[6]=c*n-o*i,e[7]=d*n-l*i,e};C.fromRotationTranslation=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=i+i,l=n+n,u=a+a,h=i*o,c=i*l,d=i*u,f=n*l,v=n*u,p=a*u,m=s*o,g=s*l,T=s*u;return e[0]=1-(f+p),e[1]=c+T,e[2]=d-g,e[3]=0,e[4]=c-T,e[5]=1-(h+p),e[6]=v+m,e[7]=0,e[8]=d+g,e[9]=v-m,e[10]=1-(h+f),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e};C.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r+r,o=i+i,l=n+n,u=r*s,h=i*s,c=i*o,d=n*s,f=n*o,v=n*l,p=a*s,m=a*o,g=a*l;return e[0]=1-c-v,e[1]=h+g,e[2]=d-m,e[3]=0,e[4]=h-g,e[5]=1-u-v,e[6]=f+p,e[7]=0,e[8]=d+m,e[9]=f-p,e[10]=1-u-c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e};C.frustum=function(e,t,r,i,n,a,s){var o=1/(r-t),l=1/(n-i),u=1/(a-s);return e[0]=a*2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a*2*l,e[6]=0,e[7]=0,e[8]=(r+t)*o,e[9]=(n+i)*l,e[10]=(s+a)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*a*2*u,e[15]=0,e};C.perspective=function(e,t,r,i,n){var a=1/Math.tan(t/2),s=1/(i-n);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(n+i)*s,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*n*i*s,e[15]=0,e};C.ortho=function(e,t,r,i,n,a,s){var o=1/(t-r),l=1/(i-n),u=1/(a-s);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(n+i)*l,e[14]=(s+a)*u,e[15]=1,e};C.lookAt=function(e,t,r,i){var n,a,s,o,l,u,h,c,d,f,v=t[0],p=t[1],m=t[2],g=i[0],T=i[1],y=i[2],x=r[0],E=r[1],S=r[2];return Math.abs(v-x)<Br&&Math.abs(p-E)<Br&&Math.abs(m-S)<Br?C.identity(e):(h=v-x,c=p-E,d=m-S,f=1/Math.sqrt(h*h+c*c+d*d),h*=f,c*=f,d*=f,n=T*d-y*c,a=y*h-g*d,s=g*c-T*h,f=Math.sqrt(n*n+a*a+s*s),f?(f=1/f,n*=f,a*=f,s*=f):(n=0,a=0,s=0),o=c*s-d*a,l=d*n-h*s,u=h*a-c*n,f=Math.sqrt(o*o+l*l+u*u),f?(f=1/f,o*=f,l*=f,u*=f):(o=0,l=0,u=0),e[0]=n,e[1]=o,e[2]=h,e[3]=0,e[4]=a,e[5]=l,e[6]=c,e[7]=0,e[8]=s,e[9]=u,e[10]=d,e[11]=0,e[12]=-(n*v+a*p+s*m),e[13]=-(o*v+l*p+u*m),e[14]=-(h*v+c*p+d*m),e[15]=1,e)};C.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))};var _={};_.create=function(){var e=new Ae(3);return e[0]=0,e[1]=0,e[2]=0,e};_.clone=function(e){var t=new Ae(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t};_.fromValues=function(e,t,r){var i=new Ae(3);return i[0]=e,i[1]=t,i[2]=r,i};_.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e};_.set=function(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e};_.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e};_.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e};_.sub=_.subtract;_.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e};_.mul=_.multiply;_.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e};_.div=_.divide;_.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e};_.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e};_.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e};_.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e};_.distance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(r*r+i*i+n*n)};_.dist=_.distance;_.squaredDistance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return r*r+i*i+n*n};_.sqrDist=_.squaredDistance;_.length=function(e){var t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)};_.len=_.length;_.squaredLength=function(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i};_.sqrLen=_.squaredLength;_.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e};_.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e};_.normalize=function(e,t){var r=t[0],i=t[1],n=t[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e};_.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]};_.cross=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[0],o=r[1],l=r[2];return e[0]=n*l-a*o,e[1]=a*s-i*l,e[2]=i*o-n*s,e};_.lerp=function(e,t,r,i){var n=t[0],a=t[1],s=t[2];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e[2]=s+i*(r[2]-s),e};_.random=function(e,t){t=t||1;var r=Xt()*2*Math.PI,i=Xt()*2-1,n=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(r)*n,e[1]=Math.sin(r)*n,e[2]=i*t,e};_.transformMat4=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[3]*i+r[7]*n+r[11]*a+r[15];return s=s||1,e[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/s,e[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/s,e[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/s,e};_.transformMat3=function(e,t,r){var i=t[0],n=t[1],a=t[2];return e[0]=i*r[0]+n*r[3]+a*r[6],e[1]=i*r[1]+n*r[4]+a*r[7],e[2]=i*r[2]+n*r[5]+a*r[8],e};_.transformQuat=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[0],o=r[1],l=r[2],u=r[3],h=u*i+o*a-l*n,c=u*n+l*i-s*a,d=u*a+s*n-o*i,f=-s*i-o*n-l*a;return e[0]=h*u+f*-s+c*-l-d*-o,e[1]=c*u+f*-o+d*-s-h*-l,e[2]=d*u+f*-l+h*-o-c*-s,e};_.rotateX=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[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),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e};_.rotateY=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[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),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e};_.rotateZ=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[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],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e};_.forEach=function(){var e=_.create();return function(t,r,i,n,a,s){var o,l;for(r||(r=3),i||(i=0),n?l=Math.min(n*r+i,t.length):l=t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],a(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}}();_.angle=function(e,t){var r=_.fromValues(e[0],e[1],e[2]),i=_.fromValues(t[0],t[1],t[2]);_.normalize(r,r),_.normalize(i,i);var n=_.dot(r,i);return n>1?0:Math.acos(n)};F.import(ya);var oe=C.create,Sn={};function An(e){return e.material}function Zo(e,t,r){return t.uniforms[r].value}function $o(e,t,r,i){return r!==i}function Ko(e){return!0}function Cn(){}var Mn={float:b.FLOAT,byte:b.BYTE,ubyte:b.UNSIGNED_BYTE,short:b.SHORT,ushort:b.UNSIGNED_SHORT};function Qo(e,t,r){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=r,this.vao=null}function Jo(e){var t,r;this.bind=function(i){t||(t=J.createCanvas(),t.width=t.height=1,t.getContext("2d"));var n=i.gl,a=!r;a&&(r=n.createTexture()),n.bindTexture(n.TEXTURE_2D,r),a&&n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)},this.unbind=function(i){i.gl.bindTexture(i.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var We=Pe.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:typeof window<"u"&&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=J.createCanvas());var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new Lo(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(r){throw"Error creating WebGL Context "+r}this._programMgr=new pa(this),this._placeholderTexture=new Jo},{resize:function(e,t){var r=this.canvas,i=this.devicePixelRatio;e!=null?(r.style&&(r.style.width=e+"px",r.style.height=t+"px"),r.width=e*i,r.height=t*i,this._width=e,this._height=t):(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 e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,r,i,n){if(typeof e=="object"){var a=e;e=a.x,t=a.y,r=a.width,i=a.height,n=a.devicePixelRatio}n=n||this.devicePixelRatio,this.gl.viewport(e*n,t*n,r*n,i*n),this.viewport={x:e,y:t,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 e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,r,i){var n=this.gl,a=this.clearColor;if(this.clearBit){n.colorMask(!0,!0,!0,!0),n.depthMask(!0);var s=this.viewport,o=!1,l=s.devicePixelRatio;(s.width!==this._width||s.height!==this._height||l&&l!==this.devicePixelRatio||s.x||s.y)&&(o=!0,n.enable(n.SCISSOR_TEST),n.scissor(s.x*l,s.y*l,s.width*l,s.height*l)),n.clearColor(a[0],a[1],a[2],a[3]),n.clear(this.clearBit),o&&n.disable(n.SCISSOR_TEST)}if(r||e.update(!1),e.updateLights(),t=t||e.getMainCamera(),!t){console.error("Can't find camera in the scene.");return}t.update();var u=e.updateRenderList(t,!0);this._sceneRendering=e;var h=u.opaque,c=u.transparent,d=e.material;e.trigger("beforerender",this,e,t,u),i?(this.renderPreZ(h,e,t),n.depthFunc(n.LEQUAL)):n.depthFunc(n.LESS);for(var f=oe(),v=_.create(),p=0;p<c.length;p++){var m=c[p];C.multiplyAffine(f,t.viewMatrix.array,m.worldTransform.array),_.transformMat4(v,m.position.array,f),m.__depth=v[2]}this.renderPass(h,t,{getMaterial:function(g){return d||g.material},sortCompare:this.opaqueSortCompare}),this.renderPass(c,t,{getMaterial:function(g){return d||g.material},sortCompare:this.transparentSortCompare}),e.trigger("afterrender",this,e,t,u),this._sceneRendering=null},getProgram:function(e,t,r){return t=t||e.material,this._programMgr.getProgram(e,t,r)},validateProgram:function(e){if(e.__error){var t=e.__error;if(Sn[e.__uid__])return;if(Sn[e.__uid__]=!0,this.throwError)throw new Error(t);this.trigger("error",t)}},updatePrograms:function(e,t,r){var i=r&&r.getMaterial||An;t=t||null;for(var n=0;n<e.length;n++){var a=e[n],s=i.call(this,a);if(n>0){var o=e[n-1],l=o.joints?o.joints.length:0,u=a.joints?a.joints.length:0;if(u===l&&a.material===o.material&&a.lightGroup===o.lightGroup){a.__program=o.__program;continue}}var h=this._programMgr.getProgram(a,s,t);this.validateProgram(h),a.__program=h}},renderPass:function(e,t,r){this.trigger("beforerenderpass",this,e,t,r),r=r||{},r.getMaterial=r.getMaterial||An,r.getUniform=r.getUniform||Zo,r.isMaterialChanged=r.isMaterialChanged||$o,r.beforeRender=r.beforeRender||Cn,r.afterRender=r.afterRender||Cn;var i=r.ifRender||Ko;this.updatePrograms(e,this._sceneRendering,r),r.sortCompare&&e.sort(r.sortCompare);var n=this.viewport,a=n.devicePixelRatio,s=[n.x*a,n.y*a,n.width*a,n.height*a],o=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*o,this._height*o],u=[s[2],s[3]],h=Date.now();t?(C.copy(se.VIEW,t.viewMatrix.array),C.copy(se.PROJECTION,t.projectionMatrix.array),C.copy(se.VIEWINVERSE,t.worldTransform.array)):(C.identity(se.VIEW),C.identity(se.PROJECTION),C.identity(se.VIEWINVERSE)),C.multiply(se.VIEWPROJECTION,se.PROJECTION,se.VIEW),C.invert(se.PROJECTIONINVERSE,se.PROJECTION),C.invert(se.VIEWPROJECTIONINVERSE,se.VIEWPROJECTION);for(var c=this.gl,d=this._sceneRendering,f,v,p,m,g,T,y,x,E,S,O,P,B=null,k=0;k<e.length;k++){var N=e[k],V=N.worldTransform!=null,z;if(i(N)){V&&(z=N.isSkinnedMesh&&N.isSkinnedMesh()?N.offsetMatrix?N.offsetMatrix.array:se.IDENTITY:N.worldTransform.array);var U=N.geometry,X=r.getMaterial.call(this,N),G=N.__program,Y=X.shader,H=U.__uid__+"-"+G.__uid__,le=H!==S;S=H,V&&(C.copy(se.WORLD,z),C.multiply(se.WORLDVIEWPROJECTION,se.VIEWPROJECTION,z),C.multiplyAffine(se.WORLDVIEW,se.VIEW,z),(Y.matrixSemantics.WORLDINVERSE||Y.matrixSemantics.WORLDINVERSETRANSPOSE)&&C.invert(se.WORLDINVERSE,z),(Y.matrixSemantics.WORLDVIEWINVERSE||Y.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&C.invert(se.WORLDVIEWINVERSE,se.WORLDVIEW),(Y.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||Y.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&C.invert(se.WORLDVIEWPROJECTIONINVERSE,se.WORLDVIEWPROJECTION)),N.beforeRender&&N.beforeRender(this),r.beforeRender.call(this,N,X,f);var j=G!==v;j?(G.bind(this),G.setUniformOfSemantic(c,"VIEWPORT",s),G.setUniformOfSemantic(c,"WINDOW_SIZE",l),t&&(G.setUniformOfSemantic(c,"NEAR",t.near),G.setUniformOfSemantic(c,"FAR",t.far)),G.setUniformOfSemantic(c,"DEVICEPIXELRATIO",a),G.setUniformOfSemantic(c,"TIME",h),G.setUniformOfSemantic(c,"VIEWPORT_SIZE",u),d&&d.setLightUniforms(G,N.lightGroup,this)):G=v,(j||r.isMaterialChanged(N,p,X,f))&&(X.depthTest!==m&&(X.depthTest?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST),m=X.depthTest),X.depthMask!==g&&(c.depthMask(X.depthMask),g=X.depthMask),X.transparent!==E&&(X.transparent?c.enable(c.BLEND):c.disable(c.BLEND),E=X.transparent),X.transparent&&(X.blend?X.blend(c):(c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA))),P=this._bindMaterial(N,X,G,p||null,f||null,v||null,r.getUniform),f=X);var ve=Y.matrixSemanticKeys;if(V)for(var re=0;re<ve.length;re++){var ue=ve[re],he=Y.matrixSemantics[ue],Ce=se[ue];if(he.isTranspose){var Me=se[he.semanticNoTranspose];C.transpose(Ce,Me)}G.setUniform(c,he.type,he.symbol,Ce)}N.cullFace!==y&&(y=N.cullFace,c.cullFace(y)),N.frontFace!==x&&(x=N.frontFace,c.frontFace(x)),N.culling!==T&&(T=N.culling,T?c.enable(c.CULL_FACE):c.disable(c.CULL_FACE)),this._updateSkeleton(N,G,P),le&&(O=this._bindVAO(B,Y,U,G)),this._renderObject(N,O,G),r.afterRender(this,N),N.afterRender&&N.afterRender(this),v=G,p=N}}this.trigger("afterrenderpass",this,e,t,r)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(e,t,r){var i=this.gl,n=e.skeleton;if(n)if(n.update(),e.joints.length>this.getMaxJointNumber()){var a=n.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,a,r),t.setUniform(i,"1i","skinMatricesTexture",r),t.setUniform(i,"1f","skinMatricesTextureSize",a.width)}else{var s=n.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(i,"SKIN_MATRIX",s)}},_renderObject:function(e,t,r){var i=this.gl,n=e.geometry,a=e.mode;a==null&&(a=4);var s=null,o=e.isInstancedMesh&&e.isInstancedMesh();if(o&&(s=this.getGLExtension("ANGLE_instanced_arrays"),!s)){console.warn("Device not support ANGLE_instanced_arrays extension");return}var l;if(o&&(l=this._bindInstancedAttributes(e,r,s)),t.indicesBuffer){var u=this.getGLExtension("OES_element_index_uint"),h=u&&n.indices instanceof Uint32Array,c=h?i.UNSIGNED_INT:i.UNSIGNED_SHORT;o?s.drawElementsInstancedANGLE(a,t.indicesBuffer.count,c,0,e.getInstanceCount()):i.drawElements(a,t.indicesBuffer.count,c,0)}else o?s.drawArraysInstancedANGLE(a,0,n.vertexCount,e.getInstanceCount()):i.drawArrays(a,0,n.vertexCount);if(o)for(var d=0;d<l.length;d++)i.disableVertexAttribArray(l[d])},_bindInstancedAttributes:function(e,t,r){for(var i=this.gl,n=e.getInstancedAttributesBuffers(this),a=[],s=0;s<n.length;s++){var o=n[s],l=t.getAttribLocation(i,o.symbol);if(!(l<0)){var u=Mn[o.type]||i.FLOAT;i.enableVertexAttribArray(l),i.bindBuffer(i.ARRAY_BUFFER,o.buffer),i.vertexAttribPointer(l,o.size,u,!1,0,0),r.vertexAttribDivisorANGLE(l,o.divisor),a.push(l)}}return a},_bindMaterial:function(e,t,r,i,n,a,s){for(var o=this.gl,l=a===r,u=r.currentTextureSlot(),h=t.getEnabledUniforms(),c=t.getTextureUniforms(),d=this._placeholderTexture,f=0;f<c.length;f++){var v=c[f],p=s(e,t,v),m=t.uniforms[v].type;if(m==="t"&&p)p.__slot=-1;else if(m==="tv")for(var g=0;g<p.length;g++)p[g]&&(p[g].__slot=-1)}d.__slot=-1;for(var f=0;f<h.length;f++){var v=h[f],T=t.uniforms[v],p=s(e,t,v),m=T.type,y=m==="t";if(y&&(!p||!p.isRenderable())&&(p=d),n&&l){var x=s(i,n,v);if(y&&(!x||!x.isRenderable())&&(x=d),x===p){if(y)r.takeCurrentTextureSlot(this,null);else if(m==="tv"&&p)for(var g=0;g<p.length;g++)r.takeCurrentTextureSlot(this,null);continue}}if(p!=null)if(y)if(p.__slot<0){var E=r.currentTextureSlot(),S=r.setUniform(o,"1i",v,E);S&&(r.takeCurrentTextureSlot(this,p),p.__slot=E)}else r.setUniform(o,"1i",v,p.__slot);else if(Array.isArray(p)){if(p.length===0)continue;if(m==="tv"){if(!r.hasUniform(v))continue;for(var O=[],g=0;g<p.length;g++){var P=p[g];if(P.__slot<0){var E=r.currentTextureSlot();O.push(E),r.takeCurrentTextureSlot(this,P),P.__slot=E}else O.push(P.__slot)}r.setUniform(o,"1iv",v,O)}else r.setUniform(o,T.type,v,p)}else r.setUniform(o,T.type,v,p)}var B=r.currentTextureSlot();return r.resetTextureSlot(u),B},_bindVAO:function(e,t,r,i){var n=!r.dynamic,a=this.gl,s=this.__uid__+"-"+i.__uid__,o=r.__vaoCache[s];if(!o){var l=r.getBufferChunks(this);if(!l||!l.length)return;for(var u=l[0],h=u.attributeBuffers,x=u.indicesBuffer,y=[],c=[],d=0;d<h.length;d++){var f=h[d],v=f.name,p=f.semantic,m;if(p){var g=t.attributeSemantics[p];m=g&&g.symbol}else m=v;m&&i.attributes[m]&&(y.push(f),c.push(m))}o=new Qo(y,c,x),n&&(r.__vaoCache[s]=o)}var T=!0;e&&n&&(o.vao==null?o.vao=e.createVertexArrayOES():T=!1,e.bindVertexArrayOES(o.vao));var y=o.availableAttributes,x=o.indicesBuffer;if(T){for(var E=i.enableAttributes(this,o.availableAttributeSymbols,e&&n&&o),d=0;d<y.length;d++){var S=E[d];if(S!==-1){var f=y[d],O=f.buffer,P=f.size,B=Mn[f.type]||a.FLOAT;a.bindBuffer(a.ARRAY_BUFFER,O),a.vertexAttribPointer(S,P,B,!1,0,0)}}r.isUseIndices()&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,x.buffer)}return o},renderPreZ:function(e,t,r){var i=this.gl,n=this._prezMaterial||new vt({shader:new F(F.source("clay.prez.vertex"),F.source("clay.prez.fragment"))});this._prezMaterial=n,i.colorMask(!1,!1,!1,!1),i.depthMask(!0),this.renderPass(e,r,{ifRender:function(a){return!a.ignorePreZ},isMaterialChanged:function(a,s){var o=a.material,l=s.material;return o.get("diffuseMap")!==l.get("diffuseMap")||(o.get("alphaCutoff")||0)!==(l.get("alphaCutoff")||0)},getUniform:function(a,s,o){if(o==="alphaMap")return a.material.get("diffuseMap");if(o==="alphaCutoff"){if(a.material.isDefined("fragment","ALPHA_TEST")&&a.material.get("diffuseMap")){var l=a.material.get("alphaCutoff");return l||0}return 0}else return o==="uvRepeat"?a.material.get("uvRepeat"):o==="uvOffset"?a.material.get("uvOffset"):s.get(o)},getMaterial:function(){return n},sort:this.opaqueSortCompare}),i.colorMask(!0,!0,!0,!0),i.depthMask(!0)},disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,r){e.getParent()&&e.getParent().remove(e);var i={};e.traverse(function(n){var a=n.material;if(n.geometry&&t&&n.geometry.dispose(this),r&&a&&!i[a.__uid__]){for(var s=a.getTextureUniforms(),o=0;o<s.length;o++){var l=s[o],u=a.uniforms[l].value,h=a.uniforms[l].type;if(u){if(h==="t")u.dispose&&u.dispose(this);else if(h==="tv")for(var c=0;c<u.length;c++)u[c]&&u[c].dispose&&u[c].dispose(this)}}i[a.__uid__]=!0}n.dispose&&n.dispose(this)},this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,r){r||(r=new q),t=this._height-t;var i=this.viewport,n=r.array;return n[0]=(e-i.x)/i.width,n[0]=n[0]*2-1,n[1]=(t-i.y)/i.height,n[1]=n[1]*2-1,r}});We.opaqueSortCompare=We.prototype.opaqueSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.renderOrder-t.renderOrder};We.transparentSortCompare=We.prototype.transparentSortCompare=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.__program===t.__program?e.material===t.material?e.geometry.__uid__-t.geometry.__uid__:e.material.__uid__-t.material.__uid__:e.__program&&t.__program?e.__program.__uid__-t.__program.__uid__:0:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var se={IDENTITY:oe(),WORLD:oe(),VIEW:oe(),PROJECTION:oe(),WORLDVIEW:oe(),VIEWPROJECTION:oe(),WORLDVIEWPROJECTION:oe(),WORLDINVERSE:oe(),VIEWINVERSE:oe(),PROJECTIONINVERSE:oe(),WORLDVIEWINVERSE:oe(),VIEWPROJECTIONINVERSE:oe(),WORLDVIEWPROJECTIONINVERSE:oe(),WORLDTRANSPOSE:oe(),VIEWTRANSPOSE:oe(),PROJECTIONTRANSPOSE:oe(),WORLDVIEWTRANSPOSE:oe(),VIEWPROJECTIONTRANSPOSE:oe(),WORLDVIEWPROJECTIONTRANSPOSE:oe(),WORLDINVERSETRANSPOSE:oe(),VIEWINVERSETRANSPOSE:oe(),PROJECTIONINVERSETRANSPOSE:oe(),WORLDVIEWINVERSETRANSPOSE:oe(),VIEWPROJECTIONINVERSETRANSPOSE:oe(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:oe()};We.COLOR_BUFFER_BIT=b.COLOR_BUFFER_BIT;We.DEPTH_BUFFER_BIT=b.DEPTH_BUFFER_BIT;We.STENCIL_BUFFER_BIT=b.STENCIL_BUFFER_BIT;var w=function(e,t,r){e=e||0,t=t||0,r=r||0,this.array=_.fromValues(e,t,r),this._dirty=!0};w.prototype={constructor:w,add:function(e){return _.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,r){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new w(this.x,this.y,this.z)},copy:function(e){return _.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return _.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return _.dist(this.array,e.array)},distance:function(e){return _.distance(this.array,e.array)},div:function(e){return _.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return _.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return _.dot(this.array,e.array)},len:function(){return _.len(this.array)},length:function(){return _.length(this.array)},lerp:function(e,t,r){return _.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return _.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return _.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return _.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return _.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return _.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return _.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return _.random(this.array,e),this._dirty=!0,this},scale:function(e){return _.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return _.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return _.sqrDist(this.array,e.array)},squaredDistance:function(e){return _.squaredDistance(this.array,e.array)},sqrLen:function(){return _.sqrLen(this.array)},squaredLength:function(){return _.squaredLength(this.array)},sub:function(e){return _.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return _.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return _.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return _.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return _.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(e=e.array,e[15]===0){var r=-1/t[2];t[0]=e[0]*t[0]*r,t[1]=e[5]*t[1]*r,t[2]=(e[10]*t[2]+e[14])*r}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){w.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){w.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Cr=Object.defineProperty;if(Cr){var li=w.prototype;Cr(li,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),Cr(li,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),Cr(li,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}w.add=function(e,t,r){return _.add(e.array,t.array,r.array),e._dirty=!0,e};w.set=function(e,t,r,i){_.set(e.array,t,r,i),e._dirty=!0};w.copy=function(e,t){return _.copy(e.array,t.array),e._dirty=!0,e};w.cross=function(e,t,r){return _.cross(e.array,t.array,r.array),e._dirty=!0,e};w.dist=function(e,t){return _.distance(e.array,t.array)};w.distance=w.dist;w.div=function(e,t,r){return _.divide(e.array,t.array,r.array),e._dirty=!0,e};w.divide=w.div;w.dot=function(e,t){return _.dot(e.array,t.array)};w.len=function(e){return _.length(e.array)};w.lerp=function(e,t,r,i){return _.lerp(e.array,t.array,r.array,i),e._dirty=!0,e};w.min=function(e,t,r){return _.min(e.array,t.array,r.array),e._dirty=!0,e};w.max=function(e,t,r){return _.max(e.array,t.array,r.array),e._dirty=!0,e};w.mul=function(e,t,r){return _.multiply(e.array,t.array,r.array),e._dirty=!0,e};w.multiply=w.mul;w.negate=function(e,t){return _.negate(e.array,t.array),e._dirty=!0,e};w.normalize=function(e,t){return _.normalize(e.array,t.array),e._dirty=!0,e};w.random=function(e,t){return _.random(e.array,t),e._dirty=!0,e};w.scale=function(e,t,r){return _.scale(e.array,t.array,r),e._dirty=!0,e};w.scaleAndAdd=function(e,t,r,i){return _.scaleAndAdd(e.array,t.array,r.array,i),e._dirty=!0,e};w.sqrDist=function(e,t){return _.sqrDist(e.array,t.array)};w.squaredDistance=w.sqrDist;w.sqrLen=function(e){return _.sqrLen(e.array)};w.squaredLength=w.sqrLen;w.sub=function(e,t,r){return _.subtract(e.array,t.array,r.array),e._dirty=!0,e};w.subtract=w.sub;w.transformMat3=function(e,t,r){return _.transformMat3(e.array,t.array,r.array),e._dirty=!0,e};w.transformMat4=function(e,t,r){return _.transformMat4(e.array,t.array,r.array),e._dirty=!0,e};w.transformQuat=function(e,t,r){return _.transformQuat(e.array,t.array,r.array),e._dirty=!0,e};function Ge(e,t,r){return e<t?t:e>r?r:e}var ie=Math.atan2,ke=Math.asin,Ut=Math.abs;w.eulerFromQuat=function(e,t,d){e._dirty=!0,t=t.array;var i=e.array,n=t[0],a=t[1],s=t[2],o=t[3],l=n*n,u=a*a,h=s*s,c=o*o,d=(d||"XYZ").toUpperCase();switch(d){case"XYZ":i[0]=ie(2*(n*o-a*s),c-l-u+h),i[1]=ke(Ge(2*(n*s+a*o),-1,1)),i[2]=ie(2*(s*o-n*a),c+l-u-h);break;case"YXZ":i[0]=ke(Ge(2*(n*o-a*s),-1,1)),i[1]=ie(2*(n*s+a*o),c-l-u+h),i[2]=ie(2*(n*a+s*o),c-l+u-h);break;case"ZXY":i[0]=ke(Ge(2*(n*o+a*s),-1,1)),i[1]=ie(2*(a*o-s*n),c-l-u+h),i[2]=ie(2*(s*o-n*a),c-l+u-h);break;case"ZYX":i[0]=ie(2*(n*o+s*a),c-l-u+h),i[1]=ke(Ge(2*(a*o-n*s),-1,1)),i[2]=ie(2*(n*a+s*o),c+l-u-h);break;case"YZX":i[0]=ie(2*(n*o-s*a),c-l+u-h),i[1]=ie(2*(a*o-n*s),c+l-u-h),i[2]=ke(Ge(2*(n*a+s*o),-1,1));break;case"XZY":i[0]=ie(2*(n*o+a*s),c-l+u-h),i[1]=ie(2*(n*s+a*o),c+l-u-h),i[2]=ke(Ge(2*(s*o-n*a),-1,1));break;default:console.warn("Unkown order: "+d)}return e};w.eulerFromMat3=function(e,t,v){var i=t.array,n=i[0],a=i[3],s=i[6],o=i[1],l=i[4],u=i[7],h=i[2],c=i[5],d=i[8],f=e.array,v=(v||"XYZ").toUpperCase();switch(v){case"XYZ":f[1]=ke(Ge(s,-1,1)),Ut(s)<.99999?(f[0]=ie(-u,d),f[2]=ie(-a,n)):(f[0]=ie(c,l),f[2]=0);break;case"YXZ":f[0]=ke(-Ge(u,-1,1)),Ut(u)<.99999?(f[1]=ie(s,d),f[2]=ie(o,l)):(f[1]=ie(-h,n),f[2]=0);break;case"ZXY":f[0]=ke(Ge(c,-1,1)),Ut(c)<.99999?(f[1]=ie(-h,d),f[2]=ie(-a,l)):(f[1]=0,f[2]=ie(o,n));break;case"ZYX":f[1]=ke(-Ge(h,-1,1)),Ut(h)<.99999?(f[0]=ie(c,d),f[2]=ie(o,n)):(f[0]=0,f[2]=ie(-a,l));break;case"YZX":f[2]=ke(Ge(o,-1,1)),Ut(o)<.99999?(f[0]=ie(-u,l),f[1]=ie(-h,n)):(f[0]=0,f[1]=ie(s,d));break;case"XZY":f[2]=ke(-Ge(a,-1,1)),Ut(a)<.99999?(f[0]=ie(c,l),f[1]=ie(s,n)):(f[0]=ie(-u,d),f[1]=0);break;default:console.warn("Unkown order: "+v)}return e._dirty=!0,e};Object.defineProperties(w,{POSITIVE_X:{get:function(){return new w(1,0,0)}},NEGATIVE_X:{get:function(){return new w(-1,0,0)}},POSITIVE_Y:{get:function(){return new w(0,1,0)}},NEGATIVE_Y:{get:function(){return new w(0,-1,0)}},POSITIVE_Z:{get:function(){return new w(0,0,1)}},NEGATIVE_Z:{get:function(){return new w(0,0,-1)}},UP:{get:function(){return new w(0,1,0)}},ZERO:{get:function(){return new w}}});var el=1e-5,Lt=function(e,t){this.origin=e||new w,this.direction=t||new w};Lt.prototype={constructor:Lt,intersectPlane:function(e,t){var r=e.normal.array,i=e.distance,n=this.origin.array,a=this.direction.array,s=_.dot(r,a);if(s===0)return null;t||(t=new w);var o=(_.dot(r,n)-i)/s;return _.scaleAndAdd(t.array,n,a,-o),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=_.dot(e.normal.array,this.direction.array);_.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,-t*2),this.direction._dirty=!0},distanceToPoint:function(){var e=_.create();return function(t){_.sub(e,t,this.origin.array);var r=_.dot(e,this.direction.array);if(r<0)return _.distance(this.origin.array,t);var i=_.lenSquared(e);return Math.sqrt(i-r*r)}}(),intersectSphere:function(){var e=_.create();return function(t,r,i){var n=this.origin.array,a=this.direction.array;t=t.array,_.sub(e,t,n);var s=_.dot(e,a),o=_.squaredLength(e),l=o-s*s,u=r*r;if(!(l>u)){var h=Math.sqrt(u-l),c=s-h,d=s+h;return i||(i=new w),c<0?d<0?null:(_.scaleAndAdd(i.array,n,a,d),i):(_.scaleAndAdd(i.array,n,a,c),i)}}}(),intersectBoundingBox:function(e,t){var r=this.direction.array,i=this.origin.array,n=e.min.array,a=e.max.array,s=1/r[0],o=1/r[1],l=1/r[2],u,h,c,d,f,v;if(s>=0?(u=(n[0]-i[0])*s,h=(a[0]-i[0])*s):(h=(n[0]-i[0])*s,u=(a[0]-i[0])*s),o>=0?(c=(n[1]-i[1])*o,d=(a[1]-i[1])*o):(d=(n[1]-i[1])*o,c=(a[1]-i[1])*o),u>d||c>h||((c>u||u!==u)&&(u=c),(d<h||h!==h)&&(h=d),l>=0?(f=(n[2]-i[2])*l,v=(a[2]-i[2])*l):(v=(n[2]-i[2])*l,f=(a[2]-i[2])*l),u>v||f>h)||((f>u||u!==u)&&(u=f),(v<h||h!==h)&&(h=v),h<0))return null;var p=u>=0?u:h;return t||(t=new w),_.scaleAndAdd(t.array,i,r,p),t},intersectTriangle:function(){var e=_.create(),t=_.create(),r=_.create(),i=_.create();return function(n,a,s,o,l,u){var h=this.direction.array,c=this.origin.array;n=n.array,a=a.array,s=s.array,_.sub(e,a,n),_.sub(t,s,n),_.cross(i,t,h);var d=_.dot(e,i);if(o){if(d>-1e-5)return null}else if(d>-1e-5&&d<el)return null;_.sub(r,c,n);var f=_.dot(i,r)/d;if(f<0||f>1)return null;_.cross(i,e,r);var v=_.dot(h,i)/d;if(v<0||v>1||f+v>1)return null;_.cross(i,e,t);var p=-_.dot(r,i)/d;return p<0?null:(l||(l=new w),u&&w.set(u,1-f-v,f,v),_.scaleAndAdd(l.array,c,h,p),l)}}(),applyTransform:function(e){w.add(this.direction,this.direction,this.origin),w.transformMat4(this.origin,this.origin,e),w.transformMat4(this.direction,this.direction,e),w.sub(this.direction,this.direction,this.origin),w.normalize(this.direction,this.direction)},copy:function(e){w.copy(this.origin,e.origin),w.copy(this.direction,e.direction)},clone:function(){var e=new Lt;return e.copy(this),e}};var A={};A.create=function(){var e=new Ae(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e};A.clone=function(e){var t=new Ae(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};A.fromValues=function(e,t,r,i){var n=new Ae(4);return n[0]=e,n[1]=t,n[2]=r,n[3]=i,n};A.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e};A.set=function(e,t,r,i,n){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e};A.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e};A.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e};A.sub=A.subtract;A.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e};A.mul=A.multiply;A.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e};A.div=A.divide;A.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e};A.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e};A.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e};A.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e};A.distance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(r*r+i*i+n*n+a*a)};A.dist=A.distance;A.squaredDistance=function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],a=t[3]-e[3];return r*r+i*i+n*n+a*a};A.sqrDist=A.squaredDistance;A.length=function(e){var t=e[0],r=e[1],i=e[2],n=e[3];return Math.sqrt(t*t+r*r+i*i+n*n)};A.len=A.length;A.squaredLength=function(e){var t=e[0],r=e[1],i=e[2],n=e[3];return t*t+r*r+i*i+n*n};A.sqrLen=A.squaredLength;A.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e};A.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e};A.normalize=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r*r+i*i+n*n+a*a;return s>0&&(s=1/Math.sqrt(s),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s),e};A.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]};A.lerp=function(e,t,r,i){var n=t[0],a=t[1],s=t[2],o=t[3];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e[2]=s+i*(r[2]-s),e[3]=o+i*(r[3]-o),e};A.random=function(e,t){return t=t||1,e[0]=Xt(),e[1]=Xt(),e[2]=Xt(),e[3]=Xt(),A.normalize(e,e),A.scale(e,e,t),e};A.transformMat4=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3];return e[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*s,e[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*s,e[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*s,e[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*s,e};A.transformQuat=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[0],o=r[1],l=r[2],u=r[3],h=u*i+o*a-l*n,c=u*n+l*i-s*a,d=u*a+s*n-o*i,f=-s*i-o*n-l*a;return e[0]=h*u+f*-s+c*-l-d*-o,e[1]=c*u+f*-o+d*-s-h*-l,e[2]=d*u+f*-l+h*-o-c*-s,e};A.forEach=function(){var e=A.create();return function(t,r,i,n,a,s){var o,l;for(r||(r=4),i||(i=0),n?l=Math.min(n*r+i,t.length):l=t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],a(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}}();var W={};W.create=function(){var e=new Ae(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e};W.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e};W.clone=function(e){var t=new Ae(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t};W.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e};W.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e};W.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e};W.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],h=t[8],c=h*s-o*u,d=-h*a+o*l,f=u*a-s*l,v=r*c+i*d+n*f;return v?(v=1/v,e[0]=c*v,e[1]=(-h*i+n*u)*v,e[2]=(o*i-n*s)*v,e[3]=d*v,e[4]=(h*r-n*l)*v,e[5]=(-o*r+n*a)*v,e[6]=f*v,e[7]=(-u*r+i*l)*v,e[8]=(s*r-i*a)*v,e):null};W.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],h=t[8];return e[0]=s*h-o*u,e[1]=n*u-i*h,e[2]=i*o-n*s,e[3]=o*l-a*h,e[4]=r*h-n*l,e[5]=n*a-r*o,e[6]=a*u-s*l,e[7]=i*l-r*u,e[8]=r*s-i*a,e};W.determinant=function(e){var t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8];return t*(u*a-s*l)+r*(-u*n+s*o)+i*(l*n-a*o)};W.multiply=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=r[0],f=r[1],v=r[2],p=r[3],m=r[4],g=r[5],T=r[6],y=r[7],x=r[8];return e[0]=d*i+f*s+v*u,e[1]=d*n+f*o+v*h,e[2]=d*a+f*l+v*c,e[3]=p*i+m*s+g*u,e[4]=p*n+m*o+g*h,e[5]=p*a+m*l+g*c,e[6]=T*i+y*s+x*u,e[7]=T*n+y*o+x*h,e[8]=T*a+y*l+x*c,e};W.mul=W.multiply;W.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=r[0],f=r[1];return e[0]=i,e[1]=n,e[2]=a,e[3]=s,e[4]=o,e[5]=l,e[6]=d*i+f*s+u,e[7]=d*n+f*o+h,e[8]=d*a+f*l+c,e};W.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=Math.sin(r),f=Math.cos(r);return e[0]=f*i+d*s,e[1]=f*n+d*o,e[2]=f*a+d*l,e[3]=f*s-d*i,e[4]=f*o-d*n,e[5]=f*l-d*a,e[6]=u,e[7]=h,e[8]=c,e};W.scale=function(e,t,r){var i=r[0],n=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e};W.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e};W.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r+r,o=i+i,l=n+n,u=r*s,h=i*s,c=i*o,d=n*s,f=n*o,v=n*l,p=a*s,m=a*o,g=a*l;return e[0]=1-c-v,e[3]=h-g,e[6]=d+m,e[1]=h+g,e[4]=1-u-v,e[7]=f-p,e[2]=d-m,e[5]=f+p,e[8]=1-u-c,e};W.normalFromMat4=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],f=t[11],v=t[12],p=t[13],m=t[14],g=t[15],T=r*o-i*s,y=r*l-n*s,x=r*u-a*s,E=i*l-n*o,S=i*u-a*o,O=n*u-a*l,P=h*p-c*v,B=h*m-d*v,k=h*g-f*v,N=c*m-d*p,V=c*g-f*p,z=d*g-f*m,U=T*z-y*V+x*N+E*k-S*B+O*P;return U?(U=1/U,e[0]=(o*z-l*V+u*N)*U,e[1]=(l*k-s*z-u*B)*U,e[2]=(s*V-o*k+u*P)*U,e[3]=(n*V-i*z-a*N)*U,e[4]=(r*z-n*k+a*B)*U,e[5]=(i*k-r*V-a*P)*U,e[6]=(p*O-m*S+g*E)*U,e[7]=(m*x-v*O-g*y)*U,e[8]=(v*S-p*x+g*T)*U,e):null};W.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))};var D={};D.create=function(){var e=new Ae(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e};D.rotationTo=function(){var e=_.create(),t=_.fromValues(1,0,0),r=_.fromValues(0,1,0);return function(i,n,a){var s=_.dot(n,a);return s<-.999999?(_.cross(e,t,n),_.length(e)<1e-6&&_.cross(e,r,n),_.normalize(e,e),D.setAxisAngle(i,e,Math.PI),i):s>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(_.cross(e,n,a),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+s,D.normalize(i,i))}}();D.setAxes=function(){var e=W.create();return function(t,r,i,n){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=n[0],e[4]=n[1],e[7]=n[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],D.normalize(t,D.fromMat3(t,e))}}();D.clone=A.clone;D.fromValues=A.fromValues;D.copy=A.copy;D.set=A.set;D.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e};D.setAxisAngle=function(e,t,r){r=r*.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e};D.add=A.add;D.multiply=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=r[0],l=r[1],u=r[2],h=r[3];return e[0]=i*h+s*o+n*u-a*l,e[1]=n*h+s*l+a*o-i*u,e[2]=a*h+s*u+i*l-n*o,e[3]=s*h-i*o-n*l-a*u,e};D.mul=D.multiply;D.scale=A.scale;D.rotateX=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l+s*o,e[1]=n*l+a*o,e[2]=a*l-n*o,e[3]=s*l-i*o,e};D.rotateY=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l-a*o,e[1]=n*l+s*o,e[2]=a*l+i*o,e[3]=s*l-n*o,e};D.rotateZ=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l+n*o,e[1]=n*l-i*o,e[2]=a*l+s*o,e[3]=s*l-a*o,e};D.calculateW=function(e,t){var r=t[0],i=t[1],n=t[2];return e[0]=r,e[1]=i,e[2]=n,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),e};D.dot=A.dot;D.lerp=A.lerp;D.slerp=function(e,t,r,i){var n=t[0],a=t[1],s=t[2],o=t[3],l=r[0],u=r[1],h=r[2],c=r[3],d,f,v,p,m;return f=n*l+a*u+s*h+o*c,f<0&&(f=-f,l=-l,u=-u,h=-h,c=-c),1-f>1e-6?(d=Math.acos(f),v=Math.sin(d),p=Math.sin((1-i)*d)/v,m=Math.sin(i*d)/v):(p=1-i,m=i),e[0]=p*n+m*l,e[1]=p*a+m*u,e[2]=p*s+m*h,e[3]=p*o+m*c,e};D.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r*r+i*i+n*n+a*a,o=s?1/s:0;return e[0]=-r*o,e[1]=-i*o,e[2]=-n*o,e[3]=a*o,e};D.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e};D.length=A.length;D.len=D.length;D.squaredLength=A.squaredLength;D.sqrLen=D.squaredLength;D.normalize=A.normalize;D.fromMat3=function(e,t){var r=t[0]+t[4]+t[8],i;if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[n*3+n]&&(n=2);var a=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[n*3+n]-t[a*3+a]-t[s*3+s]+1),e[n]=.5*i,i=.5/i,e[3]=(t[a*3+s]-t[s*3+a])*i,e[a]=(t[a*3+n]+t[n*3+a])*i,e[s]=(t[s*3+n]+t[n*3+s])*i}return e};var I=function(){this._axisX=new w,this._axisY=new w,this._axisZ=new w,this.array=C.create(),this._dirty=!0};I.prototype={constructor:I,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return C.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return new I().copy(this)},copy:function(e){return C.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return C.determinant(this.array)},fromQuat:function(e){return C.fromQuat(this.array,e.array),this._dirty=!0,this},fromRotationTranslation:function(e,t){return C.fromRotationTranslation(this.array,e.array,t.array),this._dirty=!0,this},fromMat2d:function(e){return I.fromMat2d(this,e),this},frustum:function(e,t,r,i,n,a){return C.frustum(this.array,e,t,r,i,n,a),this._dirty=!0,this},identity:function(){return C.identity(this.array),this._dirty=!0,this},invert:function(){return C.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(e,t,r){return C.lookAt(this.array,e.array,t.array,r.array),this._dirty=!0,this},mul:function(e){return C.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return C.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return C.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return C.multiply(this.array,e.array,this.array),this._dirty=!0,this},ortho:function(e,t,r,i,n,a){return C.ortho(this.array,e,t,r,i,n,a),this._dirty=!0,this},perspective:function(e,t,r,i){return C.perspective(this.array,e,t,r,i),this._dirty=!0,this},rotate:function(e,t){return C.rotate(this.array,this.array,e,t.array),this._dirty=!0,this},rotateX:function(e){return C.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return C.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return C.rotateZ(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return C.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return C.translate(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return C.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:function(){var e=_.create(),t=_.create(),r=_.create(),i=W.create();return function(n,a,s){var o=this.array;_.set(e,o[0],o[1],o[2]),_.set(t,o[4],o[5],o[6]),_.set(r,o[8],o[9],o[10]);var l=_.length(e),u=_.length(t),h=_.length(r),c=this.determinant();c<0&&(l=-l),n&&n.set(l,u,h),s.set(o[12],o[13],o[14]),W.fromMat4(i,o),i[0]/=l,i[1]/=l,i[2]/=l,i[3]/=u,i[4]/=u,i[5]/=u,i[6]/=h,i[7]/=h,i[8]/=h,D.fromMat3(a.array,i),D.normalize(a.array,a.array),a._dirty=!0,s._dirty=!0}}(),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Mr=Object.defineProperty;if(Mr){var ui=I.prototype;Mr(ui,"z",{get:function(){var e=this.array;return this._axisZ.set(e[8],e[9],e[10]),this._axisZ},set:function(e){var t=this.array;e=e.array,t[8]=e[0],t[9]=e[1],t[10]=e[2],this._dirty=!0}}),Mr(ui,"y",{get:function(){var e=this.array;return this._axisY.set(e[4],e[5],e[6]),this._axisY},set:function(e){var t=this.array;e=e.array,t[4]=e[0],t[5]=e[1],t[6]=e[2],this._dirty=!0}}),Mr(ui,"x",{get:function(){var e=this.array;return this._axisX.set(e[0],e[1],e[2]),this._axisX},set:function(e){var t=this.array;e=e.array,t[0]=e[0],t[1]=e[1],t[2]=e[2],this._dirty=!0}})}I.adjoint=function(e,t){return C.adjoint(e.array,t.array),e._dirty=!0,e};I.copy=function(e,t){return C.copy(e.array,t.array),e._dirty=!0,e};I.determinant=function(e){return C.determinant(e.array)};I.identity=function(e){return C.identity(e.array),e._dirty=!0,e};I.ortho=function(e,t,r,i,n,a,s){return C.ortho(e.array,t,r,i,n,a,s),e._dirty=!0,e};I.perspective=function(e,t,r,i,n){return C.perspective(e.array,t,r,i,n),e._dirty=!0,e};I.lookAt=function(e,t,r,i){return C.lookAt(e.array,t.array,r.array,i.array),e._dirty=!0,e};I.invert=function(e,t){return C.invert(e.array,t.array),e._dirty=!0,e};I.mul=function(e,t,r){return C.mul(e.array,t.array,r.array),e._dirty=!0,e};I.multiply=I.mul;I.fromQuat=function(e,t){return C.fromQuat(e.array,t.array),e._dirty=!0,e};I.fromRotationTranslation=function(e,t,r){return C.fromRotationTranslation(e.array,t.array,r.array),e._dirty=!0,e};I.fromMat2d=function(i,r){i._dirty=!0;var r=r.array,i=i.array;return i[0]=r[0],i[4]=r[2],i[12]=r[4],i[1]=r[1],i[5]=r[3],i[13]=r[5],i};I.rotate=function(e,t,r,i){return C.rotate(e.array,t.array,r,i.array),e._dirty=!0,e};I.rotateX=function(e,t,r){return C.rotateX(e.array,t.array,r),e._dirty=!0,e};I.rotateY=function(e,t,r){return C.rotateY(e.array,t.array,r),e._dirty=!0,e};I.rotateZ=function(e,t,r){return C.rotateZ(e.array,t.array,r),e._dirty=!0,e};I.scale=function(e,t,r){return C.scale(e.array,t.array,r.array),e._dirty=!0,e};I.transpose=function(e,t){return C.transpose(e.array,t.array),e._dirty=!0,e};I.translate=function(e,t,r){return C.translate(e.array,t.array,r.array),e._dirty=!0,e};var te=function(e,t,r,i){e=e||0,t=t||0,r=r||0,i=i===void 0?1:i,this.array=D.fromValues(e,t,r,i),this._dirty=!0};te.prototype={constructor:te,add:function(e){return D.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return D.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,r,i){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this.array[3]=i,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new te(this.x,this.y,this.z,this.w)},conjugate:function(){return D.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return D.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return D.dot(this.array,e.array)},fromMat3:function(e){return D.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:function(){var e=W.create();return function(t){return W.fromMat4(e,t.array),W.transpose(e,e),D.fromMat3(this.array,e),this._dirty=!0,this}}(),identity:function(){return D.identity(this.array),this._dirty=!0,this},invert:function(){return D.invert(this.array,this.array),this._dirty=!0,this},len:function(){return D.len(this.array)},length:function(){return D.length(this.array)},lerp:function(e,t,r){return D.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},mul:function(e){return D.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return D.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return D.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return D.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return D.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return D.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return D.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return D.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return D.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,r){return D.setAxes(this.array,e.array,t.array,r.array),this._dirty=!0,this},setAxisAngle:function(e,t){return D.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,r){return D.slerp(this.array,e.array,t.array,r),this._dirty=!0,this},sqrLen:function(){return D.sqrLen(this.array)},squaredLength:function(){return D.squaredLength(this.array)},fromEuler:function(e,t){return te.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var er=Object.defineProperty;if(er){var Pr=te.prototype;er(Pr,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),er(Pr,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),er(Pr,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),er(Pr,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}te.add=function(e,t,r){return D.add(e.array,t.array,r.array),e._dirty=!0,e};te.set=function(e,t,r,i,n){D.set(e.array,t,r,i,n),e._dirty=!0};te.copy=function(e,t){return D.copy(e.array,t.array),e._dirty=!0,e};te.calculateW=function(e,t){return D.calculateW(e.array,t.array),e._dirty=!0,e};te.conjugate=function(e,t){return D.conjugate(e.array,t.array),e._dirty=!0,e};te.identity=function(e){return D.identity(e.array),e._dirty=!0,e};te.invert=function(e,t){return D.invert(e.array,t.array),e._dirty=!0,e};te.dot=function(e,t){return D.dot(e.array,t.array)};te.len=function(e){return D.length(e.array)};te.lerp=function(e,t,r,i){return D.lerp(e.array,t.array,r.array,i),e._dirty=!0,e};te.slerp=function(e,t,r,i){return D.slerp(e.array,t.array,r.array,i),e._dirty=!0,e};te.mul=function(e,t,r){return D.multiply(e.array,t.array,r.array),e._dirty=!0,e};te.multiply=te.mul;te.rotateX=function(e,t,r){return D.rotateX(e.array,t.array,r),e._dirty=!0,e};te.rotateY=function(e,t,r){return D.rotateY(e.array,t.array,r),e._dirty=!0,e};te.rotateZ=function(e,t,r){return D.rotateZ(e.array,t.array,r),e._dirty=!0,e};te.setAxisAngle=function(e,t,r){return D.setAxisAngle(e.array,t.array,r),e._dirty=!0,e};te.normalize=function(e,t){return D.normalize(e.array,t.array),e._dirty=!0,e};te.sqrLen=function(e){return D.sqrLen(e.array)};te.squaredLength=te.sqrLen;te.fromMat3=function(e,t){return D.fromMat3(e.array,t.array),e._dirty=!0,e};te.setAxes=function(e,t,r,i){return D.setAxes(e.array,t.array,r.array,i.array),e._dirty=!0,e};te.rotationTo=function(e,t,r){return D.rotationTo(e.array,t.array,r.array),e._dirty=!0,e};te.fromEuler=function(e,t,h){e._dirty=!0,t=t.array;var i=e.array,n=Math.cos(t[0]/2),a=Math.cos(t[1]/2),s=Math.cos(t[2]/2),o=Math.sin(t[0]/2),l=Math.sin(t[1]/2),u=Math.sin(t[2]/2),h=(h||"XYZ").toUpperCase();switch(h){case"XYZ":i[0]=o*a*s+n*l*u,i[1]=n*l*s-o*a*u,i[2]=n*a*u+o*l*s,i[3]=n*a*s-o*l*u;break;case"YXZ":i[0]=o*a*s+n*l*u,i[1]=n*l*s-o*a*u,i[2]=n*a*u-o*l*s,i[3]=n*a*s+o*l*u;break;case"ZXY":i[0]=o*a*s-n*l*u,i[1]=n*l*s+o*a*u,i[2]=n*a*u+o*l*s,i[3]=n*a*s-o*l*u;break;case"ZYX":i[0]=o*a*s-n*l*u,i[1]=n*l*s+o*a*u,i[2]=n*a*u-o*l*s,i[3]=n*a*s+o*l*u;break;case"YZX":i[0]=o*a*s+n*l*u,i[1]=n*l*s+o*a*u,i[2]=n*a*u-o*l*s,i[3]=n*a*s-o*l*u;break;case"XZY":i[0]=o*a*s-n*l*u,i[1]=n*l*s-o*a*u,i[2]=n*a*u+o*l*s,i[3]=n*a*s+o*l*u;break}};var _t=_.set,Rr=_.copy,Se=function(e,t){this.min=e||new w(1/0,1/0,1/0),this.max=t||new w(-1/0,-1/0,-1/0),this.vertices=null};Se.prototype={constructor:Se,updateFromVertices:function(e){if(e.length>0){var t=this.min,r=this.max,i=t.array,n=r.array;Rr(i,e[0]),Rr(n,e[0]);for(var a=1;a<e.length;a++){var s=e[a];s[0]<i[0]&&(i[0]=s[0]),s[1]<i[1]&&(i[1]=s[1]),s[2]<i[2]&&(i[2]=s[2]),s[0]>n[0]&&(n[0]=s[0]),s[1]>n[1]&&(n[1]=s[1]),s[2]>n[2]&&(n[2]=s[2])}t._dirty=!0,r._dirty=!0}},union:function(e){var t=this.min,r=this.max;return _.min(t.array,t.array,e.min.array),_.max(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersection:function(e){var t=this.min,r=this.max;return _.max(t.array,t.array,e.min.array),_.min(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,r=this.max.array,i=e.min.array,n=e.max.array;return!(t[0]>n[0]||t[1]>n[1]||t[2]>n[2]||r[0]<i[0]||r[1]<i[1]||r[2]<i[2])},containBoundingBox:function(e){var t=this.min.array,r=this.max.array,i=e.min.array,n=e.max.array;return t[0]<=i[0]&&t[1]<=i[1]&&t[2]<=i[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},containPoint:function(e){var t=this.min.array,r=this.max.array,i=e.array;return t[0]<=i[0]&&t[1]<=i[1]&&t[2]<=i[2]&&r[0]>=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:function(){var e=_.create(),t=_.create(),r=_.create(),i=_.create(),n=_.create(),a=_.create();return function(s,o){var l=s.min.array,u=s.max.array,h=o.array;return e[0]=h[0]*l[0],e[1]=h[1]*l[0],e[2]=h[2]*l[0],t[0]=h[0]*u[0],t[1]=h[1]*u[0],t[2]=h[2]*u[0],r[0]=h[4]*l[1],r[1]=h[5]*l[1],r[2]=h[6]*l[1],i[0]=h[4]*u[1],i[1]=h[5]*u[1],i[2]=h[6]*u[1],n[0]=h[8]*l[2],n[1]=h[9]*l[2],n[2]=h[10]*l[2],a[0]=h[8]*u[2],a[1]=h[9]*u[2],a[2]=h[10]*u[2],l=this.min.array,u=this.max.array,l[0]=Math.min(e[0],t[0])+Math.min(r[0],i[0])+Math.min(n[0],a[0])+h[12],l[1]=Math.min(e[1],t[1])+Math.min(r[1],i[1])+Math.min(n[1],a[1])+h[13],l[2]=Math.min(e[2],t[2])+Math.min(r[2],i[2])+Math.min(n[2],a[2])+h[14],u[0]=Math.max(e[0],t[0])+Math.max(r[0],i[0])+Math.max(n[0],a[0])+h[12],u[1]=Math.max(e[1],t[1])+Math.max(r[1],i[1])+Math.max(n[1],a[1])+h[13],u[2]=Math.max(e[2],t[2])+Math.max(r[2],i[2])+Math.max(n[2],a[2])+h[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min.array,r=this.max.array,i=e.array,n=t[0],a=t[1],s=t[2],o=r[0],l=r[1],u=t[2],h=r[0],c=r[1],d=r[2];if(i[15]===1)t[0]=i[0]*n+i[12],t[1]=i[5]*a+i[13],r[2]=i[10]*s+i[14],r[0]=i[0]*h+i[12],r[1]=i[5]*c+i[13],t[2]=i[10]*d+i[14];else{var f=-1/s;t[0]=i[0]*n*f,t[1]=i[5]*a*f,r[2]=(i[10]*s+i[14])*f,f=-1/u,r[0]=i[0]*o*f,r[1]=i[5]*l*f,f=-1/d,t[2]=(i[10]*d+i[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=_.fromValues(0,0,0);this.vertices=e}var r=this.min.array,i=this.max.array;return _t(e[0],r[0],r[1],r[2]),_t(e[1],r[0],i[1],r[2]),_t(e[2],i[0],r[1],r[2]),_t(e[3],i[0],i[1],r[2]),_t(e[4],r[0],r[1],i[2]),_t(e[5],r[0],i[1],i[2]),_t(e[6],i[0],r[1],i[2]),_t(e[7],i[0],i[1],i[2]),this},copy:function(e){var t=this.min,r=this.max;return Rr(t.array,e.min.array),Rr(r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new Se;return e.copy(this),e}};var tl=0,tt=Pe.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")+"_"+tl++),this.position||(this.position=new w),this.rotation||(this.rotation=new te),this.scale||(this.scale=new w(1,1,1)),this.worldTransform=new I,this.localTransform=new I,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var r=t._nodeRepository;delete r[this.name],r[e]=this}this.name=e},add:function(e){var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var r=this._scene;r&&r!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){var t=this._children,r=t.indexOf(e);r<0||(t.splice(r,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t<e.length;t++)e[t]._parent=null,this._scene&&e[t].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(e){e._scene.removeFromScene(e),e._scene=null},_addSelfToScene:function(e){this._scene.addToScene(e),e._scene=this._scene},isAncestor:function(e){for(var t=e._parent;t;){if(t===this)return!0;t=t._parent}return!1},children:function(){return this._children.slice()},childAt:function(e){return this._children[e]},getChildByName:function(e){for(var t=this._children,r=0;r<t.length;r++)if(t[r].name===e)return t[r]},getDescendantByName:function(e){for(var t=this._children,r=0;r<t.length;r++){var i=t[r];if(i.name===e)return i;var n=i.getDescendantByName(e);if(n)return n}},queryNode:function(e){if(e){for(var t=e.split("/"),r=this,i=0;i<t.length;i++){var n=t[i];if(n){for(var a=!1,s=r._children,o=0;o<s.length;o++){var l=s[o];if(l.name===n){r=l,a=!0;break}}if(!a)return}}return r}},getPath:function(e){if(!this._parent)return"/";for(var t=this._parent,r=this.name;t._parent&&(r=t.name+"/"+r,t._parent!=e);)t=t._parent;return!t._parent&&e?null:r},traverse:function(e,t){e.call(t,this);for(var r=this._children,i=0,n=r.length;i<n;i++)r[i].traverse(e,t)},eachChild:function(e,t){for(var r=this._children,i=0,n=r.length;i<n;i++){var a=r[i];e.call(t,a,i)}},setLocalTransform:function(e){C.copy(this.localTransform.array,e.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(e){var t=e?null:this.scale;this.localTransform.decomposeMatrix(t,this.rotation,this.position)},setWorldTransform:function(e){C.copy(this.worldTransform.array,e.array),this.decomposeWorldTransform()},decomposeWorldTransform:function(){var e=C.create();return function(t){var r=this.localTransform,i=this.worldTransform;this._parent?(C.invert(e,this._parent.worldTransform.array),C.multiply(r.array,e,i.array)):C.copy(r.array,i.array);var n=t?null:this.scale;r.decomposeMatrix(n,this.rotation,this.position)}}(),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var e=this.position,t=this.rotation,r=this.scale;if(this.transformNeedsUpdate()){var i=this.localTransform.array;C.fromRotationTranslation(i,t.array,e.array),C.scale(i,i,r.array),t._dirty=!1,r._dirty=!1,e._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var e=this.localTransform.array,t=this.worldTransform.array;this._parent?C.multiplyAffine(t,this._parent.worldTransform.array,e):C.copy(t,e)},updateWorldTransform:function(){for(var e=this;e&&e.getParent()&&e.getParent().transformNeedsUpdate();)e=e.getParent();e.update()},update:function(e){this.autoUpdateLocalTransform?this.updateLocalTransform():e=!0,(e||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),e=!0,this._needsUpdateWorldTransform=!1);for(var t=this._children,r=0,i=t.length;r<i;r++)t[r].update(e)},getBoundingBox:function(){function e(n){return!n.invisible&&n.geometry}var t=new Se,r=new I,i=new I;return function(n,a){return a=a||new Se,this._parent?I.invert(i,this._parent.worldTransform):I.identity(i),this.traverse(function(s){s.geometry&&s.geometry.boundingBox&&(t.copy(s.geometry.boundingBox),I.multiply(r,i,s.worldTransform),t.applyTransform(r),a.union(t))},this,e),a}}(),getWorldPosition:function(e){this.transformNeedsUpdate()&&this.updateWorldTransform();var t=this.worldTransform.array;if(e){var r=e.array;return r[0]=t[12],r[1]=t[13],r[2]=t[14],e}else return new w(t[12],t[13],t[14])},clone:function(){var e=new this.constructor,t=this._children;e.setName(this.name),e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale);for(var r=0;r<t.length;r++)e.add(t[r].clone());return e},rotateAround:function(){var e=new w,t=new I;return function(r,i,n){e.copy(this.position).subtract(r);var a=this.localTransform;a.identity(),a.translate(r),a.rotate(n,i),t.fromRotationTranslation(this.rotation,e),a.multiply(t),a.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var e=new I;return function(t,r){e.lookAt(this.position,t,r||this.localTransform.y).invert(),this.setLocalTransform(e),this.target=t}}()}),Ie=tt.extend({material:null,geometry:null,mode:b.TRIANGLES,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:b.BACK,frontFace:b.CCW,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=tt.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:function(){var e=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"];return function(){var t=tt.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var r=0;r<e.length;r++){var i=e[r];t[i]!==this[i]&&(t[i]=this[i])}return t}}()});Ie.POINTS=b.POINTS;Ie.LINES=b.LINES;Ie.LINE_LOOP=b.LINE_LOOP;Ie.LINE_STRIP=b.LINE_STRIP;Ie.TRIANGLES=b.TRIANGLES;Ie.TRIANGLE_STRIP=b.TRIANGLE_STRIP;Ie.TRIANGLE_FAN=b.TRIANGLE_FAN;Ie.BACK=b.BACK;Ie.FRONT=b.FRONT;Ie.FRONT_AND_BACK=b.FRONT_AND_BACK;Ie.CW=b.CW;Ie.CCW=b.CCW;var Zi=Pe.extend({scene:null,camera:null,renderer:null},function(){this._ray=new Lt,this._ndc=new q},{pick:function(e,t,r){var i=this.pickAll(e,t,[],r);return i[0]||null},pickAll:function(e,t,r,i){return this.renderer.screenToNDC(e,t,this._ndc),this.camera.castRay(this._ndc,this._ray),r=r||[],this._intersectNode(this.scene,r,i||!1),r.sort(this._intersectionCompareFunc),r},_intersectNode:function(e,t,r){e instanceof Ie&&e.isRenderable()&&(!e.ignorePicking||r)&&(e.mode===b.TRIANGLES&&e.geometry.isUseIndices()||e.geometry.pickByRay||e.geometry.pick)&&this._intersectRenderable(e,t);for(var i=0;i<e._children.length;i++)this._intersectNode(e._children[i],t,r)},_intersectRenderable:function(){var e=new w,t=new w,r=new w,i=new Lt,n=new I;return function(a,s){var o=a.isSkinnedMesh();i.copy(this._ray),I.invert(n,a.worldTransform),o||i.applyTransform(n);var l=a.geometry,u=o?a.skeleton.boundingBox:l.boundingBox;if(!(u&&!i.intersectBoundingBox(u))){if(l.pick){l.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,a,s);return}else if(l.pickByRay){l.pickByRay(i,a,s);return}var h=a.cullFace===b.BACK&&a.frontFace===b.CCW||a.cullFace===b.FRONT&&a.frontFace===b.CW,c,d=l.indices,f=l.attributes.position,v=l.attributes.weight,p=l.attributes.joint,m,g=[];if(!(!f||!f.value||!d)){if(o){m=a.skeleton.getSubSkinMatrices(a.__uid__,a.joints);for(var T=0;T<a.joints.length;T++){g[T]=g[T]||[];for(var y=0;y<16;y++)g[T][y]=m[T*16+y]}var x=[],E=[],S=[],O=[],P=[],B=l.attributes.skinnedPosition;(!B||!B.value)&&(l.createAttribute("skinnedPosition","f",3),B=l.attributes.skinnedPosition,B.init(l.vertexCount));for(var T=0;T<l.vertexCount;T++){f.get(T,x),v.get(T,E),p.get(T,S),E[3]=1-E[0]-E[1]-E[2],_.set(O,0,0,0);for(var y=0;y<4;y++)S[y]>=0&&E[y]>1e-4&&(_.transformMat4(P,x,g[S[y]]),_.scaleAndAdd(O,O,P,E[y]));B.set(T,O)}}for(var T=0;T<d.length;T+=3){var k=d[T],N=d[T+1],V=d[T+2],z=o?l.attributes.skinnedPosition:f;if(z.get(k,e.array),z.get(N,t.array),z.get(V,r.array),h?c=i.intersectTriangle(e,t,r,a.culling):c=i.intersectTriangle(e,r,t,a.culling),c){var U=new w;o?w.copy(U,c):w.transformMat4(U,c,a.worldTransform),s.push(new Zi.Intersection(c,U,a,[k,N,V],T/3,w.dist(U,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});Zi.Intersection=function(e,t,r,i,n,a){this.point=e,this.pointWorld=t,this.target=r,this.triangle=i,this.triangleIndex=n,this.distance=a};var tr="__dt__",Zt=function(){this._contextId=0,this._caches=[],this._context={}};Zt.prototype={use:function(e,t){var r=this._caches;r[e]||(r[e]={},t&&(r[e]=t())),this._contextId=e,this._context=r[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){e=e||"";var t=tr+e;this.put(t,!0)},dirtyAll:function(e){e=e||"";for(var t=tr+e,r=this._caches,i=0;i<r.length;i++)r[i]&&(r[i][t]=!0)},fresh:function(e){e=e||"";var t=tr+e;this.put(t,!1)},freshAll:function(e){e=e||"";for(var t=tr+e,r=this._caches,i=0;i<r.length;i++)r[i]&&(r[i][t]=!1)},isDirty:function(e){e=e||"";var t=tr+e,r=this._context;return!r.hasOwnProperty(t)||r[t]===!0},deleteContext:function(e){delete this._caches[e],this._context={}},delete:function(e){delete this._context[e]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(e,t){var r=Object.keys(this._caches);r.forEach(function(i){e&&e.call(t,i)})},miss:function(e){return!this._context.hasOwnProperty(e)}};Zt.prototype.constructor=Zt;var L=Pe.extend({width:512,height:512,type:b.UNSIGNED_BYTE,format:b.RGBA,wrapS:b.REPEAT,wrapT:b.REPEAT,minFilter:b.LINEAR_MIPMAP_LINEAR,magFilter:b.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},function(){this._cache=new Zt},{getWebGLTexture:function(e){var t=e.gl,r=this._cache;return r.use(e.__uid__),r.miss("webgl_texture")&&r.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):r.isDirty()&&(this.update(e),r.fresh()),r.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===b.DEPTH_COMPONENT&&(this.useMipmap=!1);var r=e.getGLExtension("EXT_sRGB");this.format===L.SRGB&&!r&&(this.format=L.RGB),this.format===L.SRGB_ALPHA&&!r&&(this.format=L.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?b.CLAMP_TO_EDGE:this.wrapS},getAvailableWrapT:function(){return this.NPOT?b.CLAMP_TO_EDGE:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===b.NEAREST_MIPMAP_NEAREST||e===b.NEAREST_MIPMAP_LINEAR?b.NEAREST:e===b.LINEAR_MIPMAP_LINEAR||e===b.LINEAR_MIPMAP_NEAREST?b.LINEAR:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e=e|e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var r=t.get("webgl_texture");r&&e.gl.deleteTexture(r),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(L.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}});Object.defineProperty(L.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}});L.BYTE=b.BYTE;L.UNSIGNED_BYTE=b.UNSIGNED_BYTE;L.SHORT=b.SHORT;L.UNSIGNED_SHORT=b.UNSIGNED_SHORT;L.INT=b.INT;L.UNSIGNED_INT=b.UNSIGNED_INT;L.FLOAT=b.FLOAT;L.HALF_FLOAT=36193;L.UNSIGNED_INT_24_8_WEBGL=34042;L.DEPTH_COMPONENT=b.DEPTH_COMPONENT;L.DEPTH_STENCIL=b.DEPTH_STENCIL;L.ALPHA=b.ALPHA;L.RGB=b.RGB;L.RGBA=b.RGBA;L.LUMINANCE=b.LUMINANCE;L.LUMINANCE_ALPHA=b.LUMINANCE_ALPHA;L.SRGB=35904;L.SRGB_ALPHA=35906;L.COMPRESSED_RGB_S3TC_DXT1_EXT=33776;L.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777;L.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778;L.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779;L.NEAREST=b.NEAREST;L.LINEAR=b.LINEAR;L.NEAREST_MIPMAP_NEAREST=b.NEAREST_MIPMAP_NEAREST;L.LINEAR_MIPMAP_NEAREST=b.LINEAR_MIPMAP_NEAREST;L.NEAREST_MIPMAP_LINEAR=b.NEAREST_MIPMAP_LINEAR;L.LINEAR_MIPMAP_LINEAR=b.LINEAR_MIPMAP_LINEAR;L.REPEAT=b.REPEAT;L.CLAMP_TO_EDGE=b.CLAMP_TO_EDGE;L.MIRRORED_REPEAT=b.MIRRORED_REPEAT;var Be=Ie.extend({skeleton:null,joints:null},function(){this.joints||(this.joints=[])},{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var e=Ie.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});Be.POINTS=b.POINTS;Be.LINES=b.LINES;Be.LINE_LOOP=b.LINE_LOOP;Be.LINE_STRIP=b.LINE_STRIP;Be.TRIANGLES=b.TRIANGLES;Be.TRIANGLE_STRIP=b.TRIANGLE_STRIP;Be.TRIANGLE_FAN=b.TRIANGLE_FAN;Be.BACK=b.BACK;Be.FRONT=b.FRONT;Be.FRONT_AND_BACK=b.FRONT_AND_BACK;Be.CW=b.CW;Be.CCW=b.CCW;var Tr={};Tr.isPowerOfTwo=function(e){return(e&e-1)===0};Tr.nextPowerOfTwo=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e};Tr.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))};var Pn=Tr.isPowerOfTwo;function Rn(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function rl(e,t){var r=Rn(e.width),i=Rn(e.height);t=t||document.createElement("canvas"),t.width=r,t.height=i;var n=t.getContext("2d");return n.drawImage(e.image,0,0,r,i),t}var Q=L.extend(function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}},{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var r=this.format,i=this.type,n=!!(this.convertToPOT&&!this.mipmaps.length&&this.image&&(this.wrapS===L.REPEAT||this.wrapT===L.REPEAT)&&this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,n?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,n?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n?this.minFilter:this.getAvailableMinFilter());var a=e.getGLExtension("EXT_texture_filter_anisotropic");if(a&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,a.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),i===36193){var s=e.getGLExtension("OES_texture_half_float");s||(i=b.FLOAT)}if(this.mipmaps.length)for(var o=this.width,l=this.height,u=0;u<this.mipmaps.length;u++){var h=this.mipmaps[u];this._updateTextureData(t,h,u,o,l,r,i,!1),o/=2,l/=2}else this._updateTextureData(t,this,0,this.width,this.height,r,i,n),this.useMipmap&&(!this.NPOT||n)&&t.generateMipmap(t.TEXTURE_2D);t.bindTexture(t.TEXTURE_2D,null)},_updateTextureData:function(e,t,r,i,n,a,s,o){if(t.image){var l=t.image;o&&(this._potCanvas=rl(this,this._potCanvas),l=this._potCanvas),e.texImage2D(e.TEXTURE_2D,r,a,a,s,l)}else a<=L.COMPRESSED_RGBA_S3TC_DXT5_EXT&&a>=L.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,a,i,n,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,a,i,n,0,a,s,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return Pn(this.width)&&Pn(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!!(this.width&&this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var r=J.createImage();t&&(r.crossOrigin=t);var i=this;return r.onload=function(){i.dirty(),i.trigger("success",i)},r.onerror=function(){i.trigger("error",i)},r.src=e,this.image=r,this}});Object.defineProperty(Q.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}});Object.defineProperty(Q.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}});function xa(e){return{byte:J.Int8Array,ubyte:J.Uint8Array,short:J.Int16Array,ushort:J.Uint16Array}[e]||J.Float32Array}function hi(e){return"attr_"+e}function $t(e,t,r,i){switch(this.name=e,this.type=t,this.size=r,this.semantic=i||"",this.value=null,r){case 1:this.get=function(n){return this.value[n]},this.set=function(n,a){this.value[n]=a},this.copy=function(n,a){this.value[n]=this.value[n]};break;case 2:this.get=function(n,a){var s=this.value;return a[0]=s[n*2],a[1]=s[n*2+1],a},this.set=function(n,a){var s=this.value;s[n*2]=a[0],s[n*2+1]=a[1]},this.copy=function(n,a){var s=this.value;a*=2,n*=2,s[n]=s[a],s[n+1]=s[a+1]};break;case 3:this.get=function(n,a){var s=n*3,o=this.value;return a[0]=o[s],a[1]=o[s+1],a[2]=o[s+2],a},this.set=function(n,a){var s=n*3,o=this.value;o[s]=a[0],o[s+1]=a[1],o[s+2]=a[2]},this.copy=function(n,a){var s=this.value;a*=3,n*=3,s[n]=s[a],s[n+1]=s[a+1],s[n+2]=s[a+2]};break;case 4:this.get=function(n,a){var s=this.value,o=n*4;return a[0]=s[o],a[1]=s[o+1],a[2]=s[o+2],a[3]=s[o+3],a},this.set=function(n,a){var s=this.value,o=n*4;s[o]=a[0],s[o+1]=a[1],s[o+2]=a[2],s[o+3]=a[3]},this.copy=function(n,a){var s=this.value;a*=4,n*=4,s[n]=s[a],s[n+1]=s[a+1],s[n+2]=s[a+2],s[n+3]=s[a+3]}}}$t.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=xa(this.type);this.value=new t(e*this.size)}};$t.prototype.fromArray=function(e){var t=xa(this.type),r;if(e[0]&&e[0].length){var i=0,n=this.size;r=new t(e.length*n);for(var a=0;a<e.length;a++)for(var s=0;s<n;s++)r[i++]=e[a][s]}else r=new t(e);this.value=r};$t.prototype.clone=function(e){var t=new $t(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t};function Ta(e,t,r,i,n){this.name=e,this.type=t,this.buffer=r,this.size=i,this.semantic=n,this.symbol="",this.needsRemove=!1}function wa(e){this.buffer=e,this.count=0}var Fe=Pe.extend(function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}},function(){this._cache=new Zt,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}},{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t<e.length;t++)this.dirtyAttribute(e[t]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(e){this._cache.dirtyAll(hi(e)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(e,t){if(e<this.triangleCount&&e>=0){t||(t=[]);var r=this.indices;return t[0]=r[e*3],t[1]=r[e*3+1],t[2]=r[e*3+2],t}},setTriangleIndices:function(e,t){var r=this.indices;r[e*3]=t[0],r[e*3+1]=t[1],r[e*3+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,r=this.vertexCount>65535?J.Uint32Array:J.Uint16Array;if(e[0]&&e[0].length){var i=0,n=3;t=new r(e.length*n);for(var a=0;a<e.length;a++)for(var s=0;s<n;s++)t[i++]=e[a][s]}else t=new r(e);this.indices=t},createAttribute:function(e,t,r,i){var n=new $t(e,t,r,i);return this.attributes[e]&&this.removeAttribute(e),this.attributes[e]=n,this._attributeList.push(e),n},removeAttribute:function(e){var t=this._attributeList,r=t.indexOf(e);return r>=0?(t.splice(r,1),delete this.attributes[e],!0):!1},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var r=[],i=this.vertexCount,n=0;n<t.length;n++){var a=t[n],s=this.attributes[a];s.value&&s.value.length===i*s.size&&r.push(a)}return this._enabledAttributes=r,r},getBufferChunks:function(e){var t=this._cache;t.use(e.__uid__);var r=t.isDirty("attributes"),i=t.isDirty("indices");if(r||i){this._updateBuffer(e.gl,r,i);for(var n=this.getEnabledAttributes(),a=0;a<n.length;a++)t.fresh(hi(n[a]));t.fresh("attributes"),t.fresh("indices")}return t.fresh("any"),t.get("chunks")},_updateBuffer:function(e,t,r){var i=this._cache,n=i.get("chunks"),a=!1;n||(n=[],n[0]={attributeBuffers:[],indicesBuffer:null},i.put("chunks",n),a=!0);var s=n[0],o=s.attributeBuffers,l=s.indicesBuffer;if(t||a){var u=this.getEnabledAttributes(),h={};if(!a)for(var c=0;c<o.length;c++)h[o[c].name]=o[c];for(var d=0;d<u.length;d++){var f=u[d],v=this.attributes[f],p;a||(p=h[f]);var m;p?m=p.buffer:m=e.createBuffer(),i.isDirty(hi(f))&&(e.bindBuffer(e.ARRAY_BUFFER,m),e.bufferData(e.ARRAY_BUFFER,v.value,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW)),o[d]=new Ta(f,v.type,m,v.size,v.semantic)}for(var c=d;c<o.length;c++)e.deleteBuffer(o[c].buffer);o.length=d}this.isUseIndices()&&(r||a)&&(l||(l=new wa(e.createBuffer()),s.indicesBuffer=l),l.count=this.indices.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.buffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW))},dispose:function(e){var t=this._cache;t.use(e.__uid__);var r=t.get("chunks");if(r)for(var i=0;i<r.length;i++){for(var n=r[i],a=0;a<n.attributeBuffers.length;a++){var s=n.attributeBuffers[a];e.gl.deleteBuffer(s.buffer)}n.indicesBuffer&&e.gl.deleteBuffer(n.indicesBuffer.buffer)}if(this.__vaoCache){var o=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&o.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});Object.defineProperty&&(Object.defineProperty(Fe.prototype,"vertexCount",{enumerable:!1,get:function(){var e=this.attributes[this.mainAttribute];return e||(e=this.attributes[this._attributeList[0]]),!e||!e.value?0:e.value.length/e.size}}),Object.defineProperty(Fe.prototype,"triangleCount",{enumerable:!1,get:function(){var e=this.indices;return e?e.length/3:0}}));Fe.STATIC_DRAW=b.STATIC_DRAW;Fe.DYNAMIC_DRAW=b.DYNAMIC_DRAW;Fe.STREAM_DRAW=b.STREAM_DRAW;Fe.AttributeBuffer=Ta;Fe.IndicesBuffer=wa;Fe.Attribute=$t;var Ne=_.create,Ht=_.add,wt=_.set,Ke=Fe.Attribute,ae=Fe.extend(function(){return{attributes:{position:new Ke("position","float",3,"POSITION"),texcoord0:new Ke("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new Ke("texcoord1","float",2,"TEXCOORD_1"),normal:new Ke("normal","float",3,"NORMAL"),tangent:new Ke("tangent","float",4,"TANGENT"),color:new Ke("color","float",4,"COLOR"),weight:new Ke("weight","float",3,"WEIGHT"),joint:new Ke("joint","float",4,"JOINT"),barycentric:new Ke("barycentric","float",3,null)},boundingBox:null}},{mainAttribute:"position",updateBoundingBox:function(){var e=this.boundingBox;e||(e=this.boundingBox=new Se);var t=this.attributes.position.value;if(t&&t.length){var r=e.min,i=e.max,n=r.array,a=i.array;_.set(n,t[0],t[1],t[2]),_.set(a,t[0],t[1],t[2]);for(var s=3;s<t.length;){var o=t[s++],l=t[s++],u=t[s++];o<n[0]&&(n[0]=o),l<n[1]&&(n[1]=l),u<n[2]&&(n[2]=u),o>a[0]&&(a[0]=o),l>a[1]&&(a[1]=l),u>a[2]&&(a[2]=u)}r._dirty=!0,i._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,r=t.position.value,i=t.normal.value;if(!i||i.length!==r.length)i=t.normal.value=new J.Float32Array(r.length);else for(var n=0;n<i.length;n++)i[n]=0;for(var a=Ne(),s=Ne(),o=Ne(),l=Ne(),u=Ne(),h=Ne(),c=e?e.length:this.vertexCount,d,f,v,p=0;p<c;){e?(d=e[p++],f=e[p++],v=e[p++]):(d=p++,f=p++,v=p++),wt(a,r[d*3],r[d*3+1],r[d*3+2]),wt(s,r[f*3],r[f*3+1],r[f*3+2]),wt(o,r[v*3],r[v*3+1],r[v*3+2]),_.sub(l,a,s),_.sub(u,s,o),_.cross(h,l,u);for(var n=0;n<3;n++)i[d*3+n]=i[d*3+n]+h[n],i[f*3+n]=i[f*3+n]+h[n],i[v*3+n]=i[v*3+n]+h[n]}for(var n=0;n<i.length;)wt(h,i[n],i[n+1],i[n+2]),_.normalize(h,h),i[n++]=h[0],i[n++]=h[1],i[n++]=h[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.indices,t=this.attributes,r=t.position.value,i=t.normal.value,n=Ne(),a=Ne(),s=Ne(),o=Ne(),l=Ne(),u=Ne();i||(i=t.normal.value=new Float32Array(r.length));for(var h=e?e.length:this.vertexCount,c,d,f,v=0;v<h;){e?(c=e[v++],d=e[v++],f=e[v++]):(c=v++,d=v++,f=v++),wt(n,r[c*3],r[c*3+1],r[c*3+2]),wt(a,r[d*3],r[d*3+1],r[d*3+2]),wt(s,r[f*3],r[f*3+1],r[f*3+2]),_.sub(o,n,a),_.sub(l,a,s),_.cross(u,o,l),_.normalize(u,u);for(var p=0;p<3;p++)i[c*3+p]=u[p],i[d*3+p]=u[p],i[f*3+p]=u[p]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var e=this.vertexCount,t=this.attributes;t.tangent.value||(t.tangent.value=new Float32Array(e*4));var r=t.texcoord0.value,i=t.position.value,n=t.tangent.value,a=t.normal.value;if(!r){console.warn("Geometry without texcoords can't generate tangents.");return}for(var s=[],o=[],l=0;l<e;l++)s[l]=[0,0,0],o[l]=[0,0,0];for(var u=[0,0,0],h=[0,0,0],c=this.indices,d=c?c.length:this.vertexCount,f,v,p,l=0;l<d;){c?(f=c[l++],v=c[l++],p=c[l++]):(f=l++,v=l++,p=l++);var m=r[f*2],g=r[v*2],T=r[p*2],y=r[f*2+1],x=r[v*2+1],E=r[p*2+1],S=i[f*3],O=i[v*3],P=i[p*3],B=i[f*3+1],k=i[v*3+1],N=i[p*3+1],V=i[f*3+2],z=i[v*3+2],U=i[p*3+2],X=O-S,G=P-S,Y=k-B,H=N-B,le=z-V,j=U-V,ve=g-m,re=T-m,ue=x-y,he=E-y,Ce=1/(ve*he-ue*re);u[0]=(he*X-ue*G)*Ce,u[1]=(he*Y-ue*H)*Ce,u[2]=(he*le-ue*j)*Ce,h[0]=(ve*G-re*X)*Ce,h[1]=(ve*H-re*Y)*Ce,h[2]=(ve*j-re*le)*Ce,Ht(s[f],s[f],u),Ht(s[v],s[v],u),Ht(s[p],s[p],u),Ht(o[f],o[f],h),Ht(o[v],o[v],h),Ht(o[p],o[p],h)}for(var Me=Ne(),xe=Ne(),Le=Ne(),l=0;l<e;l++){Le[0]=a[l*3],Le[1]=a[l*3+1],Le[2]=a[l*3+2];var He=s[l];_.scale(Me,Le,_.dot(Le,He)),_.sub(Me,He,Me),_.normalize(Me,Me),_.cross(xe,Le,He),n[l*4]=Me[0],n[l*4+1]=Me[1],n[l*4+2]=Me[2],n[l*4+3]=_.dot(xe,o[l])<0?-1:1}this.dirty()}},isUniqueVertex:function(){return this.isUseIndices()?this.vertexCount===this.indices.length:!0},generateUniqueVertex:function(){if(!(!this.vertexCount||!this.indices)){this.indices.length>65535&&(this.indices=new J.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),i={},n=0;n<r.length;n++){var a=r[n];i[a]=e[a].value,e[a].init(this.indices.length)}for(var s=0,o=0;o<t.length;o++){for(var l=t[o],n=0;n<r.length;n++)for(var a=r[n],u=e[a].value,h=e[a].size,c=0;c<h;c++)u[s*h+c]=i[a][l*h+c];t[o]=s,s++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var e=this.attributes,t=e.barycentric.value,r=this.indices;if(!(t&&t.length===r.length*3)){t=e.barycentric.value=new Float32Array(r.length*3);for(var i=0;i<(r?r.length:this.vertexCount/3);)for(var n=0;n<3;n++){var a=r?r[i++]:i*3+n;t[a*3+n]=1}this.dirty()}}},applyTransform:function(e){var t=this.attributes,r=t.position.value,i=t.normal.value,n=t.tangent.value;e=e.array;var a=C.create();C.invert(a,e),C.transpose(a,a);var s=_.transformMat4,o=_.forEach;o(r,3,0,null,s,e),i&&o(i,3,0,null,s,a),n&&o(n,4,0,null,s,a),this.boundingBox&&this.updateBoundingBox()},dispose:function(e){var t=this._cache;t.use(e.__uid__);var r=t.get("chunks");if(r)for(var i=0;i<r.length;i++){for(var n=r[i],a=0;a<n.attributeBuffers.length;a++){var s=n.attributeBuffers[a];e.gl.deleteBuffer(s.buffer)}n.indicesBuffer&&e.gl.deleteBuffer(n.indicesBuffer.buffer)}if(this.__vaoCache){var o=e.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var u=this.__vaoCache[l].vao;u&&o.deleteVertexArrayOES(u)}}this.__vaoCache={},t.deleteContext(e.__uid__)}});ae.STATIC_DRAW=Fe.STATIC_DRAW;ae.DYNAMIC_DRAW=Fe.DYNAMIC_DRAW;ae.STREAM_DRAW=Fe.STREAM_DRAW;ae.AttributeBuffer=Fe.AttributeBuffer;ae.IndicesBuffer=Fe.IndicesBuffer;ae.Attribute=Ke;const il="vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}";var je="uniform vec3 ",rr="uniform float ",zt="@export clay.header.",Gt="@end",Ee=":unconfigurable;";const nl=[zt+"directional_light",je+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+Ee,je+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+Ee,Gt,zt+"ambient_light",je+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+Ee,Gt,zt+"ambient_sh_light",je+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+Ee,je+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+Ee,il,Gt,zt+"ambient_cubemap_light",je+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+Ee,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+Ee,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+Ee,Gt,zt+"point_light",je+"pointLightPosition[POINT_LIGHT_COUNT]"+Ee,rr+"pointLightRange[POINT_LIGHT_COUNT]"+Ee,je+"pointLightColor[POINT_LIGHT_COUNT]"+Ee,Gt,zt+"spot_light",je+"spotLightPosition[SPOT_LIGHT_COUNT]"+Ee,je+"spotLightDirection[SPOT_LIGHT_COUNT]"+Ee,rr+"spotLightRange[SPOT_LIGHT_COUNT]"+Ee,rr+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+Ee,rr+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+Ee,rr+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+Ee,je+"spotLightColor[SPOT_LIGHT_COUNT]"+Ee,Gt].join("\n");F.import(nl);var Ze=tt.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var e=tt.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}}),lr=function(e,t){this.normal=e||new w(0,1,0),this.distance=t||0};lr.prototype={constructor:lr,distanceToPoint:function(e){return _.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new w);var r=this.distanceToPoint(e);return _.scaleAndAdd(t.array,e.array,this.normal.array,-r),t._dirty=!0,t},normalize:function(){var e=1/_.len(this.normal.array);_.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,r=this.normal.array,i=_.dot(t[0].array,r)>this.distance,n=1;n<8;n++)if(_.dot(t[n].array,r)>this.distance!=i)return!0},intersectLine:function(){var e=_.create();return function(t,r,i){var n=this.distanceToPoint(t),a=this.distanceToPoint(r);if(n>0&&a>0||n<0&&a<0)return null;var s=this.normal.array,o=this.distance,l=t.array;_.sub(e,r.array,t.array),_.normalize(e,e);var u=_.dot(s,e);if(u===0)return null;i||(i=new w);var h=(_.dot(s,l)-o)/u;return _.scaleAndAdd(i.array,l,e,-h),i._dirty=!0,i}}(),applyTransform:function(){var e=C.create(),t=A.create(),r=A.create();return r[3]=1,function(i){i=i.array,_.scale(r,this.normal.array,this.distance),A.transformMat4(r,r,i),this.distance=_.dot(r,this.normal.array),C.invert(e,i),C.transpose(e,e),t[3]=0,_.copy(t,this.normal.array),A.transformMat4(t,t,e),_.copy(this.normal.array,t)}}(),copy:function(e){_.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new lr;return e.copy(this),e}};var pe=_.set,Ln=_.copy,Nn=_.transformMat4,ci=Math.min,fi=Math.max,Yr=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new lr);this.boundingBox=new Se,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=_.fromValues(0,0,0)};Yr.prototype={setFromProjection:function(e){var t=this.planes,r=e.array,i=r[0],n=r[1],a=r[2],s=r[3],o=r[4],l=r[5],u=r[6],h=r[7],c=r[8],d=r[9],f=r[10],v=r[11],p=r[12],m=r[13],g=r[14],T=r[15];pe(t[0].normal.array,s-i,h-o,v-c),t[0].distance=-(T-p),t[0].normalize(),pe(t[1].normal.array,s+i,h+o,v+c),t[1].distance=-(T+p),t[1].normalize(),pe(t[2].normal.array,s+n,h+l,v+d),t[2].distance=-(T+m),t[2].normalize(),pe(t[3].normal.array,s-n,h-l,v-d),t[3].distance=-(T-m),t[3].normalize(),pe(t[4].normal.array,s-a,h-u,v-f),t[4].distance=-(T-g),t[4].normalize(),pe(t[5].normal.array,s+a,h+u,v+f),t[5].distance=-(T+g),t[5].normalize();var y=this.boundingBox,x=this.vertices;if(T===0){var E=l/i,S=-g/(f-1),O=-g/(f+1),P=-O/l,B=-S/l;y.min.set(-P*E,-P,O),y.max.set(P*E,P,S),pe(x[0],-P*E,-P,O),pe(x[1],-P*E,P,O),pe(x[2],P*E,-P,O),pe(x[3],P*E,P,O),pe(x[4],-B*E,-B,S),pe(x[5],-B*E,B,S),pe(x[6],B*E,-B,S),pe(x[7],B*E,B,S)}else{var k=(-1-p)/i,N=(1-p)/i,V=(1-m)/l,z=(-1-m)/l,U=(-1-g)/f,X=(1-g)/f;y.min.set(Math.min(k,N),Math.min(z,V),Math.min(X,U)),y.max.set(Math.max(N,k),Math.max(V,z),Math.max(U,X));var G=y.min.array,Y=y.max.array;pe(x[0],G[0],G[1],G[2]),pe(x[1],G[0],Y[1],G[2]),pe(x[2],Y[0],G[1],G[2]),pe(x[3],Y[0],Y[1],G[2]),pe(x[4],G[0],G[1],Y[2]),pe(x[5],G[0],Y[1],Y[2]),pe(x[6],Y[0],G[1],Y[2]),pe(x[7],Y[0],Y[1],Y[2])}},getTransformedBoundingBox:function(){var e=_.create();return function(t,r){var i=this.vertices,n=r.array,a=t.min,s=t.max,o=a.array,l=s.array,u=i[0];Nn(e,u,n),Ln(o,e),Ln(l,e);for(var h=1;h<8;h++)u=i[h],Nn(e,u,n),o[0]=ci(e[0],o[0]),o[1]=ci(e[1],o[1]),o[2]=ci(e[2],o[2]),l[0]=fi(e[0],l[0]),l[1]=fi(e[1],l[1]),l[2]=fi(e[2],l[2]);return a._dirty=!0,s._dirty=!0,t}}()};var Kt=tt.extend(function(){return{projectionMatrix:new I,invProjectionMatrix:new I,viewMatrix:new I,frustum:new Yr}},function(){this.update(!0)},{update:function(e){tt.prototype.update.call(this,e),I.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),I.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){I.copy(this.viewMatrix,e),I.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){I.copy(this.projectionMatrix,e),I.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=A.create();return function(t,r){var i=r!==void 0?r:new Lt,n=t.array[0],a=t.array[1];return A.set(e,n,a,-1,1),A.transformMat4(e,e,this.invProjectionMatrix.array),A.transformMat4(e,e,this.worldTransform.array),_.scale(i.origin.array,e,1/e[3]),A.set(e,n,a,1,1),A.transformMat4(e,e,this.invProjectionMatrix.array),A.transformMat4(e,e,this.worldTransform.array),_.scale(e,e,1/e[3]),_.sub(i.direction.array,e,i.origin.array),_.normalize(i.direction.array,i.direction.array),i.direction._dirty=!0,i.origin._dirty=!0,i}}()}),al=C.create(),Dn=C.create(),di={};function sl(e){var t=[],r=Object.keys(e);r.sort();for(var i=0;i<r.length;i++){var n=r[i];t.push(n+" "+e[n])}var a=t.join("\n");if(di[a])return di[a];var s=me.genGUID();return di[a]=s,s}function Zr(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}Zr.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0};Zr.prototype.add=function(e,t){t?this.transparent[this._transparentCount++]=e:this.opaque[this._opaqueCount++]=e};Zr.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};var xt=tt.extend(function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new Se,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new Ot(20)}},function(){this._scene=this},{addToScene:function(e){e instanceof Kt?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof Ze&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof Kt?(t=this._cameraList.indexOf(e),t>=0&&this._cameraList.splice(t,1)):e instanceof Ze&&(t=this.lights.indexOf(e),t>=0&&this.lights.splice(t,1)),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},r=0;r<e.length;r++){var i=e[r];if(!i.invisible){var n=i.group;t[n]||(t[n]={}),t[n][i.type]=t[n][i.type]||0,t[n][i.type]++}}this._lightNumber=t;for(var a in t)this._lightProgramKeys[a]=sl(t[a]);this._updateLightUniforms()},cloneNode:function(e){var t=e.clone(),r={};function i(n,a){r[n.__uid__]=a;for(var s=0;s<n._children.length;s++){var o=n._children[s],l=a._children[s];i(o,l)}}return i(e,t),t.traverse(function(n){n.skeleton&&(n.skeleton=n.skeleton.clone(r)),n.material&&(n.material=n.material.clone())}),t},updateRenderList:function(e,t){var r=e.__uid__,i=this._renderLists.get(r);i||(i=new Zr,this._renderLists.put(r,i)),i.startCount(),t&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var n=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,e,n,i,t),i.endCount(),i},getRenderList:function(e){return this._renderLists.get(e.__uid__)},_doUpdateRenderList:function(e,t,r,i,n){if(!e.invisible)for(var a=0;a<e._children.length;a++){var s=e._children[a];if(s.isRenderable()){var o=s.isSkinnedMesh()?al:s.worldTransform.array,l=s.geometry;C.multiplyAffine(Dn,t.viewMatrix.array,o),(n&&!l.boundingBox||!this.isFrustumCulled(s,t,Dn))&&i.add(s,s.material.transparent||r)}s._children.length>0&&this._doUpdateRenderList(s,t,r,i,n)}},isFrustumCulled:function(){var e=new Se,t=new I;return function(r,i,n){var a=r.boundingBox;if(a||(r.skeleton&&r.skeleton.boundingBox?a=r.skeleton.boundingBox:a=r.geometry.boundingBox),!a)return!1;if(t.array=n,e.transformFrom(a,t),r.castShadow&&this.viewBoundingBoxLastFrame.union(e),r.frustumCulling){if(!e.intersectBoundingBox(i.frustum.boundingBox))return!0;t.array=i.projectionMatrix.array,e.max.array[2]>0&&e.min.array[2]<0&&(e.max.array[2]=-1e-20),e.applyProjection(t);var s=e.min.array,o=e.max.array;if(o[0]<-1||s[0]>1||o[1]<-1||s[1]>1||o[2]<-1||s[2]>1)return!0}return!1}}(),_updateLightUniforms:function(){var e=this.lights;e.sort(ol);var t=this._lightUniforms;for(var r in t)for(var i in t[r])t[r][i].value.length=0;for(var n=0;n<e.length;n++){var a=e[n];if(!a.invisible){var r=a.group;for(var i in a.uniformTemplates){var s=a.uniformTemplates[i],o=s.value(a);if(o!=null){t[r]||(t[r]={}),t[r][i]||(t[r][i]={type:"",value:[]});var l=t[r][i];switch(l.type=s.type+"v",s.type){case"1i":case"1f":case"t":l.value.push(o);break;case"2f":case"3f":case"4f":for(var u=0;u<o.length;u++)l.value.push(o[u]);break;default:console.error("Unkown light uniform type "+s.type)}}}}}},getLightGroups:function(){var e=[];for(var t in this._lightNumber)e.push(t);return e},getNumberChangedLightGroups:function(){var e=[];for(var t in this._lightNumber)this.isLightNumberChanged(t)&&e.push(t);return e},isLightNumberChanged:function(e){var t=this._previousLightNumber,r=this._lightNumber;for(var i in r[e])if(!t[e]||r[e][i]!==t[e][i])return!0;for(var i in t[e])if(!r[e]||r[e][i]!==t[e][i])return!0;return!1},getLightsNumbers:function(e){return this._lightNumber[e]},getProgramKey:function(e){return this._lightProgramKeys[e]},setLightUniforms:function(){function e(t,r,i){for(var n in t){var a=t[n];if(a.type==="tv"){if(!r.hasUniform(n))continue;for(var s=[],o=0;o<a.value.length;o++){var l=a.value[o],u=r.takeCurrentTextureSlot(i,l);s.push(u)}r.setUniform(i.gl,"1iv",n,s)}else r.setUniform(i.gl,a.type,n,a.value)}}return function(t,r,i){e(this._lightUniforms[r],t,i),e(this.shadowUniforms,t,i)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});function ol(e,t){if(t.castShadow&&!e.castShadow)return!0}var Lr=Tr.isPowerOfTwo,ll=["px","nx","py","ny","pz","nz"],Nt=L.extend(function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}},{textureType:"textureCube",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var r=this.format,i=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var n=e.getGLExtension("EXT_texture_filter_anisotropic");if(n&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,n.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),i===36193){var a=e.getGLExtension("OES_texture_half_float");a||(i=b.FLOAT)}if(this.mipmaps.length)for(var s=this.width,o=this.height,l=0;l<this.mipmaps.length;l++){var u=this.mipmaps[l];this._updateTextureData(t,u,l,s,o,r,i),s/=2,o/=2}else this._updateTextureData(t,this,0,this.width,this.height,r,i),!this.NPOT&&this.useMipmap&&t.generateMipmap(t.TEXTURE_CUBE_MAP);t.bindTexture(t.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(e,t,r,i,n,a,s){for(var o=0;o<6;o++){var l=ll[o],u=t.image&&t.image[l];u?e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,a,a,s,u):e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,a,i,n,0,a,s,t.pixels&&t.pixels[l])}},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_CUBE_MAP))},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?Lr(this.image.px.width)&&Lr(this.image.px.height):Lr(this.width)&&Lr(this.height)},isRenderable:function(){return this.image.px?kt(this.image.px)&&kt(this.image.nx)&&kt(this.image.py)&&kt(this.image.ny)&&kt(this.image.pz)&&kt(this.image.nz):!!(this.width&&this.height)},load:function(e,t){var r=0,i=this;return me.each(e,function(n,a){var s=J.createImage();t&&(s.crossOrigin=t),s.onload=function(){r--,r===0&&(i.dirty(),i.trigger("success",i))},s.onerror=function(){r--},r++,s.src=n,i.image[a]=s}),this}});Object.defineProperty(Nt.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}});Object.defineProperty(Nt.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(e){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}});function kt(e){return e.width>0&&e.height>0}var Te=Kt.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=Math.atan(1/e[5])*2;this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=Kt.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),Nr="framebuffer",lt="renderbuffer",On=lt+"_width",In=lt+"_height",vi=lt+"_attached",pi="depthtexture_attached",Et=b.FRAMEBUFFER,ir=b.RENDERBUFFER,sr=b.DEPTH_ATTACHMENT,Ea=b.COLOR_ATTACHMENT0,ye=Pe.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},function(){this._cache=new Zt,this._textures={}},{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(e){if(e.__currentFrameBuffer){if(e.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}e.__currentFrameBuffer=this;var t=e.gl;t.bindFramebuffer(Et,this._getFrameBufferGL(e)),this._boundRenderer=e;var r=this._cache;r.put("viewport",e.viewport);var i=!1,n,a;for(var s in this._textures){i=!0;var o=this._textures[s];o&&(n=o.texture.width,a=o.texture.height,this._doAttach(e,o.texture,s,o.target))}this._width=n,this._height=a,!i&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?e.setViewport(this.viewport):e.setViewport(0,0,n,a,1);var l=r.get("attached_textures");if(l){for(var s in l)if(!this._textures[s]){var u=l[s];this._doDetach(t,s,u)}}if(!r.get(pi)&&this.depthBuffer){r.miss(lt)&&r.put(lt,t.createRenderbuffer());var h=r.get(lt);(n!==r.get(On)||a!==r.get(In))&&(t.bindRenderbuffer(ir,h),t.renderbufferStorage(ir,t.DEPTH_COMPONENT16,n,a),r.put(On,n),r.put(In,a),t.bindRenderbuffer(ir,null)),r.get(vi)||(t.framebufferRenderbuffer(Et,sr,ir,h),r.put(vi,!0))}},unbind:function(e){e.__currentFrameBuffer=null;var t=e.gl;t.bindFramebuffer(Et,null),this._boundRenderer=null,this._cache.use(e.__uid__);var r=this._cache.get("viewport");r&&e.setViewport(r),this.updateMipmap(e)},updateMipmap:function(e){var t=e.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===L.LINEAR_MIPMAP_LINEAR){var a=n.textureType==="textureCube"?b.TEXTURE_CUBE_MAP:b.TEXTURE_2D;t.bindTexture(a,n.getWebGLTexture(e)),t.generateMipmap(a),t.bindTexture(a,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(Et)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(Nr)&&t.put(Nr,e.gl.createFramebuffer()),t.get(Nr)},attach:function(e,t,r){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||Ea,r=r||b.TEXTURE_2D;var i=this._boundRenderer,n=i&&i.gl,a;if(n){var s=this._cache;s.use(i.__uid__),a=s.get("attached_textures")}var o=this._textures[t];if(!(o&&o.target===r&&o.texture===e&&a&&a[t]!=null)){var l=!0;i&&(l=this._doAttach(i,e,t,r),this.viewport||i.setViewport(0,0,e.width,e.height,1)),l&&(this._textures[t]=this._textures[t]||{},this._textures[t].texture=e,this._textures[t].target=r)}},_doAttach:function(e,t,r,i){var n=e.gl,a=t.getWebGLTexture(e),s=this._cache.get("attached_textures");if(s&&s[r]){var o=s[r];if(o.texture===t&&o.target===i)return}r=+r;var l=!0;if(r===sr||r===b.DEPTH_STENCIL_ATTACHMENT){var u=e.getGLExtension("WEBGL_depth_texture");if(u||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==b.DEPTH_COMPONENT&&t.format!==b.DEPTH_STENCIL&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l){var h=this._cache.get(lt);h&&(n.framebufferRenderbuffer(Et,sr,ir,null),n.deleteRenderbuffer(h),this._cache.put(lt,!1)),this._cache.put(vi,!1),this._cache.put(pi,!0)}}return n.framebufferTexture2D(Et,r,i,a,0),s||(s={},this._cache.put("attached_textures",s)),s[r]=s[r]||{},s[r].texture=t,s[r].target=i,l},_doDetach:function(e,t,r){e.framebufferTexture2D(Et,t,r,null,0);var i=this._cache.get("attached_textures");i&&i[t]&&(i[t]=null),(t===sr||t===b.DEPTH_STENCIL_ATTACHMENT)&&this._cache.put(pi,!1)},detach:function(e,t){if(this._textures[e]=null,this._boundRenderer){var r=this._cache;r.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,e,t)}},dispose:function(e){var t=e.gl,r=this._cache;r.use(e.__uid__);var i=r.get(lt);i&&t.deleteRenderbuffer(i);var n=r.get(Nr);n&&t.deleteFramebuffer(n),r.deleteContext(e.__uid__),this._textures={}}});ye.DEPTH_ATTACHMENT=sr;ye.COLOR_ATTACHMENT0=Ea;ye.STENCIL_ATTACHMENT=b.STENCIL_ATTACHMENT;ye.DEPTH_STENCIL_ATTACHMENT=b.DEPTH_STENCIL_ATTACHMENT;var ul=["px","nx","py","ny","pz","nz"],$i=Pe.extend(function(){var e={position:new w,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new Te({fov:90}),nx:new Te({fov:90}),py:new Te({fov:90}),ny:new Te({fov:90}),pz:new Te({fov:90}),nz:new Te({fov:90})};return t.px.lookAt(w.POSITIVE_X,w.NEGATIVE_Y),t.nx.lookAt(w.NEGATIVE_X,w.NEGATIVE_Y),t.py.lookAt(w.POSITIVE_Y,w.POSITIVE_Z),t.ny.lookAt(w.NEGATIVE_Y,w.NEGATIVE_Z),t.pz.lookAt(w.POSITIVE_Z,w.NEGATIVE_Y),t.nz.lookAt(w.NEGATIVE_Z,w.NEGATIVE_Y),e._frameBuffer=new ye,e},{getCamera:function(e){return this._cameras[e]},render:function(e,t,r){var i=e.gl;r||t.update();for(var n=this.texture.width,a=2*Math.atan(n/(n-.5))/Math.PI*180,s=0;s<6;s++){var o=ul[s],l=this._cameras[o];if(w.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=a,this.shadowMapPass){l.update();var u=t.getBoundingBox();u.applyTransform(l.viewMatrix),t.viewBoundingBoxLastFrame.copy(u),this.shadowMapPass.render(e,t,l,!0)}this._frameBuffer.attach(this.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+s),this._frameBuffer.bind(e),e.render(t,l,!0),this._frameBuffer.unbind(e)}},dispose:function(e){this._frameBuffer.dispose(e)}}),Ki=ae.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,r=this.attributes,i=[],n=[],a=[],s=[],o=0;o<=e;o++)for(var l=o/e,u=0;u<=t;u++){var h=u/t;if(i.push([2*h-1,2*l-1,0]),n&&n.push([h,l]),a&&a.push([0,0,1]),u<t&&o<e){var c=u+o*(t+1);s.push([c,c+1,c+t+1]),s.push([c+t+1,c+1,c+t+2])}}r.position.fromArray(i),r.texcoord0.fromArray(n),r.normal.fromArray(a),this.initIndicesFromArray(s),this.boundingBox=new Se,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}}),de=new I,ba=ae.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},function(){this.build()},{build:function(){var e={px:Vt("px",this.depthSegments,this.heightSegments),nx:Vt("nx",this.depthSegments,this.heightSegments),py:Vt("py",this.widthSegments,this.depthSegments),ny:Vt("ny",this.widthSegments,this.depthSegments),pz:Vt("pz",this.widthSegments,this.heightSegments),nz:Vt("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],r=0,i=0;for(var n in e)r+=e[n].vertexCount,i+=e[n].indices.length;for(var a=0;a<t.length;a++)this.attributes[t[a]].init(r);this.indices=new J.Uint16Array(i);var s=0,o=0;for(var n in e){for(var l=e[n],a=0;a<t.length;a++)for(var u=t[a],h=l.attributes[u].value,c=l.attributes[u].size,d=u==="normal",f=0;f<h.length;f++){var v=h[f];this.inside&&d&&(v=-v),this.attributes[u].value[f+c*o]=v}for(var p=l.indices.length,f=0;f<l.indices.length;f++)this.indices[f+s]=o+l.indices[this.inside?p-f-1:f];s+=l.indices.length,o+=l.vertexCount}this.boundingBox=new Se,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});function Vt(e,t,r){de.identity();var i=new Ki({widthSegments:t,heightSegments:r});switch(e){case"px":I.translate(de,de,w.POSITIVE_X),I.rotateY(de,de,Math.PI/2);break;case"nx":I.translate(de,de,w.NEGATIVE_X),I.rotateY(de,de,-Math.PI/2);break;case"py":I.translate(de,de,w.POSITIVE_Y),I.rotateX(de,de,-Math.PI/2);break;case"ny":I.translate(de,de,w.NEGATIVE_Y),I.rotateX(de,de,Math.PI/2);break;case"pz":I.translate(de,de,w.POSITIVE_Z);break;case"nz":I.translate(de,de,w.NEGATIVE_Z),I.rotateY(de,de,Math.PI);break}return i.applyTransform(de),i}const hl="@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end";F.import(hl);var mr=Be.extend(function(){var e=new F({vertex:F.source("clay.skybox.vertex"),fragment:F.source("clay.skybox.fragment")}),t=new vt({shader:e,depthMask:!1});return{scene:null,geometry:new ba,material:t,environmentMap:null,culling:!1,_dummyCamera:new Te}},function(){var e=this.scene;e&&this.attachScene(e),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(e){this.scene&&this.detachScene(),e.skybox=this,this.scene=e,e.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(e){this.detachScene(),this.geometry.dispose(e)},setEnvironmentMap:function(e){e.textureType==="texture2D"?(this.material.define("EQUIRECTANGULAR"),e.minFilter=L.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,r){this.renderSkybox(e,r)},renderSkybox:function(e,t){var r=this._dummyCamera;r.aspect=e.getViewportAspect(),r.fov=t.fov||50,r.updateProjectionMatrix(),I.invert(r.invProjectionMatrix,r.projectionMatrix),r.worldTransform.copy(t.worldTransform),r.viewMatrix.copy(t.viewMatrix),this.position.copy(t.getWorldPosition()),this.update(),e.gl.disable(e.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],r)}}),cl=542327876,fl=131072,dl=512,vl=4;function Qi(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var pl=31,ml=Qi("DXT1"),_l=Qi("DXT3"),gl=Qi("DXT5"),yl=0,xl=1,Tl=2,wl=3,El=4,bl=7,Sl=20,Al=21,Cl=28,Ml={parse:function(e,t){var r=new Int32Array(e,0,pl);if(r[yl]!==cl||!r(Sl)&vl)return null;var i=r(Al),n=r[El],a=r[wl],s=r[Cl]&dl,o=r[Tl]&fl,l,u;switch(i){case ml:l=8,u=L.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case _l:l=16,u=L.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case gl:l=16,u=L.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var h=r[xl]+4,c=s?6:1,d=1;o&&(d=Math.max(1,r[bl]));for(var f=[],v=0;v<c;v++){var p=n,m=a;f[v]=new Q({width:p,height:m,format:u});for(var g=[],T=0;T<d;T++){var y=Math.max(4,p)/4*Math.max(4,m)/4*l,x=new Uint8Array(e,h,y);h+=y,p*=.5,m*=.5,g[T]=x}f[v].pixels=g[0],o&&(f[v].mipmaps=g)}if(t)t.width=f[0].width,t.height=f[0].height,t.format=f[0].format,t.pixels=f[0].pixels,t.mipmaps=f[0].mipmaps;else return f[0]}},Ur=String.fromCharCode,Pl=8,Rl=32767;function Ll(e,t,r,i){if(e[3]>0){var n=Math.pow(2,e[3]-128-8+i);t[r+0]=e[0]*n,t[r+1]=e[1]*n,t[r+2]=e[2]*n}else t[r+0]=0,t[r+1]=0,t[r+2]=0;return t[r+3]=1,t}function Nl(e,t,r){for(var i="",n=t;n<r;n++)i+=Ur(e[n]);return i}function Dl(e,t){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3]}function Fn(e,t,r,i){for(var n=0,a=0,s=i;s>0;)if(e[a][0]=t[r++],e[a][1]=t[r++],e[a][2]=t[r++],e[a][3]=t[r++],e[a][0]===1&&e[a][1]===1&&e[a][2]===1){for(var o=e[a][3]<<n>>>0;o>0;o--)Dl(e[a-1],e[a]),a++,s--;n+=8}else a++,s--,n=0;return r}function Ol(e,t,r,i){if(i<Pl|i>Rl)return Fn(e,t,r,i);var n=t[r++];if(n!=2)return Fn(e,t,r-1,i);if(e[0][1]=t[r++],e[0][2]=t[r++],n=t[r++],(e[0][2]<<8>>>0|n)>>>0!==i)return null;for(var n=0;n<4;n++)for(var a=0;a<i;){var s=t[r++];if(s>128){s=(s&127)>>>0;for(var o=t[r++];s--;)e[a++][n]=o}else for(;s--;)e[a++][n]=t[r++]}return r}var Il={parseRGBE:function(e,t,r){r==null&&(r=0);var i=new Uint8Array(e),n=i.length;if(Nl(i,0,2)==="#?"){for(var a=2;a<n&&!(Ur(i[a])==="\n"&&Ur(i[a+1])==="\n");a++);if(!(a>=n)){a+=2;for(var s="";a<n;a++){var o=Ur(i[a]);if(o==="\n")break;s+=o}var l=s.split(" "),u=parseInt(l[1]),h=parseInt(l[3]);if(!(!h||!u)){for(var c=a+1,d=[],f=0;f<h;f++){d[f]=[];for(var v=0;v<4;v++)d[f][v]=0}for(var p=new Float32Array(h*u*4),m=0,g=0;g<u;g++){var c=Ol(d,i,c,h);if(!c)return null;for(var f=0;f<h;f++)Ll(d[f],p,m,r),m+=4}return t||(t=new Q),t.width=h,t.height=u,t.pixels=p,t.type=L.FLOAT,t}}}},parseRGBEFromPNG:function(e){}},rt={loadTexture:function(e,t,r,i){var n;if(typeof t=="function"?(r=t,i=r,t={}):t=t||{},typeof e=="string"){if(e.match(/.hdr$/)||t.fileType==="hdr")return n=new Q({width:0,height:0,sRGB:!1}),rt._fetchTexture(e,function(a){Il.parseRGBE(a,n,t.exposure),n.dirty(),r&&r(n)},i),n;e.match(/.dds$/)||t.fileType==="dds"?(n=new Q({width:0,height:0}),rt._fetchTexture(e,function(a){Ml.parse(a,n),n.dirty(),r&&r(n)},i)):(n=new Q,n.load(e),n.success(r),n.error(i))}else typeof e=="object"&&typeof e.px<"u"&&(n=new Nt,n.load(e),n.success(r),n.error(i));return n},loadPanorama:function(e,t,r,i,n,a){var s=this;typeof i=="function"?(n=i,a=n,i={}):i=i||{},rt.loadTexture(t,i,function(o){o.flipY=i.flipY||!1,s.panoramaToCubeMap(e,o,r,i),o.dispose(e),n&&n(r)},a)},panoramaToCubeMap:function(e,t,r,i){var n=new $i,a=new mr({scene:new xt});return a.setEnvironmentMap(t),i=i||{},i.encodeRGBM&&a.material.define("fragment","RGBM_ENCODE"),r.sRGB=t.sRGB,n.texture=r,n.render(e,a.scene),n.texture=null,n.dispose(e),r},heightToNormal:function(e,t){var r=document.createElement("canvas"),i=r.width=e.width,n=r.height=e.height,a=r.getContext("2d");a.drawImage(e,0,0,i,n),t=t||!1;for(var s=a.getImageData(0,0,i,n),o=a.createImageData(i,n),l=0;l<s.data.length;l+=4){if(t){var u=s.data[l],h=s.data[l+1],c=s.data[l+2],d=Math.abs(u-h)+Math.abs(h-c);if(d>20)return console.warn("Given image is not a height map"),e}var f,v,p,m;l%(i*4)===0?(f=s.data[l],p=s.data[l+4]):l%(i*4)===(i-1)*4?(f=s.data[l-4],p=s.data[l]):(f=s.data[l-4],p=s.data[l+4]),l<i*4?(v=s.data[l],m=s.data[l+i*4]):l>i*(n-1)*4?(v=s.data[l-i*4],m=s.data[l]):(v=s.data[l-i*4],m=s.data[l+i*4]),o.data[l]=f-p+127,o.data[l+1]=v-m+127,o.data[l+2]=255,o.data[l+3]=255}return a.putImageData(o,0,0),r},isHeightImage:function(e,t,r){if(!e||!e.width||!e.height)return!1;var i=document.createElement("canvas"),n=i.getContext("2d"),a=t||32;r=r||20,i.width=i.height=a,n.drawImage(e,0,0,a,a);for(var s=n.getImageData(0,0,a,a),o=0;o<s.data.length;o+=4){var l=s.data[o],u=s.data[o+1],h=s.data[o+2],c=Math.abs(l-u)+Math.abs(u-h);if(c>r)return!1}return!0},_fetchTexture:function(e,t,r){J.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,i){e=e||512,t=t||64,r=r||"black",i=i||"white";var n=Math.ceil(e/t),a=document.createElement("canvas");a.width=e,a.height=e;var s=a.getContext("2d");s.fillStyle=i,s.fillRect(0,0,e,e),s.fillStyle=r;for(var o=0;o<n;o++)for(var l=0;l<n;l++){var u=l%2?o%2:o%2-1;u&&s.fillRect(o*t,l*t,t,t)}var h=new Q({image:a,anisotropic:8});return h},createBlank:function(e){var t=document.createElement("canvas");t.width=1,t.height=1;var r=t.getContext("2d");r.fillStyle=e,r.fillRect(0,0,1,1);var i=new Q({image:t});return i}},Ri=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function Li(e){return"_on"+e}var Ni=function(e){var t=this;this._texture=new Q({anisotropic:32,flipY:!1,surface:this,dispose:function(r){t.dispose(),Q.prototype.dispose.call(this,r)}}),Ri.forEach(function(r){this[Li(r)]=function(i){i.triangle&&this._meshes.forEach(function(n){this.dispatchEvent(r,n,i.triangle,i.point)},this)}},this),this._meshes=[],e&&this.setECharts(e),this.onupdate=null};Ni.prototype={constructor:Ni,getTexture:function(){return this._texture},setECharts:function(e){this._chart=e;var t=e.getDom();if(!(t instanceof HTMLCanvasElement))console.error("ECharts must init on canvas if it is used as texture."),t=document.createElement("canvas");else{var r=this,i=e.getZr(),n=i.__oldRefreshImmediately||i.refreshImmediately;i.refreshImmediately=function(){n.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},i.__oldRefreshImmediately=n}this._texture.image=t,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var e=new w,t=new w,r=new w,i=new q,n=new q,a=new q,s=new q,o=new w;return function(l,u,h,c){var d=u.geometry,f=d.attributes.position,v=d.attributes.texcoord0,p=w.dot,m=w.cross;f.get(h[0],e.array),f.get(h[1],t.array),f.get(h[2],r.array),v.get(h[0],i.array),v.get(h[1],n.array),v.get(h[2],a.array),m(o,t,r);var g=p(e,o),T=p(c,o)/g;m(o,r,e);var y=p(c,o)/g;m(o,e,t);var x=p(c,o)/g;q.scale(s,i,T),q.scaleAndAdd(s,s,n,y),q.scaleAndAdd(s,s,a,x);var E=s.x*this._chart.getWidth(),S=s.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:E,zrY:S})}}(),attachToMesh:function(e){this._meshes.indexOf(e)>=0||(Ri.forEach(function(t){e.on(t,this[Li(t)],this)},this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),Ri.forEach(function(r){e.off(r,this[Li(r)])},this)},dispose:function(){this._meshes.forEach(function(e){this.detachFromMesh(e)},this)}};var _r=Kt.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=Kt.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});const Fl="\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";F.import(Fl);var Bl=new Ki,Bn=new Be({geometry:Bl,frustumCulling:!1}),Ul=new _r,De=Pe.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var e=new F(F.source("clay.compositor.vertex"),this.fragment),t=new vt({shader:e});t.enableTexturesAll(),this.material=t},{setUniform:function(e,t){this.material.setUniform(e,t)},getUniform:function(e){var t=this.material.uniforms[e];if(t)return t.value},attachOutput:function(e,t){this.outputs||(this.outputs={}),t=t||b.COLOR_ATTACHMENT0,this.outputs[t]=e},detachOutput:function(e){for(var t in this.outputs)this.outputs[t]===e&&(this.outputs[t]=null)},bind:function(e,t){if(this.outputs)for(var r in this.outputs){var i=this.outputs[r];i&&t.attach(i,r)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var r=e.gl;if(t){this.bind(e,t);var i=e.getGLExtension("EXT_draw_buffers");if(i&&this.outputs){var n=[];for(var a in this.outputs)a=+a,a>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&n.push(a);i.drawBuffersEXT(n)}}this.trigger("beforerender",this,e);var s=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){s=s|r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var o=this.clearColor;Array.isArray(o)&&r.clearColor(o[0],o[1],o[2],o[3])}r.clear(s),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){Bn.material=this.material,e.renderPass([Bn],Ul)},dispose:function(e){}});const Hl="#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n",zl="#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";var it={},mi=["px","nx","py","ny","pz","nz"];it.prefilterEnvironmentMap=function(e,t,r,i,n){(!n||!i)&&(i=it.generateNormalDistribution(),n=it.integrateBRDF(e,i)),r=r||{};var a=r.width||64,s=r.height||64,o=r.type||t.type,l=new Nt({width:a,height:s,type:o,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var u=Math.min(a,s),h=Math.log(u)/Math.log(2)+1,c=new vt({shader:new F({vertex:F.source("clay.skybox.vertex"),fragment:zl})});c.set("normalDistribution",i),r.encodeRGBM&&c.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&c.define("fragment","RGBM_DECODE");var d=new xt,f;if(t.textureType==="texture2D"){var v=new Nt({width:a,height:s,type:o===L.FLOAT?L.HALF_FLOAT:o});rt.panoramaToCubeMap(e,t,v,{encodeRGBM:r.decodeRGBM}),t=v}f=new mr({scene:d,material:c}),f.material.set("environmentMap",t);var p=new $i({texture:l});r.encodeRGBM&&(o=l.type=L.UNSIGNED_BYTE);for(var m=new Q({width:a,height:s,type:o}),g=new ye({depthBuffer:!1}),T=J[o===L.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],y=0;y<h;y++){l.mipmaps[y]={pixels:{}},f.material.set("roughness",y/(h-1));for(var x=m.width,E=2*Math.atan(x/(x-.5))/Math.PI*180,S=0;S<mi.length;S++){var O=new T(m.width*m.height*4);g.attach(m),g.bind(e);var P=p.getCamera(mi[S]);P.fov=E,e.render(d,P),e.gl.readPixels(0,0,m.width,m.height,L.RGBA,o,O),g.unbind(e),l.mipmaps[y].pixels[mi[S]]=O}m.width/=2,m.height/=2,m.dirty()}return g.dispose(e),m.dispose(e),f.dispose(e),i.dispose(e),{environmentMap:l,brdfLookup:n,normalDistribution:i,maxMipmapLevel:h}};it.integrateBRDF=function(e,t){t=t||it.generateNormalDistribution();var r=new ye({depthBuffer:!1}),i=new De({fragment:Hl}),n=new Q({width:512,height:256,type:L.HALF_FLOAT,wrapS:L.CLAMP_TO_EDGE,wrapT:L.CLAMP_TO_EDGE,minFilter:L.NEAREST,magFilter:L.NEAREST,useMipmap:!1});return i.setUniform("normalDistribution",t),i.setUniform("viewportSize",[512,256]),i.attachOutput(n),i.render(e,r),r.dispose(e),n};it.generateNormalDistribution=function(r,i){for(var r=r||256,i=i||1024,n=new Q({width:r,height:i,type:L.FLOAT,minFilter:L.NEAREST,magFilter:L.NEAREST,wrapS:L.CLAMP_TO_EDGE,wrapT:L.CLAMP_TO_EDGE,useMipmap:!1}),a=new Float32Array(i*r*4),s=[],o=0;o<r;o++){for(var l=o/r,u=l*l,h=0;h<i;h++){var c=(h<<16|h>>>16)>>>0;c=((c&1431655765)<<1|(c&2863311530)>>>1)>>>0,c=((c&858993459)<<2|(c&3435973836)>>>2)>>>0,c=((c&252645135)<<4|(c&4042322160)>>>4)>>>0,c=(((c&16711935)<<8|(c&4278255360)>>>8)>>>0)/4294967296;var d=Math.sqrt((1-c)/(1+(u*u-1)*c));s[h]=d}for(var h=0;h<i;h++){var f=(h*r+o)*4,d=s[h],v=Math.sqrt(1-d*d),p=h/i,m=2*Math.PI*p;a[f]=v*Math.cos(m),a[f+1]=d,a[f+2]=v*Math.sin(m),a[f+3]=1}}return n.pixels=a,n};var Gl=Ze.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){if(!e.getGLExtension("EXT_shader_texture_lod")){console.warn("Device not support textureCubeLodEXT");return}this._brdfLookup||(this._normalDistribution=it.generateNormalDistribution(),this._brdfLookup=it.integrateBRDF(e,this._normalDistribution));var r=this.cubemap;if(!r.__prefiltered){var i=it.prefilterEnvironmentMap(e,r,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=i.environmentMap,this.cubemap.__prefiltered=!0,r.dispose(e)}},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}}),kl=Ze.extend({castShadow:!1,coefficients:[]},function(){this._coefficientsTmpArr=new J.Float32Array(9*3)},{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,r=0;r<e.coefficients.length;r++)t[r]=e.coefficients[r];return t}}}}),Sa={},Rt=["px","nx","py","ny","pz","nz"];function Vl(e,t){var r=e[0],i=e[1],n=e[2];return t===0?1:t===1?r:t===2?i:t===3?n:t===4?r*n:t===5?i*n:t===6?r*i:t===7?3*n*n-1:r*r-i*i}var Wl={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};function Xl(e,t,r,i){for(var n=new J.Float32Array(27),a=_.create(),s=_.create(),o=_.create(),l=0;l<9;l++){for(var u=_.create(),h=0;h<Rt.length;h++){for(var c=t[Rt[h]],d=_.create(),f=0,v=0,p=Wl[Rt[h]],m=0;m<i;m++)for(var g=0;g<r;g++){a[0]=g/(r-1)*2-1,a[1]=m/(i-1)*2-1,a[2]=-1,_.normalize(a,a),o[0]=a[p[0]]*p[3],o[1]=a[p[1]]*p[4],o[2]=a[p[2]]*p[5],s[0]=c[v++]/255,s[1]=c[v++]/255,s[2]=c[v++]/255;var T=c[v++]/255*8.12;s[0]*=T,s[1]*=T,s[2]*=T,_.scaleAndAdd(d,d,s,Vl(o,l)*-a[2]),f+=-a[2]}_.scaleAndAdd(u,u,d,1/f)}n[l*3]=u[0]/6,n[l*3+1]=u[1]/6,n[l*3+2]=u[2]/6}return n}Sa.projectEnvironmentMap=function(e,t,r){r=r||{},r.lod=r.lod||0;var i,n=new xt,a=64;t.textureType==="texture2D"?i=new mr({scene:n,environmentMap:t}):(a=t.image&&t.image.px?t.image.px.width:t.width,i=new mr({scene:n,environmentMap:t}));var s=Math.ceil(a/Math.pow(2,r.lod)),o=Math.ceil(a/Math.pow(2,r.lod)),l=new Q({width:s,height:o}),u=new ye;i.material.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&i.material.define("fragment","RGBM_DECODE"),i.material.set("lod",r.lod);for(var h=new $i({texture:l}),c={},d=0;d<Rt.length;d++){c[Rt[d]]=new Uint8Array(s*o*4);var f=h.getCamera(Rt[d]);f.fov=90,u.attach(l),u.bind(e),e.render(n,f),e.gl.readPixels(0,0,s,o,L.RGBA,L.UNSIGNED_BYTE,c[Rt[d]]),u.unbind(e)}return i.dispose(e),u.dispose(e),l.dispose(e),Xl(e,c,s,o)};var Ve={firstNotNull:function(){for(var e=0,t=arguments.length;e<t;e++)if(arguments[e]!=null)return arguments[e]},queryDataIndex:function(e,t){if(t.dataIndexInside!=null)return t.dataIndexInside;if(t.dataIndex!=null)return ur(t.dataIndex)?an(t.dataIndex,function(r){return e.indexOfRawIndex(r)}):e.indexOfRawIndex(t.dataIndex);if(t.name!=null)return ur(t.name)?an(t.name,function(r){return e.indexOfName(r)}):e.indexOfName(t.name)}},jl=ae.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:Math.PI*2,thetaStart:0,thetaLength:Math.PI,radius:1},function(){this.build()},{build:function(){var e=this.heightSegments,t=this.widthSegments,r=this.attributes.position,i=this.attributes.texcoord0,n=this.attributes.normal,a=(t+1)*(e+1);r.init(a),i.init(a),n.init(a);var s=a>65535?Uint32Array:Uint16Array,o=this.indices=new s(t*e*6),l,u,h,c,d,f,v,y=this.radius,p=this.phiStart,m=this.phiLength,g=this.thetaStart,T=this.thetaLength,y=this.radius,x=[],E=[],S=0,O=1/y;for(v=0;v<=e;v++)for(f=0;f<=t;f++)c=f/t,d=v/e,l=-y*Math.cos(p+c*m)*Math.sin(g+d*T),u=y*Math.cos(g+d*T),h=y*Math.sin(p+c*m)*Math.sin(g+d*T),x[0]=l,x[1]=u,x[2]=h,E[0]=c,E[1]=d,r.set(S,x),i.set(S,E),x[0]*=O,x[1]*=O,x[2]*=O,n.set(S,x),S++;var P,B,k,N,V=t+1,z=0;for(v=0;v<e;v++)for(f=0;f<t;f++)B=v*V+f,P=v*V+f+1,N=(v+1)*V+f+1,k=(v+1)*V+f,o[z++]=P,o[z++]=B,o[z++]=N,o[z++]=B,o[z++]=k,o[z++]=N;this.boundingBox=new Se,this.boundingBox.max.set(y,y,y),this.boundingBox.min.set(-y,-y,-y)}}),ql=Ze.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}}}),Yl=Ze.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new w,e.__dir.copy(e.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}},clone:function(){var e=Ze.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),Zl=Ze.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(e){return e.range}},pointLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}},clone:function(){var e=Ze.prototype.clone.call(this);return e.range=this.range,e}}),$l=Ze.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(e){return e.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(e){return e.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(e){return Math.cos(e.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(e){return e.falloffFactor}},spotLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new w,e.__dir.copy(e.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}}},clone:function(){var e=Ze.prototype.clone.call(this);return e.range=this.range,e.umbraAngle=this.umbraAngle,e.penumbraAngle=this.penumbraAngle,e.falloffFactor=this.falloffFactor,e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}}),$=function(e,t,r,i){e=e||0,t=t||0,r=r||0,i=i||0,this.array=A.fromValues(e,t,r,i),this._dirty=!0};$.prototype={constructor:$,add:function(e){return A.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,r,i){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this.array[3]=i,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new $(this.x,this.y,this.z,this.w)},copy:function(e){return A.copy(this.array,e.array),this._dirty=!0,this},dist:function(e){return A.dist(this.array,e.array)},distance:function(e){return A.distance(this.array,e.array)},div:function(e){return A.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return A.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return A.dot(this.array,e.array)},len:function(){return A.len(this.array)},length:function(){return A.length(this.array)},lerp:function(e,t,r){return A.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return A.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return A.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return A.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return A.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return A.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return A.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return A.random(this.array,e),this._dirty=!0,this},scale:function(e){return A.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return A.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return A.sqrDist(this.array,e.array)},squaredDistance:function(e){return A.squaredDistance(this.array,e.array)},sqrLen:function(){return A.sqrLen(this.array)},squaredLength:function(){return A.squaredLength(this.array)},sub:function(e){return A.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return A.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return A.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return A.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var nr=Object.defineProperty;if(nr){var Dr=$.prototype;nr(Dr,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),nr(Dr,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),nr(Dr,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),nr(Dr,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}$.add=function(e,t,r){return A.add(e.array,t.array,r.array),e._dirty=!0,e};$.set=function(e,t,r,i,n){A.set(e.array,t,r,i,n),e._dirty=!0};$.copy=function(e,t){return A.copy(e.array,t.array),e._dirty=!0,e};$.dist=function(e,t){return A.distance(e.array,t.array)};$.distance=$.dist;$.div=function(e,t,r){return A.divide(e.array,t.array,r.array),e._dirty=!0,e};$.divide=$.div;$.dot=function(e,t){return A.dot(e.array,t.array)};$.len=function(e){return A.length(e.array)};$.lerp=function(e,t,r,i){return A.lerp(e.array,t.array,r.array,i),e._dirty=!0,e};$.min=function(e,t,r){return A.min(e.array,t.array,r.array),e._dirty=!0,e};$.max=function(e,t,r){return A.max(e.array,t.array,r.array),e._dirty=!0,e};$.mul=function(e,t,r){return A.multiply(e.array,t.array,r.array),e._dirty=!0,e};$.multiply=$.mul;$.negate=function(e,t){return A.negate(e.array,t.array),e._dirty=!0,e};$.normalize=function(e,t){return A.normalize(e.array,t.array),e._dirty=!0,e};$.random=function(e,t){return A.random(e.array,t),e._dirty=!0,e};$.scale=function(e,t,r){return A.scale(e.array,t.array,r),e._dirty=!0,e};$.scaleAndAdd=function(e,t,r,i){return A.scaleAndAdd(e.array,t.array,r.array,i),e._dirty=!0,e};$.sqrDist=function(e,t){return A.sqrDist(e.array,t.array)};$.squaredDistance=$.sqrDist;$.sqrLen=function(e){return A.sqrLen(e.array)};$.squaredLength=$.sqrLen;$.sub=function(e,t,r){return A.subtract(e.array,t.array,r.array),e._dirty=!0,e};$.subtract=$.sub;$.transformMat4=function(e,t,r){return A.transformMat4(e.array,t.array,r.array),e._dirty=!0,e};$.transformQuat=function(e,t,r){return A.transformQuat(e.array,t.array,r.array),e._dirty=!0,e};var K={};K.create=function(){var e=new Ae(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e};K.clone=function(e){var t=new Ae(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};K.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e};K.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e};K.transpose=function(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e};K.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r*a-n*i;return s?(s=1/s,e[0]=a*s,e[1]=-i*s,e[2]=-n*s,e[3]=r*s,e):null};K.adjoint=function(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e};K.determinant=function(e){return e[0]*e[3]-e[2]*e[1]};K.multiply=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=r[0],l=r[1],u=r[2],h=r[3];return e[0]=i*o+a*l,e[1]=n*o+s*l,e[2]=i*u+a*h,e[3]=n*u+s*h,e};K.mul=K.multiply;K.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l+a*o,e[1]=n*l+s*o,e[2]=i*-o+a*l,e[3]=n*-o+s*l,e};K.scale=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=r[0],l=r[1];return e[0]=i*o,e[1]=n*o,e[2]=a*l,e[3]=s*l,e};K.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2))};K.LDU=function(e,t,r,i){return e[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-e[2]*r[1],[e,t,r]};var Oe=function(){this.array=K.create(),this._dirty=!0};Oe.prototype={constructor:Oe,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return new Oe().copy(this)},copy:function(e){return K.copy(this.array,e.array),this._dirty=!0,this},adjoint:function(){return K.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return K.determinant(this.array)},identity:function(){return K.identity(this.array),this._dirty=!0,this},invert:function(){return K.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return K.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return K.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return K.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return K.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return K.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return K.scale(this.array,this.array,e.array),this._dirty=!0,this},transpose:function(){return K.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};Oe.adjoint=function(e,t){return K.adjoint(e.array,t.array),e._dirty=!0,e};Oe.copy=function(e,t){return K.copy(e.array,t.array),e._dirty=!0,e};Oe.determinant=function(e){return K.determinant(e.array)};Oe.identity=function(e){return K.identity(e.array),e._dirty=!0,e};Oe.invert=function(e,t){return K.invert(e.array,t.array),e._dirty=!0,e};Oe.mul=function(e,t,r){return K.mul(e.array,t.array,r.array),e._dirty=!0,e};Oe.multiply=Oe.mul;Oe.rotate=function(e,t,r){return K.rotate(e.array,t.array,r),e._dirty=!0,e};Oe.scale=function(e,t,r){return K.scale(e.array,t.array,r.array),e._dirty=!0,e};Oe.transpose=function(e,t){return K.transpose(e.array,t.array),e._dirty=!0,e};var ee={};ee.create=function(){var e=new Ae(6);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e};ee.clone=function(e){var t=new Ae(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t};ee.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e};ee.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e};ee.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=t[4],o=t[5],l=r*a-i*n;return l?(l=1/l,e[0]=a*l,e[1]=-i*l,e[2]=-n*l,e[3]=r*l,e[4]=(n*o-a*s)*l,e[5]=(i*s-r*o)*l,e):null};ee.determinant=function(e){return e[0]*e[3]-e[1]*e[2]};ee.multiply=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=r[0],h=r[1],c=r[2],d=r[3],f=r[4],v=r[5];return e[0]=i*u+a*h,e[1]=n*u+s*h,e[2]=i*c+a*d,e[3]=n*c+s*d,e[4]=i*f+a*v+o,e[5]=n*f+s*v+l,e};ee.mul=ee.multiply;ee.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=Math.sin(r),h=Math.cos(r);return e[0]=i*h+a*u,e[1]=n*h+s*u,e[2]=i*-u+a*h,e[3]=n*-u+s*h,e[4]=o,e[5]=l,e};ee.scale=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=r[0],h=r[1];return e[0]=i*u,e[1]=n*u,e[2]=a*h,e[3]=s*h,e[4]=o,e[5]=l,e};ee.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=r[0],h=r[1];return e[0]=i,e[1]=n,e[2]=a,e[3]=s,e[4]=i*u+a*h+o,e[5]=n*u+s*h+l,e};ee.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+1)};var Ue=function(){this.array=ee.create(),this._dirty=!0};Ue.prototype={constructor:Ue,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},clone:function(){return new Ue().copy(this)},copy:function(e){return ee.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return ee.determinant(this.array)},identity:function(){return ee.identity(this.array),this._dirty=!0,this},invert:function(){return ee.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return ee.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return ee.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return ee.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return ee.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return ee.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return ee.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return ee.translate(this.array,this.array,e.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};Ue.copy=function(e,t){return ee.copy(e.array,t.array),e._dirty=!0,e};Ue.determinant=function(e){return ee.determinant(e.array)};Ue.identity=function(e){return ee.identity(e.array),e._dirty=!0,e};Ue.invert=function(e,t){return ee.invert(e.array,t.array),e._dirty=!0,e};Ue.mul=function(e,t,r){return ee.mul(e.array,t.array,r.array),e._dirty=!0,e};Ue.multiply=Ue.mul;Ue.rotate=function(e,t,r){return ee.rotate(e.array,t.array,r),e._dirty=!0,e};Ue.scale=function(e,t,r){return ee.scale(e.array,t.array,r.array),e._dirty=!0,e};Ue.translate=function(e,t,r){return ee.translate(e.array,t.array,r.array),e._dirty=!0,e};var ge=function(){this.array=W.create(),this._dirty=!0};ge.prototype={constructor:ge,setArray:function(e){for(var t=0;t<this.array.length;t++)this.array[t]=e[t];return this._dirty=!0,this},adjoint:function(){return W.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return new ge().copy(this)},copy:function(e){return W.copy(this.array,e.array),this._dirty=!0,this},determinant:function(){return W.determinant(this.array)},fromMat2d:function(e){return W.fromMat2d(this.array,e.array),this._dirty=!0,this},fromMat4:function(e){return W.fromMat4(this.array,e.array),this._dirty=!0,this},fromQuat:function(e){return W.fromQuat(this.array,e.array),this._dirty=!0,this},identity:function(){return W.identity(this.array),this._dirty=!0,this},invert:function(){return W.invert(this.array,this.array),this._dirty=!0,this},mul:function(e){return W.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return W.mul(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return W.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return W.multiply(this.array,e.array,this.array),this._dirty=!0,this},rotate:function(e){return W.rotate(this.array,this.array,e),this._dirty=!0,this},scale:function(e){return W.scale(this.array,this.array,e.array),this._dirty=!0,this},translate:function(e){return W.translate(this.array,this.array,e.array),this._dirty=!0,this},normalFromMat4:function(e){return W.normalFromMat4(this.array,e.array),this._dirty=!0,this},transpose:function(){return W.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};ge.adjoint=function(e,t){return W.adjoint(e.array,t.array),e._dirty=!0,e};ge.copy=function(e,t){return W.copy(e.array,t.array),e._dirty=!0,e};ge.determinant=function(e){return W.determinant(e.array)};ge.identity=function(e){return W.identity(e.array),e._dirty=!0,e};ge.invert=function(e,t){return W.invert(e.array,t.array),e};ge.mul=function(e,t,r){return W.mul(e.array,t.array,r.array),e._dirty=!0,e};ge.multiply=ge.mul;ge.fromMat2d=function(e,t){return W.fromMat2d(e.array,t.array),e._dirty=!0,e};ge.fromMat4=function(e,t){return W.fromMat4(e.array,t.array),e._dirty=!0,e};ge.fromQuat=function(e,t){return W.fromQuat(e.array,t.array),e._dirty=!0,e};ge.normalFromMat4=function(e,t){return W.normalFromMat4(e.array,t.array),e._dirty=!0,e};ge.rotate=function(e,t,r){return W.rotate(e.array,t.array,r),e._dirty=!0,e};ge.scale=function(e,t,r){return W.scale(e.array,t.array,r.array),e._dirty=!0,e};ge.transpose=function(e,t){return W.transpose(e.array,t.array),e._dirty=!0,e};ge.translate=function(e,t,r){return W.translate(e.array,t.array,r.array),e._dirty=!0,e};var Kl={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(e,t){this._animators=this._animators||[];var r=this,i;if(e){for(var n=e.split("."),a=r,s=0,o=n.length;s<o;s++)a&&(a=a[n[s]]);a&&(i=a)}else i=r;if(i==null)throw new Error("Target "+e+" not exists");var l=this._animators,u=new ds(i,t),h=this;return u.during(function(){h.__zr&&h.__zr.refresh()}).done(function(){var c=l.indexOf(u);c>=0&&l.splice(c,1)}),l.push(u),this.__zr&&this.__zr.animation.addAnimator(u),u},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,r=t.length,i=0;i<r;i++)t[i].stop(e);return t.length=0,this},addAnimatorsToZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.addAnimator(this._animators[t])},removeAnimatorsFromZr:function(e){if(this._animators)for(var t=0;t<this._animators.length;t++)e.animation.removeAnimator(this._animators[t])}};const Ql="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end",Jl="\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",eu="@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",tu="/**\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",ru="@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",iu="@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",nu="@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";Object.assign(tt.prototype,Kl);F.import(Ql);F.import(ya);F.import(Jl);F.import(eu);F.import(tu);F.import(ru);F.import(iu);F.import(nu);function au(e){return!e||e==="none"}function Aa(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function su(e){return e.getZr&&e.setOption}var ou=xt.prototype.addToScene,lu=xt.prototype.removeFromScene;xt.prototype.addToScene=function(e){if(ou.call(this,e),this.__zr){var t=this.__zr;e.traverse(function(r){r.__zr=t,r.addAnimatorsToZr&&r.addAnimatorsToZr(t)})}};xt.prototype.removeFromScene=function(e){lu.call(this,e),e.traverse(function(t){var r=t.__zr;t.__zr=null,r&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(r)})};vt.prototype.setTextureImage=function(e,t,r,i){if(this.shader){var n=r.getZr(),a=this,s;return a.autoUpdateTextureStatus=!1,a.disableTexture(e),au(t)||(s=M.loadTexture(t,r,i,function(o){a.enableTexture(e),n&&n.refresh()}),a.set(e,s)),s}};var M={};M.Renderer=We;M.Node=tt;M.Mesh=Be;M.Shader=F;M.Material=vt;M.Texture=L;M.Texture2D=Q;M.Geometry=ae;M.SphereGeometry=jl;M.PlaneGeometry=Ki;M.CubeGeometry=ba;M.AmbientLight=ql;M.DirectionalLight=Yl;M.PointLight=Zl;M.SpotLight=$l;M.PerspectiveCamera=Te;M.OrthographicCamera=_r;M.Vector2=q;M.Vector3=w;M.Vector4=$;M.Quaternion=te;M.Matrix2=Oe;M.Matrix2d=Ue;M.Matrix3=ge;M.Matrix4=I;M.Plane=lr;M.Ray=Lt;M.BoundingBox=Se;M.Frustum=Yr;var Or=null;function uu(){return Or!==null||(Or=rt.createBlank("rgba(255,255,255,0)").image),Or}function Un(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function Hn(e){if((e.wrapS===L.REPEAT||e.wrapT===L.REPEAT)&&e.image){var t=Un(e.width),r=Un(e.height);if(t!==e.width||r!==e.height){var i=document.createElement("canvas");i.width=t,i.height=r;var n=i.getContext("2d");n.drawImage(e.image,0,0,t,r),e.image=i}}}M.loadTexture=function(e,t,r,i){typeof r=="function"&&(i=r,r={}),r=r||{};for(var n=Object.keys(r).sort(),a="",s=0;s<n.length;s++)a+=n[s]+"_"+r[n[s]]+"_";var o=t.__textureCache=t.__textureCache||new vs(20);if(su(e)){var l=e.__textureid__,u=o.get(a+l);if(u)u.texture.surface.setECharts(e),i&&i(u.texture);else{var h=new Ni(e);h.onupdate=function(){t.getZr().refresh()},u={texture:h.getTexture()};for(var s=0;s<n.length;s++)u.texture[n[s]]=r[n[s]];l=e.__textureid__||"__ecgl_ec__"+u.texture.__uid__,e.__textureid__=l,o.put(a+l,u),i&&i(u.texture)}return u.texture}else if(Aa(e)){var l=e.__textureid__,u=o.get(a+l);if(!u){u={texture:new M.Texture2D({image:e})};for(var s=0;s<n.length;s++)u.texture[n[s]]=r[n[s]];l=e.__textureid__||"__ecgl_image__"+u.texture.__uid__,e.__textureid__=l,o.put(a+l,u),Hn(u.texture),i&&i(u.texture)}return u.texture}else{var u=o.get(a+e);if(u)u.callbacks?u.callbacks.push(i):i&&i(u.texture);else if(e.match(/.hdr$|^data:application\/octet-stream/)){u={callbacks:[i]};var c=rt.loadTexture(e,{exposure:r.exposure,fileType:"hdr"},function(){c.dirty(),u.callbacks.forEach(function(v){v&&v(c)}),u.callbacks=null});u.texture=c,o.put(a+e,u)}else{for(var c=new M.Texture2D({image:new Image}),s=0;s<n.length;s++)c[n[s]]=r[n[s]];u={texture:c,callbacks:[i]};var d=c.image;d.onload=function(){c.image=d,Hn(c),c.dirty(),u.callbacks.forEach(function(p){p&&p(c)}),u.callbacks=null},d.crossOrigin="Anonymous",d.src=e,c.image=uu(),o.put(a+e,u)}return u.texture}};M.createAmbientCubemap=function(e,t,r,i){e=e||{};var n=e.texture,a=Ve.firstNotNull(e.exposure,1),s=new Gl({intensity:Ve.firstNotNull(e.specularIntensity,1)}),o=new kl({intensity:Ve.firstNotNull(e.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return s.cubemap=M.loadTexture(n,r,{exposure:a},function(){s.cubemap.flipY=!1,s.prefilter(t,32),o.coefficients=Sa.projectEnvironmentMap(t,s.cubemap,{lod:1}),i&&i()}),{specular:s,diffuse:o}};M.createBlankTexture=rt.createBlank;M.isImage=Aa;M.additiveBlend=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)};M.parseColor=function(e,t){return e instanceof Array?(t||(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],e.length>3?t[3]=e[3]:t[3]=1,t):(t=na(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)};M.directionFromAlphaBeta=function(e,t){var r=e/180*Math.PI+Math.PI/2,i=-t/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};M.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096;break}return t};M.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"];M.createShader=function(e){e==="ecgl.shadow"&&(e="ecgl.displayShadow");var t=F.source(e+".vertex"),r=F.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),r||console.error("Fragment shader of '%s' not exits",e);var i=new F(t,r);return i.name=e,i};M.createMaterial=function(e,t){t instanceof Array||(t=[t]);var r=M.createShader(e),i=new vt({shader:r});return t.forEach(function(n){typeof n=="string"&&i.define(n)}),i};M.setMaterialFromModel=function(e,t,r,i){t.autoUpdateTextureStatus=!1;var n=r.getModel(e+"Material"),a=n.get("detailTexture"),s=Ve.firstNotNull(n.get("textureTiling"),1),o=Ve.firstNotNull(n.get("textureOffset"),0);typeof s=="number"&&(s=[s,s]),typeof o=="number"&&(o=[o,o]);var l=s[0]>1||s[1]>1?M.Texture.REPEAT:M.Texture.CLAMP_TO_EDGE,u={anisotropic:8,wrapS:l,wrapT:l};if(e==="realistic"){var h=n.get("roughness"),c=n.get("metalness");c!=null?isNaN(c)&&(t.setTextureImage("metalnessMap",c,i,u),c=Ve.firstNotNull(n.get("metalnessAdjust"),.5)):c=0,h!=null?isNaN(h)&&(t.setTextureImage("roughnessMap",h,i,u),h=Ve.firstNotNull(n.get("roughnessAdjust"),.5)):h=.5;var d=n.get("normalTexture");t.setTextureImage("detailMap",a,i,u),t.setTextureImage("normalMap",d,i,u),t.set({roughness:h,metalness:c,detailUvRepeat:s,detailUvOffset:o})}else if(e==="lambert")t.setTextureImage("detailMap",a,i,u),t.set({detailUvRepeat:s,detailUvOffset:o});else if(e==="color")t.setTextureImage("detailMap",a,i,u),t.set({detailUvRepeat:s,detailUvOffset:o});else if(e==="hatching"){var f=n.get("hatchingTextures")||[];f.length<6;for(var v=0;v<6;v++)t.setTextureImage("hatch"+(v+1),f[v],i,{anisotropic:8,wrapS:M.Texture.REPEAT,wrapT:M.Texture.REPEAT});t.set({detailUvRepeat:s,detailUvOffset:o})}};M.updateVertexAnimation=function(e,t,r,i){var n=i.get("animation"),a=i.get("animationDurationUpdate"),s=i.get("animationEasingUpdate"),o=r.shadowDepthMaterial;if(n&&t&&a>0&&t.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,o&&o.define("vertex","VERTEX_ANIMATION");for(var l=0;l<e.length;l++)r.geometry.attributes[e[l][0]].value=t.geometry.attributes[e[l][1]].value;r.geometry.dirty(),r.__percent=0,r.material.set("percent",0),r.stopAnimation(),r.animate().when(a,{__percent:1}).during(function(){r.material.set("percent",r.__percent),o&&o.set("percent",r.__percent)}).done(function(){r.ignorePreZ=!1,r.material.undefine("vertex","VERTEX_ANIMATION"),o&&o.undefine("vertex","VERTEX_ANIMATION")}).start(s)}else r.material.undefine("vertex","VERTEX_ANIMATION"),o&&o.undefine("vertex","VERTEX_ANIMATION")};var ne=function(e,t){this.id=e,this.zr=t;try{this.renderer=new We({clearBit:0,devicePixelRatio:t.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(t.painter.getWidth(),t.painter.getHeight())}catch(i){this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",console.error(i);return}this.onglobalout=this.onglobalout.bind(this),t.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var r=this.dom.style;r.position="absolute",r.left="0",r.top="0",this.views=[],this._picking=new Zi({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new aa({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null,this._disposed=!1};ne.prototype.setUnpainted=function(){};ne.prototype.addView=function(e){if(e.layer!==this){var t=this._viewsToDispose.indexOf(e);t>=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var r=this.zr;e.scene.traverse(function(i){i.__zr=r,i.addAnimatorsToZr&&i.addAnimatorsToZr(r)})}};function Ca(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}ne.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(Ca,this),e.layer=null,this._viewsToDispose.push(e))}};ne.prototype.removeViewsAll=function(){this.views.forEach(function(e){e.scene.traverse(Ca,this),e.layer=null,this._viewsToDispose.push(e)},this),this.views.length=0};ne.prototype.resize=function(e,t){var r=this.renderer;r.resize(e,t)};ne.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)};ne.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)};ne.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)};ne.prototype.needsRefresh=function(){this.zr.refresh()};ne.prototype.refresh=function(e){this._backgroundColor=e?M.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t<this.views.length;t++)this.views[t].prepareRender(this.renderer);this._doRender(!1),this._trackAndClean();for(var t=0;t<this._viewsToDispose.length;t++)this._viewsToDispose[t].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()};ne.prototype.renderToCanvas=function(e){this._startAccumulating(!0),e.drawImage(this.dom,0,0,e.canvas.width,e.canvas.height)};ne.prototype._doRender=function(e){this.clear(),this.renderer.saveViewport();for(var t=0;t<this.views.length;t++)this.views[t].render(this.renderer,e);this.renderer.restoreViewport()};ne.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var hu=1;ne.prototype._startAccumulating=function(e){var t=this;this._stopAccumulating();for(var r=!1,i=0;i<this.views.length;i++)r=this.views[i].needsAccumulate()||r;if(!r)return;function n(a){if(!(!t._accumulatingId||a!==t._accumulatingId)){for(var s=!0,o=0;o<t.views.length;o++)s=t.views[o].isAccumulateFinished()&&r;s||(t._doRender(!0),e?n(a):ms(function(){n(a)}))}}this._accumulatingId=hu++,e?n(t._accumulatingId):this._accumulatingTimeout=setTimeout(function(){n(t._accumulatingId)},50)};ne.prototype._trackAndClean=function(){var e=[],t=[];this._textureList&&(Hr(this._textureList),Hr(this._geometriesList));for(var r=0;r<this.views.length;r++)cu(this.views[r].scene,e,t);this._textureList&&(zr(this.renderer,this._textureList),zr(this.renderer,this._geometriesList)),this._textureList=e,this._geometriesList=t};function Hr(e){for(var t=0;t<e.length;t++)e[t].__used__=0}function zr(e,t){for(var r=0;r<t.length;r++)t[r].__used__||t[r].dispose(e)}function Ir(e,t){e.__used__=e.__used__||0,e.__used__++,e.__used__===1&&t.push(e)}function cu(e,t,r){var i,n;e.traverse(function(s){if(s.isRenderable()){var o=s.geometry,l=s.material;if(l!==i)for(var u=l.getTextureUniforms(),h=0;h<u.length;h++){var c=u[h],d=l.uniforms[c].value;if(d){if(d instanceof L)Ir(d,t);else if(d instanceof Array)for(var f=0;f<d.length;f++)d[f]instanceof L&&Ir(d[f],t)}}o!==n&&Ir(o,r),i=l,n=o}});for(var a=0;a<e.lights.length;a++)e.lights[a].cubemap&&Ir(e.lights[a].cubemap,t)}ne.prototype.dispose=function(){this._disposed||(this._stopAccumulating(),this._textureList&&(Hr(this._textureList),Hr(this._geometriesList),zr(this.renderer,this._textureList),zr(this.renderer,this._geometriesList)),this.zr.off("globalout",this.onglobalout),this._disposed=!0)};ne.prototype.onmousedown=function(e){if(!(e.target&&e.target.__isGLToZRProxy)){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mousedown",e,t),this._dispatchDataEvent("mousedown",e,t)),this._downX=e.offsetX,this._downY=e.offsetY}};ne.prototype.onmousemove=function(e){if(!(e.target&&e.target.__isGLToZRProxy)){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY),r=t&&t.target,i=this._hovered;this._hovered=t,i&&r!==i.target&&(i.relatedTarget=r,this._dispatchEvent("mouseout",e,i),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",e,t),t&&(this.zr.setCursorStyle("pointer"),(!i||r!==i.target)&&this._dispatchEvent("mouseover",e,t)),this._dispatchDataEvent("mousemove",e,t)}};ne.prototype.onmouseup=function(e){if(!(e.target&&e.target.__isGLToZRProxy)){e=e.event;var t=this.pickObject(e.offsetX,e.offsetY);t&&(this._dispatchEvent("mouseup",e,t),this._dispatchDataEvent("mouseup",e,t)),this._upX=e.offsetX,this._upY=e.offsetY}};ne.prototype.onclick=ne.prototype.dblclick=function(e){if(!(e.target&&e.target.__isGLToZRProxy)){var t=this._upX-this._downX,r=this._upY-this._downY;if(!(Math.sqrt(t*t+r*r)>20)){e=e.event;var i=this.pickObject(e.offsetX,e.offsetY);i&&(this._dispatchEvent(e.type,e,i),this._dispatchDataEvent(e.type,e,i));var n=this._clickToSetFocusPoint(e);if(n){var a=n.view.setDOFFocusOnPoint(n.distance);a&&this.zr.refresh()}}}};ne.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,r=t.viewport,i=this.views.length-1;i>=0;i--){var n=this.views[i];if(n.hasDOF()&&n.containPoint(e.offsetX,e.offsetY)){this._picking.scene=n.scene,this._picking.camera=n.camera,t.viewport=n.viewport;var a=this._picking.pick(e.offsetX,e.offsetY,!0);if(a)return a.view=n,a}}t.viewport=r};ne.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})};ne.prototype.pickObject=function(e,t){for(var r=[],i=this.renderer,n=i.viewport,a=0;a<this.views.length;a++){var s=this.views[a];s.containPoint(e,t)&&(this._picking.scene=s.scene,this._picking.camera=s.camera,i.viewport=s.viewport,this._picking.pickAll(e,t,r))}return i.viewport=n,r.sort(function(o,l){return o.distance-l.distance}),r[0]};ne.prototype._dispatchEvent=function(e,t,r){r||(r={});var i=r.target;for(r.cancelBubble=!1,r.event=t,r.type=e,r.offsetX=t.offsetX,r.offsetY=t.offsetY;i&&(i.trigger(e,r),i=i.getParent(),!r.cancelBubble););this._dispatchToView(e,r)};ne.prototype._dispatchDataEvent=function(e,t,r){var i=r&&r.target,n=i&&i.dataIndex,a=i&&i.seriesIndex,s=i&&i.eventData,o=!1,l=this._zrEventProxy;l.x=t.offsetX,l.y=t.offsetY,l.update();var u={target:l};const h=ps(l);e==="mousemove"&&(n!=null?n!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(h.dataIndex=this._lastDataIndex,h.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",t)),o=!0):s!=null&&s!==this._lastEventData&&(this._lastEventData!=null&&(h.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",t)),o=!0),this._lastEventData=s,this._lastDataIndex=n,this._lastSeriesIndex=a),h.eventData=s,h.dataIndex=n,h.seriesIndex=a,(s!=null||parseInt(n,10)>=0&&parseInt(a,10)>=0)&&(this.zr.handler.dispatchToElement(u,e,t),o&&this.zr.handler.dispatchToElement(u,"mouseover",t))};ne.prototype._dispatchToView=function(e,t){for(var r=0;r<this.views.length;r++)this.views[r].containPoint(t.offsetX,t.offsetY)&&this.views[r].trigger(e,t)};Object.assign(ne.prototype,Yi);var fu=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function or(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var r=e[t].normal,i=e[t].emphasis;r&&(e[t]=r),i&&(e.emphasis=e.emphasis||{},e.emphasis[t]=i)}}function du(e){or(e,"itemStyle"),or(e,"lineStyle"),or(e,"areaStyle"),or(e,"label")}function Fr(e){e&&(e instanceof Array||(e=[e]),hr(e,function(t){if(t.axisLabel){var r=t.axisLabel;Object.assign(r,r.textStyle),r.textStyle=null}}))}function vu(e){hr(e.series,function(t){_s(fu,t.type)>=0&&(du(t),t.coordinateSystem==="mapbox"&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))}),Fr(e.xAxis3D),Fr(e.yAxis3D),Fr(e.zAxis3D),Fr(e.grid3D),or(e.geo3D)}function Ma(e){this._layers={},this._zr=e}Ma.prototype.update=function(e,t){var r=this,i=t.getZr();if(!i.getWidth()||!i.getHeight()){console.warn("Dom has no width or height");return}function n(o){i.setSleepAfterStill(0);var l;o.coordinateSystem&&o.coordinateSystem.model,l=o.get("zlevel");var u=r._layers,h=u[l];if(!h){if(h=u[l]=new ne("gl-"+l,i),i.painter.isSingleCanvas()){h.virtual=!0;var c=new Ts({z:1e4,style:{image:h.renderer.canvas},silent:!0});h.__hostImage=c,i.add(c)}i.painter.insertLayer(l,h)}return h.__hostImage&&h.__hostImage.setStyle({width:h.renderer.getWidth(),height:h.renderer.getHeight()}),h}function a(o,l){o&&o.traverse(function(u){u.isRenderable&&u.isRenderable()&&(u.ignorePicking=u.$ignorePicking!=null?u.$ignorePicking:l)})}for(var s in this._layers)this._layers[s].removeViewsAll();e.eachComponent(function(o,l){if(o!=="series"){var u=t.getViewOfComponentModel(l),h=l.coordinateSystem;if(u.__ecgl__){var c;if(h){if(!h.viewGL){console.error("Can't find viewGL in coordinateSystem of component "+l.id);return}c=h.viewGL}else{if(!l.viewGL){console.error("Can't find viewGL of component "+l.id);return}c=h.viewGL}var c=h.viewGL,d=n(l);d.addView(c),u.afterRender&&u.afterRender(l,e,t,d),a(u.groupGL,l.get("silent"))}}}),e.eachSeries(function(o){var l=t.getViewOfSeriesModel(o),u=o.coordinateSystem;if(l.__ecgl__){if(u&&!u.viewGL&&!l.viewGL){console.error("Can't find viewGL of series "+l.id);return}var h=u&&u.viewGL||l.viewGL,c=n(o);c.addView(h),l.afterRender&&l.afterRender(o,e,t,c),a(l.groupGL,o.get("silent"))}})};gs(function(e){var t=e.getZr(),r=t.painter.dispose;t.painter.dispose=function(){typeof this.eachOtherLayer=="function"&&this.eachOtherLayer(function(i){i instanceof ne&&i.dispose()}),r.call(this)},t.painter.getRenderedCanvas=function(i){if(i=i||{},this._singleCanvas)return this._layers[0].dom;var n=document.createElement("canvas"),a=i.pixelRatio||this.dpr;n.width=this.getWidth()*a,n.height=this.getHeight()*a;var s=n.getContext("2d");s.dpr=a,s.clearRect(0,0,n.width,n.height),i.backgroundColor&&(s.fillStyle=i.backgroundColor,s.fillRect(0,0,n.width,n.height));var o=this.storage.getDisplayList(!0),l={},u,h=this;function c(p,m){var g=h._zlevelList;p==null&&(p=-1/0);for(var T,y=0;y<g.length;y++){var x=g[y],E=h._layers[x];if(!E.__builtin__&&x>p&&x<m){T=E;break}}T&&T.renderToCanvas&&(s.save(),T.renderToCanvas(s),s.restore())}for(var d={ctx:s},f=0;f<o.length;f++){var v=o[f];v.zlevel!==u&&(c(u,v.zlevel),u=v.zlevel),this._doPaintEl(v,d,!0,null,l)}return c(u,1/0),n}});ys(function(e,t){var r=t.getZr(),i=r.__egl=r.__egl||new Ma(r);i.update(e,t)});xs(vu);const pu={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(e){e=e||{},this.option.viewControl=this.option.viewControl||{},e.alpha!=null&&(this.option.viewControl.alpha=e.alpha),e.beta!=null&&(this.option.viewControl.beta=e.beta),e.distance!=null&&(this.option.viewControl.distance=e.distance),e.center!=null&&(this.option.viewControl.center=e.center)}},mu={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"}}},_u={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 $r=sa.extend({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});ht($r.prototype,pu);ht($r.prototype,mu);ht($r.prototype,_u);var ar=Ve.firstNotNull,zn={left:0,middle:1,right:2};function Gn(e){return e instanceof Array||(e=[e,e]),e}var Pa=Pe.extend(function(){return{zr:null,viewGL:null,_center:new w,minDistance:.5,maxDistance:1.5,maxOrthographicSize:300,minOrthographicSize:30,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",_mode:"rotate",_camera:null,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new q,_panVelocity:new q,_distance:500,_zoomSpeed:0,_stillTimeout:0,_animators:[]}},function(){["_mouseDownHandler","_mouseWheelHandler","_mouseMoveHandler","_mouseUpHandler","_pinchHandler","_contextMenuHandler","_update"].forEach(function(e){this[e]=this[e].bind(this)},this)},{init:function(){var e=this.zr;e&&(e.on("mousedown",this._mouseDownHandler),e.on("globalout",this._mouseUpHandler),e.on("mousewheel",this._mouseWheelHandler),e.on("pinch",this._pinchHandler),e.animation.on("frame",this._update),e.dom.addEventListener("contextmenu",this._contextMenuHandler))},dispose:function(){var e=this.zr;e&&(e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("pinch",this._pinchHandler),e.off("globalout",this._mouseUpHandler),e.dom.removeEventListener("contextmenu",this._contextMenuHandler),e.animation.off("frame",this._update)),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getOrthographicSize:function(){return this._orthoSize},setOrthographicSize:function(e){this._orthoSize=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setViewGL:function(e){this.viewGL=e},getCamera:function(){return this.viewGL.camera},setFromViewControlModel:function(e,t){t=t||{};var r=t.baseDistance||0,i=t.baseOrthoSize||1,n=e.get("projection");n!=="perspective"&&n!=="orthographic"&&n!=="isometric"&&(n="perspective"),this._projection=n,this.viewGL.setProjection(n);var a=e.get("distance")+r,s=e.get("orthographicSize")+i;[["damping",.8],["autoRotate",!1],["autoRotateAfterStill",3],["autoRotateDirection","cw"],["autoRotateSpeed",10],["minDistance",30],["maxDistance",400],["minOrthographicSize",30],["maxOrthographicSize",300],["minAlpha",-90],["maxAlpha",90],["minBeta",-1/0],["maxBeta",1/0],["rotateSensitivity",1],["zoomSensitivity",1],["panSensitivity",1],["panMouseButton","left"],["rotateMouseButton","middle"]].forEach(function(d){this[d[0]]=ar(e.get(d[0]),d[1])},this),this.minDistance+=r,this.maxDistance+=r,this.minOrthographicSize+=i,this.maxOrthographicSize+=i;var o=e.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach(function(d){l[d]=ar(e.get(d),o&&o.get(d))});var u=ar(t.alpha,e.get("alpha"))||0,h=ar(t.beta,e.get("beta"))||0,c=ar(t.center,e.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:u,beta:h,center:c,distance:a,orthographicSize:s,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(u),this.setBeta(h),this.setCenter(c),this.setOrthographicSize(s)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(e){var t=this.zr,r=this,i={},n={};return e.distance!=null&&(i.distance=this.getDistance(),n.distance=e.distance),e.orthographicSize!=null&&(i.orthographicSize=this.getOrthographicSize(),n.orthographicSize=e.orthographicSize),e.alpha!=null&&(i.alpha=this.getAlpha(),n.alpha=e.alpha),e.beta!=null&&(i.beta=this.getBeta(),n.beta=e.beta),e.center!=null&&(i.center=this.getCenter(),n.center=e.center),this._addAnimator(t.animation.animate(i).when(e.duration||1e3,n).during(function(){i.alpha!=null&&r.setAlpha(i.alpha),i.beta!=null&&r.setBeta(i.beta),i.distance!=null&&r.setDistance(i.distance),i.center!=null&&r.setCenter(i.center),i.orthographicSize!=null&&r.setOrthographicSize(i.orthographicSize),r._needsUpdate=!0})).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e<this._animators.length;e++)this._animators[e].stop();this._animators.length=0},update:function(){this._needsUpdate=!0,this._update(20)},_isAnimating:function(){return this._animators.length>0},_update:function(e){if(this._rotating){var t=(this.autoRotateDirection==="cw"?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){this._projection==="perspective"?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),r=this._orthoSize,i=r/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-i/2,t.right=i/2,t.top=r/2,t.bottom=-r/2},_updatePan:function(e){var t=this._panVelocity,r=this._distance,i=this.getCamera(),n=i.worldTransform.y,a=i.worldTransform.x;this._center.scaleAndAdd(a,-t.x*r/200).scaleAndAdd(n,-t.y*r/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new w,r=this._theta+Math.PI/2,i=this._phi+Math.PI/2,n=Math.sin(r);t.x=n*Math.cos(i),t.y=-Math.cos(r),t.z=n*Math.sin(i),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout(function(){t._rotating=!0},e*1e3))},_vectorDamping:function(e,t){var r=e.len();r=r*t,r<1e-4&&(r=0),e.normalize().scale(r)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),r=Math.atan2(e.x,e.z);this._theta=t,this._phi=-r,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,r=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,r)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?e.event.targetTouches.length===1&&(this._mode="rotate"):e.event.button===zn[this.rotateMouseButton]?this._mode="rotate":e.event.button===zn[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy)&&!this._isAnimating()){var t=Gn(this.panSensitivity),r=Gn(this.rotateSensitivity);this._mode==="rotate"?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*r[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*r[1]):this._mode==="pan"&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(t!==0){var r=e.offsetX,i=e.offsetY;if(!(this.viewGL&&!this.viewGL.containPoint(r,i))){var n;this._projection==="perspective"?n=Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):n=Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*n*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&this._mode==="rotate"&&this._startCountingStill(),e.event.preventDefault()}}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return this.rotateMouseButton==="right"||this.panMouseButton==="right"},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var r=t.indexOf(e);r>=0&&t.splice(r,1)}),e}});Object.defineProperty(Pa.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});const Ji={convertToDynamicArray:function(e){e&&this.resetOffset();var t=this.attributes;for(var r in t)e||!t[r].value?t[r].value=[]:t[r].value=Array.prototype.slice.call(t[r].value);e||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var e=this.attributes;for(var t in e)e[t].value&&e[t].value.length>0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},Kr={vec3:_};var _i=Kr.vec3,kn=[[0,0],[1,1]],Qr=ae.extend(function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new ae.Attribute("position","float",3,"POSITION"),positionPrev:new ae.Attribute("positionPrev","float",3),positionNext:new ae.Attribute("positionNext","float",3),prevPositionPrev:new ae.Attribute("prevPositionPrev","float",3),prevPosition:new ae.Attribute("prevPosition","float",3),prevPositionNext:new ae.Attribute("prevPositionNext","float",3),offset:new ae.Attribute("offset","float",1),color:new ae.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.positionPrev.init(e),t.positionNext.init(e),t.offset.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(e===0?this.indices=null:this.indices=this.vertexCount>65535?new Uint32Array(e*3):new Uint16Array(e*3))},_getCubicCurveApproxStep:function(e,t,r,i){var n=_i.dist(e,t)+_i.dist(r,t)+_i.dist(i,r),a=1/(n+1)*this.segmentScale;return a},getCubicCurveVertexCount:function(e,t,r,i){var n=this._getCubicCurveApproxStep(e,t,r,i),a=Math.ceil(1/n);return this.useNativeLine?a*2:a*2+2},getCubicCurveTriangleCount:function(e,t,r,i){var n=this._getCubicCurveApproxStep(e,t,r,i),a=Math.ceil(1/n);return this.useNativeLine?0:a*2},getLineVertexCount:function(){return this.getPolylineVertexCount(kn)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(kn)},getPolylineVertexCount:function(e){var t;if(typeof e=="number")t=e;else{var r=typeof e[0]!="number";t=r?e.length:e.length/3}return this.useNativeLine?(t-1)*2:(t-1)*2+2},getPolylineTriangleCount:function(e){var t;if(typeof e=="number")t=e;else{var r=typeof e[0]!="number";t=r?e.length:e.length/3}return this.useNativeLine?0:Math.max(t-1,0)*2},addCubicCurve:function(e,t,r,i,n,a){a==null&&(a=1);for(var s=e[0],o=e[1],l=e[2],u=t[0],h=t[1],c=t[2],d=r[0],f=r[1],v=r[2],p=i[0],m=i[1],g=i[2],T=this._getCubicCurveApproxStep(e,t,r,i),y=T*T,x=y*T,E=3*T,S=3*y,O=6*y,P=6*x,B=s-u*2+d,k=o-h*2+f,N=l-c*2+v,V=(u-d)*3-s+p,z=(h-f)*3-o+m,U=(c-v)*3-l+g,X=s,G=o,Y=l,H=(u-s)*E+B*S+V*x,le=(h-o)*E+k*S+z*x,j=(c-l)*E+N*S+U*x,ve=B*O+V*P,re=k*O+z*P,ue=N*O+U*P,he=V*P,Ce=z*P,Me=U*P,xe=0,Le=0,He=Math.ceil(1/T),Re=new Float32Array((He+1)*3),Re=[],Xe=0,Le=0;Le<He+1;Le++)Re[Xe++]=X,Re[Xe++]=G,Re[Xe++]=Y,X+=H,G+=le,Y+=j,H+=ve,le+=re,j+=ue,ve+=he,re+=Ce,ue+=Me,xe+=T,xe>1&&(X=H>0?Math.min(X,p):Math.max(X,p),G=le>0?Math.min(G,m):Math.max(G,m),Y=j>0?Math.min(Y,g):Math.max(Y,g));return this.addPolyline(Re,n,a)},addLine:function(e,t,r,i){return this.addPolyline([e,t],r,i)},addPolyline:function(e,t,r,i,n){if(e.length){var a=typeof e[0]!="number";if(n==null&&(n=a?e.length:e.length/3),!(n<2)){i==null&&(i=0),r==null&&(r=1),this._itemVertexOffsets.push(this._vertexOffset);var a=typeof e[0]!="number",s=a?typeof t[0]!="number":t.length/4===n,o=this.attributes.position,l=this.attributes.positionPrev,u=this.attributes.positionNext,h=this.attributes.color,c=this.attributes.offset,d=this.indices,f=this._vertexOffset,v,p;r=Math.max(r,.01);for(var m=i;m<n;m++){if(a)v=e[m],s?p=t[m]:p=t;else{var g=m*3;if(v=v||[],v[0]=e[g],v[1]=e[g+1],v[2]=e[g+2],s){var T=m*4;p=p||[],p[0]=t[T],p[1]=t[T+1],p[2]=t[T+2],p[3]=t[T+3]}else p=t}if(this.useNativeLine?m>1&&(o.copy(f,f-1),h.copy(f,f-1),f++):(m<n-1&&(l.set(f+2,v),l.set(f+3,v)),m>0&&(u.set(f-2,v),u.set(f-1,v)),o.set(f,v),o.set(f+1,v),h.set(f,p),h.set(f+1,p),c.set(f,r/2),c.set(f+1,-r/2),f+=2),this.useNativeLine)h.set(f,p),o.set(f,v),f++;else if(m>0){var y=this._triangleOffset*3,d=this.indices;d[y]=f-4,d[y+1]=f-3,d[y+2]=f-2,d[y+3]=f-3,d[y+4]=f-1,d[y+5]=f-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,E=this._vertexOffset+n*2;l.copy(x,x+2),l.copy(x+1,x+3),u.copy(E-1,E-3),u.copy(E-2,E-4)}return this._vertexOffset=f,this._vertexOffset}}},setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],i=e<this._itemVertexOffsets.length-1?this._itemVertexOffsets[e+1]:this._vertexOffset,n=r;n<i;n++)this.attributes.color.set(n,t);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});xr(Qr.prototype,Ji);function Gr(e,t,r,i,n,a,s){this._zr=e,this._x=0,this._y=0,this._rowHeight=0,this.width=i,this.height=n,this.offsetX=t,this.offsetY=r,this.dpr=s,this.gap=a}Gr.prototype={constructor:Gr,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(e,t,r){var i=e.getBoundingRect();t==null&&(t=i.width),r==null&&(r=i.height),t*=this.dpr,r*=this.dpr,this._fitElement(e,t,r);var n=this._x,a=this._y,s=this.width*this.dpr,o=this.height*this.dpr,l=this.gap;if(n+t+l>s&&(n=this._x=0,a+=this._rowHeight+l,this._y=a,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,r),a+r+l>o)return null;e.x+=this.offsetX*this.dpr+n,e.y+=this.offsetY*this.dpr+a,this._zr.add(e);var u=[this.offsetX/this.width,this.offsetY/this.height],h=[[n/s+u[0],a/o+u[1]],[(n+t)/s+u[0],(a+r)/o+u[1]]];return h},_fitElement:function(e,t,r){var i=e.getBoundingRect(),n=t/i.width,a=r/i.height;e.x=-i.x*n,e.y=-i.y*a,e.scaleX=n,e.scaleY=a,e.update()}};function Di(e){e=e||{},e.width=e.width||512,e.height=e.height||512,e.devicePixelRatio=e.devicePixelRatio||1,e.gap=e.gap==null?2:e.gap;var t=document.createElement("canvas");t.width=e.width*e.devicePixelRatio,t.height=e.height*e.devicePixelRatio,this._canvas=t,this._texture=new Q({image:t,flipY:!1});var r=this;this._zr=ws(t);var i=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){i.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new Gr(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}Di.prototype={clear:function(){for(var e=0;e<this._textureAtlasNodes.length;e++)this._textureAtlasNodes[e].clear();this._currentNodeIdx=0,this._zr.clear(),this._coords={}},getWidth:function(){return this._width},getHeight:function(){return this._height},getTexture:function(){return this._texture},getDevicePixelRatio:function(){return this._dpr},getZr:function(){return this._zr},_getCurrentNode:function(){return this._textureAtlasNodes[this._currentNodeIdx]},_expand:function(){if(this._currentNodeIdx++,this._textureAtlasNodes[this._currentNodeIdx])return this._textureAtlasNodes[this._currentNodeIdx];var e=4096/this._dpr,t=this._textureAtlasNodes,r=t.length,i=r*this._nodeWidth%e,n=Math.floor(r*this._nodeWidth/e)*this._nodeHeight;if(!(n>=e)){var a=(i+this._nodeWidth)*this._dpr,s=(n+this._nodeHeight)*this._dpr;try{this._zr.resize({width:a,height:s})}catch{this._canvas.width=a,this._canvas.height=s}var o=new Gr(this._zr,i,n,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(o),o}},add:function(e,t,r){if(this._coords[e.id])return this._coords[e.id];var i=this._getCurrentNode().add(e,t,r);if(!i){var n=this._expand();if(!n)return;i=n.add(e,t,r)}return this._coords[e.id]=i,i},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]},dispose:function(){this._zr.dispose()}};function Oi(){}Oi.prototype={constructor:Oi,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new M.DirectionalLight({shadowBias:.005}),this.ambientLight=new M.AmbientLight,e.add(this.mainLight),e.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(e){var t=this.mainLight,r=this.ambientLight,i=e.getModel("light"),n=i.getModel("main"),a=i.getModel("ambient");t.intensity=n.get("intensity"),r.intensity=a.get("intensity"),t.color=M.parseColor(n.get("color")).slice(0,3),r.color=M.parseColor(a.get("color")).slice(0,3);var s=n.get("alpha")||0,o=n.get("beta")||0;t.position.setArray(M.directionFromAlphaBeta(s,o)),t.lookAt(M.Vector3.ZERO),t.castShadow=n.get("shadow"),t.shadowResolution=M.getShadowResolution(n.get("shadowQuality"))},updateAmbientCubemap:function(e,t,r){var i=t.getModel("light.ambientCubemap"),n=i.get("texture");if(n){this._cubemapLightsCache=this._cubemapLightsCache||{};var a=this._cubemapLightsCache[n];if(!a){var s=this;a=this._cubemapLightsCache[n]=M.createAmbientCubemap(i.option,e,r,function(){s._isSkyboxFromAmbientCubemap&&s._skybox.setEnvironmentMap(a.specular.cubemap),r.getZr().refresh()})}this._lightRoot.add(a.diffuse),this._lightRoot.add(a.specular),this._currentCubemapLights=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(e,t,r){var i=t.get("environment"),n=this;function a(){return n._skybox=n._skybox||new mr,n._skybox}var s=a();if(i&&i!=="none")if(i==="auto")if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var o=this._currentCubemapLights.specular.cubemap;s.setEnvironmentMap(o),this._scene&&s.attachScene(this._scene),s.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if(typeof i=="object"&&i.colorStops||typeof i=="string"&&na(i)){this._isSkyboxFromAmbientCubemap=!1;var l=new M.Texture2D({anisotropic:8,flipY:!1});s.setEnvironmentMap(l);var u=l.image=document.createElement("canvas");u.width=u.height=16;var h=u.getContext("2d"),c=new aa({shape:{x:0,y:0,width:16,height:16},style:{fill:i}});Es(h,c),s.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;var l=M.loadTexture(i,r,{anisotropic:8,flipY:!1});s.setEnvironmentMap(l),s.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var d=t.coordinateSystem;if(this._skybox)if(d&&d.viewGL&&i!=="auto"&&!(i.match&&i.match(/.hdr$/))){var f=d.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[f]("fragment","SRGB_DECODE")}else this._skybox.material.undefine("fragment","SRGB_DECODE")}};var bt=Kr.vec3,Ra=ae.extend(function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new ae.Attribute("position","float",3,"POSITION"),normal:new ae.Attribute("normal","float",3,"NORMAL"),color:new ae.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,r=this.getQuadVertexCount()*e,i=this.getQuadTriangleCount()*e;this.vertexCount!==r&&(t.position.init(r),t.normal.init(r),t.color.init(r)),this.triangleCount!==i&&(this.indices=r>65535?new Uint32Array(i*3):new Uint16Array(i*3))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=bt.create(),t=bt.create(),r=bt.create(),i=[0,3,1,3,2,1];return function(n,a){var s=this.attributes.position,o=this.attributes.normal,l=this.attributes.color;bt.sub(e,n[1],n[0]),bt.sub(t,n[2],n[1]),bt.cross(r,e,t),bt.normalize(r,r);for(var u=0;u<4;u++)s.set(this._vertexOffset+u,n[u]),l.set(this._vertexOffset+u,a),o.set(this._vertexOffset+u,r);for(var h=this._faceOffset*3,u=0;u<6;u++)this.indices[h+u]=i[u]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});xr(Ra.prototype,Ji);var Ii=Ve.firstNotNull,gu={x:0,y:2,z:1};function yu(e,t,r,i){var n=[0,0,0],a=i<0?r.getExtentMin():r.getExtentMax();n[gu[r.dim]]=a,e.position.setArray(n),e.rotation.identity(),t.distance=-Math.abs(a),t.normal.set(0,0,0),r.dim==="x"?(e.rotation.rotateY(i*Math.PI/2),t.normal.x=-i):r.dim==="z"?(e.rotation.rotateX(-i*Math.PI/2),t.normal.y=-i):(i>0&&e.rotation.rotateY(Math.PI),t.normal.z=-i)}function Jr(e,t,r){this.rootNode=new M.Node;var i=new M.Mesh({geometry:new Qr({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),n=new M.Mesh({geometry:new Ra,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(n),this.rootNode.add(i),this.faceInfo=e,this.plane=new M.Plane,this.linesMesh=i,this.quadsMesh=n}Jr.prototype.update=function(e,t,r){var i=e.coordinateSystem,n=[i.getAxis(this.faceInfo[0]),i.getAxis(this.faceInfo[1])],a=this.linesMesh.geometry,s=this.quadsMesh.geometry;a.convertToDynamicArray(!0),s.convertToDynamicArray(!0),this._updateSplitLines(a,n,e,r),this._udpateSplitAreas(s,n,e,r),a.convertToTypedArray(),s.convertToTypedArray();var o=i.getAxis(this.faceInfo[2]);yu(this.rootNode,this.plane,o,this.faceInfo[3])};Jr.prototype._updateSplitLines=function(e,t,r,i){var n=i.getDevicePixelRatio();t.forEach(function(a,s){var o=a.model,l=t[1-s].getExtent();if(!a.scale.isBlank()){var u=o.getModel("splitLine",r.getModel("splitLine"));if(u.get("show")){var h=u.getModel("lineStyle"),c=h.get("color"),d=Ii(h.get("opacity"),1),f=Ii(h.get("width"),1);c=ur(c)?c:[c];for(var v=a.getTicksCoords({tickModel:u}),p=0,m=0;m<v.length;m++){var g=v[m].coord,T=M.parseColor(c[p%c.length]);T[3]*=d;var y=[0,0,0],x=[0,0,0];y[s]=x[s]=g,y[1-s]=l[0],x[1-s]=l[1],e.addLine(y,x,T,f*n),p++}}}})};Jr.prototype._udpateSplitAreas=function(e,t,r,i){t.forEach(function(n,a){var s=n.model,o=t[1-a].getExtent();if(!n.scale.isBlank()){var l=s.getModel("splitArea",r.getModel("splitArea"));if(l.get("show")){var u=l.getModel("areaStyle"),h=u.get("color"),c=Ii(u.get("opacity"),1);h=ur(h)?h:[h];for(var d=n.getTicksCoords({tickModel:l,clamp:!0}),f=0,v=[0,0,0],p=[0,0,0],m=0;m<d.length;m++){var g=d[m].coord,T=[0,0,0],y=[0,0,0];if(T[a]=y[a]=g,T[1-a]=o[0],y[1-a]=o[1],m===0){v=T,p=y;continue}var x=M.parseColor(h[f%h.length]);x[3]*=c,e.addQuad([v,T,y,p],x),v=T,p=y,f++}}}})};var Vn=[0,1,2,0,2,3],La=ae.extend(function(){return{attributes:{position:new ae.Attribute("position","float",3,"POSITION"),texcoord:new ae.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new ae.Attribute("offset","float",2),color:new ae.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(e){this._spriteCount=e;var t=e*4,r=e*2;this.vertexCount!==t&&(this.attributes.position.init(t),this.attributes.offset.init(t),this.attributes.color.init(t)),this.triangleCount!==r&&(this.indices=t>65535?new Uint32Array(r*3):new Uint16Array(r*3))},setSpriteAlign:function(e,t,r,i,n){r==null&&(r="left"),i==null&&(i="top");var a,s,o,l;switch(n=n||0,r){case"left":a=n,o=t[0]+n;break;case"center":case"middle":a=-t[0]/2,o=t[0]/2;break;case"right":a=-t[0]-n,o=-n;break}switch(i){case"bottom":s=n,l=t[1]+n;break;case"middle":s=-t[1]/2,l=t[1]/2;break;case"top":s=-t[1]-n,l=-n;break}var u=e*4,h=this.attributes.offset;h.set(u,[a,l]),h.set(u+1,[o,l]),h.set(u+2,[o,s]),h.set(u+3,[a,s])},addSprite:function(e,t,r,i,n,a){var s=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,r,i,n,a);for(var o=0;o<Vn.length;o++)this.indices[this._faceOffset*3+o]=Vn[o]+s;return this._faceOffset+=2,this._vertexOffset+=4,s/4},setSprite:function(e,t,r,i,n,a,s){for(var o=e*4,l=this.attributes,u=0;u<4;u++)l.position.set(o+u,t);var h=l.texcoord;h.set(o,[i[0][0],i[0][1]]),h.set(o+1,[i[1][0],i[0][1]]),h.set(o+2,[i[1][0],i[1][1]]),h.set(o+3,[i[0][0],i[1][1]]),this.setSpriteAlign(e,r,n,a,s)}});xr(La.prototype,Ji);const xu="@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end";M.Shader.import(xu);const Na=M.Mesh.extend(function(){var e=new La({dynamic:!0}),t=new M.Material({shader:M.createShader("ecgl.labels"),transparent:!0,depthMask:!1});return{geometry:e,material:t,culling:!1,castShadow:!1,ignorePicking:!0}});var St=Ve.firstNotNull,At={x:0,y:2,z:1};function en(e,t){var r=new M.Mesh({geometry:new Qr({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),i=new Na;i.material.depthMask=!1;var n=new M.Node;n.add(r),n.add(i),this.rootNode=n,this.dim=e,this.linesMesh=r,this.labelsMesh=i,this.axisLineCoords=null,this.labelElements=[]}var gi={x:"y",y:"x",z:"y"};en.prototype.update=function(e,t,r){var i=e.coordinateSystem,n=i.getAxis(this.dim),a=this.linesMesh.geometry,s=this.labelsMesh.geometry;a.convertToDynamicArray(!0),s.convertToDynamicArray(!0);var o=n.model,l=n.getExtent(),N=r.getDevicePixelRatio(),u=o.getModel("axisLine",e.getModel("axisLine")),h=o.getModel("axisTick",e.getModel("axisTick")),c=o.getModel("axisLabel",e.getModel("axisLabel")),d=u.get("lineStyle.color");if(u.get("show")){var f=u.getModel("lineStyle"),v=[0,0,0],p=[0,0,0],m=At[n.dim];v[m]=l[0],p[m]=l[1],this.axisLineCoords=[v,p];var g=M.parseColor(d),T=St(f.get("width"),1),y=St(f.get("opacity"),1);g[3]*=y,a.addLine(v,p,g,T*N)}if(h.get("show")){var x=h.getModel("lineStyle"),E=M.parseColor(St(x.get("color"),d)),T=St(x.get("width"),1);E[3]*=St(x.get("opacity"),1);for(var S=n.getTicksCoords(),O=h.get("length"),P=0;P<S.length;P++){var B=S[P].coord,v=[0,0,0],p=[0,0,0],m=At[n.dim],k=At[gi[n.dim]];v[m]=p[m]=B,p[k]=O,a.addLine(v,p,E,T*N)}}this.labelElements=[];var N=r.getDevicePixelRatio();if(c.get("show"))for(var S=n.getTicksCoords(),V=o.get("data"),z=c.get("margin"),U=n.getViewLabels(),P=0;P<U.length;P++){var X=U[P].tickValue,G=U[P].formattedLabel,Y=U[P].rawLabel,B=n.dataToCoord(X),H=[0,0,0],m=At[n.dim],k=At[gi[n.dim]];H[m]=H[m]=B,H[k]=z;var le=c;V&&V[X]&&V[X].textStyle&&(le=new bs(V[X].textStyle,c,o.ecModel));var j=St(le.get("color"),d),ve=new Ei({style:bi(le,{text:G,fill:typeof j=="function"?j(n.type==="category"?Y:n.type==="value"?X+"":X,P):j,verticalAlign:"top",align:"left"})}),re=t.add(ve),ue=ve.getBoundingRect();s.addSprite(H,[ue.width*N,ue.height*N],re),this.labelElements.push(ve)}if(o.get("name")){var he=o.getModel("nameTextStyle"),H=[0,0,0],m=At[n.dim],k=At[gi[n.dim]],Ce=St(he.get("color"),d),Me=he.get("borderColor"),T=he.get("borderWidth");H[m]=H[m]=(l[0]+l[1])/2,H[k]=o.get("nameGap");var ve=new Ei({style:bi(he,{text:o.get("name"),fill:Ce,stroke:Me,lineWidth:T})}),re=t.add(ve),ue=ve.getBoundingRect();s.addSprite(H,[ue.width*N,ue.height*N],re),ve.__idx=this.labelElements.length,this.nameLabelElement=ve}this.labelsMesh.material.set("textureAtlas",t.getTexture()),this.labelsMesh.material.set("uvScale",t.getCoordsScale()),a.convertToTypedArray(),s.convertToTypedArray()};en.prototype.setSpriteAlign=function(e,t,r){for(var i=r.getDevicePixelRatio(),n=this.labelsMesh.geometry,a=0;a<this.labelElements.length;a++){var s=this.labelElements[a],o=s.getBoundingRect();n.setSpriteAlign(a,[o.width*i,o.height*i],e,t)}var l=this.nameLabelElement;if(l){var o=l.getBoundingRect();n.setSpriteAlign(l.__idx,[o.width*i,o.height*i],e,t),n.dirty()}this.textAlign=e,this.textVerticalAlign=t};const Tu="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end";var Wn=Ve.firstNotNull;M.Shader.import(Tu);var Ct={x:0,y:2,z:1};const wu=Ss.extend({type:"grid3D",__ecgl__:!0,init:function(e,t){var r=[["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"]],i=["x","y","z"],n=new M.Material({shader:M.createShader("ecgl.color"),depthMask:!1,transparent:!0}),a=new M.Material({shader:M.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});n.define("fragment","DOUBLE_SIDED"),n.define("both","VERTEX_COLOR"),this.groupGL=new M.Node,this._control=new Pa({zr:t.getZr()}),this._control.init(),this._faces=r.map(function(o){var l=new Jr(o,a,n);return this.groupGL.add(l.rootNode),l},this),this._axes=i.map(function(o){var l=new en(o,a);return this.groupGL.add(l.rootNode),l},this);var s=t.getDevicePixelRatio();this._axisLabelSurface=new Di({width:256,height:256,devicePixelRatio:s}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new M.Mesh({geometry:new Qr({useNativeLine:!1}),material:a,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new Di({width:128,height:128,devicePixelRatio:s}),this._axisPointerLabelsMesh=new Na({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new M.Node,this._sceneHelper=new Oi,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,r){this._model=e,this._api=r;var i=e.coordinateSystem;i.viewGL.add(this._lightRoot),e.get("show")?i.viewGL.add(this.groupGL):i.viewGL.remove(this.groupGL);var n=this._control;n.setViewGL(i.viewGL);var a=e.getModel("viewControl");n.setFromViewControlModel(a,0),this._axisLabelSurface.clear(),n.off("update"),e.get("show")&&(this._faces.forEach(function(s){s.update(e,t,r)},this),this._axes.forEach(function(s){s.update(e,this._axisLabelSurface,r)},this)),n.on("update",this._onCameraChange.bind(this,e,r),this),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(e),i.viewGL.setPostEffect(e.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,e,r),this._sceneHelper.updateSkybox(n,e,r)},showAxisPointer:function(e,t,r,i){this._doShowAxisPointer(),this._updateAxisPointer(i.value)},hideAxisPointer:function(e,t,r,i){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem,r=t.viewGL;e.get("show")&&e.get("axisPointer.show")?r.on("mousemove",this._updateAxisPointerOnMousePosition,this):r.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t=this._model,r=t.coordinateSystem,i=r.viewGL,n=i.castRay(e.offsetX,e.offsetY,new M.Ray),a,s=0;s<this._faces.length;s++){var o=this._faces[s];if(!o.rootNode.invisible){o.plane.normal.dot(i.camera.worldTransform.z)<0&&o.plane.normal.negate();var l=n.intersectPlane(o.plane);if(l){var u=r.getAxis(o.faceInfo[0]),h=r.getAxis(o.faceInfo[1]),c=Ct[o.faceInfo[0]],d=Ct[o.faceInfo[1]];u.contain(l.array[c])&&h.contain(l.array[d])&&(a=l)}}}if(a){var f=r.pointToData(a.array,[],!0);this._updateAxisPointer(f),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(e,t){e.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var r=this._control;t.dispatchAction({type:"grid3DChangeCamera",alpha:r.getAlpha(),beta:r.getBeta(),distance:r.getDistance(),center:r.getCenter(),from:this.uid,grid3DId:e.id})},_updateFaceVisibility:function(){var e=this._control.getCamera(),t=new M.Vector3;e.update();for(var r=0;r<this._faces.length/2;r++){for(var i=[],n=0;n<2;n++){var a=this._faces[r*2+n];a.rootNode.getWorldPosition(t),t.transformMat4(e.viewMatrix),i[n]=t.z}var s=i[0]>i[1]?0:1,o=this._faces[r*2+s],l=this._faces[r*2+1-s];o.rootNode.invisible=!0,l.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),r=e.getAxis("y"),i=e.getAxis("z"),n=i.getExtentMax(),a=i.getExtentMin(),s=t.getExtentMin(),o=t.getExtentMax(),l=r.getExtentMax(),u=r.getExtentMin(),h=this._axes[0].rootNode,c=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,v=f[4].rootNode.invisible?u:l,p=f[2].rootNode.invisible?n:a,m=f[0].rootNode.invisible?s:o,g=f[2].rootNode.invisible?n:a,T=f[0].rootNode.invisible?o:s,y=f[4].rootNode.invisible?u:l;h.rotation.identity(),c.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,h.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,c.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),h.position.set(0,p,v),c.position.set(m,g,0),d.position.set(T,0,y),h.update(),c.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new M.Vector4,new M.Vector4],r=new M.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach(function(i){var n=i.axisLineCoords;i.labelsMesh.geometry;for(var a=0;a<t.length;a++)t[a].setArray(n[a]),t[a].w=1,t[a].transformMat4(i.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),t[a].x/=t[a].w,t[a].y/=t[a].w;var s=t[1].x-t[0].x,o=t[1].y-t[0].y,l=(t[1].x+t[0].x)/2,u=(t[1].y+t[0].y)/2,h,c;Math.abs(o/s)<.5?(h="center",c=u>r.y?"bottom":"top"):(c="middle",h=l>r.x?"left":"right"),i.setSpriteAlign(h,c,this._api)},this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){var t=this._model.coordinateSystem,r=t.dataToPoint(e),i=this._axisPointerLineMesh,n=i.geometry,a=this._model.getModel("axisPointer"),s=this._api.getDevicePixelRatio();n.convertToDynamicArray(!0);function o(P){return Ve.firstNotNull(P.model.get("axisPointer.show"),a.get("show"))}function l(P){var B=P.model.getModel("axisPointer",a),k=B.getModel("lineStyle"),N=M.parseColor(k.get("color")),V=Wn(k.get("width"),1),z=Wn(k.get("opacity"),1);return N[3]*=z,{color:N,lineWidth:V}}for(var u=0;u<this._faces.length;u++){var h=this._faces[u];if(!h.rootNode.invisible){for(var c=h.faceInfo,d=c[3]<0?t.getAxis(c[2]).getExtentMin():t.getAxis(c[2]).getExtentMax(),f=Ct[c[2]],v=0;v<2;v++){var p=c[v],m=c[1-v],g=t.getAxis(p),T=t.getAxis(m);if(o(g)){var y=[0,0,0],x=[0,0,0],E=Ct[p],S=Ct[m];y[E]=x[E]=r[E],y[f]=x[f]=d,y[S]=T.getExtentMin(),x[S]=T.getExtentMax();var O=l(g);n.addLine(y,x,O.color,O.lineWidth*s)}}if(o(t.getAxis(c[2]))){var y=r.slice(),x=r.slice();x[f]=d;var O=l(t.getAxis(c[2]));n.addLine(y,x,O.color,O.lineWidth*s)}}}n.convertToTypedArray(),this._updateAxisPointerLabelsMesh(e),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(e){var t=this._model,r=this._axisPointerLabelsMesh,i=this._axisPointerLabelsSurface,n=t.coordinateSystem,a=t.getModel("axisPointer");r.geometry.convertToDynamicArray(!0),i.clear();var s={x:"y",y:"x",z:"y"};this._axes.forEach(function(o,l){var u=n.getAxis(o.dim),h=u.model,c=h.getModel("axisPointer",a),d=c.getModel("label"),f=c.get("lineStyle.color");if(!(!d.get("show")||!c.get("show"))){var v=e[l],p=d.get("formatter"),m=u.scale.getLabel({value:v});if(p!=null)m=p(m,e);else if(u.scale.type==="interval"||u.scale.type==="log"){var g=oa(u.scale.getTicks()[0]);m=v.toFixed(g+2)}var T=d.get("color"),y=new Ei({style:bi(d,{text:m,fill:T||f,align:"left",verticalAlign:"top"})}),x=i.add(y),E=y.getBoundingRect(),S=this._api.getDevicePixelRatio(),O=o.rootNode.position.toArray(),P=Ct[s[o.dim]];O[P]+=(o.flipped?-1:1)*d.get("margin"),O[Ct[o.dim]]=u.dataToCoord(e[l]),r.geometry.addSprite(O,[E.width*S,E.height*S],x,o.textAlign,o.textVerticalAlign)}},this),i.getZr().refreshImmediately(),r.material.set("uvScale",i.getCoordsScale()),r.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose(),this._axisLabelSurface.dispose(),this._axisPointerLabelsSurface.dispose()}});function gr(e){la.call(this,e),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}gr.prototype={constructor:gr,model:null,containPoint:function(e){return this.getAxis("x").contain(e[0])&&this.getAxis("y").contain(e[2])&&this.getAxis("z").contain(e[1])},containData:function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])&&this.getAxis("z").containData(e[2])},dataToPoint:function(e,t,r){return t=t||[],t[0]=this.getAxis("x").dataToCoord(e[0],r),t[2]=this.getAxis("y").dataToCoord(e[1],r),t[1]=this.getAxis("z").dataToCoord(e[2],r),t},pointToData:function(e,t,r){return t=t||[],t[0]=this.getAxis("x").coordToData(e[0],r),t[1]=this.getAxis("y").coordToData(e[2],r),t[2]=this.getAxis("z").coordToData(e[1],r),t}};ua(gr,la);function kr(e,t,r){ha.call(this,e,t,r)}kr.prototype={constructor:kr,getExtentMin:function(){var e=this._extent;return Math.min(e[0],e[1])},getExtentMax:function(){var e=this._extent;return Math.max(e[0],e[1])},calculateCategoryInterval:function(){return Math.floor(this.scale.count()/8)}};ua(kr,ha);var Vr=function(){this._pool={},this._allocatedTextures=[]};Vr.prototype={constructor:Vr,get:function(e){var t=Xn(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var r=this._pool[t];if(!r.length){var i=new Q(e);return this._allocatedTextures.push(i),i}return r.pop()},put:function(e){var t=Xn(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var r=this._pool[t];r.push(e)},clear:function(e){for(var t=0;t<this._allocatedTextures.length;t++)this._allocatedTextures[t].dispose(e);this._pool={},this._allocatedTextures=[]}};var Da={width:512,height:512,type:b.UNSIGNED_BYTE,format:b.RGBA,wrapS:b.CLAMP_TO_EDGE,wrapT:b.CLAMP_TO_EDGE,minFilter:b.LINEAR_MIPMAP_LINEAR,magFilter:b.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},yi=Object.keys(Da);function Xn(e){me.defaultsWithPropList(e,Da,yi),Eu(e);for(var t="",r=0;r<yi.length;r++){var i=yi[r],n=e[i].toString();t+=n}return t}function Eu(e){var t=bu(e.width,e.height);e.format===b.DEPTH_COMPONENT&&(e.useMipmap=!1),(!t||!e.useMipmap)&&(e.minFilter==b.NEAREST_MIPMAP_NEAREST||e.minFilter==b.NEAREST_MIPMAP_LINEAR?e.minFilter=b.NEAREST:(e.minFilter==b.LINEAR_MIPMAP_LINEAR||e.minFilter==b.LINEAR_MIPMAP_NEAREST)&&(e.minFilter=b.LINEAR)),t||(e.wrapS=b.CLAMP_TO_EDGE,e.wrapT=b.CLAMP_TO_EDGE)}function bu(e,t){return(e&e-1)===0&&(t&t-1)===0}const Su="@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end";var gt=["px","nx","py","ny","pz","nz"];F.import(Su);function xi(e,t,r){if(r==="alphaMap")return e.material.get("diffuseMap");if(r==="alphaCutoff"){if(e.material.isDefined("fragment","ALPHA_TEST")&&e.material.get("diffuseMap")){var i=e.material.get("alphaCutoff");return i||0}return 0}else return r==="uvRepeat"?e.material.get("uvRepeat"):r==="uvOffset"?e.material.get("uvOffset"):t.get(r)}function jn(e,t){var r=e.material,i=t.material;return r.get("diffuseMap")!==i.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(i.get("alphaCutoff")||0)}var Qe=Pe.extend(function(){return{softShadow:Qe.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 ye,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new Vr}},function(){this._gaussianPassH=new De({fragment:F.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new De({fragment:F.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 De({fragment:F.source("clay.sm.debug_depth")})},{render:function(e,t,r,i){r||(r=t.getMainCamera()),this.trigger("beforerender",this,e,t,r),this._renderShadowPass(e,t,r,i),this.trigger("afterrender",this,e,t,r)},renderDebug:function(e,t){e.saveClear();var r=e.viewport,i=0,n=0,a=t||r.width/4,s=a;this.softShadow===Qe.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM");for(var o in this._textures){var l=this._textures[o];e.setViewport(i,n,a*l.width/l.height,s),this._outputDepthPass.setUniform("depthMap",l),this._outputDepthPass.render(e),i+=a*l.width/l.height}e.setViewport(r),e.restoreClear()},_updateReceivers:function(e,t){if(t.receiveShadow?(this._receivers.push(t),t.material.set("shadowEnabled",1),t.material.set("pcfKernel",this.kernelPCF)):t.material.set("shadowEnabled",0),this.softShadow===Qe.VSM)t.material.define("fragment","USE_VSM"),t.material.undefine("fragment","PCF_KERNEL_SIZE");else{t.material.undefine("fragment","USE_VSM");var r=this.kernelPCF;r&&r.length?t.material.define("fragment","PCF_KERNEL_SIZE",r.length/2):t.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(e,t){var r=this;t.traverse(function(a){a.isRenderable()&&r._updateReceivers(e,a)});for(var i=0;i<t.lights.length;i++){var n=t.lights[i];n.castShadow&&!n.invisible&&this._lightsCastShadow.push(n)}},_renderShadowPass:function(e,t,r,i){for(var n in this._shadowMapNumber)this._shadowMapNumber[n]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var a=e.gl;if(i||t.update(),r&&r.update(),t.updateLights(),this._update(e,t),!this._lightsCastShadow.length&&this._lastRenderNotCastShadow)return;this._lastRenderNotCastShadow=this._lightsCastShadow===0,a.enable(a.DEPTH_TEST),a.depthMask(!0),a.disable(a.BLEND),a.clearColor(1,1,1,1);for(var s=[],o=[],l=[],u=[],h=[],c=[],d,f=0;f<this._lightsCastShadow.length;f++){var v=this._lightsCastShadow[f];if(v.type==="DIRECTIONAL_LIGHT"){if(d){console.warn("Only one direectional light supported with shadow cascade");continue}if(v.shadowCascade>4){console.warn("Support at most 4 cascade");continue}v.shadowCascade>1&&(d=v),this.renderDirectionalLightShadow(e,t,r,v,h,u,l)}else v.type==="SPOT_LIGHT"?this.renderSpotLightShadow(e,t,v,o,s):v.type==="POINT_LIGHT"&&this.renderPointLightShadow(e,t,v,c);this._shadowMapNumber[v.type]++}for(var p in this._shadowMapNumber)for(var m=this._shadowMapNumber[p],g=p+"_SHADOWMAP_COUNT",f=0;f<this._receivers.length;f++){var T=this._receivers[f],y=T.material;y.fragmentDefines[g]!==m&&(m>0?y.define("fragment",g,m):y.isDefined("fragment",g)&&y.undefine("fragment",g))}for(var f=0;f<this._receivers.length;f++){var T=this._receivers[f],y=T.material;d?y.define("fragment","SHADOW_CASCADE",d.shadowCascade):y.undefine("fragment","SHADOW_CASCADE")}var x=t.shadowUniforms;function E(k){return k.height}if(l.length>0){var S=l.map(E);if(x.directionalLightShadowMaps={value:l,type:"tv"},x.directionalLightMatrices={value:u,type:"m4v"},x.directionalLightShadowMapSizes={value:S,type:"1fv"},d){var O=h.slice(),P=h.slice();O.pop(),P.shift(),O.reverse(),P.reverse(),u.reverse(),x.shadowCascadeClipsNear={value:O,type:"1fv"},x.shadowCascadeClipsFar={value:P,type:"1fv"}}}if(s.length>0){var B=s.map(E),x=t.shadowUniforms;x.spotLightShadowMaps={value:s,type:"tv"},x.spotLightMatrices={value:o,type:"m4v"},x.spotLightShadowMapSizes={value:B,type:"1fv"}}c.length>0&&(x.pointLightShadowMaps={value:c,type:"tv"})},renderDirectionalLightShadow:function(){var e=new Yr,t=new I,r=new Se,i=new I,n=new I,a=new I,s=new I;return function(o,l,u,h,c,d,f){var v=this._getDepthMaterial(h),p={getMaterial:function(ue){return ue.shadowDepthMaterial||v},isMaterialChanged:jn,getUniform:xi,ifRender:function(ue){return ue.castShadow},sortCompare:We.opaqueSortCompare};if(!l.viewBoundingBoxLastFrame.isFinite()){var m=l.getBoundingBox();l.viewBoundingBoxLastFrame.copy(m).applyTransform(u.viewMatrix)}var g=Math.min(-l.viewBoundingBoxLastFrame.min.z,u.far),T=Math.max(-l.viewBoundingBoxLastFrame.max.z,u.near),y=this._getDirectionalLightCamera(h,l,u),x=a.array;s.copy(y.projectionMatrix),C.invert(n.array,y.worldTransform.array),C.multiply(n.array,n.array,u.worldTransform.array),C.multiply(x,s.array,n.array);for(var E=[],S=u instanceof Te,O=(u.near+u.far)/(u.near-u.far),P=2*u.near*u.far/(u.near-u.far),B=0;B<=h.shadowCascade;B++){var k=T*Math.pow(g/T,B/h.shadowCascade),N=T+(g-T)*B/h.shadowCascade,V=k*h.cascadeSplitLogFactor+N*(1-h.cascadeSplitLogFactor);E.push(V),c.push(-(-V*O+P)/-V)}var z=this._getTexture(h,h.shadowCascade);f.push(z);var U=o.viewport,X=o.gl;this._frameBuffer.attach(z),this._frameBuffer.bind(o),X.clear(X.COLOR_BUFFER_BIT|X.DEPTH_BUFFER_BIT);for(var B=0;B<h.shadowCascade;B++){var G=E[B],Y=E[B+1];S?C.perspective(t.array,u.fov/180*Math.PI,u.aspect,G,Y):C.ortho(t.array,u.left,u.right,u.bottom,u.top,G,Y),e.setFromProjection(t),e.getTransformedBoundingBox(r,n),r.applyProjection(s);var H=r.min.array,le=r.max.array;H[0]=Math.max(H[0],-1),H[1]=Math.max(H[1],-1),le[0]=Math.min(le[0],1),le[1]=Math.min(le[1],1),i.ortho(H[0],le[0],H[1],le[1],1,-1),y.projectionMatrix.multiplyLeft(i);var j=h.shadowResolution||512;o.setViewport((h.shadowCascade-B-1)*j,0,j,j,1);var ve=l.updateRenderList(y);o.renderPass(ve.opaque,y,p),this.softShadow===Qe.VSM&&this._gaussianFilter(o,z,z.width);var re=new I;re.copy(y.viewMatrix).multiplyLeft(y.projectionMatrix),d.push(re.array),y.projectionMatrix.copy(s)}this._frameBuffer.unbind(o),o.setViewport(U)}}(),renderSpotLightShadow:function(e,t,r,i,n){var a=this._getTexture(r),s=this._getSpotLightCamera(r),o=e.gl;this._frameBuffer.attach(a),this._frameBuffer.bind(e),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(r),u={getMaterial:function(d){return d.shadowDepthMaterial||l},isMaterialChanged:jn,getUniform:xi,ifRender:function(d){return d.castShadow},sortCompare:We.opaqueSortCompare},h=t.updateRenderList(s);e.renderPass(h.opaque,s,u),this._frameBuffer.unbind(e),this.softShadow===Qe.VSM&&this._gaussianFilter(e,a,a.width);var c=new I;c.copy(s.worldTransform).invert().multiplyLeft(s.projectionMatrix),n.push(a),i.push(c.array)},renderPointLightShadow:function(e,t,r,i){var n=this._getTexture(r),a=e.gl;i.push(n);var s=this._getDepthMaterial(r),o={getMaterial:function(T){return T.shadowDepthMaterial||s},getUniform:xi,sortCompare:We.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},u=new Se,h=r.getWorldPosition().array,c=new Se,d=r.range;c.min.setArray(h),c.max.setArray(h);var f=new w(d,d,d);c.max.add(f),c.min.sub(f);var v={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};t.traverse(function(T){if(T.isRenderable()&&T.castShadow){var y=T.geometry;if(!y.boundingBox){for(var x=0;x<gt.length;x++)l[gt[x]].push(T);return}if(u.transformFrom(y.boundingBox,T.worldTransform),!u.intersectBoundingBox(c))return;u.updateVertices();for(var x=0;x<gt.length;x++)v[gt[x]]=!1;for(var x=0;x<8;x++){var E=u.vertices[x],S=E[0]-h[0],O=E[1]-h[1],P=E[2]-h[2],B=Math.abs(S),k=Math.abs(O),N=Math.abs(P);B>k?B>N?v[S>0?"px":"nx"]=!0:v[P>0?"pz":"nz"]=!0:k>N?v[O>0?"py":"ny"]=!0:v[P>0?"pz":"nz"]=!0}for(var x=0;x<gt.length;x++)v[gt[x]]&&l[gt[x]].push(T)}});for(var p=0;p<6;p++){var m=gt[p],g=this._getPointLightCamera(r,m);this._frameBuffer.attach(n,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+p),this._frameBuffer.bind(e),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),e.renderPass(l[m],g,o)}this._frameBuffer.unbind(e)},_getDepthMaterial:function(e){var t=this._lightMaterials[e.__uid__],r=e.type==="POINT_LIGHT";if(!t){var i=r?"clay.sm.distance.":"clay.sm.depth.";t=new vt({precision:this.precision,shader:new F(F.source(i+"vertex"),F.source(i+"fragment"))}),this._lightMaterials[e.__uid__]=t}return e.shadowSlopeScale!=null&&t.setUniform("slopeScale",e.shadowSlopeScale),e.shadowBias!=null&&t.setUniform("bias",e.shadowBias),this.softShadow===Qe.VSM?t.define("fragment","USE_VSM"):t.undefine("fragment","USE_VSM"),r&&(t.set("lightPosition",e.getWorldPosition().array),t.set("range",e.range)),t},_gaussianFilter:function(e,t,r){var i={width:r,height:r,type:L.FLOAT},n=this._texturePool.get(i);this._frameBuffer.attach(n),this._frameBuffer.bind(e),this._gaussianPassH.setUniform("texture",t),this._gaussianPassH.setUniform("textureWidth",r),this._gaussianPassH.render(e),this._frameBuffer.attach(t),this._gaussianPassV.setUniform("texture",n),this._gaussianPassV.setUniform("textureHeight",r),this._gaussianPassV.render(e),this._frameBuffer.unbind(e),this._texturePool.put(n)},_getTexture:function(e,t){var r=e.__uid__,i=this._textures[r],n=e.shadowResolution||512;return t=t||1,i||(e.type==="POINT_LIGHT"?i=new Nt:i=new Q,i.width=n*t,i.height=n,this.softShadow===Qe.VSM?(i.type=L.FLOAT,i.anisotropic=4):(i.minFilter=b.NEAREST,i.magFilter=b.NEAREST,i.useMipmap=!1),this._textures[r]=i),i},_getPointLightCamera:function(e,t){this._lightCameras.point||(this._lightCameras.point={px:new Te,nx:new Te,py:new Te,ny:new Te,pz:new Te,nz:new Te});var r=this._lightCameras.point[t];switch(r.far=e.range,r.fov=90,r.position.set(0,0,0),t){case"px":r.lookAt(w.POSITIVE_X,w.NEGATIVE_Y);break;case"nx":r.lookAt(w.NEGATIVE_X,w.NEGATIVE_Y);break;case"py":r.lookAt(w.POSITIVE_Y,w.POSITIVE_Z);break;case"ny":r.lookAt(w.NEGATIVE_Y,w.NEGATIVE_Z);break;case"pz":r.lookAt(w.POSITIVE_Z,w.NEGATIVE_Y);break;case"nz":r.lookAt(w.NEGATIVE_Z,w.NEGATIVE_Y);break}return e.getWorldPosition(r.position),r.update(),r},_getDirectionalLightCamera:function(){var e=new I,t=new Se,r=new Se;return function(i,n,a){this._lightCameras.directional||(this._lightCameras.directional=new _r);var s=this._lightCameras.directional;t.copy(n.viewBoundingBoxLastFrame),t.intersection(a.frustum.boundingBox),s.position.copy(t.min).add(t.max).scale(.5).transformMat4(a.worldTransform),s.rotation.copy(i.rotation),s.scale.copy(i.scale),s.updateWorldTransform(),I.invert(e,s.worldTransform),I.multiply(e,e,a.worldTransform),r.copy(t).applyTransform(e);var o=r.min.array,l=r.max.array;return s.position.set((o[0]+l[0])/2,(o[1]+l[1])/2,l[2]).transformMat4(s.worldTransform),s.near=0,s.far=-o[2]+l[2],isNaN(this.lightFrustumBias)?s.far*=4:s.far+=this.lightFrustumBias,s.left=o[0],s.right=l[0],s.top=l[1],s.bottom=o[1],s.update(!0),s}}(),_getSpotLightCamera:function(e){this._lightCameras.spot||(this._lightCameras.spot=new Te);var t=this._lightCameras.spot;return t.fov=e.penumbraAngle*2,t.far=e.range,t.worldTransform.copy(e.worldTransform),t.updateProjectionMatrix(),C.invert(t.viewMatrix.array,t.worldTransform.array),t},dispose:function(e){var t=e.gl||e;this._frameBuffer&&this._frameBuffer.dispose(t);for(var r in this._textures)this._textures[r].dispose(t);this._texturePool.clear(e.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var i=0;i<this._receivers.length;i++){var n=this._receivers[i];if(n.material){var a=n.material;a.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),a.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),a.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),a.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});Qe.VSM=1;Qe.PCF=2;var yr=Pe.extend(function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},{updateParameter:function(e,t){var r=this.outputs[e],i=r.parameters,n=r._parametersCopy;if(n||(n=r._parametersCopy={}),i)for(var a in i)a!=="width"&&a!=="height"&&(n[a]=i[a]);var s,o;return i.width instanceof Function?s=i.width.call(this,t):s=i.width,i.height instanceof Function?o=i.height.call(this,t):o=i.height,(n.width!==s||n.height!==o)&&this._outputTextures[e]&&this._outputTextures[e].dispose(t.gl),n.width=s,n.height=o,n},setParameter:function(e,t){},getParameter:function(e){},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},render:function(){},getOutput:function(e,t){if(t==null)return t=e,this._outputTextures[t];var r=this.outputs[t];if(r)return this._rendered?r.outputLastFrame?this._prevOutputTextures[t]:this._outputTextures[t]:this._rendering?(this._prevOutputTextures[t]||(this._prevOutputTextures[t]=this._compositor.allocateTexture(r.parameters||{})),this._prevOutputTextures[t]):(this.render(e),this._outputTextures[t])},removeReference:function(e){if(this._outputReferences[e]--,this._outputReferences[e]===0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}},link:function(e,t,r){this.inputLinks[e]={node:t,pin:r},t.outputLinks[r]||(t.outputLinks[r]=[]),t.outputLinks[r].push({node:this,pin:e}),this.pass.material.enableTexture(e)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var r=this.inputLinks[t];r.node.updateReference(r.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}}),qn=Pe.extend(function(){return{nodes:[]}},{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){typeof e=="string"&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t<this.nodes.length;t++)if(this.nodes[t].name===e)return this.nodes[t]},update:function(){for(var e=0;e<this.nodes.length;e++)this.nodes[e].clear();for(var e=0;e<this.nodes.length;e++){var t=this.nodes[e];if(t.inputs){for(var r in t.inputs)if(t.inputs[r]){if(t.pass&&!t.pass.material.isUniformEnabled(r)){console.warn("Pin "+t.name+"."+r+" not used.");continue}var i=t.inputs[r],n=this.findPin(i);n?t.link(r,n.node,n.pin):console.warn(typeof i=="string"?"Node "+i+" not exist":"Pin of "+i.node+"."+i.pin+" not exist")}}}},findPin:function(e){var t;if((typeof e=="string"||e instanceof yr)&&(e={node:e}),typeof e.node=="string")for(var r=0;r<this.nodes.length;r++){var i=this.nodes[r];i.name===e.node&&(t=i)}else t=e.node;if(t){var n=e.pin;if(n||t.outputs&&(n=Object.keys(t.outputs)[0]),t.outputs[n])return{node:t,pin:n}}}}),Au=qn.extend(function(){return{_outputs:[],_texturePool:new Vr,_frameBuffer:new ye({depthBuffer:!1})}},{addNode:function(e){qn.prototype.addNode.call(this,e),e._compositor=this},render:function(e,t){if(this._dirty){this.update(),this._dirty=!1,this._outputs.length=0;for(var r=0;r<this.nodes.length;r++)this.nodes[r].outputs||this._outputs.push(this.nodes[r])}for(var r=0;r<this.nodes.length;r++)this.nodes[r].beforeFrame();for(var r=0;r<this._outputs.length;r++)this._outputs[r].updateReference();for(var r=0;r<this._outputs.length;r++)this._outputs[r].render(e,t);for(var r=0;r<this.nodes.length;r++)this.nodes[r].afterFrame()},allocateTexture:function(e){return this._texturePool.get(e)},releaseTexture:function(e){this._texturePool.put(e)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(e){this._texturePool.clear(e)}}),Cu=yr.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},function(){this.frameBuffer=new ye},{render:function(e){this._rendering=!0;var t=e.gl;this.trigger("beforerender");var r;if(!this.outputs)r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);else{var i=this.frameBuffer;for(var n in this.outputs){var a=this.updateParameter(n,e),s=this.outputs[n],o=this._compositor.allocateTexture(a);this._outputTextures[n]=o;var l=s.attachment||t.COLOR_ATTACHMENT0;typeof l=="string"&&(l=t[l]),i.attach(o,l)}i.bind(e);var u=e.getGLExtension("EXT_draw_buffers");if(u){var h=[];for(var l in this.outputs)l=parseInt(l),l>=t.COLOR_ATTACHMENT0&&l<=t.COLOR_ATTACHMENT0+8&&h.push(l);u.drawBuffersEXT(h)}e.saveClear(),e.clearBit=b.DEPTH_BUFFER_BIT|b.COLOR_BUFFER_BIT,r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),i.unbind(e)}this.trigger("afterrender",r),this._rendering=!1,this._rendered=!0}}),Mu=yr.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),Pu=yr.extend(function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},function(){var e=new De({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var r=e.gl;for(var i in this.inputLinks){var n=this.inputLinks[i],a=n.node.getOutput(e,n.pin);this.pass.setUniform(i,a)}if(!this.outputs)this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);else{this.pass.outputs={};var s={};for(var o in this.outputs){var l=this.updateParameter(o,e);isNaN(l.width)&&this.updateParameter(o,e);var u=this.outputs[o],h=this._compositor.allocateTexture(l);this._outputTextures[o]=h;var c=u.attachment||r.COLOR_ATTACHMENT0;typeof c=="string"&&(c=r[c]),s[c]=h}this._compositor.getFrameBuffer().bind(e);for(var c in s)this._compositor.getFrameBuffer().attach(s[c],c);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}for(var i in this.inputLinks){var n=this.inputLinks[i];n.node.removeReference(n.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var r=this.outputs[e],i=r.parameters,n=r._parametersCopy;if(n||(n=r._parametersCopy={}),i)for(var a in i)a!=="width"&&a!=="height"&&(n[a]=i[a]);var s,o;return typeof i.width=="function"?s=i.width.call(this,t):s=i.width,typeof i.height=="function"?o=i.height.call(this,t):o=i.height,s=Math.ceil(s),o=Math.ceil(o),(n.width!==s||n.height!==o)&&this._outputTextures[e]&&this._outputTextures[e].dispose(t),n.width=s,n.height=o,n},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){if(this._outputReferences[e]--,this._outputReferences[e]===0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}},clear:function(){yr.prototype.clear.call(this),this.pass.material.disableTexturesAll()}});const Ru="@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",Oa="@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",Lu="@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",Ia="\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",Nu="@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",Fa="@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",Ba="@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",Ua="@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",Ha="\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",za="@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",Du="@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",Ga="@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",ka="@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 Ou(e){e.import(Ru),e.import(Oa),e.import(Lu),e.import(Ia),e.import(Nu),e.import(Fa),e.import(Ba),e.import(Ua),e.import(Ha),e.import(za),e.import(Du),e.import(Ga),e.import(ka)}Ou(F);var Iu=/^#source\((.*?)\)/;function Fu(e,t){var r=new Au;t=t||{};var i={textures:{},parameters:{}},n=function(o,l){for(var u=0;u<e.nodes.length;u++){var h=e.nodes[u],c=Bu(h,i,t);c&&r.addNode(c)}};for(var a in e.parameters){var s=e.parameters[a];i.parameters[a]=tn(s)}return zu(e,i,t,function(o){i.textures=o,n()}),r}function Bu(e,t,r){var i=e.type||"filter",n,a,s;if(i==="filter"){var o=e.shader.trim(),l=Iu.exec(o);if(l?n=F.source(l[1].trim()):o.charAt(0)==="#"&&(n=t.shaders[o.substr(1)]),n||(n=o),!n)return}if(e.inputs){a={};for(var u in e.inputs)typeof e.inputs[u]=="string"?a[u]=e.inputs[u]:a[u]={node:e.inputs[u].node,pin:e.inputs[u].pin}}if(e.outputs){s={};for(var u in e.outputs){var h=e.outputs[u];s[u]={},h.attachment!=null&&(s[u].attachment=h.attachment),h.keepLastFrame!=null&&(s[u].keepLastFrame=h.keepLastFrame),h.outputLastFrame!=null&&(s[u].outputLastFrame=h.outputLastFrame),h.parameters&&(s[u].parameters=tn(h.parameters))}}var c;if(i==="scene"?c=new Cu({name:e.name,scene:r.scene,camera:r.camera,outputs:s}):i==="texture"?c=new Mu({name:e.name,outputs:s}):c=new Pu({name:e.name,shader:n,inputs:a,outputs:s}),c){if(e.parameters)for(var u in e.parameters){var d=e.parameters[u];typeof d=="string"?(d=d.trim(),d.charAt(0)==="#"?d=t.textures[d.substr(1)]:c.on("beforerender",Gu(u,Va(d)))):typeof d=="function"&&c.on("beforerender",d),c.setParameter(u,d)}if(e.defines&&c.pass)for(var u in e.defines){var d=e.defines[u];c.pass.material.define("fragment",u,d)}}return c}function Uu(e,t){return e}function Hu(e,t){return t}function tn(e){var t={};if(!e)return t;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach(function(i){var n=e[i];n!=null&&(typeof n=="string"&&(n=L[n]),t[i]=n)});var r=e.scale||1;return["width","height"].forEach(function(i){if(e[i]!=null){var n=e[i];typeof n=="string"?(n=n.trim(),t[i]=ku(i,Va(n),r)):t[i]=n}}),t.width||(t.width=Uu),t.height||(t.height=Hu),e.useMipmap!=null&&(t.useMipmap=e.useMipmap),t}function zu(e,t,r,i){if(!e.textures){i({});return}var n={},a=0,s=!1,o=r.textureRootPath;me.each(e.textures,function(l,u){var h,c=l.path,d=tn(l.parameters);if(Array.isArray(c)&&c.length===6)o&&(c=c.map(function(f){return me.relative2absolute(f,o)})),h=new Nt(d);else if(typeof c=="string")o&&(c=me.relative2absolute(c,o)),h=new Q(d);else return;h.load(c),a++,h.once("success",function(){n[u]=h,a--,a===0&&(i(n),s=!0)})}),a===0&&!s&&i(n)}function Gu(e,t){return function(r){var i=r.getDevicePixelRatio(),n=r.getWidth(),a=r.getHeight(),s=t(n,a,i);this.setParameter(e,s)}}function ku(e,t,r){return r=r||1,function(i){var n=i.getDevicePixelRatio(),a=i.getWidth()*r,s=i.getHeight()*r;return t(a,s,n)}}function Va(e){var t=/^expr\((.*)\)$/.exec(e);if(t)try{var r=new Function("width","height","dpr","return "+t[1]);return r(1,1),r}catch{throw new Error("Invalid expression.")}}function Qt(e,t){for(var r=0,i=1/t,n=e;n>0;)r=r+i*(n%t),n=Math.floor(n/t),i=i/t;return r}const Vu="@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n";F.import(Vu);function Wa(e){for(var t=new Uint8Array(e*e*4),r=0,i=new w,n=0;n<e;n++)for(var a=0;a<e;a++)i.set(Math.random()*2-1,Math.random()*2-1,0).normalize(),t[r++]=(i.x*.5+.5)*255,t[r++]=(i.y*.5+.5)*255,t[r++]=0,t[r++]=255;return t}function Yn(e){return new Q({pixels:Wa(e),wrapS:L.REPEAT,wrapT:L.REPEAT,width:e,height:e})}function Wu(e,t,r){var i=new Float32Array(e*3);t=t||0;for(var n=0;n<e;n++){var a=Qt(n+t,2)*(r?1:2)*Math.PI,s=Qt(n+t,3)*Math.PI,o=Math.random(),l=Math.cos(a)*Math.sin(s)*o,u=Math.cos(s)*o,h=Math.sin(a)*Math.sin(s)*o;i[n*3]=l,i[n*3+1]=u,i[n*3+2]=h}return i}function pt(e){e=e||{},this._ssaoPass=new De({fragment:F.source("ecgl.ssao.estimate")}),this._blurPass=new De({fragment:F.source("ecgl.ssao.blur")}),this._framebuffer=new ye({depthBuffer:!1}),this._ssaoTexture=new Q,this._blurTexture=new Q,this._blurTexture2=new Q,this._depthTex=e.depthTexture,this._normalTex=e.normalTexture,this.setNoiseSize(4),this.setKernelSize(e.kernelSize||12),e.radius!=null&&this.setParameter("radius",e.radius),e.power!=null&&this.setParameter("power",e.power),this._normalTex||(this._ssaoPass.material.disableTexture("normalTex"),this._blurPass.material.disableTexture("normalTex")),this._depthTex||this._blurPass.material.disableTexture("depthTex"),this._blurPass.material.setUniform("normalTex",this._normalTex),this._blurPass.material.setUniform("depthTex",this._depthTex)}pt.prototype.setDepthTexture=function(e){this._depthTex=e};pt.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)};pt.prototype.update=function(e,t,r){var i=e.getWidth(),n=e.getHeight(),a=this._ssaoPass,s=this._blurPass;a.setUniform("kernel",this._kernels[r%this._kernels.length]),a.setUniform("depthTex",this._depthTex),this._normalTex!=null&&a.setUniform("normalTex",this._normalTex),a.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var o=new I;I.transpose(o,t.worldTransform),a.setUniform("projection",t.projectionMatrix.array),a.setUniform("projectionInv",t.invProjectionMatrix.array),a.setUniform("viewInverseTranspose",o.array);var l=this._ssaoTexture,u=this._blurTexture,h=this._blurTexture2;l.width=i/2,l.height=n/2,u.width=i,u.height=n,h.width=i,h.height=n,this._framebuffer.attach(l),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),a.render(e),s.setUniform("textureSize",[i/2,n/2]),s.setUniform("projection",t.projectionMatrix.array),this._framebuffer.attach(u),s.setUniform("direction",0),s.setUniform("ssaoTexture",l),s.render(e),this._framebuffer.attach(h),s.setUniform("textureSize",[i,n]),s.setUniform("direction",1),s.setUniform("ssaoTexture",u),s.render(e),this._framebuffer.unbind(e);var c=e.clearColor;e.gl.clearColor(c[0],c[1],c[2],c[3])};pt.prototype.getTargetTexture=function(){return this._blurTexture2};pt.prototype.setParameter=function(e,t){e==="noiseTexSize"?this.setNoiseSize(t):e==="kernelSize"?this.setKernelSize(t):e==="intensity"?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)};pt.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=Wu(e,t*e,!!this._normalTex)};pt.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=Wa(e),t.width=t.height=e,t.dirty()):(t=Yn(e),this._ssaoPass.setUniform("noiseTex",Yn(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])};pt.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e),this._blurTexture2.dispose(e)};const Xu="@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";F.import(Xu);function mt(e){e=e||{},this._ssrPass=new De({fragment:F.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new De({fragment:F.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new De({fragment:F.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new De({fragment:F.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",e.normalTexture),this._ssrPass.setUniform("gBufferTexture2",e.depthTexture),this._blurPass1.setUniform("gBufferTexture1",e.normalTexture),this._blurPass1.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.setUniform("gBufferTexture1",e.normalTexture),this._blurPass2.setUniform("gBufferTexture2",e.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new Q({type:L.HALF_FLOAT}),this._texture2=new Q({type:L.HALF_FLOAT}),this._texture3=new Q({type:L.HALF_FLOAT}),this._prevTexture=new Q({type:L.HALF_FLOAT}),this._currentTexture=new Q({type:L.HALF_FLOAT}),this._frameBuffer=new ye({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}mt.prototype.setAmbientCubemap=function(e,t){this._ssrPass.material.set("specularCubemap",e),this._ssrPass.material.set("specularIntensity",t);var r=e&&t;this._ssrPass.material[r?"enableTexture":"disableTexture"]("specularCubemap")};mt.prototype.update=function(e,t,r,i){var n=e.getWidth(),a=e.getHeight(),s=this._ssrTexture,o=this._texture2,l=this._texture3;s.width=this._prevTexture.width=this._currentTexture.width=n/this._downScale,s.height=this._prevTexture.height=this._currentTexture.height=a/this._downScale,o.width=l.width=n,o.height=l.height=a;var u=this._frameBuffer,h=this._ssrPass,c=this._blurPass1,d=this._blurPass2,f=this._blendPass,v=new I,p=new I;I.transpose(v,t.worldTransform),I.transpose(p,t.viewMatrix),h.setUniform("sourceTexture",r),h.setUniform("projection",t.projectionMatrix.array),h.setUniform("projectionInv",t.invProjectionMatrix.array),h.setUniform("toViewSpace",v.array),h.setUniform("toWorldSpace",p.array),h.setUniform("nearZ",t.near);var m=i/this._totalSamples*this._samplePerFrame;if(h.setUniform("jitterOffset",m),h.setUniform("sampleOffset",i*this._samplePerFrame),c.setUniform("textureSize",[s.width,s.height]),d.setUniform("textureSize",[n,a]),d.setUniform("sourceTexture",r),c.setUniform("projection",t.projectionMatrix.array),d.setUniform("projection",t.projectionMatrix.array),u.attach(s),u.bind(e),h.render(e),this._physicallyCorrect&&(u.attach(this._currentTexture),f.setUniform("texture1",this._prevTexture),f.setUniform("texture2",s),f.material.set({weight1:i>=1?.95:0,weight2:i>=1?.05:1}),f.render(e)),u.attach(o),c.setUniform("texture",this._physicallyCorrect?this._currentTexture:s),c.render(e),u.attach(l),d.setUniform("texture",o),d.render(e),u.unbind(e),this._physicallyCorrect){var g=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=g}};mt.prototype.getTargetTexture=function(){return this._texture3};mt.prototype.setParameter=function(e,t){e==="maxIteration"?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)};mt.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=it.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e};mt.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")};mt.prototype.isFinished=function(e){return this._physicallyCorrect?e>this._totalSamples/this._samplePerFrame:!0};mt.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)};const Zn=[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],ju="@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";F.import(ju);function Ti(e,t,r,i,n){var a=e.gl;t.setUniform(a,"1i",r,n),a.activeTexture(a.TEXTURE0+n),i.isRenderable()?i.bind(e):i.unbind(e)}function qu(e,t,r,i,n){var a,s,o,l,u=e.gl;return function(h,c,d){if(!(l&&l.material===h.material)){var f=h.material,v=h.__program,p=f.get("roughness");p==null&&(p=1);var m=f.get("normalMap")||t,g=f.get("roughnessMap"),T=f.get("bumpMap"),y=f.get("uvRepeat"),x=f.get("uvOffset"),E=f.get("detailUvRepeat"),S=f.get("detailUvOffset"),O=!!T&&f.isTextureEnabled("bumpMap"),P=!!g&&f.isTextureEnabled("roughnessMap"),B=f.isDefined("fragment","DOUBLE_SIDED");T=T||r,g=g||i,d!==c?(c.set("normalMap",m),c.set("bumpMap",T),c.set("roughnessMap",g),c.set("useBumpMap",O),c.set("useRoughnessMap",P),c.set("doubleSide",B),y!=null&&c.set("uvRepeat",y),x!=null&&c.set("uvOffset",x),E!=null&&c.set("detailUvRepeat",E),S!=null&&c.set("detailUvOffset",S),c.set("roughness",p)):(v.setUniform(u,"1f","roughness",p),a!==m&&Ti(e,v,"normalMap",m,0),s!==T&&T&&Ti(e,v,"bumpMap",T,1),o!==g&&g&&Ti(e,v,"roughnessMap",g,2),y!=null&&v.setUniform(u,"2f","uvRepeat",y),x!=null&&v.setUniform(u,"2f","uvOffset",x),E!=null&&v.setUniform(u,"2f","detailUvRepeat",E),S!=null&&v.setUniform(u,"2f","detailUvOffset",S),v.setUniform(u,"1i","useBumpMap",+O),v.setUniform(u,"1i","useRoughnessMap",+P),v.setUniform(u,"1i","doubleSide",+B)),a=m,s=T,o=g,l=h}}}function Jt(e){this._depthTex=new Q({format:L.DEPTH_COMPONENT,type:L.UNSIGNED_INT}),this._normalTex=new Q({type:L.HALF_FLOAT}),this._framebuffer=new ye,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,ye.DEPTH_ATTACHMENT),this._normalMaterial=new vt({shader:new F(F.source("ecgl.normal.vertex"),F.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=rt.createBlank("#000"),this._defaultBumpMap=rt.createBlank("#000"),this._defaultRoughessMap=rt.createBlank("#000"),this._debugPass=new De({fragment:F.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}Jt.prototype.getDepthTexture=function(){return this._depthTex};Jt.prototype.getNormalTexture=function(){return this._normalTex};Jt.prototype.update=function(e,t,r){var i=e.getWidth(),n=e.getHeight(),a=this._depthTex,s=this._normalTex,o=this._normalMaterial;a.width=i,a.height=n,s.width=i,s.height=n;var l=t.getRenderList(r).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,r,{getMaterial:function(){return o},ifRender:function(u){return u.renderNormal},beforeRender:qu(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)};Jt.prototype.renderDebug=function(e){this._debugPass.render(e)};Jt.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)};function wr(e){e=e||{},this._edgePass=new De({fragment:F.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new Q({type:L.HALF_FLOAT}),this._frameBuffer=new ye,this._frameBuffer.attach(this._targetTexture)}wr.prototype.update=function(e,t,r,i){var n=e.getWidth(),a=e.getHeight(),s=this._targetTexture;s.width=n,s.height=a;var o=this._frameBuffer;o.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[n,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(e),o.unbind(e)};wr.prototype.getTargetTexture=function(){return this._targetTexture};wr.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)};wr.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};const Yu={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"}}]},Zu="@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",$u="@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";F.import(Oa);F.import(Ia);F.import(Fa);F.import(Ba);F.import(Ua);F.import(Ha);F.import(za);F.import(Ga);F.import(ka);F.import(Zu);F.import($u);function Xa(e,t){return{color:{parameters:{width:e,height:t}}}}var rn=["composite","FXAA"];function Z(){this._width,this._height,this._dpr,this._sourceTexture=new Q({type:L.HALF_FLOAT}),this._depthTexture=new Q({format:L.DEPTH_COMPONENT,type:L.UNSIGNED_INT}),this._framebuffer=new ye,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,ye.DEPTH_ATTACHMENT),this._normalPass=new Jt,this._compositor=Fu(Yu);var e=this._compositor.getNodeByName("source");e.texture=this._sourceTexture;var t=this._compositor.getNodeByName("coc");this._sourceNode=e,this._cocNode=t,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map(function(i){return this._compositor.getNodeByName(i)},this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=rn.map(function(i){return this._compositor.getNodeByName(i)},this);var r={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new pt(r),this._ssrPass=new mt(r),this._edgePass=new wr(r)}Z.prototype.resize=function(i,n,r){r=r||1;var i=i*r,n=n*r,a=this._sourceTexture,s=this._depthTexture;a.width=i,a.height=n,s.width=i,s.height=n;var o={getWidth:function(){return i},getHeight:function(){return n},getDevicePixelRatio:function(){return r}};function l(u,h){if(typeof u[h]=="function"){var c=u[h].__original||u[h];u[h]=function(d){return c.call(this,o)},u[h].__original=c}}this._compositor.nodes.forEach(function(u){for(var h in u.outputs){var c=u.outputs[h].parameters;c&&(l(c,"width"),l(c,"height"))}for(var d in u.parameters)l(u.parameters,d)}),this._width=i,this._height=n,this._dpr=r};Z.prototype.getWidth=function(){return this._width};Z.prototype.getHeight=function(){return this._height};Z.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR};Z.prototype._getPrevNode=function(e){for(var t=rn.indexOf(e.name)-1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t-=1,r=this._finalNodesChain[t];return r};Z.prototype._getNextNode=function(e){for(var t=rn.indexOf(e.name)+1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t+=1,r=this._finalNodesChain[t];return r};Z.prototype._addChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(e.inputs.texture=t.name,r?(e.outputs=Xa(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))};Z.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(r?(t.outputs=Xa(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))};Z.prototype.updateNormal=function(e,t,r,i){this._ifRenderNormalPass()&&this._normalPass.update(e,t,r)};Z.prototype.updateSSAO=function(e,t,r,i){this._ssaoPass.update(e,r,i)};Z.prototype.enableSSAO=function(){this._enableSSAO=!0};Z.prototype.disableSSAO=function(){this._enableSSAO=!1};Z.prototype.enableSSR=function(){this._enableSSR=!0};Z.prototype.disableSSR=function(){this._enableSSR=!1};Z.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()};Z.prototype.getSourceFrameBuffer=function(){return this._framebuffer};Z.prototype.getSourceTexture=function(){return this._sourceTexture};Z.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)};Z.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)};Z.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()};Z.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()};Z.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()};Z.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()};Z.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0};Z.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1};Z.prototype.enableEdge=function(){this._enableEdge=!0};Z.prototype.disableEdge=function(){this._enableEdge=!1};Z.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)};Z.prototype.setSSAOParameter=function(e,t){switch(e){case"quality":var r={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",r);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/200);break;case"intensity":this._ssaoPass.setParameter(e,t);break}};Z.prototype.setDOFParameter=function(e,t){switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].setParameter("blurRadius",t);break;case"quality":var i={low:4,medium:8,high:16,ultra:32}[t]||8;this._dofBlurKernelSize=i;for(var r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].pass.material.define("POISSON_KERNEL_SIZE",i);this._dofBlurKernel=new Float32Array(i*2);break}};Z.prototype.setSSRParameter=function(e,t){if(t!=null)switch(e){case"quality":var r={low:10,medium:15,high:30,ultra:80}[t]||20,i={low:32,medium:16,high:8,ultra:4}[t]||16;this._ssrPass.setParameter("maxIteration",r),this._ssrPass.setParameter("pixelStride",i);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-t,1),0));break;case"physical":this.setPhysicallyCorrectSSR(t);break;default:console.warn("Unkown SSR parameter "+e)}};Z.prototype.setPhysicallyCorrectSSR=function(e){this._ssrPass.setPhysicallyCorrect(e)};Z.prototype.setEdgeColor=function(e){var t=M.parseColor(e);this._edgePass.setParameter("edgeColor",t)};Z.prototype.setExposure=function(e){this._compositeNode.setParameter("exposure",Math.pow(2,e))};Z.prototype.setColorLookupTexture=function(e,t){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?e:"none",t,{minFilter:M.Texture.NEAREST,magFilter:M.Texture.NEAREST,flipY:!1})};Z.prototype.setColorCorrection=function(e,t){this._compositeNode.setParameter(e,t)};Z.prototype.isSSREnabled=function(){return this._enableSSR};Z.prototype.composite=function(e,t,r,i,n){var a=this._sourceTexture,s=a;this._enableEdge&&(this._edgePass.update(e,r,a,n),a=s=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(e,r,a,n),s=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=s,this._cocNode.setParameter("depth",this._depthTexture);for(var o=this._dofBlurKernel,l=this._dofBlurKernelSize,u=Math.floor(Zn.length/2/l),h=n%u,c=0;c<l*2;c++)o[c]=Zn[c+h*l*2];for(var c=0;c<this._dofBlurNodes.length;c++)this._dofBlurNodes[c].setParameter("percent",n/30),this._dofBlurNodes[c].setParameter("poissonKernel",o);this._cocNode.setParameter("zNear",r.near),this._cocNode.setParameter("zFar",r.far),this._compositor.render(e,i)};Z.prototype.dispose=function(e){this._sourceTexture.dispose(e),this._depthTexture.dispose(e),this._framebuffer.dispose(e),this._compositor.dispose(e),this._normalPass.dispose(e),this._ssaoPass.dispose(e)};function Fi(e){for(var t=[],r=0;r<30;r++)t.push([Qt(r,2),Qt(r,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new Q,this._sourceFb=new ye,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new Q,this._outputTex=new Q;var i=this._blendPass=new De({fragment:F.source("clay.compositor.blend")});i.material.disableTexturesAll(),i.material.enableTexture(["texture1","texture2"]),this._blendFb=new ye({depthBuffer:!1}),this._outputPass=new De({fragment:F.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(n){n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}}Fi.prototype={constructor:Fi,jitterProjection:function(e,t){var r=e.viewport,i=r.devicePixelRatio||e.getDevicePixelRatio(),n=r.width*i,a=r.height*i,s=this._haltonSequence[this._frame%this._haltonSequence.length],o=new I;o.array[12]=(s[0]*2-1)/n,o.array[13]=(s[1]*2-1)/a,I.mul(t.projectionMatrix,o,t.projectionMatrix),I.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,r){var i=this._blendPass;this._frame===0?(i.setUniform("weight1",0),i.setUniform("weight2",1)):(i.setUniform("weight1",.9),i.setUniform("weight2",.1)),i.setUniform("texture1",this._prevFrameTex),i.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),i.render(e),this._blendFb.unbind(e),r||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}};function fe(e){e=e||"perspective",this.layer=null,this.scene=new xt,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new Z,this._temporalSS=new Fi,this._shadowMapPass=new Qe;for(var t=[],r=0,i=0;i<30;i++){for(var n=[],a=0;a<6;a++)n.push(Qt(r,2)*4-2),n.push(Qt(r,3)*4-2),r++;t.push(n)}this._pcfKernels=t,this.scene.on("beforerender",function(s,o,l){this.needsTemporalSS()&&this._temporalSS.jitterProjection(s,l)},this)}fe.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),e==="perspective"?this.camera instanceof Te||(this.camera=new Te,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof _r||(this.camera=new _r,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3};fe.prototype.setViewport=function(e,t,r,i,n){this.camera instanceof Te&&(this.camera.aspect=r/i),n=n||1,this.viewport.x=e,this.viewport.y=t,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)};fe.prototype.containPoint=function(e,t){var r=this.viewport,i=this.layer.renderer.getHeight();return t=i-t,e>=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var $n=new q;fe.prototype.castRay=function(e,t,r){var i=this.layer.renderer,n=i.viewport;return i.viewport=this.viewport,i.screenToNDC(e,t,$n),this.camera.castRay($n,r),i.viewport=n,r};fe.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t<e.transparent.length;t++){var r=e.transparent[t],i=r.geometry;i.needsSortVerticesProgressively&&i.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),i.needsSortTrianglesProgressively&&i.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()};fe.prototype.render=function(e,t){this._doRender(e,t,this._frame),this._frame++};fe.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively};fe.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return e==="auto"&&(e=this._enablePostEffect),e};fe.prototype.hasDOF=function(){return this._enableDOF};fe.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30};fe.prototype._doRender=function(e,t,r){var i=this.scene,n=this.camera;r=r||0,this._updateTransparent(e,i,n,r),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,i,n,!0)),this._updateShadowPCFKernel(r);var a=e.clearColor;if(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,n),this._compositor.updateNormal(e,i,n,this._temporalSS.getFrame())),this._updateSSAO(e,i,n,this._temporalSS.getFrame()),this._enablePostEffect){var s=this._compositor.getSourceFrameBuffer();s.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(i,n,!0,!0),s.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,i,n,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,i,n,null,0))}else if(this.needsTemporalSS()&&t){var s=this._temporalSS.getSourceFrameBuffer();s.bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(i,n,!0,!0),e.restoreClear(),s.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)}else e.setViewport(this.viewport),e.render(i,n,!0,!0)};fe.prototype._updateTransparent=function(e,t,r,i){for(var n=new w,a=new I,s=r.getWorldPosition(),o=t.getRenderList(r).transparent,l=0;l<o.length;l++){var u=o[l],h=u.geometry;I.invert(a,u.worldTransform),w.transformMat4(n,s,a),h.needsSortTriangles&&h.needsSortTriangles()&&h.doSortTriangles(n,i),h.needsSortVertices&&h.needsSortVertices()&&h.doSortVertices(n,i)}};fe.prototype._updateSSAO=function(e,t,r){var i=this._enableSSAO&&this._enablePostEffect;i&&this._compositor.updateSSAO(e,t,r,this._temporalSS.getFrame());for(var n=t.getRenderList(r),a=0;a<n.opaque.length;a++){var s=n.opaque[a];s.renderNormal&&s.material[i?"enableTexture":"disableTexture"]("ssaoMap"),i&&s.material.set("ssaoMap",this._compositor.getSSAOTexture())}};fe.prototype._updateShadowPCFKernel=function(e){for(var t=this._pcfKernels[e%this._pcfKernels.length],r=this.scene.getRenderList(this.camera),i=r.opaque,n=0;n<i.length;n++)i[n].receiveShadow&&(i[n].material.set("pcfKernel",t),i[n].material.define("fragment","PCF_KERNEL_SIZE",t.length/2))};fe.prototype.dispose=function(e){this._compositor.dispose(e.gl),this._temporalSS.dispose(e.gl),this._shadowMapPass.dispose(e)};fe.prototype.setPostEffect=function(e,t){var r=this._compositor;this._enablePostEffect=e.get("enable");var i=e.getModel("bloom"),n=e.getModel("edge"),a=e.getModel("DOF",e.getModel("depthOfField")),s=e.getModel("SSAO",e.getModel("screenSpaceAmbientOcclusion")),o=e.getModel("SSR",e.getModel("screenSpaceReflection")),l=e.getModel("FXAA"),u=e.getModel("colorCorrection");i.get("enable")?r.enableBloom():r.disableBloom(),a.get("enable")?r.enableDOF():r.disableDOF(),o.get("enable")?r.enableSSR():r.disableSSR(),u.get("enable")?r.enableColorCorrection():r.disableColorCorrection(),n.get("enable")?r.enableEdge():r.disableEdge(),l.get("enable")?r.enableFXAA():r.disableFXAA(),this._enableDOF=a.get("enable"),this._enableSSAO=s.get("enable"),this._enableSSAO?r.enableSSAO():r.disableSSAO(),r.setBloomIntensity(i.get("intensity")),r.setEdgeColor(n.get("color")),r.setColorLookupTexture(u.get("lookupTexture"),t),r.setExposure(u.get("exposure")),["radius","quality","intensity"].forEach(function(h){r.setSSAOParameter(h,s.get(h))}),["quality","maxRoughness","physical"].forEach(function(h){r.setSSRParameter(h,o.get(h))}),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach(function(h){r.setDOFParameter(h,a.get(h))}),["brightness","contrast","saturation"].forEach(function(h){r.setColorCorrection(h,u.get(h))})};fe.prototype.setDOFFocusOnPoint=function(e){if(this._enablePostEffect)return e>this.camera.far||e<this.camera.near?void 0:(this._compositor.setDOFParameter("focalDistance",e),!0)};fe.prototype.setTemporalSuperSampling=function(e){this._enableTemporalSS=e.get("enable")};fe.prototype.isLinearSpace=function(){return this._enablePostEffect};fe.prototype.setRootNode=function(e){if(this.rootNode!==e){for(var t=this.rootNode.children(),r=0;r<t.length;r++)e.add(t[r]);e!==this.scene&&this.scene.add(e),this.rootNode=e}};fe.prototype.add=function(e){this.rootNode.add(e)};fe.prototype.remove=function(e){this.rootNode.remove(e)};fe.prototype.removeAll=function(e){this.rootNode.removeAll(e)};Object.assign(fe.prototype,Yi);function Ku(e,t){var r=e.getBoxLayoutParams(),i=As(r,{width:t.getWidth(),height:t.getHeight()});i.y=t.getHeight()-i.y-i.height,this.viewGL.setViewport(i.x,i.y,i.width,i.height,t.getDevicePixelRatio());var n=e.get("boxWidth"),a=e.get("boxHeight"),s=e.get("boxDepth");this.getAxis("x").setExtent(-n/2,n/2),this.getAxis("y").setExtent(s/2,-s/2),this.getAxis("z").setExtent(-a/2,a/2),this.size=[n,a,s]}function Qu(e,t){var r={};function i(n,a){r[n]=r[n]||[1/0,-1/0],r[n][0]=Math.min(a[0],r[n][0]),r[n][1]=Math.max(a[1],r[n][1])}e.eachSeries(function(n){if(n.coordinateSystem===this){var a=n.getData();["x","y","z"].forEach(function(s){a.mapDimensionsAll(s,!0).forEach(function(o){i(s,a.getDataExtent(o,!0))})})}},this),["xAxis3D","yAxis3D","zAxis3D"].forEach(function(n){e.eachComponent(n,function(a){var s=n.charAt(0),o=a.getReferringComponents("grid3D").models[0],l=o.coordinateSystem;if(l===this){var u=l.getAxis(s);if(!u){var h=Cs(r[s]||[1/0,-1/0],a);u=new kr(s,h),u.type=a.get("type");var c=u.type==="category";u.onBand=c&&a.get("boundaryGap"),u.inverse=a.get("inverse"),a.axis=u,u.model=a,u.getLabelModel=function(){return a.getModel("axisLabel",o.getModel("axisLabel"))},u.getTickModel=function(){return a.getModel("axisTick",o.getModel("axisTick"))},l.addAxis(u)}}},this)},this),this.resize(this.model,t)}var Ju={dimensions:gr.prototype.dimensions,create:function(e,t){var r=[];e.eachComponent("grid3D",function(a){a.__viewGL=a.__viewGL||new fe;var s=new gr;s.model=a,s.viewGL=a.__viewGL,a.coordinateSystem=s,r.push(s),s.resize=Ku,s.update=Qu});var i=["xAxis3D","yAxis3D","zAxis3D"];function n(a,s){return i.map(function(o){var l=a.getReferringComponents(o).models[0];return l==null&&(l=s.getComponent(o)),l})}return e.eachSeries(function(a){if(a.get("coordinateSystem")==="cartesian3D"){var s=a.getReferringComponents("grid3D").models[0];if(s==null){var o=n(a,e),s=o[0].getCoordSysModel();o.forEach(function(h){h.getCoordSysModel()})}var l=s.coordinateSystem;a.coordinateSystem=l}}),r}},ja=sa.extend({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});Ms(ja);var qa={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},eh=ht({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},qa),nn=ht({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},qa),th=xr({scale:!0,min:"dataMin",max:"dataMax"},nn),Ya=xr({logBase:10},nn);Ya.scale=!0;const rh={categoryAxis3D:eh,valueAxis3D:nn,timeAxis3D:th,logAxis3D:Ya};var ih=["value","category","time","log"];function nh(e,t,r,i,n){ih.forEach(function(a){var s=r.extend({type:t+"Axis3D."+a,__ordinalMeta:null,mergeDefaultAndTheme:function(o,l){var u=l.getTheme();ht(o,u.get(a+"Axis3D")),ht(o,this.getDefaultOption()),o.type=i(t,o)},optionUpdated:function(){var o=this.option;o.type==="category"&&(this.__ordinalMeta=Rs.createByAxisModel(this))},getCategories:function(){if(this.option.type==="category")return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:ht(Ps(rh[a+"Axis3D"]),n||{},!0)});e.registerComponentModel(s)}),e.registerSubTypeDefaulter(t+"Axis3D",Ls(i,t))}function ah(e,t){return t.type||(t.data?"category":"value")}function sh(e){e.registerComponentModel($r),e.registerComponentView(wu),e.registerCoordinateSystem("grid3D",Ju),["x","y","z"].forEach(function(t){nh(e,t,ja,ah,{name:t.toUpperCase()});const r=e.ComponentView.extend({type:t+"Axis3D"});e.registerComponentView(r)}),e.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},function(t,r){r.eachComponent({mainType:"grid3D",query:t},function(i){i.setView(t)})}),e.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},function(t,r){}),e.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},function(t,r){})}const oh={defaultOption:{shading:null,realisticMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},lambertMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},colorMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},hatchingMaterial:{textureTiling:1,textureOffset:0,paperColor:"#fff"}}};function wi(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function Za(e,t,r,i,n){var a=r,s=e[t];wi(e,t,i);for(var o=r;o<i;o++)n(e[o],s)<0&&(wi(e,o,a),a++);return wi(e,i,a),a}function Wr(e,t,r,i){if(r<i){var n=Math.floor((r+i)/2),a=Za(e,n,r,i,t);Wr(e,t,r,a-1),Wr(e,t,a+1,i)}}function Xr(){this._parts=[]}Xr.prototype.step=function(e,t,r){var i=e.length;if(r===0){this._parts=[],this._sorted=!1;var n=Math.floor(i/2);this._parts.push({pivot:n,left:0,right:i-1}),this._currentSortPartIdx=0}if(!this._sorted){var a=this._parts;if(a.length===0)return this._sorted=!0,!0;if(a.length<512){for(var s=0;s<a.length;s++)a[s].pivot=Za(e,a[s].pivot,a[s].left,a[s].right,t);for(var o=[],s=0;s<a.length;s++){var l=a[s].left,u=a[s].pivot-1;u>l&&o.push({pivot:Math.floor((u+l)/2),left:l,right:u});var l=a[s].pivot+1,u=a[s].right;u>l&&o.push({pivot:Math.floor((u+l)/2),left:l,right:u})}a=this._parts=o}else for(var s=0;s<Math.floor(a.length/10);s++){var h=a.length-1-this._currentSortPartIdx;if(Wr(e,t,a[h].left,a[h].right),this._currentSortPartIdx++,this._currentSortPartIdx===a.length)return this._sorted=!0,!0}return!1}};Xr.sort=Wr;var jt=Kr.vec3,Kn=jt.create(),Qn=jt.create(),Jn=jt.create();const lh={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(e,t){var r=this.indices;if(t===0){var i=this.attributes.position,e=e.array;(!this._triangleZList||this._triangleZList.length!==this.triangleCount)&&(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new r.constructor(r.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var n=0,a,s=0;s<r.length;){i.get(r[s++],Kn),i.get(r[s++],Qn),i.get(r[s++],Jn);var o=jt.sqrDist(Kn,e),l=jt.sqrDist(Qn,e),u=jt.sqrDist(Jn,e),h=Math.min(o,l);h=Math.min(h,u),s===3?(a=h,h=0):h=h-a,this._triangleZList[n++]=h}}for(var c=this._sortedTriangleIndices,s=0;s<c.length;s++)c[s]=s;if(this.triangleCount<2e4)t===0&&this._simpleSort(!0);else for(var s=0;s<3;s++)this._progressiveQuickSort(t*3+s);for(var d=this._indicesTmp,f=this._triangleZListTmp,v=this._triangleZList,s=0;s<this.triangleCount;s++){var p=c[s]*3,m=s*3;d[m++]=r[p++],d[m++]=r[p++],d[m]=r[p],f[s]=v[c[s]]}var g=this._indicesTmp;this._indicesTmp=this.indices,this.indices=g;var g=this._triangleZListTmp;this._triangleZListTmp=this._triangleZList,this._triangleZList=g,this.dirtyIndices()},_simpleSort:function(e){var t=this._triangleZList,r=this._sortedTriangleIndices;function i(n,a){return t[a]-t[n]}e?Array.prototype.sort.call(r,i):Xr.sort(r,i,0,r.length-1)},_progressiveQuickSort:function(e){var t=this._triangleZList,r=this._sortedTriangleIndices;this._quickSort=this._quickSort||new Xr,this._quickSort.step(r,function(i,n){return t[n]-t[i]},e)}};function Bi(e,t){const r=e.getItemVisual(t,"style");if(r){const i=e.getVisual("drawType");return r[i]}}function ea(e,t){const r=e.getItemVisual(t,"style");return r&&r.opacity}function uh(e,t){var r=[];return hr(e.dimensions,function(i){var n=e.getDimensionInfo(i),a=n.otherDims,s=a[t];s!=null&&s!==!1&&(r[s]=n.name)}),r}function hh(e,t,r){function i(c){var d=[],f=uh(n,"tooltip");f.length?hr(f,function(p){v(n.get(p,t),p)}):hr(c,v);function v(p,m){var g=n.getDimensionInfo(m);if(!(!g||g.otherDims.tooltip===!1)){var T=g.type,y="- "+(g.tooltipName||g.name)+": "+(T==="ordinal"?p+"":T==="time"?Os("yyyy/MM/dd hh:mm:ss",p):sn(p));y&&d.push(br(y))}}return"<br/>"+d.join("<br/>")}var n=e.getData(),a=e.getRawValue(t),s=ur(a)?i(a):br(sn(a)),o=n.getName(t),l=Bi(n,t);Ns(l)&&l.colorStops&&(l=(l.colorStops[0]||{}).color),l=l||"transparent";var u=Ds(l),h=e.name;return h==="\0-"&&(h=""),h=h?br(h)+"<br/>":"",h+u+(o?br(o)+": "+s:s)}function ch(e,t,r){r=r||e.getSource();var i=t||Is(e.get("coordinateSystem"))||["x","y","z"],n=Fs(r,{dimensionsDefine:r.dimensionsDefine||e.get("dimensions"),encodeDefine:r.encodeDefine||e.get("encode"),coordDimensions:i.map(function(o){var l=e.getReferringComponents(o+"Axis3D").models[0];return{type:l&&l.get("type")==="category"?"ordinal":"float",name:o}})});e.get("coordinateSystem")==="cartesian3D"&&n.forEach(function(o){if(i.indexOf(o.coordDim)>=0){var l=e.getReferringComponents(o.coordDim+"Axis3D").models[0];l&&l.get("type")==="category"&&(o.ordinalMeta=l.getOrdinalMeta())}});var a=Bs.enableDataStack(e,n,{byIndex:!0,stackedCoordDimension:"z"}),s=new Us(n,e);return s.setCalculationInfo(a),s.initData(r),s}var $a=Hs.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return hh(this,e)},getInitialData:function(e,t){var r=e.data;function i(Y){return!(isNaN(Y.min)||isNaN(Y.max)||isNaN(Y.step))}function n(Y){var H=oa;return Math.max(H(Y.min),H(Y.max),H(Y.step))+1}if(!r)if(e.parametric){var x=e.parametricEquation||{},E=x.u||{},S=x.v||{};["u","v"].forEach(function(H){i(x[H])}),["x","y","z"].forEach(function(H){x[H]});var O=Math.floor((E.max+E.step-E.min)/E.step),P=Math.floor((S.max+S.step-S.min)/S.step);r=new Float32Array(O*P*5);for(var B=n(E),k=n(S),d=0,f=0;f<P;f++)for(var v=0;v<O;v++){var N=v*E.step+E.min,V=f*S.step+S.min,z=Sr(Math.min(N,E.max),B),U=Sr(Math.min(V,S.max),k),p=x.x(z,U),m=x.y(z,U),y=x.z(z,U);r[d++]=p,r[d++]=m,r[d++]=y,r[d++]=z,r[d++]=U}}else{var a=e.equation||{},s=a.x||{},o=a.y||{};if(["x","y"].forEach(function(Y){i(a[Y])}),typeof a.z!="function")return;var l=Math.floor((s.max+s.step-s.min)/s.step),u=Math.floor((o.max+o.step-o.min)/o.step);r=new Float32Array(l*u*3);for(var h=n(s),c=n(o),d=0,f=0;f<u;f++)for(var v=0;v<l;v++){var p=v*s.step+s.min,m=f*o.step+o.min,g=Sr(Math.min(p,s.max),h),T=Sr(Math.min(m,o.max),c),y=a.z(g,T);r[d++]=g,r[d++]=T,r[d++]=y}}var X=["x","y","z"];e.parametric&&X.push("u","v");var G=ch(this,X,r);return G},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,shading:"lambert",parametric:!1,wireframe:{show:!0,lineStyle:{color:"rgba(0,0,0,0.5)",width:1}},equation:{x:{min:-1,max:1,step:.1},y:{min:-1,max:1,step:.1},z:null},parametricEquation:{u:{min:-1,max:1,step:.1},v:{min:-1,max:1,step:.1},x:null,y:null,z:null},dataShape:null,itemStyle:{},animationDurationUpdate:500}});ht($a.prototype,oh);var Mt=Kr.vec3;function fh(e){return isNaN(e[0])||isNaN(e[1])||isNaN(e[2])}const dh=zs.extend({type:"surface",__ecgl__:!0,init:function(e,t){this.groupGL=new M.Node},render:function(e,t,r){var i=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=i,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var n=e.coordinateSystem,a=e.get("shading"),s=e.getData(),o="ecgl."+a;if((!this._surfaceMesh.material||this._surfaceMesh.material.shader.name!==o)&&(this._surfaceMesh.material=M.createMaterial(o,["VERTEX_COLOR","DOUBLE_SIDED"])),M.setMaterialFromModel(a,this._surfaceMesh.material,e,r),n&&n.viewGL){n.viewGL.add(this.groupGL);var l=n.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var u=e.get("parametric"),h=e.get("dataShape");h||(h=this._getDataShape(s,u));var c=e.getModel("wireframe"),d=c.get("lineStyle.width"),f=c.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,e,h,f);var v=this._surfaceMesh.material;f?(v.define("WIREFRAME_QUAD"),v.set("wireframeLineWidth",d),v.set("wireframeLineColor",M.parseColor(c.get("lineStyle.color")))):v.undefine("WIREFRAME_QUAD"),this._initHandler(e,r),this._updateAnimation(e)},_updateAnimation:function(e){M.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new M.Mesh({geometry:new M.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new M.Material({shader:new M.Shader(M.Shader.source("ecgl.sm.depth.vertex"),M.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),Object.assign(e.geometry,lh),e},_initHandler:function(e,t){var r=e.getData(),i=this._surfaceMesh,n=e.coordinateSystem;function a(o,l){for(var u=1/0,h=-1,c=[],d=0;d<o.length;d++){i.geometry.attributes.position.get(o[d],c);var f=Mt.dist(l.array,c);f<u&&(u=f,h=o[d])}return h}i.seriesIndex=e.seriesIndex;var s=-1;i.off("mousemove"),i.off("mouseout"),i.on("mousemove",function(o){var l=a(o.triangle,o.point);if(l>=0){var u=[];i.geometry.attributes.position.get(l,u);for(var h=n.pointToData(u),c=1/0,d=-1,f=[],v=0;v<r.count();v++){f[0]=r.get("x",v),f[1]=r.get("y",v),f[2]=r.get("z",v);var p=Mt.squaredDistance(f,h);p<c&&(d=v,c=p)}d!==s&&t.dispatchAction({type:"grid3DShowAxisPointer",value:h}),s=d,i.dataIndex=d}else i.dataIndex=-1},this),i.on("mouseout",function(o){s=-1,i.dataIndex=-1,t.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_updateSurfaceMesh:function(e,t,r,i){var n=e.geometry,a=t.getData(),s=a.getLayout("points"),o=0;a.each(function($e){a.hasValue($e)||o++});var l=o||i,u=n.attributes.position,h=n.attributes.normal,c=n.attributes.texcoord0,d=n.attributes.barycentric,f=n.attributes.color,v=r[0],p=r[1],m=t.get("shading"),g=m!=="color";if(l){var T=(v-1)*(p-1)*4;u.init(T),i&&d.init(T)}else u.value=new Float32Array(s);f.init(n.vertexCount),c.init(n.vertexCount);var y=[0,3,1,1,3,2],x=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],E=n.indices=new(n.vertexCount>65535?Uint32Array:Uint16Array)((v-1)*(p-1)*6),S=function($e,It,st){st[1]=$e*p+It,st[0]=$e*p+It+1,st[3]=($e+1)*p+It+1,st[2]=($e+1)*p+It},O=!1;if(l){var P=[],B=[],k=0;g?h.init(n.vertexCount):h.value=null;for(var N=[[],[],[]],V=[],z=[],U=Mt.create(),X=function($e,It,st){var ei=It*3;return st[0]=$e[ei],st[1]=$e[ei+1],st[2]=$e[ei+2],st},G=new Float32Array(s.length),Y=new Float32Array(s.length/3*4),H=0;H<a.count();H++)if(a.hasValue(H)){var Re=M.parseColor(Bi(a,H)),le=ea(a,H);le!=null&&(Re[3]*=le),Re[3]<.99&&(O=!0);for(var j=0;j<4;j++)Y[H*4+j]=Re[j]}for(var ve=[1e7,1e7,1e7],H=0;H<v-1;H++)for(var re=0;re<p-1;re++){var ue=H*(p-1)+re,he=ue*4;S(H,re,P);for(var Ce=!1,j=0;j<4;j++)X(s,P[j],B),fh(B)&&(Ce=!0);for(var j=0;j<4;j++)Ce?u.set(he+j,ve):(X(s,P[j],B),u.set(he+j,B)),i&&d.set(he+j,x[j]);for(var j=0;j<6;j++)E[k++]=y[j]+he;if(g&&!Ce)for(var j=0;j<2;j++){for(var Me=j*3,xe=0;xe<3;xe++){var Le=P[y[Me]+xe];X(s,Le,N[xe])}Mt.sub(V,N[0],N[1]),Mt.sub(z,N[1],N[2]),Mt.cross(U,V,z);for(var xe=0;xe<3;xe++){var He=P[y[Me]+xe]*3;G[He]=G[He]+U[0],G[He+1]=G[He+1]+U[1],G[He+2]=G[He+2]+U[2]}}}if(g)for(var H=0;H<G.length/3;H++)X(G,H,U),Mt.normalize(U,U),G[H*3]=U[0],G[H*3+1]=U[1],G[H*3+2]=U[2];for(var Re=[],Xe=[],H=0;H<v-1;H++)for(var re=0;re<p-1;re++){var ue=H*(p-1)+re,he=ue*4;S(H,re,P);for(var j=0;j<4;j++){for(var xe=0;xe<4;xe++)Re[xe]=Y[P[j]*4+xe];f.set(he+j,Re),g&&(X(G,P[j],U),h.set(he+j,U));var Le=P[j];Xe[0]=Le%p/(p-1),Xe[1]=Math.floor(Le/p)/(v-1),c.set(he+j,Xe)}ue++}}else{for(var Xe=[],H=0;H<a.count();H++){Xe[0]=H%p/(p-1),Xe[1]=Math.floor(H/p)/(v-1);var Re=M.parseColor(Bi(a,H)),le=ea(a,H);le!=null&&(Re[3]*=le),Re[3]<.99&&(O=!0),f.set(H,Re),c.set(H,Xe)}for(var P=[],Ka=0,H=0;H<v-1;H++)for(var re=0;re<p-1;re++){S(H,re,P);for(var j=0;j<6;j++)E[Ka++]=P[y[j]]}g?n.generateVertexNormals():h.value=null}e.material.get("normalMap")&&n.generateTangents(),n.updateBoundingBox(),n.dirty(),e.material.transparent=O,e.material.depthMask=!O},_getDataShape:function(e,t){for(var r=-1/0,i=0,n=0,a=!1,s=t?"u":"x",o=e.count(),l=0;l<o;l++){var u=e.get(s,l);u<r&&(n=0,i++),r=u,n++}if((!i||n===1)&&(a=!0),!a)return[i+1,n];for(var h=Math.floor(Math.sqrt(o));h>0;){if(Math.floor(o/h)===o/h)return[h,o/h];h--}return h=Math.floor(Math.sqrt(o)),[h,h]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function vh(e){e.registerChartView(dh),e.registerSeriesModel($a),e.registerLayout(function(t,r){t.eachSeriesByType("surface",function(i){var n=i.coordinateSystem;!n||n.type;var a=i.getData(),s=new Float32Array(3*a.count()),o=[NaN,NaN,NaN];if(n&&n.type==="cartesian3D"){var l=n.dimensions,u=l.map(function(h){return i.coordDimToDataDim(h)[0]});a.each(u,function(h,c,d,f){var v;a.hasValue(f)?v=n.dataToPoint([h,c,d]):v=o,s[f*3]=v[0],s[f*3+1]=v[1],s[f*3+2]=v[2]})}a.setLayout("points",s)})})}var ph=Object.defineProperty,mh=Object.getOwnPropertyDescriptor,Tt=(e,t,r,i)=>{for(var n=i>1?void 0:i?mh(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=(i?s(t,r,n):s(n))||n);return i&&n&&ph(t,r,n),n};Gs([ks,Vs,sh,vh]);let nt=class extends ct(ft,dr,rs){get chart(){var e,t;return(t=(e=this.heightmap)==null?void 0:e.chart)!=null?t:null}get chartOptions(){return{tooltip:{backgroundColor:this.bgColor(.9),borderWidth:0,textStyle:{color:this.fgColor(1),fontSize:"14px"},padding:15,formatter:this.tooltipFormatter},darkMode:this.$vuetify.theme.dark,animation:!1,legend:{show:!1,selected:this.selected},visualMap:{show:!0,min:this.visualMapRange[0],max:this.visualMapRange[1],calculable:!0,dimension:2,inRange:{color:this.colorMap},seriesIndex:this.visualMapSeriesIndex,left:this.isMobile?10:30,top:20,bottom:0,itemWidth:this.isMobile?10:30,itemHeight:550,precision:3,textStyle:{color:this.fgColorHi,fontSize:14}},xAxis3D:{type:"value",nameTextStyle:{color:this.fgColorMid},min:this.rangeX[0],max:this.rangeX[1],minInterval:1},yAxis3D:{type:"value",nameTextStyle:{color:this.fgColorMid},min:this.rangeY[0],max:this.rangeY[1]},zAxis3D:{type:"value",min:this.scaleZMax*-1,max:this.scaleZMax,nameTextStyle:{color:this.fgColorMid},axisPointer:{label:{formatter:function(e){return e=parseFloat(e),e.toFixed(2)}}}},grid3D:{axisLabel:{textStyle:{color:this.fgColorMid}},axisLine:{lineStyle:{color:this.fgColorLow}},axisTick:{lineStyle:{color:this.fgColorLow}},splitLine:{lineStyle:{color:this.fgColorLow}},axisPointer:{lineStyle:{color:this.fgColorHi},label:{textStyle:{color:this.fgColorHi}}},boxWidth:100*this.scaleX,boxDepth:100*this.scaleY,viewControl:{distance:200,...this.defaultOrientation}},series:this.series}}get selected(){return{probed:this.showProbed,mesh:this.showMesh,flat:this.showFlat}}get series(){const e=[];return this.bed_mesh&&(e.push(this.seriesProbed),e.push(this.seriesMesh),e.push(this.seriesFlat)),e}get seriesProbed(){const e={type:"surface",name:"probed",data:[],itemStyle:{opacity:1},wireframe:{show:this.wireframe}};if(this.bed_mesh){const t=this.bed_mesh.probed_matrix[0].length,r=this.bed_mesh.probed_matrix.length,i=this.bed_mesh.mesh_min[0],n=this.bed_mesh.mesh_max[0],a=this.bed_mesh.mesh_min[1],s=this.bed_mesh.mesh_max[1],o=(n-i)/(t-1),l=(s-a)/(r-1),u=[];let h=0;this.bed_mesh.probed_matrix.forEach(c=>{let d=0;c.forEach(f=>{u.push([i+o*d,a+l*h,f]),d++}),h++}),e.data=u,e.dataShape=[r,t]}return e}get seriesMesh(){const e={type:"surface",name:"mesh",data:[],itemStyle:{opacity:1},wireframe:{show:this.wireframe}};if(this.bed_mesh){const t=this.bed_mesh.mesh_matrix[0].length,r=this.bed_mesh.mesh_matrix.length,i=this.bed_mesh.mesh_min[0],n=this.bed_mesh.mesh_max[0],a=this.bed_mesh.mesh_min[1],s=this.bed_mesh.mesh_max[1],o=(n-i)/(t-1),l=(s-a)/(r-1),u=[];let h=0;this.bed_mesh.mesh_matrix.forEach(c=>{let d=0;c.forEach(f=>{u.push([i+o*d,a+l*h,f]),d++}),h++}),e.data=u,e.dataShape=[r,t]}return e}get seriesFlat(){var r,i,n,a;const e={type:"surface",name:"flat",data:[],itemStyle:{color:[1,1,1,1],opacity:.5},wireframe:{show:this.wireframe}},t=(i=(r=this.$store.state.printer.configfile)==null?void 0:r.settings)==null?void 0:i.bed_mesh;if(t){let s=[1,1];t.probe_count&&typeof t.probe_count=="string"?s=t.probe_count.split(","):t.probe_count?s=t.probe_count.length<2?[t.probe_count,t.probe_count]:t.probe_count:t.round_probe_count&&(s=[t.round_probe_count,t.round_probe_count]);let o=(n=t.mesh_min)!=null?n:[0,0],l=(a=t.mesh_max)!=null?a:[200,200];"mesh_radius"in t&&(o=[t.mesh_radius*-1,t.mesh_radius*-1],l=[t.mesh_radius,t.mesh_radius]);const u=s[0],h=s[1],c=parseFloat(o[0]),d=parseFloat(l[0]),f=parseFloat(o[1]),v=parseFloat(l[1]),p=(d-c)/(u-1),m=(v-f)/(h-1),g=[];for(let T=0;T<h;T++)for(let y=0;y<u;y++)g.push([c+p*y,f+m*T,0]);e.data=g,e.dataShape=[h,u]}return e}get colorMap(){return this.$store.getters["gui/heightmap/getActiveColorSchemeList"]}get visualMapSeriesIndex(){const e=[];return this.showProbed?e.push(0):this.showMesh&&e.push(1),e}get visualMapRange(){return this.scaleGradient?this.heightmapLimit:[-.1,.1]}get heightmapLimit(){let e=0,t=0;if(this.bed_mesh){const r=[];if(this.showProbed)for(const i of this.bed_mesh.probed_matrix)for(const n of i)r.push(n);if(this.showMesh)for(const i of this.bed_mesh.mesh_matrix)for(const n of i)r.push(n);e=Math.min(e,...r),t=Math.max(t,...r)}return[e,t]}get rangeX(){var r,i,n,a;const e=(r=this.$store.state.printer.toolhead)==null?void 0:r.axis_minimum,t=(i=this.$store.state.printer.toolhead)==null?void 0:i.axis_maximum;return[(n=e[0])!=null?n:0,(a=t[0])!=null?a:0]}get rangeY(){var r,i,n,a,s,o;const e=(i=(r=this.$store.state.printer.toolhead)==null?void 0:r.axis_minimum)!=null?i:[0,0],t=(a=(n=this.$store.state.printer.toolhead)==null?void 0:n.axis_maximum)!=null?a:[0,0];return[(s=e[1])!=null?s:0,(o=t[1])!=null?o:0]}get absRangeX(){return this.rangeX[1]-this.rangeX[0]}get absRangeY(){return this.rangeY[1]-this.rangeY[0]}get minRangeXY(){return Math.min(this.absRangeX,this.absRangeY)}get scaleX(){return this.minRangeXY===0?1:this.absRangeX/this.minRangeXY}get scaleY(){return this.minRangeXY===0?1:this.absRangeY/this.minRangeXY}get defaultOrientation(){var t;switch((t=this.$store.state.gui.heightmap.defaultOrientation)!=null?t:"rightFront"){case"leftFront":return{alpha:25,beta:-40};case"front":return{alpha:25,beta:0};case"top":return{alpha:90,beta:0};default:return{alpha:25,beta:40}}}tooltipFormatter(e){const t=[];return t.push("<b>".concat(e.seriesName,"</b>")),Object.keys(e.encode).sort().forEach(r=>{const i=e.data[e.encode[r][0]].toFixed(r==="z"?3:1);t.push("<b>".concat(r.toUpperCase(),"</b>: ").concat(i," mm"))}),t.join("<br />")}beforeDestroy(){typeof window>"u"||this.chart&&this.chart.dispose()}};Tt([ze({type:Boolean,default:!1})],nt.prototype,"showProbed",2);Tt([ze({type:Boolean,default:!1})],nt.prototype,"showMesh",2);Tt([ze({type:Boolean,default:!1})],nt.prototype,"showFlat",2);Tt([ze({type:Boolean,default:!1})],nt.prototype,"wireframe",2);Tt([ze({type:Boolean,default:!1})],nt.prototype,"scaleGradient",2);Tt([ze({type:Number,default:1})],nt.prototype,"scaleZMax",2);Tt([is("heightmap")],nt.prototype,"heightmap",2);nt=Tt([at],nt);var _h=function(){var t=this,r=t._self._c;return t._self._setupProxy,r("e-chart",{ref:"heightmap",staticStyle:{height:"600px",width:"100%",overflow:"hidden"},attrs:{option:t.chartOptions,"init-options":{renderer:"canvas"}}})},gh=[],yh=dt(nt,_h,gh,!1,null,null);const xh=yh.exports;var Th=Object.getOwnPropertyDescriptor,wh=(e,t,r,i)=>{for(var n=i>1?void 0:i?Th(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n};let Ui=class extends ct(ft,ns,dr){constructor(){super(...arguments),this.mdiGrid=jr,this.mdiHome=as,this.calibrateDialog=!1}get showProbed(){var e;return(e=this.$store.state.gui.view.heightmap.probed)!=null?e:!0}set showProbed(e){this.$store.dispatch("gui/saveSetting",{name:"view.heightmap.probed",value:e})}get showMesh(){var e;return(e=this.$store.state.gui.view.heightmap.mesh)!=null?e:!0}set showMesh(e){this.$store.dispatch("gui/saveSetting",{name:"view.heightmap.mesh",value:e})}get showFlat(){var e;return(e=this.$store.state.gui.view.heightmap.flat)!=null?e:!0}set showFlat(e){this.$store.dispatch("gui/saveSetting",{name:"view.heightmap.flat",value:e})}get wireframe(){var e;return(e=this.$store.state.gui.view.heightmap.wireframe)!=null?e:!0}set wireframe(e){this.$store.dispatch("gui/saveSetting",{name:"view.heightmap.wireframe",value:e})}get scaleGradient(){var e;return(e=this.$store.state.gui.view.heightmap.scaleGradient)!=null?e:!1}set scaleGradient(e){this.$store.dispatch("gui/saveSetting",{name:"view.heightmap.scaleGradient",value:e})}get scaleZMax(){var e;return(e=this.$store.state.gui.view.heightmap.scaleZMax)!=null?e:.5}set scaleZMax(e){this.$store.dispatch("gui/saveSetting",{name:"view.heightmap.scaleZMax",value:e})}get heightmapRangeLimit(){const e=Math.round(Math.max(Math.abs(this.min),Math.abs(this.max))*10)/10,t=Math.max(e,1);return[e,t]}homePrinter(){const e="G28";this.$store.dispatch("server/addEvent",{message:e,type:"command"}),this.$socket.emit("printer.gcode.script",{script:e},{loading:"homeAll"})}clearBedMesh(){const e="BED_MESH_CLEAR";this.$store.dispatch("server/addEvent",{message:e,type:"command"}),this.$socket.emit("printer.gcode.script",{script:e},{loading:"bedMeshClear"})}};Ui=wh([at({components:{HeightmapCalibrateMeshDialog:da}})],Ui);var Eh=function(){var t=this,r=t._self._c;return t._self._setupProxy,r(Dt,{attrs:{"card-class":"heightmap-map-panel",title:t.$t("Heightmap.Heightmap"),icon:t.mdiGrid},scopedSlots:t._u([{key:"buttons",fn:function(){return[r(be,{staticClass:"d-none d-sm-flex",attrs:{icon:"",tile:"",disabled:t.printerIsPrinting,color:t.homedAxes.includes("xyz")?"primary":"warning",loading:t.loadings.includes("homeAll"),title:t.$t("Heightmap.TitleHomeAll"),ripple:!0},on:{click:t.homePrinter}},[r(ut,[t._v(t._s(t.mdiHome))])],1),t.is_active?r(be,{staticClass:"d-none d-sm-flex",attrs:{text:"",tile:"",loading:t.loadings.includes("bedMeshClear"),title:t.$t("Heightmap.TitleClear")},on:{click:t.clearBedMesh}},[t._v(" "+t._s(t.$t("Heightmap.Clear"))+" ")]):t._e(),r(be,{staticClass:"d-none d-sm-flex",attrs:{text:"",tile:"",loading:t.loadings.includes("bedMeshCalibrate"),disabled:t.printerIsPrinting,title:t.$t("Heightmap.TitleCalibrate")},on:{click:function(i){t.calibrateDialog=!0}}},[t._v(" "+t._s(t.$t("Heightmap.Calibrate"))+" ")])]},proxy:!0}])},[r(et,{staticClass:"d-sm-none text-center pb-0"},[r(us,{staticClass:"v-btn-toggle",attrs:{tile:"",name:"controllers"}},[r(be,{staticClass:"px-2 minwidth-0",attrs:{text:"",small:"",disabled:t.printerIsPrinting,color:t.homedAxes.includes("xyz")?"primary":"warning",loading:t.loadings.includes("homeAll"),title:t.$t("Heightmap.TitleHomeAll")},on:{click:t.homePrinter}},[r(ut,{attrs:{color:t.homedAxes.includes("xyz")?"primary":"warning",small:""}},[t._v(" "+t._s(t.mdiHome)+" ")])],1),t.bed_mesh?r(be,{staticClass:"px-2 minwidth-0",attrs:{text:"",small:"",color:"primary",loading:t.loadings.includes("bedMeshClear"),title:t.$t("Heightmap.TitleClear")},on:{click:t.clearBedMesh}},[t._v(" "+t._s(t.$t("Heightmap.Clear"))+" ")]):t._e(),r(be,{staticClass:"px-2 minwidth-0",attrs:{text:"",small:"",color:"primary",loading:t.loadings.includes("bedMeshCalibrate"),disabled:t.printerIsPrinting,title:t.$t("Heightmap.TitleCalibrate")},on:{click:function(i){t.calibrateDialog=!0}}},[t._v(" "+t._s(t.$t("Heightmap.Calibrate"))+" ")])],1)],1),t.is_active?[r(et,{staticClass:"py-0 px-0"},[r(Je,[r(_e,{},[r(xh,{attrs:{"show-probed":t.showProbed,"show-mesh":t.showMesh,"show-flat":t.showFlat,wireframe:t.wireframe,"scale-gradient":t.scaleGradient,"scale-z-max":t.scaleZMax}})],1)],1),r(Je,[r(_e,{staticClass:"col-12 col-sm-auto pt-0 pb-0 pl-lg-6 d-flex justify-center justify-sm-start"},[r(hs,{staticClass:"mt-0 ml-5",attrs:{label:t.$t("Heightmap.ScaleGradient")},model:{value:t.scaleGradient,callback:function(i){t.scaleGradient=i},expression:"scaleGradient"}})],1),r(_e,{staticClass:"d-flex justify-center pt-0 pb-6 pb-lg-3"},[r(Er,{staticClass:"mx-3 mt-0",attrs:{label:t.$t("Heightmap.Probed"),"hide-details":""},model:{value:t.showProbed,callback:function(i){t.showProbed=i},expression:"showProbed"}}),r(Er,{staticClass:"mx-3 mt-0",attrs:{label:t.$t("Heightmap.Mesh"),"hide-details":""},model:{value:t.showMesh,callback:function(i){t.showMesh=i},expression:"showMesh"}}),r(Er,{staticClass:"mx-3 mt-0",attrs:{label:t.$t("Heightmap.Flat"),"hide-details":""},model:{value:t.showFlat,callback:function(i){t.showFlat=i},expression:"showFlat"}}),r(Er,{staticClass:"mx-3 mt-0",attrs:{label:t.$t("Heightmap.Wireframe"),"hide-details":""},model:{value:t.wireframe,callback:function(i){t.wireframe=i},expression:"wireframe"}})],1)],1)],1),r(Wt),r(et,{staticClass:"pt-0 pb-3"},[r(Je,[r(_e,[r(cs,{staticClass:"mt-4",attrs:{label:t.$t("Heightmap.ScaleZMax"),min:t.heightmapRangeLimit[0],max:t.heightmapRangeLimit[1],step:.1,ticks:"always","hide-details":""},model:{value:t.scaleZMax,callback:function(i){t.scaleZMax=i},expression:"scaleZMax"}})],1)],1)],1)]:[r(et,{staticClass:"text-center py-3 font-italic"},[t._v(" "+t._s(t.$t("Heightmap.NoBedMeshHasBeenLoadedYet"))+" ")])],r(da,{attrs:{show:t.calibrateDialog},on:{close:function(i){t.calibrateDialog=!1}}})],2)},bh=[],Sh=dt(Ui,Eh,bh,!1,null,null);const Ah=Sh.exports;var Ch=Object.getOwnPropertyDescriptor,Mh=(e,t,r,i)=>{for(var n=i>1?void 0:i?Ch(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(n=s(n)||n);return n};let Hi=class extends ct(ft){constructor(){super(...arguments),this.mdiLockOutline=ss}};Hi=Mh([at({components:{Panel:Dt}})],Hi);var Ph=function(){var t=this,r=t._self._c;return t._self._setupProxy,r("div",[r(Je,[t.klipperReadyForGui?[r(_e,{staticClass:"col-12 col-md-8 pb-0"},[r(Ah)],1),r(_e,{staticClass:"col-12 col-md-4"},[r(yo),r(ho)],1)]:[r(_e,[r(fs,{staticClass:"mx-auto mt-6",attrs:{dense:"",text:"",type:"warning",elevation:"2","max-width":"500",icon:t.mdiLockOutline}},[t._v(" "+t._s(t.$t("Heightmap.ErrorKlipperNotReady"))+" ")])],1)]],2)],1)},Rh=[],Lh=dt(Hi,Ph,Rh,!1,null,null);const Bh=Lh.exports;export{Bh as default};
|