import{m as Et,B as At,a as Xs,C as vt,_ as Wt,b as hi,c as vn,W as za,P as Ke,n as St,d as $s,e as Ga,f as js,g as qs,h as Ys,i as Zs,j as Ks,T as Qs}from"./index-17a5ec1d.js";import{h as fi,f as Pe,c as gt,i as ft,n as Va,o as di,d as vi,l as ht,m as we,r as Js,x as nr,V as eo,B as to,M as ro,p as Ur,A as no,F as io}from"./vuetify-4c65b4c3.js";import{j as Ar,m as Ii,A as ao,L as so,p as ka,R as Wa,k as oo,r as lo,l as Sr,n as co,o as uo,q as ho,s as fo,Z as vo,C as Xa,v as xt,w as Ir,x as _o,y as mo,M as po,z as $n,B as jn,D as go,E as $a,F as ja,G as qa,H as Ya,I as xo,J as yo,K as To,O as Eo,N as Ao,P as So,Q as Hr,S as Bi,T as wo,U as bo,V as Co,W as Ro,X as Mo,Y as Lo,_ as No,$ as Po,a0 as zr,a1 as Do,u as Oo,a2 as Io,a3 as Bo}from"./echarts-ff51454d.js";import"./overlayscrollbars-44d87bcf.js";var Fo=Object.defineProperty,Uo=Object.getOwnPropertyDescriptor,Ho=(e,t,r,n)=>{for(var i=n>1?void 0:n?Uo(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Fo(t,r,i),i};let qn=class extends Et(At){constructor(){super(...arguments),this.mdiLockOutline=Xs}};qn=Ho([vt({components:{Panel:Wt}})],qn);var zo=Object.defineProperty,Go=Object.getOwnPropertyDescriptor,_n=(e,t,r,n)=>{for(var i=n>1?void 0:n?Go(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&zo(t,r,i),i};let sr=class extends Et(At){constructor(){super(...arguments),this.mdiCloseThick=hi,this.mdiGrid=vn,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)}))}};_n([Ke({type:Boolean,required:!0})],sr.prototype,"show",2);_n([Ke({type:String,required:!0})],sr.prototype,"name",2);_n([za("show")],sr.prototype,"showChanged",1);sr=_n([vt],sr);var Vo=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r(fi,{attrs:{value:e.show,persistent:"","max-width":400},on:{keydown:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"esc",27,n.key,["Esc","Escape"])?null:e.closeDialog.apply(null,arguments)}}},[r(Wt,{attrs:{title:e.$t("Heightmap.RenameBedMeshProfile"),icon:e.mdiGrid,"card-class":"heightmap-rename-dialog","margin-bottom":!1},scopedSlots:e._u([{key:"buttons",fn:function(){return[r(Pe,{attrs:{icon:"",tile:""},on:{click:e.closeDialog}},[r(gt,[e._v(e._s(e.mdiCloseThick))])],1)]},proxy:!0}])},[r(ft,[r(Va,{ref:"input",attrs:{label:e.$t("Heightmap.Name"),required:"",rules:e.rules},on:{"update:error":function(n){e.isInvalidName=n},keyup:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"enter",13,n.key,"Enter")?null:e.renameProfile.apply(null,arguments)}},model:{value:e.newName,callback:function(n){e.newName=n},expression:"newName"}})],1),r(di,[r(vi),r(Pe,{attrs:{text:""},on:{click:e.closeDialog}},[e._v(e._s(e.$t("Heightmap.Abort")))]),r(Pe,{attrs:{disabled:e.isInvalidName,color:"primary",text:""},on:{click:e.renameProfile}},[e._v(" "+e._s(e.$t("Heightmap.Rename"))+" ")])],1)],1)],1)},ko=[];const Fi={};var Wo=St(sr,Vo,ko,!1,Xo,null,null,null);function Xo(e){for(let t in Fi)this[t]=Fi[t]}const _i=function(){return Wo.exports}();var $o=Object.defineProperty,jo=Object.getOwnPropertyDescriptor,mi=(e,t,r,n)=>{for(var i=n>1?void 0:n?jo(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&$o(t,r,i),i};let wr=class extends Et(At){constructor(){super(...arguments),this.mdiCloseThick=hi,this.mdiGrid=vn}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")}};mi([Ke({type:Boolean,required:!0})],wr.prototype,"show",2);mi([Ke({type:String,required:!0})],wr.prototype,"name",2);wr=mi([vt],wr);var qo=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r(fi,{attrs:{value:e.show,persistent:"","max-width":400},on:{keydown:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"esc",27,n.key,["Esc","Escape"])?null:e.closeDialog.apply(null,arguments)}}},[r(Wt,{attrs:{title:e.$t("Heightmap.BedMeshRemove"),icon:e.mdiGrid,"card-class":"heightmap-remove-dialog","margin-bottom":!1},scopedSlots:e._u([{key:"buttons",fn:function(){return[r(Pe,{attrs:{icon:"",tile:""},on:{click:e.closeDialog}},[r(gt,[e._v(e._s(e.mdiCloseThick))])],1)]},proxy:!0}])},[r(ft,[r("p",{staticClass:"mb-0"},[e._v(e._s(e.$t("Heightmap.DoYouReallyWantToDelete",{name:e.name})))])]),r(di,[r(vi),r(Pe,{attrs:{text:""},on:{click:e.closeDialog}},[e._v(e._s(e.$t("Heightmap.Abort")))]),r(Pe,{attrs:{color:"error",text:""},on:{click:e.removeProfile}},[e._v(e._s(e.$t("Heightmap.Remove")))])],1)],1)],1)},Yo=[];const Ui={};var Zo=St(wr,qo,Yo,!1,Ko,null,null,null);function Ko(e){for(let t in Ui)this[t]=Ui[t]}const Za=function(){return Zo.exports}();var Qo=Object.defineProperty,Jo=Object.getOwnPropertyDescriptor,pi=(e,t,r,n)=>{for(var i=n>1?void 0:n?Jo(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Qo(t,r,i),i};let br=class extends Et(At){constructor(){super(...arguments),this.mdiDelete=$s,this.mdiPencil=Ga,this.mdiProgressUpload=js,this.showRemove=!1,this.showRename=!1}get points(){const e=[];for(let t=0;t{for(var i=n>1?void 0:n?al(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&il(t,r,i),i};let Yn=class extends Et(At){constructor(){super(...arguments),this.mdiStackOverflow=qs}get profiles(){var e,t;return(t=(e=this.$store.state.printer.bed_mesh)==null?void 0:e.profiles)!=null?t:{}}};Yn=sl([vt({components:{HeightmapProfilesPanelRow:Ka}})],Yn);var ol=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r(Wt,{staticClass:"mt-6 mt-md-0",attrs:{title:e.$t("Heightmap.Profiles"),"card-class":"heightmap-profiles-panel",icon:e.mdiStackOverflow,collapsible:!0}},[Object.keys(e.profiles).length?r(ft,{staticClass:"px-0 py-3"},[e._l(e.profiles,function(n,i,a){return[a?r(nr,{key:"deliver_".concat(i),staticClass:"my-3"}):e._e(),r(Ka,{key:"profile_".concat(i),attrs:{profile:n,name:i}})]})],2):r(ft,[r("p",{staticClass:"mb-0"},[e._v(e._s(e.$t("Heightmap.NoProfile")))])])],1)},ll=[];const zi={};var cl=St(Yn,ol,ll,!1,ul,null,null,null);function ul(e){for(let t in zi)this[t]=zi[t]}const hl=function(){return cl.exports}();var fl=Object.defineProperty,dl=Object.getOwnPropertyDescriptor,vl=(e,t,r,n)=>{for(var i=n>1?void 0:n?dl(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&fl(t,r,i),i};let Cr=class extends eo{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{for(var i=n>1?void 0:n?ml(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&_l(t,r,i),i};let Zn=class extends Et(At,Cr){constructor(){super(...arguments),this.mdiInformation=Ys,this.mdiPencil=Ga,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}};Zn=pl([vt({components:{}})],Zn);var gl=function(){var e=this,t=e.$createElement,r=e._self._c||t;return e.is_active?r(Wt,{staticClass:"mt-0",attrs:{title:e.$t("Heightmap.CurrentMesh.Headline"),"card-class":"heightmap-current-mesh-panel",icon:e.mdiInformation,collapsible:!0}},[r(ft,{staticClass:"py-3 px-0"},[r(ht,{staticClass:"px-3"},[r(we,[e._v(e._s(e.$t("Heightmap.CurrentMesh.Name")))]),r(we,{staticClass:"text-right"},[e.name.startsWith("adaptive-")?r("span",{staticClass:"font-weight-bold"},[e._v(e._s(e.name))]):r("span",{staticClass:"currentMeshName cursor-pointer font-weight-bold",on:{click:function(n){e.showRename=!0}}},[r(gt,{attrs:{left:"",small:"",color:"primary"}},[e._v(e._s(e.mdiPencil))]),e._v(" "+e._s(e.name)+" ")],1)])],1),r(nr,{staticClass:"my-3"}),r(ht,{staticClass:"px-3"},[r(we,[e._v(e._s(e.$t("Heightmap.CurrentMesh.Size")))]),r(we,{staticClass:"text-right"},[e._v(e._s(e.x_count)+"x"+e._s(e.y_count))])],1),r(nr,{staticClass:"my-3"}),e.index_max>-1?r(ht,{staticClass:"px-3"},[r(we,[e._v(" "+e._s(e.$t("Heightmap.CurrentMesh.Max"))+" ["+e._s(e.position_max_x.toFixed(1))+", "+e._s(e.position_max_y.toFixed(1))+"] ")]),r(we,{staticClass:"text-right"},[e._v(e._s(e.max.toFixed(3))+" mm")])],1):e._e(),r(nr,{staticClass:"my-3"}),r(ht,{staticClass:"px-3"},[r(we,[e._v(" "+e._s(e.$t("Heightmap.CurrentMesh.Min"))+" ["+e._s(e.position_min_x.toFixed(1))+", "+e._s(e.position_min_y.toFixed(1))+"] ")]),r(we,{staticClass:"text-right"},[e._v(e._s(e.min.toFixed(3))+" mm")])],1),r(nr,{staticClass:"my-3"}),r(ht,{staticClass:"px-3"},[r(we,[e._v(e._s(e.$t("Heightmap.CurrentMesh.Range")))]),r(we,{staticClass:"text-right"},[e._v(e._s(e.variance)+" mm")])],1)],1),r(_i,{attrs:{show:e.showRename,name:e.name},on:{close:function(n){e.showRename=!1}}})],1):e._e()},xl=[];const Gi={};var yl=St(Zn,gl,xl,!1,Tl,"a3cfb25c",null,null);function Tl(e){for(let t in Gi)this[t]=Gi[t]}const El=function(){return yl.exports}();var Al=Object.defineProperty,Sl=Object.getOwnPropertyDescriptor,gi=(e,t,r,n)=>{for(var i=n>1?void 0:n?Sl(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Al(t,r,i),i};let Rr=class extends Et(At){constructor(){super(...arguments),this.mdiCloseThick=hi,this.mdiGrid=vn,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)}))}};gi([Ke({type:Boolean,required:!0})],Rr.prototype,"show",2);gi([za("show")],Rr.prototype,"showChanged",1);Rr=gi([vt],Rr);var wl=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r(fi,{attrs:{value:e.show,persistent:"","max-width":400},on:{keydown:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"esc",27,n.key,["Esc","Escape"])?null:e.closeDialog.apply(null,arguments)}}},[r(Wt,{attrs:{title:e.$t("Heightmap.BedMeshCalibrate"),icon:e.mdiGrid,"card-class":"heightmap-calibrate-dialog","margin-bottom":!1},scopedSlots:e._u([{key:"buttons",fn:function(){return[r(Pe,{attrs:{icon:"",tile:""},on:{click:e.closeDialog}},[r(gt,[e._v(e._s(e.mdiCloseThick))])],1)]},proxy:!0}])},[r(ft,[r(Va,{ref:"input",attrs:{label:e.$t("Heightmap.Name"),required:"",rules:e.rules},on:{"update:error":function(n){e.isInvalidName=n},keyup:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"enter",13,n.key,"Enter")?null:e.calibrateMesh.apply(null,arguments)}},model:{value:e.name,callback:function(n){e.name=n},expression:"name"}})],1),r(di,[r(vi),r(Pe,{attrs:{text:""},on:{click:e.closeDialog}},[e._v(e._s(e.$t("Heightmap.Abort")))]),r(Pe,{attrs:{disabled:e.isInvalidName,color:"primary",text:""},on:{click:e.calibrateMesh}},[e._v(" "+e._s(e.$t("Heightmap.Calibrate"))+" ")])],1)],1)],1)},bl=[];const Vi={};var Cl=St(Rr,wl,bl,!1,Rl,null,null,null);function Rl(e){for(let t in Vi)this[t]=Vi[t]}const Qa=function(){return Cl.exports}();var Ml=Object.defineProperty,Ll=Object.getOwnPropertyDescriptor,Nl=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ll(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Ml(t,r,i),i};let Kn=class extends Et(At,Zs,Cr){constructor(){super(...arguments),this.mdiGrid=vn,this.mdiHome=Ks,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"})}};Kn=Nl([vt({components:{HeightmapCalibrateMeshDialog:Qa}})],Kn);function ki(e,t,r){typeof t=="object"&&(r=t,t=null);var n=this,i;if(!(e instanceof Function)){i=[];for(var a in e)e.hasOwnProperty(a)&&i.push(a)}var s=function(l){if(n.apply(this,arguments),e instanceof Function?Wi(this,e.call(this,l)):Pl(this,e,i),this.constructor===s)for(var c=s.__initializers__,u=0;u=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}const Gl={get:zl};var An,Xe={};Xe.supportWebGL=function(){if(An==null)try{var e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)throw new Error}catch{An=!1}return An};Xe.Int8Array=typeof Int8Array>"u"?Array:Int8Array;Xe.Uint8Array=typeof Uint8Array>"u"?Array:Uint8Array;Xe.Uint16Array=typeof Uint16Array>"u"?Array:Uint16Array;Xe.Uint32Array=typeof Uint32Array>"u"?Array:Uint32Array;Xe.Int16Array=typeof Int16Array>"u"?Array:Int16Array;Xe.Float32Array=typeof Float32Array>"u"?Array:Float32Array;Xe.Float64Array=typeof Float64Array>"u"?Array:Float64Array;var zt={};typeof window<"u"?zt=window:typeof global<"u"&&(zt=global);Xe.requestAnimationFrame=zt.requestAnimationFrame||zt.msRequestAnimationFrame||zt.mozRequestAnimationFrame||zt.webkitRequestAnimationFrame||function(e){setTimeout(e,16)};Xe.createCanvas=function(){return document.createElement("canvas")};Xe.createImage=function(){return new zt.Image};Xe.request={get:Gl.get};Xe.addEventListener=function(e,t,r,n){e.addEventListener(t,r,n)};Xe.removeEventListener=function(e,t,r){e.removeEventListener(t,r)};const Se=Xe;var Le=function(){this.head=null,this.tail=null,this._length=0};Le.prototype.insert=function(e){var t=new Le.Entry(e);return this.insertEntry(t),t};Le.prototype.insertAt=function(e,t){if(!(e<0)){for(var r=this.head,n=0;r&&n!=e;)r=r.next,n++;if(r){var i=new Le.Entry(t),a=r.prev;a?(a.next=i,i.prev=a):this.head=i,i.next=r,r.prev=i}else this.insert(t)}};Le.prototype.insertBeforeEntry=function(e,t){var r=new Le.Entry(e),n=t.prev;n?(n.next=r,r.prev=n):this.head=r,r.next=t,t.prev=r,this._length++};Le.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++};Le.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--};Le.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}};Le.prototype.getHead=function(){if(this.head)return this.head.value};Le.prototype.getTail=function(){if(this.tail)return this.tail.value};Le.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t.value}};Le.prototype.indexOf=function(e){for(var t=this.head,r=0;t;){if(t.value===e)return r;t=t.next,r++}};Le.prototype.length=function(){return this._length};Le.prototype.isEmpty=function(){return this._length===0};Le.prototype.forEach=function(e,t){for(var r=this.head,n=0,i=typeof t<"u";r;)i?e.call(t,r.value,n):e(r.value,n),r=r.next,n++};Le.prototype.clear=function(){this.tail=this.head=null,this._length=0};Le.Entry=function(e){this.value=e,this.next=null,this.prev=null};const Vl=Le;var hr=function(e){this._list=new Vl,this._map={},this._maxSize=e||10};hr.prototype.setMaxSize=function(e){this._maxSize=e};hr.prototype.put=function(e,t){if(!this._map.hasOwnProperty(e)){var r=this._list.length();if(r>=this._maxSize&&r>0){var n=this._list.head;this._list.remove(n),delete this._map[n.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}};hr.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};hr.prototype.remove=function(e){var t=this._map[e];typeof t<"u"&&(delete this._map[e],this._list.remove(t))};hr.prototype.clear=function(){this._list.clear(),this._map={}};const Ja=hr;var me={},ji={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 st(e){return e=Math.round(e),e<0?0:e>255?255:e}function kl(e){return e=Math.round(e),e<0?0:e>360?360:e}function Mr(e){return e<0?0:e>1?1:e}function Sn(e){return e.length&&e.charAt(e.length-1)==="%"?st(parseFloat(e)/100*255):st(parseInt(e,10))}function or(e){return e.length&&e.charAt(e.length-1)==="%"?Mr(parseFloat(e)/100):Mr(parseFloat(e))}function wn(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 Lt(e,t,r){return e+(t-e)*r}function at(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function Qn(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}var es=new Ja(20),Gr=null;function Yt(e,t){Gr&&Qn(Gr,t),Gr=es.put(e,Gr||t.slice())}me.parse=function(e,t){if(e){t=t||[];var r=es.get(e);if(r)return Qn(t,r);e=e+"";var n=e.replace(/ /g,"").toLowerCase();if(n in ji)return Qn(t,ji[n]),Yt(e,t),t;if(n.charAt(0)==="#"){if(n.length===4){var i=parseInt(n.substr(1),16);if(!(i>=0&&i<=4095)){at(t,0,0,0,1);return}return at(t,(i&3840)>>4|(i&3840)>>8,i&240|(i&240)>>4,i&15|(i&15)<<4,1),Yt(e,t),t}else if(n.length===7){var i=parseInt(n.substr(1),16);if(!(i>=0&&i<=16777215)){at(t,0,0,0,1);return}return at(t,(i&16711680)>>16,(i&65280)>>8,i&255,1),Yt(e,t),t}return}var a=n.indexOf("("),s=n.indexOf(")");if(a!==-1&&s+1===n.length){var o=n.substr(0,a),l=n.substr(a+1,s-(a+1)).split(","),c=1;switch(o){case"rgba":if(l.length!==4){at(t,0,0,0,1);return}c=or(l.pop());case"rgb":if(l.length!==3){at(t,0,0,0,1);return}return at(t,Sn(l[0]),Sn(l[1]),Sn(l[2]),c),Yt(e,t),t;case"hsla":if(l.length!==4){at(t,0,0,0,1);return}return l[3]=or(l[3]),Jn(l,t),Yt(e,t),t;case"hsl":if(l.length!==3){at(t,0,0,0,1);return}return Jn(l,t),Yt(e,t),t;default:return}}at(t,0,0,0,1)}};me.parseToFloat=function(e,t){if(t=me.parse(e,t),!!t)return t[0]/=255,t[1]/=255,t[2]/=255,t};function Jn(e,t){var r=(parseFloat(e[0])%360+360)%360/360,n=or(e[1]),i=or(e[2]),a=i<=.5?i*(n+1):i+n-i*n,s=i*2-a;return t=t||[],at(t,st(wn(s,a,r+1/3)*255),st(wn(s,a,r)*255),st(wn(s,a,r-1/3)*255),1),e.length===4&&(t[3]=e[3]),t}function Wl(e){if(e){var t=e[0]/255,r=e[1]/255,n=e[2]/255,i=Math.min(t,r,n),a=Math.max(t,r,n),s=a-i,o=(a+i)/2,l,c;if(s===0)l=0,c=0;else{o<.5?c=s/(a+i):c=s/(2-a-i);var u=((a-t)/6+s/2)/s,h=((a-r)/6+s/2)/s,d=((a-n)/6+s/2)/s;t===a?l=d-h:r===a?l=1/3+u-d:n===a&&(l=2/3+h-u),l<0&&(l+=1),l>1&&(l-=1)}var f=[l*360,c,o];return e[3]!=null&&f.push(e[3]),f}}me.lift=function(e,t){var r=me.parse(e);if(r){for(var n=0;n<3;n++)t<0?r[n]=r[n]*(1-t)|0:r[n]=(255-r[n])*t+r[n]|0;return me.stringify(r,r.length===4?"rgba":"rgb")}};me.toHex=function(e){var t=me.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)};me.fastLerp=function(e,t,r){if(!(!(t&&t.length)||!(e>=0&&e<=1))){r=r||[];var n=e*(t.length-1),i=Math.floor(n),a=Math.ceil(n),s=t[i],o=t[a],l=n-i;return r[0]=st(Lt(s[0],o[0],l)),r[1]=st(Lt(s[1],o[1],l)),r[2]=st(Lt(s[2],o[2],l)),r[3]=Mr(Lt(s[3],o[3],l)),r}};me.fastMapToColor=me.fastLerp;me.lerp=function(e,t,r){if(!(!(t&&t.length)||!(e>=0&&e<=1))){var n=e*(t.length-1),i=Math.floor(n),a=Math.ceil(n),s=me.parse(t[i]),o=me.parse(t[a]),l=n-i,c=me.stringify([st(Lt(s[0],o[0],l)),st(Lt(s[1],o[1],l)),st(Lt(s[2],o[2],l)),Mr(Lt(s[3],o[3],l))],"rgba");return r?{color:c,leftIndex:i,rightIndex:a,value:n}:c}};me.mapToColor=me.lerp;me.modifyHSL=function(e,t,r,n){if(e=me.parse(e),e)return e=Wl(e),t!=null&&(e[0]=kl(t)),r!=null&&(e[1]=or(r)),n!=null&&(e[2]=or(n)),me.stringify(Jn(e),"rgba")};me.modifyAlpha=function(e,t){if(e=me.parse(e),e&&t!=null)return e[3]=Mr(t),me.stringify(e,"rgba")};me.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+")"}};const Xl=me;var $l=Xl.parseToFloat,bn={};function qi(e){var t=Object.keys(e);t.sort();for(var r=[],n=0;n=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 n=e[r];this.setUniform(r,n)}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 n=this.uniforms;this._enabledUniforms=Object.keys(n),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter(function(c){var u=this.uniforms[c].type;return u==="t"||u==="tv"},this);var i=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=De.clone(e.vertexDefines),this.fragmentDefines=De.clone(e.fragmentDefines),t){for(var s in r)n[s]&&(n[s].value=r[s].value);De.defaults(this.vertexDefines,i),De.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=De.clone(this.vertexDefines),e.fragmentDefines=De.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,r){var n=this.vertexDefines,i=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")&&n[t]!==r&&(n[t]=r,this._programKey=""),(e==="fragment"||e==="both")&&i[t]!==r&&(i[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;t0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e};Z.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]};Z.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e};Z.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e};Z.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};Z.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e};Z.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e};Z.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e};Z.transformMat4=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e};Z.forEach=function(){var e=Z.create();return function(t,r,n,i,a,s){var o,l;for(r||(r=2),n||(n=0),i?l=Math.min(i*r+n,t.length):l=t.length,o=n;o0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}if(r)for(var s=0;sl.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),h+="\n"+Rn(d)+"\n"}a&&(h+="\n#define INSTANCING\n");var f=h+Rn(t.vertexDefines,o,u),v=h+Rn(t.fragmentDefines,o,u),_=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 p=Jl(m)+"\n"+ec(t.precision)+"\n"+v+"\n"+t.shader.fragment,y=ta(_,t.vertexDefines,o),g=ta(p,t.fragmentDefines,o),x=new Kl;x.uniformSemantics=t.shader.uniformSemantics,x.attributes=t.shader.attributes;var E=x.buildProgram(c,t.shader,y,g);return x.__error=E,n[s]=x,x};var ra=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,tc=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,na=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,rc={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 mt(e){for(var t=[],r=0;r=0){if(d!==o&&d!==u){Zt();break}d=l,v=[];continue}else if(d===o){e==="bool"?f[_].value=p==="true":f[_].value=parseFloat(p),v=null;continue}else if(d===u){var y=p;ei.indexOf(y)>=0||rs.indexOf(y)>=0||ns.indexOf(y)>=0?f[_].semantic=y:y==="ignore"||y==="unconfigurable"?f[_].ignore=!0:e==="bool"?f[_].value=y==="true":f[_].value=parseFloat(y);continue}m(p),d=s}}return f}function L(e,t){typeof e=="object"&&(t=e.fragment,e=e.vertex),e=aa(e),t=aa(t),this._shaderID=ic(e,t),this._vertexCode=L.parseImport(e),this._fragmentCode=L.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()}L.prototype={constructor:L,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=L.parseImport(this.vertex),this._fragmentCode=L.parseImport(this.fragment)},_addSemanticUniform:function(e,t,r){if(ei.indexOf(r)>=0)this.attributeSemantics[r]={symbol:e,type:t};else if(ns.indexOf(r)>=0){var n=!1,i=r;r.match(/TRANSPOSE$/)&&(n=!0,i=r.slice(0,-9)),this.matrixSemantics[r]={symbol:e,type:t,isTranspose:n,semanticNoTranspose:i}}else rs.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:e,type:t})},_addMaterialUniform:function(e,t,r,n,i,a){a[e]={type:r,value:i?ia.array:n||ia[t],semantic:null}},_parseUniforms:function(){var e={},t=this,r="vertex";this._uniformList=[],this._vertexCode=this._vertexCode.replace(ra,i),r="fragment",this._fragmentCode=this._fragmentCode.replace(ra,i),t.matrixSemanticKeys=Object.keys(this.matrixSemantics);function n(a){return a!=null?function(){return a}:null}function i(a,s,o){var l=sa(s,o),c=[];for(var u in l){var h=l[u],d=h.semantic,f=u,v=rc[s],_=n(l[u].value);l[u].isArray&&(f+="["+l[u].arraySize+"]",v+="v"),c.push(f),t._uniformList.push(u),h.ignore||((s==="sampler2D"||s==="samplerCube")&&(t.textures[u]={shaderType:r,type:s}),d?t._addSemanticUniform(u,v,d):t._addMaterialUniform(u,s,v,_,l[u].isArray,e))}return c.length>0?"uniform "+s+" "+c.join(",")+";\n":""}this.uniformTemplates=e},_parseAttributes:function(){var e={},t=this;this._vertexCode=this._vertexCode.replace(tc,r);function r(n,i,a){var s=sa(i,a),o=nc[i]||1,l=[];for(var c in s){var u=s[c].semantic;if(e[c]={type:"float",size:o,semantic:u||null},u){if(ei.indexOf(u)<0)throw new Error('Unkown semantic "'+u+'"');t.attributeSemantics[u]={symbol:c,type:i}}l.push(c)}return"attribute "+i+" "+l.join(",")+";\n"}this.attributes=e},_parseDefines:function(){var e=this,t="vertex";this._vertexCode=this._vertexCode.replace(na,r),t="fragment",this._fragmentCode=this._fragmentCode.replace(na,r);function r(n,i,a){var s=t==="vertex"?e.vertexDefines:e.fragmentDefines;return s[i]||(a==="false"?s[i]=!1:a==="true"?s[i]=!0:s[i]=a?isNaN(parseFloat(a))?a.trim():parseFloat(a):null),""}},clone:function(){var e=is[this._shaderID],t=new L(e.vertex,e.fragment);return t}};Object.defineProperty&&(Object.defineProperty(L.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(L.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(L.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(L.prototype,"uniforms",{get:function(){return this._uniformList}}));var ac=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;L.parseImport=function(e){return e=e.replace(ac,function(i,r,n){var i=L.source(n);return i?L.parseImport(i):(console.error('Shader chunk "'+n+'" not existed in library'),"")}),e};var sc=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;L.import=function(e){e.replace(sc,function(t,r,n,a){var a=a.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"");if(a){for(var s=n.split("."),o=L.codes,l=0,c;l0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e};X.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]};X.cross=function(e,t,r){var n=t[0],i=t[1],a=t[2],s=r[0],o=r[1],l=r[2];return e[0]=i*l-a*o,e[1]=a*s-n*l,e[2]=n*o-i*s,e};X.lerp=function(e,t,r,n){var i=t[0],a=t[1],s=t[2];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=s+n*(r[2]-s),e};X.random=function(e,t){t=t||1;var r=ir()*2*Math.PI,n=ir()*2-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e};X.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],s=r[3]*n+r[7]*i+r[11]*a+r[15];return s=s||1,e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/s,e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/s,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/s,e};X.transformMat3=function(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=n*r[0]+i*r[3]+a*r[6],e[1]=n*r[1]+i*r[4]+a*r[7],e[2]=n*r[2]+i*r[5]+a*r[8],e};X.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],s=r[0],o=r[1],l=r[2],c=r[3],u=c*n+o*a-l*i,h=c*i+l*n-s*a,d=c*a+s*i-o*n,f=-s*n-o*i-l*a;return e[0]=u*c+f*-s+h*-l-d*-o,e[1]=h*c+f*-o+d*-s-u*-l,e[2]=d*c+f*-l+u*-o-h*-s,e};X.rotateX=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e};X.rotateY=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e};X.rotateZ=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e};X.forEach=function(){var e=X.create();return function(t,r,n,i,a,s){var o,l;for(r||(r=3),n||(n=0),i?l=Math.min(i*r+n,t.length):l=t.length,o=n;o1?0:Math.acos(i)};const T=X;L.import(as);var de=C.create,oa={};function la(e){return e.material}function oc(e,t,r){return t.uniforms[r].value}function lc(e,t,r,n){return r!==n}function cc(e){return!0}function ca(){}var ua={float:A.FLOAT,byte:A.BYTE,ubyte:A.UNSIGNED_BYTE,short:A.SHORT,ushort:A.UNSIGNED_SHORT};function uc(e,t,r){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=r,this.vao=null}function hc(e){var t,r;this.bind=function(n){t||(t=Se.createCanvas(),t.width=t.height=1,t.getContext("2d"));var i=n.gl,a=!r;a&&(r=i.createTexture()),i.bindTexture(i.TEXTURE_2D,r),a&&i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t)},this.unbind=function(n){n.gl.bindTexture(n.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var Nt=qe.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=Se.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 Hl(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 ts(this),this._placeholderTexture=new hc},{resize:function(e,t){var r=this.canvas,n=this.devicePixelRatio;e!=null?(r.style&&(r.style.width=e+"px",r.style.height=t+"px"),r.width=e*n,r.height=t*n,this._width=e,this._height=t):(this._width=r.width/n,this._height=r.height/n),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,r,n,i){if(typeof e=="object"){var a=e;e=a.x,t=a.y,r=a.width,n=a.height,i=a.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,r*i,n*i),this.viewport={x:e,y:t,width:r,height:n,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,r,n){var i=this.gl,a=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.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,i.enable(i.SCISSOR_TEST),i.scissor(s.x*l,s.y*l,s.width*l,s.height*l)),i.clearColor(a[0],a[1],a[2],a[3]),i.clear(this.clearBit),o&&i.disable(i.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 c=e.updateRenderList(t,!0);this._sceneRendering=e;var u=c.opaque,h=c.transparent,d=e.material;e.trigger("beforerender",this,e,t,c),n?(this.renderPreZ(u,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var f=de(),v=T.create(),_=0;_0){var o=e[i-1],l=o.joints?o.joints.length:0,c=a.joints?a.joints.length:0;if(c===l&&a.material===o.material&&a.lightGroup===o.lightGroup){a.__program=o.__program;continue}}var u=this._programMgr.getProgram(a,s,t);this.validateProgram(u),a.__program=u}},renderPass:function(e,t,r){this.trigger("beforerenderpass",this,e,t,r),r=r||{},r.getMaterial=r.getMaterial||la,r.getUniform=r.getUniform||oc,r.isMaterialChanged=r.isMaterialChanged||lc,r.beforeRender=r.beforeRender||ca,r.afterRender=r.afterRender||ca;var n=r.ifRender||cc;this.updatePrograms(e,this._sceneRendering,r),r.sortCompare&&e.sort(r.sortCompare);var i=this.viewport,a=i.devicePixelRatio,s=[i.x*a,i.y*a,i.width*a,i.height*a],o=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*o,this._height*o],c=[s[2],s[3]],u=Date.now();t?(C.copy(fe.VIEW,t.viewMatrix.array),C.copy(fe.PROJECTION,t.projectionMatrix.array),C.copy(fe.VIEWINVERSE,t.worldTransform.array)):(C.identity(fe.VIEW),C.identity(fe.PROJECTION),C.identity(fe.VIEWINVERSE)),C.multiply(fe.VIEWPROJECTION,fe.PROJECTION,fe.VIEW),C.invert(fe.PROJECTIONINVERSE,fe.PROJECTION),C.invert(fe.VIEWPROJECTIONINVERSE,fe.VIEWPROJECTION);for(var h=this.gl,d=this._sceneRendering,f,v,_,m,p,y,g,x,E,S,R,w,M=null,F=0;Fthis.getMaxJointNumber()){var a=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,a,r),t.setUniform(n,"1i","skinMatricesTexture",r),t.setUniform(n,"1f","skinMatricesTextureSize",a.width)}else{var s=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(n,"SKIN_MATRIX",s)}},_renderObject:function(e,t,r){var n=this.gl,i=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 c=this.getGLExtension("OES_element_index_uint"),u=c&&i.indices instanceof Uint32Array,h=u?n.UNSIGNED_INT:n.UNSIGNED_SHORT;o?s.drawElementsInstancedANGLE(a,t.indicesBuffer.count,h,0,e.getInstanceCount()):n.drawElements(a,t.indicesBuffer.count,h,0)}else o?s.drawArraysInstancedANGLE(a,0,i.vertexCount,e.getInstanceCount()):n.drawArrays(a,0,i.vertexCount);if(o)for(var d=0;dr?r:e}var oe=Math.atan2,tt=Math.asin,Kt=Math.abs;W.eulerFromQuat=function(e,t,d){e._dirty=!0,t=t.array;var n=e.array,i=t[0],a=t[1],s=t[2],o=t[3],l=i*i,c=a*a,u=s*s,h=o*o,d=(d||"XYZ").toUpperCase();switch(d){case"XYZ":n[0]=oe(2*(i*o-a*s),h-l-c+u),n[1]=tt(et(2*(i*s+a*o),-1,1)),n[2]=oe(2*(s*o-i*a),h+l-c-u);break;case"YXZ":n[0]=tt(et(2*(i*o-a*s),-1,1)),n[1]=oe(2*(i*s+a*o),h-l-c+u),n[2]=oe(2*(i*a+s*o),h-l+c-u);break;case"ZXY":n[0]=tt(et(2*(i*o+a*s),-1,1)),n[1]=oe(2*(a*o-s*i),h-l-c+u),n[2]=oe(2*(s*o-i*a),h-l+c-u);break;case"ZYX":n[0]=oe(2*(i*o+s*a),h-l-c+u),n[1]=tt(et(2*(a*o-i*s),-1,1)),n[2]=oe(2*(i*a+s*o),h+l-c-u);break;case"YZX":n[0]=oe(2*(i*o-s*a),h-l+c-u),n[1]=oe(2*(a*o-i*s),h+l-c-u),n[2]=tt(et(2*(i*a+s*o),-1,1));break;case"XZY":n[0]=oe(2*(i*o+a*s),h-l+c-u),n[1]=oe(2*(i*s+a*o),h+l-c-u),n[2]=tt(et(2*(s*o-i*a),-1,1));break;default:console.warn("Unkown order: "+d)}return e};W.eulerFromMat3=function(e,t,v){var n=t.array,i=n[0],a=n[3],s=n[6],o=n[1],l=n[4],c=n[7],u=n[2],h=n[5],d=n[8],f=e.array,v=(v||"XYZ").toUpperCase();switch(v){case"XYZ":f[1]=tt(et(s,-1,1)),Kt(s)<.99999?(f[0]=oe(-c,d),f[2]=oe(-a,i)):(f[0]=oe(h,l),f[2]=0);break;case"YXZ":f[0]=tt(-et(c,-1,1)),Kt(c)<.99999?(f[1]=oe(s,d),f[2]=oe(o,l)):(f[1]=oe(-u,i),f[2]=0);break;case"ZXY":f[0]=tt(et(h,-1,1)),Kt(h)<.99999?(f[1]=oe(-u,d),f[2]=oe(-a,l)):(f[1]=0,f[2]=oe(o,i));break;case"ZYX":f[1]=tt(-et(u,-1,1)),Kt(u)<.99999?(f[0]=oe(h,d),f[2]=oe(o,i)):(f[0]=0,f[2]=oe(-a,l));break;case"YZX":f[2]=tt(et(o,-1,1)),Kt(o)<.99999?(f[0]=oe(-c,l),f[1]=oe(-u,i)):(f[0]=0,f[1]=oe(s,d));break;case"XZY":f[2]=tt(-et(a,-1,1)),Kt(a)<.99999?(f[0]=oe(h,l),f[1]=oe(s,i)):(f[0]=oe(-c,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}}});const P=W;var Nn=1e-5,Jr=function(e,t){this.origin=e||new P,this.direction=t||new P};Jr.prototype={constructor:Jr,intersectPlane:function(e,t){var r=e.normal.array,n=e.distance,i=this.origin.array,a=this.direction.array,s=T.dot(r,a);if(s===0)return null;t||(t=new P);var o=(T.dot(r,i)-n)/s;return T.scaleAndAdd(t.array,i,a,-o),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=T.dot(e.normal.array,this.direction.array);T.scaleAndAdd(this.direction.array,this.direction.array,e.normal.array,-t*2),this.direction._dirty=!0},distanceToPoint:function(){var e=T.create();return function(t){T.sub(e,t,this.origin.array);var r=T.dot(e,this.direction.array);if(r<0)return T.distance(this.origin.array,t);var n=T.lenSquared(e);return Math.sqrt(n-r*r)}}(),intersectSphere:function(){var e=T.create();return function(t,r,n){var i=this.origin.array,a=this.direction.array;t=t.array,T.sub(e,t,i);var s=T.dot(e,a),o=T.squaredLength(e),l=o-s*s,c=r*r;if(!(l>c)){var u=Math.sqrt(c-l),h=s-u,d=s+u;return n||(n=new P),h<0?d<0?null:(T.scaleAndAdd(n.array,i,a,d),n):(T.scaleAndAdd(n.array,i,a,h),n)}}}(),intersectBoundingBox:function(e,t){var r=this.direction.array,n=this.origin.array,i=e.min.array,a=e.max.array,s=1/r[0],o=1/r[1],l=1/r[2],c,u,h,d,f,v;if(s>=0?(c=(i[0]-n[0])*s,u=(a[0]-n[0])*s):(u=(i[0]-n[0])*s,c=(a[0]-n[0])*s),o>=0?(h=(i[1]-n[1])*o,d=(a[1]-n[1])*o):(d=(i[1]-n[1])*o,h=(a[1]-n[1])*o),c>d||h>u||((h>c||c!==c)&&(c=h),(d=0?(f=(i[2]-n[2])*l,v=(a[2]-n[2])*l):(v=(i[2]-n[2])*l,f=(a[2]-n[2])*l),c>v||f>u)||((f>c||c!==c)&&(c=f),(v=0?c:u;return t||(t=new P),T.scaleAndAdd(t.array,n,r,_),t},intersectTriangle:function(){var e=T.create(),t=T.create(),r=T.create(),n=T.create();return function(i,a,s,o,l,c){var u=this.direction.array,h=this.origin.array;i=i.array,a=a.array,s=s.array,T.sub(e,a,i),T.sub(t,s,i),T.cross(n,t,u);var d=T.dot(e,n);if(o){if(d>-Nn)return null}else if(d>-Nn&&d1)return null;T.cross(n,e,r);var v=T.dot(u,n)/d;if(v<0||v>1||f+v>1)return null;T.cross(n,e,t);var _=-T.dot(r,n)/d;return _<0?null:(l||(l=new P),c&&P.set(c,1-f-v,f,v),T.scaleAndAdd(l.array,h,u,_),l)}}(),applyTransform:function(e){P.add(this.direction,this.direction,this.origin),P.transformMat4(this.origin,this.origin,e),P.transformMat4(this.direction,this.direction,e),P.sub(this.direction,this.direction,this.origin),P.normalize(this.direction,this.direction)},copy:function(e){P.copy(this.origin,e.origin),P.copy(this.direction,e.direction)},clone:function(){var e=new Jr;return e.copy(this),e}};const sn=Jr;var K={};K.create=function(){var e=new Oe(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e};K.clone=function(e){var t=new Oe(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};K.fromValues=function(e,t,r,n){var i=new Oe(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i};K.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e};K.set=function(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e};K.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};K.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};K.sub=K.subtract;K.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};K.mul=K.multiply;K.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};K.div=K.divide;K.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};K.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};K.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};K.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e};K.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(r*r+n*n+i*i+a*a)};K.dist=K.distance;K.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return r*r+n*n+i*i+a*a};K.sqrDist=K.squaredDistance;K.length=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)};K.len=K.length;K.squaredLength=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i};K.sqrLen=K.squaredLength;K.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e};K.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};K.normalize=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],s=r*r+n*n+i*i+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};K.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]};K.lerp=function(e,t,r,n){var i=t[0],a=t[1],s=t[2],o=t[3];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=s+n*(r[2]-s),e[3]=o+n*(r[3]-o),e};K.random=function(e,t){return t=t||1,e[0]=ir(),e[1]=ir(),e[2]=ir(),e[3]=ir(),K.normalize(e,e),K.scale(e,e,t),e};K.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],s=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*s,e[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*s,e[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*s,e[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*s,e};K.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],s=r[0],o=r[1],l=r[2],c=r[3],u=c*n+o*a-l*i,h=c*i+l*n-s*a,d=c*a+s*i-o*n,f=-s*n-o*i-l*a;return e[0]=u*c+f*-s+h*-l-d*-o,e[1]=h*c+f*-o+d*-s-u*-l,e[2]=d*c+f*-l+u*-o-h*-s,e};K.forEach=function(){var e=K.create();return function(t,r,n,i,a,s){var o,l;for(r||(r=4),n||(n=0),i?l=Math.min(i*r+n,t.length):l=t.length,o=n;o.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(T.cross(e,i,a),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,ne.normalize(n,n))}}();ne.setAxes=function(){var e=ee.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],ne.normalize(t,ne.fromMat3(t,e))}}();ne.clone=D.clone;ne.fromValues=D.fromValues;ne.copy=D.copy;ne.set=D.set;ne.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e};ne.setAxisAngle=function(e,t,r){r=r*.5;var n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e};ne.add=D.add;ne.multiply=function(e,t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*u+s*o+i*c-a*l,e[1]=i*u+s*l+a*o-n*c,e[2]=a*u+s*c+n*l-i*o,e[3]=s*u-n*o-i*l-a*c,e};ne.mul=ne.multiply;ne.scale=D.scale;ne.rotateX=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+s*o,e[1]=i*l+a*o,e[2]=a*l-i*o,e[3]=s*l-n*o,e};ne.rotateY=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l-a*o,e[1]=i*l+s*o,e[2]=a*l+n*o,e[3]=s*l-i*o,e};ne.rotateZ=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*o,e[1]=i*l-n*o,e[2]=a*l+s*o,e[3]=s*l-a*o,e};ne.calculateW=function(e,t){var r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e};ne.dot=D.dot;ne.lerp=D.lerp;ne.slerp=function(e,t,r,n){var i=t[0],a=t[1],s=t[2],o=t[3],l=r[0],c=r[1],u=r[2],h=r[3],d,f,v,_,m;return f=i*l+a*c+s*u+o*h,f<0&&(f=-f,l=-l,c=-c,u=-u,h=-h),1-f>1e-6?(d=Math.acos(f),v=Math.sin(d),_=Math.sin((1-n)*d)/v,m=Math.sin(n*d)/v):(_=1-n,m=n),e[0]=_*i+m*l,e[1]=_*a+m*c,e[2]=_*s+m*u,e[3]=_*o+m*h,e};ne.invert=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],s=r*r+n*n+i*i+a*a,o=s?1/s:0;return e[0]=-r*o,e[1]=-n*o,e[2]=-i*o,e[3]=a*o,e};ne.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e};ne.length=D.length;ne.len=ne.length;ne.squaredLength=D.squaredLength;ne.sqrLen=ne.squaredLength;ne.normalize=D.normalize;ne.fromMat3=function(e,t){var r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);var a=(i+1)%3,s=(i+2)%3;n=Math.sqrt(t[i*3+i]-t[a*3+a]-t[s*3+s]+1),e[i]=.5*n,n=.5/n,e[3]=(t[a*3+s]-t[s*3+a])*n,e[a]=(t[a*3+i]+t[i*3+a])*n,e[s]=(t[s*3+i]+t[i*3+s])*n}return e};const j=ne;var ue=function(){this._axisX=new P,this._axisY=new P,this._axisZ=new P,this.array=C.create(),this._dirty=!0};ue.prototype={constructor:ue,setArray:function(e){for(var t=0;t0){var t=this.min,r=this.max,n=t.array,i=r.array;Xr(n,e[0]),Xr(i,e[0]);for(var a=1;ai[0]&&(i[0]=s[0]),s[1]>i[1]&&(i[1]=s[1]),s[2]>i[2]&&(i[2]=s[2])}t._dirty=!0,r._dirty=!0}},union:function(e){var t=this.min,r=this.max;return T.min(t.array,t.array,e.min.array),T.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 T.max(t.array,t.array,e.min.array),T.min(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,r=this.max.array,n=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||r[0]=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},containPoint:function(e){var t=this.min.array,r=this.max.array,n=e.array;return t[0]<=n[0]&&t[1]<=n[1]&&t[2]<=n[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},isFinite:function(){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=T.create(),t=T.create(),r=T.create(),n=T.create(),i=T.create(),a=T.create();return function(s,o){var l=s.min.array,c=s.max.array,u=o.array;return e[0]=u[0]*l[0],e[1]=u[1]*l[0],e[2]=u[2]*l[0],t[0]=u[0]*c[0],t[1]=u[1]*c[0],t[2]=u[2]*c[0],r[0]=u[4]*l[1],r[1]=u[5]*l[1],r[2]=u[6]*l[1],n[0]=u[4]*c[1],n[1]=u[5]*c[1],n[2]=u[6]*c[1],i[0]=u[8]*l[2],i[1]=u[9]*l[2],i[2]=u[10]*l[2],a[0]=u[8]*c[2],a[1]=u[9]*c[2],a[2]=u[10]*c[2],l=this.min.array,c=this.max.array,l[0]=Math.min(e[0],t[0])+Math.min(r[0],n[0])+Math.min(i[0],a[0])+u[12],l[1]=Math.min(e[1],t[1])+Math.min(r[1],n[1])+Math.min(i[1],a[1])+u[13],l[2]=Math.min(e[2],t[2])+Math.min(r[2],n[2])+Math.min(i[2],a[2])+u[14],c[0]=Math.max(e[0],t[0])+Math.max(r[0],n[0])+Math.max(i[0],a[0])+u[12],c[1]=Math.max(e[1],t[1])+Math.max(r[1],n[1])+Math.max(i[1],a[1])+u[13],c[2]=Math.max(e[2],t[2])+Math.max(r[2],n[2])+Math.max(i[2],a[2])+u[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min.array,r=this.max.array,n=e.array,i=t[0],a=t[1],s=t[2],o=r[0],l=r[1],c=t[2],u=r[0],h=r[1],d=r[2];if(n[15]===1)t[0]=n[0]*i+n[12],t[1]=n[5]*a+n[13],r[2]=n[10]*s+n[14],r[0]=n[0]*u+n[12],r[1]=n[5]*h+n[13],t[2]=n[10]*d+n[14];else{var f=-1/s;t[0]=n[0]*i*f,t[1]=n[5]*a*f,r[2]=(n[10]*s+n[14])*f,f=-1/c,r[0]=n[0]*o*f,r[1]=n[5]*l*f,f=-1/d,t[2]=(n[10]*d+n[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=T.fromValues(0,0,0);this.vertices=e}var r=this.min.array,n=this.max.array;return Rt(e[0],r[0],r[1],r[2]),Rt(e[1],r[0],n[1],r[2]),Rt(e[2],n[0],r[1],r[2]),Rt(e[3],n[0],n[1],r[2]),Rt(e[4],r[0],r[1],n[2]),Rt(e[5],r[0],n[1],n[2]),Rt(e[6],n[0],r[1],n[2]),Rt(e[7],n[0],n[1],n[2]),this},copy:function(e){var t=this.min,r=this.max;return Xr(t.array,e.min.array),Xr(r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new en;return e.copy(this),e}};const Ve=en;var fc=0,dc=qe.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")+"_"+fc++),this.position||(this.position=new P),this.rotation||(this.rotation=new ss),this.scale||(this.scale=new P(1,1,1)),this.worldTransform=new z,this.localTransform=new z,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;t0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=dt.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=dt.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var r=0;r=0&&E[g]>1e-4&&(T.transformMat4(w,x,p[S[g]]),T.scaleAndAdd(R,R,w,E[g]));M.set(y,R)}}for(var y=0;y>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(te.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}});Object.defineProperty(te.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}});te.BYTE=A.BYTE;te.UNSIGNED_BYTE=A.UNSIGNED_BYTE;te.SHORT=A.SHORT;te.UNSIGNED_SHORT=A.UNSIGNED_SHORT;te.INT=A.INT;te.UNSIGNED_INT=A.UNSIGNED_INT;te.FLOAT=A.FLOAT;te.HALF_FLOAT=36193;te.UNSIGNED_INT_24_8_WEBGL=34042;te.DEPTH_COMPONENT=A.DEPTH_COMPONENT;te.DEPTH_STENCIL=A.DEPTH_STENCIL;te.ALPHA=A.ALPHA;te.RGB=A.RGB;te.RGBA=A.RGBA;te.LUMINANCE=A.LUMINANCE;te.LUMINANCE_ALPHA=A.LUMINANCE_ALPHA;te.SRGB=35904;te.SRGB_ALPHA=35906;te.COMPRESSED_RGB_S3TC_DXT1_EXT=33776;te.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777;te.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778;te.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779;te.NEAREST=A.NEAREST;te.LINEAR=A.LINEAR;te.NEAREST_MIPMAP_NEAREST=A.NEAREST_MIPMAP_NEAREST;te.LINEAR_MIPMAP_NEAREST=A.LINEAR_MIPMAP_NEAREST;te.NEAREST_MIPMAP_LINEAR=A.NEAREST_MIPMAP_LINEAR;te.LINEAR_MIPMAP_LINEAR=A.LINEAR_MIPMAP_LINEAR;te.REPEAT=A.REPEAT;te.CLAMP_TO_EDGE=A.CLAMP_TO_EDGE;te.MIRRORED_REPEAT=A.MIRRORED_REPEAT;const q=te;var Je=ti.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=ti.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});Je.POINTS=A.POINTS;Je.LINES=A.LINES;Je.LINE_LOOP=A.LINE_LOOP;Je.LINE_STRIP=A.LINE_STRIP;Je.TRIANGLES=A.TRIANGLES;Je.TRIANGLE_STRIP=A.TRIANGLE_STRIP;Je.TRIANGLE_FAN=A.TRIANGLE_FAN;Je.BACK=A.BACK;Je.FRONT=A.FRONT;Je.FRONT_AND_BACK=A.FRONT_AND_BACK;Je.CW=A.CW;Je.CCW=A.CCW;const Ei=Je;var pn={};pn.isPowerOfTwo=function(e){return(e&e-1)===0};pn.nextPowerOfTwo=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e};pn.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))};const os=pn;var ha=os.isPowerOfTwo;function fa(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function _c(e,t){var r=fa(e.width),n=fa(e.height);t=t||document.createElement("canvas"),t.width=r,t.height=n;var i=t.getContext("2d");return i.drawImage(e.image,0,0,r,n),t}var Ai=q.extend(function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}},{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var r=this.format,n=this.type,i=!!(this.convertToPOT&&!this.mipmaps.length&&this.image&&(this.wrapS===q.REPEAT||this.wrapT===q.REPEAT)&&this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var a=e.getGLExtension("EXT_texture_filter_anisotropic");if(a&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,a.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),n===36193){var s=e.getGLExtension("OES_texture_half_float");s||(n=A.FLOAT)}if(this.mipmaps.length)for(var o=this.width,l=this.height,c=0;c=q.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,a,n,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,a,n,i,0,a,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 ha(this.width)&&ha(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=Se.createImage();t&&(r.crossOrigin=t);var n=this;return r.onload=function(){n.dirty(),n.trigger("success",n)},r.onerror=function(){n.trigger("error",n)},r.src=e,this.image=r,this}});Object.defineProperty(Ai.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(Ai.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)}});const ie=Ai;function ls(e){return{byte:Se.Int8Array,ubyte:Se.Uint8Array,short:Se.Int16Array,ushort:Se.Uint16Array}[e]||Se.Float32Array}function Dn(e){return"attr_"+e}function lr(e,t,r,n){switch(this.name=e,this.type=t,this.size=r,this.semantic=n||"",this.value=null,r){case 1:this.get=function(i){return this.value[i]},this.set=function(i,a){this.value[i]=a},this.copy=function(i,a){this.value[i]=this.value[i]};break;case 2:this.get=function(i,a){var s=this.value;return a[0]=s[i*2],a[1]=s[i*2+1],a},this.set=function(i,a){var s=this.value;s[i*2]=a[0],s[i*2+1]=a[1]},this.copy=function(i,a){var s=this.value;a*=2,i*=2,s[i]=s[a],s[i+1]=s[a+1]};break;case 3:this.get=function(i,a){var s=i*3,o=this.value;return a[0]=o[s],a[1]=o[s+1],a[2]=o[s+2],a},this.set=function(i,a){var s=i*3,o=this.value;o[s]=a[0],o[s+1]=a[1],o[s+2]=a[2]},this.copy=function(i,a){var s=this.value;a*=3,i*=3,s[i]=s[a],s[i+1]=s[a+1],s[i+2]=s[a+2]};break;case 4:this.get=function(i,a){var s=this.value,o=i*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(i,a){var s=this.value,o=i*4;s[o]=a[0],s[o+1]=a[1],s[o+2]=a[2],s[o+3]=a[3]},this.copy=function(i,a){var s=this.value;a*=4,i*=4,s[i]=s[a],s[i+1]=s[a+1],s[i+2]=s[a+2],s[i+3]=s[a+3]}}}lr.prototype.init=function(e){if(!this.value||this.value.length!==e*this.size){var t=ls(this.type);this.value=new t(e*this.size)}};lr.prototype.fromArray=function(e){var t=ls(this.type),r;if(e[0]&&e[0].length){var n=0,i=this.size;r=new t(e.length*i);for(var a=0;a=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?Se.Uint32Array:Se.Uint16Array;if(e[0]&&e[0].length){var n=0,i=3;t=new r(e.length*i);for(var a=0;a=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=[],n=this.vertexCount,i=0;ia[0]&&(a[0]=o),l>a[1]&&(a[1]=l),c>a[2]&&(a[2]=c)}r._dirty=!0,n._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,r=t.position.value,n=t.normal.value;if(!n||n.length!==r.length)n=t.normal.value=new Se.Float32Array(r.length);else for(var i=0;i65535&&(this.indices=new Se.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),n={},i=0;ithis.distance,i=1;i<8;i++)if(T.dot(t[i].array,r)>this.distance!=n)return!0},intersectLine:function(){var e=T.create();return function(t,r,n){var i=this.distanceToPoint(t),a=this.distanceToPoint(r);if(i>0&&a>0||i<0&&a<0)return null;var s=this.normal.array,o=this.distance,l=t.array;T.sub(e,r.array,t.array),T.normalize(e,e);var c=T.dot(s,e);if(c===0)return null;n||(n=new P);var u=(T.dot(s,l)-o)/c;return T.scaleAndAdd(n.array,l,e,-u),n._dirty=!0,n}}(),applyTransform:function(){var e=C.create(),t=D.create(),r=D.create();return r[3]=1,function(n){n=n.array,T.scale(r,this.normal.array,this.distance),D.transformMat4(r,r,n),this.distance=T.dot(r,this.normal.array),C.invert(e,n),C.transpose(e,e),t[3]=0,T.copy(t,this.normal.array),D.transformMat4(t,t,e),T.copy(this.normal.array,t)}}(),copy:function(e){T.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new tn;return e.copy(this),e}};const hs=tn;var Te=T.set,da=T.copy,va=T.transformMat4,On=Math.min,In=Math.max,fs=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new hs);this.boundingBox=new Ve,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=T.fromValues(0,0,0)};fs.prototype={setFromProjection:function(e){var t=this.planes,r=e.array,n=r[0],i=r[1],a=r[2],s=r[3],o=r[4],l=r[5],c=r[6],u=r[7],h=r[8],d=r[9],f=r[10],v=r[11],_=r[12],m=r[13],p=r[14],y=r[15];Te(t[0].normal.array,s-n,u-o,v-h),t[0].distance=-(y-_),t[0].normalize(),Te(t[1].normal.array,s+n,u+o,v+h),t[1].distance=-(y+_),t[1].normalize(),Te(t[2].normal.array,s+i,u+l,v+d),t[2].distance=-(y+m),t[2].normalize(),Te(t[3].normal.array,s-i,u-l,v-d),t[3].distance=-(y-m),t[3].normalize(),Te(t[4].normal.array,s-a,u-c,v-f),t[4].distance=-(y-p),t[4].normalize(),Te(t[5].normal.array,s+a,u+c,v+f),t[5].distance=-(y+p),t[5].normalize();var g=this.boundingBox,x=this.vertices;if(y===0){var E=l/n,S=-p/(f-1),R=-p/(f+1),w=-R/l,M=-S/l;g.min.set(-w*E,-w,R),g.max.set(w*E,w,S),Te(x[0],-w*E,-w,R),Te(x[1],-w*E,w,R),Te(x[2],w*E,-w,R),Te(x[3],w*E,w,R),Te(x[4],-M*E,-M,S),Te(x[5],-M*E,M,S),Te(x[6],M*E,-M,S),Te(x[7],M*E,M,S)}else{var F=(-1-_)/n,b=(1-_)/n,U=(1-m)/l,I=(-1-m)/l,N=(-1-p)/f,G=(1-p)/f;g.min.set(Math.min(F,b),Math.min(I,U),Math.min(G,N)),g.max.set(Math.max(b,F),Math.max(U,I),Math.max(N,G));var B=g.min.array,Y=g.max.array;Te(x[0],B[0],B[1],B[2]),Te(x[1],B[0],Y[1],B[2]),Te(x[2],Y[0],B[1],B[2]),Te(x[3],Y[0],Y[1],B[2]),Te(x[4],B[0],B[1],Y[2]),Te(x[5],B[0],Y[1],Y[2]),Te(x[6],Y[0],B[1],Y[2]),Te(x[7],Y[0],Y[1],Y[2])}},getTransformedBoundingBox:function(){var e=T.create();return function(t,r){var n=this.vertices,i=r.array,a=t.min,s=t.max,o=a.array,l=s.array,c=n[0];va(e,c,i),da(o,e),da(l,e);for(var u=1;u<8;u++)c=n[u],va(e,c,i),o[0]=On(e[0],o[0]),o[1]=On(e[1],o[1]),o[2]=On(e[2],o[2]),l[0]=In(e[0],l[0]),l[1]=In(e[1],l[1]),l[2]=In(e[2],l[2]);return a._dirty=!0,s._dirty=!0,t}}()};const Si=fs;var xc=dt.extend(function(){return{projectionMatrix:new z,invProjectionMatrix:new z,viewMatrix:new z,frustum:new Si}},function(){this.update(!0)},{update:function(e){dt.prototype.update.call(this,e),z.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),z.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){z.copy(this.viewMatrix,e),z.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){z.copy(this.projectionMatrix,e),z.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=D.create();return function(t,r){var n=r!==void 0?r:new sn,i=t.array[0],a=t.array[1];return D.set(e,i,a,-1,1),D.transformMat4(e,e,this.invProjectionMatrix.array),D.transformMat4(e,e,this.worldTransform.array),T.scale(n.origin.array,e,1/e[3]),D.set(e,i,a,1,1),D.transformMat4(e,e,this.invProjectionMatrix.array),D.transformMat4(e,e,this.worldTransform.array),T.scale(e,e,1/e[3]),T.sub(n.direction.array,e,n.origin.array),T.normalize(n.direction.array,n.direction.array),n.direction._dirty=!0,n.origin._dirty=!0,n}}()});const cr=xc;var yc=C.create(),_a=C.create(),Bn={};function Tc(e){var t=[],r=Object.keys(e);r.sort();for(var n=0;n0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof ot&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof cr?(t=this._cameraList.indexOf(e),t>=0&&this._cameraList.splice(t,1)):e instanceof ot&&(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;r0&&this._doUpdateRenderList(s,t,r,n,i)}},isFrustumCulled:function(){var e=new Ve,t=new z;return function(r,n,i){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=i,e.transformFrom(a,t),r.castShadow&&this.viewBoundingBoxLastFrame.union(e),r.frustumCulling){if(!e.intersectBoundingBox(n.frustum.boundingBox))return!0;t.array=n.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(Ac);var t=this._lightUniforms;for(var r in t)for(var n in t[r])t[r][n].value.length=0;for(var i=0;i1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),n===36193){var a=e.getGLExtension("OES_texture_half_float");a||(n=A.FLOAT)}if(this.mipmaps.length)for(var s=this.width,o=this.height,l=0;l0&&e.height>0}const Lr=wi;var wc=cr.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=cr.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}});const Me=wc;var jr="framebuffer",pt="renderbuffer",ma=pt+"_width",pa=pt+"_height",Fn=pt+"_attached",Un="depthtexture_attached",Ot=A.FRAMEBUFFER,mr=A.RENDERBUFFER,yr=A.DEPTH_ATTACHMENT,ds=A.COLOR_ATTACHMENT0,Br=qe.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},function(){this._cache=new Ti,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(Ot,this._getFrameBufferGL(e)),this._boundRenderer=e;var r=this._cache;r.put("viewport",e.viewport);var n=!1,i,a;for(var s in this._textures){n=!0;var o=this._textures[s];o&&(i=o.texture.width,a=o.texture.height,this._doAttach(e,o.texture,s,o.target))}this._width=i,this._height=a,!n&&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,i,a,1);var l=r.get("attached_textures");if(l){for(var s in l)if(!this._textures[s]){var c=l[s];this._doDetach(t,s,c)}}if(!r.get(Un)&&this.depthBuffer){r.miss(pt)&&r.put(pt,t.createRenderbuffer());var u=r.get(pt);(i!==r.get(ma)||a!==r.get(pa))&&(t.bindRenderbuffer(mr,u),t.renderbufferStorage(mr,t.DEPTH_COMPONENT16,i,a),r.put(ma,i),r.put(pa,a),t.bindRenderbuffer(mr,null)),r.get(Fn)||(t.framebufferRenderbuffer(Ot,yr,mr,u),r.put(Fn,!0))}},unbind:function(e){e.__currentFrameBuffer=null;var t=e.gl;t.bindFramebuffer(Ot,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 n=this._textures[r];if(n){var i=n.texture;if(!i.NPOT&&i.useMipmap&&i.minFilter===q.LINEAR_MIPMAP_LINEAR){var a=i.textureType==="textureCube"?A.TEXTURE_CUBE_MAP:A.TEXTURE_2D;t.bindTexture(a,i.getWebGLTexture(e)),t.generateMipmap(a),t.bindTexture(a,null)}}}},checkStatus:function(e){return e.checkFramebufferStatus(Ot)},_getFrameBufferGL:function(e){var t=this._cache;return t.use(e.__uid__),t.miss(jr)&&t.put(jr,e.gl.createFramebuffer()),t.get(jr)},attach:function(e,t,r){if(!e.width)throw new Error("The texture attached to color buffer is not a valid.");t=t||ds,r=r||A.TEXTURE_2D;var n=this._boundRenderer,i=n&&n.gl,a;if(i){var s=this._cache;s.use(n.__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;n&&(l=this._doAttach(n,e,t,r),this.viewport||n.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,n){var i=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===n)return}r=+r;var l=!0;if(r===yr||r===A.DEPTH_STENCIL_ATTACHMENT){var c=e.getGLExtension("WEBGL_depth_texture");if(c||(console.error("Depth texture is not supported by the browser"),l=!1),t.format!==A.DEPTH_COMPONENT&&t.format!==A.DEPTH_STENCIL&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l){var u=this._cache.get(pt);u&&(i.framebufferRenderbuffer(Ot,yr,mr,null),i.deleteRenderbuffer(u),this._cache.put(pt,!1)),this._cache.put(Fn,!1),this._cache.put(Un,!0)}}return i.framebufferTexture2D(Ot,r,n,a,0),s||(s={},this._cache.put("attached_textures",s)),s[r]=s[r]||{},s[r].texture=t,s[r].target=n,l},_doDetach:function(e,t,r){e.framebufferTexture2D(Ot,t,r,null,0);var n=this._cache.get("attached_textures");n&&n[t]&&(n[t]=null),(t===yr||t===A.DEPTH_STENCIL_ATTACHMENT)&&this._cache.put(Un,!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 n=r.get(pt);n&&t.deleteRenderbuffer(n);var i=r.get(jr);i&&t.deleteFramebuffer(i),r.deleteContext(e.__uid__),this._textures={}}});Br.DEPTH_ATTACHMENT=yr;Br.COLOR_ATTACHMENT0=ds;Br.STENCIL_ATTACHMENT=A.STENCIL_ATTACHMENT;Br.DEPTH_STENCIL_ATTACHMENT=A.DEPTH_STENCIL_ATTACHMENT;const Ue=Br;var bc=["px","nx","py","ny","pz","nz"],Cc=qe.extend(function(){var e={position:new P,far:1e3,near:.1,texture:null,shadowMapPass:null},t=e._cameras={px:new Me({fov:90}),nx:new Me({fov:90}),py:new Me({fov:90}),ny:new Me({fov:90}),pz:new Me({fov:90}),nz:new Me({fov:90})};return t.px.lookAt(P.POSITIVE_X,P.NEGATIVE_Y),t.nx.lookAt(P.NEGATIVE_X,P.NEGATIVE_Y),t.py.lookAt(P.POSITIVE_Y,P.POSITIVE_Z),t.ny.lookAt(P.NEGATIVE_Y,P.NEGATIVE_Z),t.pz.lookAt(P.POSITIVE_Z,P.NEGATIVE_Y),t.nz.lookAt(P.NEGATIVE_Z,P.NEGATIVE_Y),e._frameBuffer=new Ue,e},{getCamera:function(e){return this._cameras[e]},render:function(e,t,r){var n=e.gl;r||t.update();for(var i=this.texture.width,a=2*Math.atan(i/(i-.5))/Math.PI*180,s=0;s<6;s++){var o=bc[s],l=this._cameras[o];if(P.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=a,this.shadowMapPass){l.update();var c=t.getBoundingBox();c.applyTransform(l.viewMatrix),t.viewBoundingBoxLastFrame.copy(c),this.shadowMapPass.render(e,t,l,!0)}this._frameBuffer.attach(this.texture,n.COLOR_ATTACHMENT0,n.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)}});const bi=Cc;var Rc=Ee.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,r=this.attributes,n=[],i=[],a=[],s=[],o=0;o<=e;o++)for(var l=o/e,c=0;c<=t;c++){var u=c/t;if(n.push([2*u-1,2*l-1,0]),i&&i.push([u,l]),a&&a.push([0,0,1]),c0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],r)}});const Nr=Nc;var Pc=542327876,Dc=131072,Oc=512,Ic=4;function Ri(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var Bc=31,Fc=Ri("DXT1"),Uc=Ri("DXT3"),Hc=Ri("DXT5"),zc=0,Gc=1,Vc=2,kc=3,Wc=4,Xc=7,$c=20,jc=21,qc=28,Yc={parse:function(e,t){var r=new Int32Array(e,0,Bc);if(r[zc]!==Pc||!r($c)&Ic)return null;var n=r(jc),i=r[Wc],a=r[kc],s=r[qc]&Oc,o=r[Vc]&Dc,l,c;switch(n){case Fc:l=8,c=q.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case Uc:l=16,c=q.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case Hc:l=16,c=q.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var u=r[Gc]+4,h=s?6:1,d=1;o&&(d=Math.max(1,r[Xc]));for(var f=[],v=0;v0){var i=Math.pow(2,e[3]-128-8+n);t[r+0]=e[0]*i,t[r+1]=e[1]*i,t[r+2]=e[2]*i}else t[r+0]=0,t[r+1]=0,t[r+2]=0;return t[r+3]=1,t}function eu(e,t,r){for(var n="",i=t;i0;)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]<>>0;o>0;o--)tu(e[a-1],e[a]),a++,s--;i+=8}else a++,s--,i=0;return r}function ru(e,t,r,n){if(nQc)return ga(e,t,r,n);var i=t[r++];if(i!=2)return ga(e,t,r-1,n);if(e[0][1]=t[r++],e[0][2]=t[r++],i=t[r++],(e[0][2]<<8>>>0|i)>>>0!==n)return null;for(var i=0;i<4;i++)for(var a=0;a128){s=(s&127)>>>0;for(var o=t[r++];s--;)e[a++][i]=o}else for(;s--;)e[a++][i]=t[r++]}return r}var nu={parseRGBE:function(e,t,r){r==null&&(r=0);var n=new Uint8Array(e),i=n.length;if(eu(n,0,2)==="#?"){for(var a=2;a=i)){a+=2;for(var s="";a20)return console.warn("Given image is not a height map"),e}var f,v,_,m;l%(n*4)===0?(f=s.data[l],_=s.data[l+4]):l%(n*4)===(n-1)*4?(f=s.data[l-4],_=s.data[l]):(f=s.data[l-4],_=s.data[l+4]),ln*(i-1)*4?(v=s.data[l-n*4],m=s.data[l]):(v=s.data[l-n*4],m=s.data[l+n*4]),o.data[l]=f-_+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 n=document.createElement("canvas"),i=n.getContext("2d"),a=t||32;r=r||20,n.width=n.height=a,i.drawImage(e,0,0,a,a);for(var s=i.getImageData(0,0,a,a),o=0;or)return!1}return!0},_fetchTexture:function(e,t,r){Se.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,n){e=e||512,t=t||64,r=r||"black",n=n||"white";var i=Math.ceil(e/t),a=document.createElement("canvas");a.width=e,a.height=e;var s=a.getContext("2d");s.fillStyle=n,s.fillRect(0,0,e,e),s.fillStyle=r;for(var o=0;o=0||(ri.forEach(function(t){e.on(t,this[ni(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[ni(r)])},this)},dispose:function(){this._meshes.forEach(function(e){this.detachFromMesh(e)},this)}};const au=ii;var su=cr.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=cr.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 Pr=su,ou="\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";L.import(ou);var lu=new Ci,xa=new Ei({geometry:lu,frustumCulling:!1}),cu=new Pr,uu=qe.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var e=new L(L.source("clay.compositor.vertex"),this.fragment),t=new wt({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||A.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 n=this.outputs[r];n&&t.attach(n,r)}t&&t.bind(e)},unbind:function(e,t){t.unbind(e)},render:function(e,t){var r=e.gl;if(t){this.bind(e,t);var n=e.getGLExtension("EXT_draw_buffers");if(n&&this.outputs){var i=[];for(var a in this.outputs)a=+a,a>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&i.push(a);n.drawBuffersEXT(i)}}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){xa.material=this.material,e.renderPass([xa],cu)},dispose:function(e){}});const ke=uu,hu="#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",fu="#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 kt={},Hn=["px","nx","py","ny","pz","nz"];kt.prefilterEnvironmentMap=function(e,t,r,n,i){(!i||!n)&&(n=kt.generateNormalDistribution(),i=kt.integrateBRDF(e,n)),r=r||{};var a=r.width||64,s=r.height||64,o=r.type||t.type,l=new Lr({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 c=Math.min(a,s),u=Math.log(c)/Math.log(2)+1,h=new wt({shader:new L({vertex:L.source("clay.skybox.vertex"),fragment:fu})});h.set("normalDistribution",n),r.encodeRGBM&&h.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&h.define("fragment","RGBM_DECODE");var d=new Pt,f;if(t.textureType==="texture2D"){var v=new Lr({width:a,height:s,type:o===q.FLOAT?q.HALF_FLOAT:o});Vt.panoramaToCubeMap(e,t,v,{encodeRGBM:r.decodeRGBM}),t=v}f=new Nr({scene:d,material:h}),f.material.set("environmentMap",t);var _=new bi({texture:l});r.encodeRGBM&&(o=l.type=q.UNSIGNED_BYTE);for(var m=new ie({width:a,height:s,type:o}),p=new Ue({depthBuffer:!1}),y=Se[o===q.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],g=0;g>>16)>>>0;h=((h&1431655765)<<1|(h&2863311530)>>>1)>>>0,h=((h&858993459)<<2|(h&3435973836)>>>2)>>>0,h=((h&252645135)<<4|(h&4042322160)>>>4)>>>0,h=(((h&16711935)<<8|(h&4278255360)>>>8)>>>0)/4294967296;var d=Math.sqrt((1-h)/(1+(c*c-1)*h));s[u]=d}for(var u=0;u65535?Uint32Array:Uint16Array,o=this.indices=new s(t*e*6),l,c,u,h,d,f,v,g=this.radius,_=this.phiStart,m=this.phiLength,p=this.thetaStart,y=this.thetaLength,g=this.radius,x=[],E=[],S=0,R=1/g;for(v=0;v<=e;v++)for(f=0;f<=t;f++)h=f/t,d=v/e,l=-g*Math.cos(_+h*m)*Math.sin(p+d*y),c=g*Math.cos(p+d*y),u=g*Math.sin(_+h*m)*Math.sin(p+d*y),x[0]=l,x[1]=c,x[2]=u,E[0]=h,E[1]=d,r.set(S,x),n.set(S,E),x[0]*=R,x[1]*=R,x[2]*=R,i.set(S,x),S++;var w,M,F,b,U=t+1,I=0;for(v=0;v=0&&l.splice(h,1)}),l.push(c),this.__zr&&this.__zr.animation.addAnimator(c),c},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,r=t.length,n=0;n 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",Hu="\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",zu="@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",Gu="/**\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",Vu="@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",ku="@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",Wu="@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(dt.prototype,Fu);L.import(Uu);L.import(as);L.import(Hu);L.import(zu);L.import(Gu);L.import(Vu);L.import(ku);L.import(Wu);function Xu(e){return!e||e==="none"}function ms(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function $u(e){return e.getZr&&e.setOption}var ju=Pt.prototype.addToScene,qu=Pt.prototype.removeFromScene;Pt.prototype.addToScene=function(e){if(ju.call(this,e),this.__zr){var t=this.__zr;e.traverse(function(r){r.__zr=t,r.addAnimatorsToZr&&r.addAnimatorsToZr(t)})}};Pt.prototype.removeFromScene=function(e){qu.call(this,e),e.traverse(function(t){var r=t.__zr;t.__zr=null,r&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(r)})};wt.prototype.setTextureImage=function(e,t,r,n){if(this.shader){var i=r.getZr(),a=this,s;return a.autoUpdateTextureStatus=!1,a.disableTexture(e),Xu(t)||(s=$.loadTexture(t,r,n,function(o){a.enableTexture(e),i&&i.refresh()}),a.set(e,s)),s}};var $={};$.Renderer=Er;$.Node=dt;$.Mesh=Ei;$.Shader=L;$.Material=wt;$.Texture=q;$.Texture2D=ie;$.Geometry=Ee;$.SphereGeometry=Au;$.PlaneGeometry=Ci;$.CubeGeometry=vs;$.AmbientLight=wu;$.DirectionalLight=Cu;$.PointLight=Mu;$.SpotLight=Nu;$.PerspectiveCamera=Me;$.OrthographicCamera=Pr;$.Vector2=Ze;$.Vector3=P;$.Vector4=Pu;$.Quaternion=ss;$.Matrix2=Du;$.Matrix2d=Ou;$.Matrix3=Iu;$.Matrix4=z;$.Plane=hs;$.Ray=sn;$.BoundingBox=Ve;$.Frustum=Si;var Yr=null;function Yu(){return Yr!==null||(Yr=Vt.createBlank("rgba(255,255,255,0)").image),Yr}function ya(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function Ta(e){if((e.wrapS===q.REPEAT||e.wrapT===q.REPEAT)&&e.image){var t=ya(e.width),r=ya(e.height);if(t!==e.width||r!==e.height){var n=document.createElement("canvas");n.width=t,n.height=r;var i=n.getContext("2d");i.drawImage(e.image,0,0,t,r),e.image=n}}}$.loadTexture=function(e,t,r,n){typeof r=="function"&&(n=r,r={}),r=r||{};for(var i=Object.keys(r).sort(),a="",s=0;s3?t[3]=e[3]:t[3]=1,t):(t=ka(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)};$.directionFromAlphaBeta=function(e,t){var r=e/180*Math.PI+Math.PI/2,n=-t/180*Math.PI+Math.PI/2,i=[],a=Math.sin(r);return i[0]=a*Math.cos(n),i[1]=-Math.cos(r),i[2]=a*Math.sin(n),i};$.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};$.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"];$.createShader=function(e){e==="ecgl.shadow"&&(e="ecgl.displayShadow");var t=L.source(e+".vertex"),r=L.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),r||console.error("Fragment shader of '%s' not exits",e);var n=new L(t,r);return n.name=e,n};$.createMaterial=function(e,t){t instanceof Array||(t=[t]);var r=$.createShader(e),n=new wt({shader:r});return t.forEach(function(i){typeof i=="string"&&n.define(i)}),n};$.setMaterialFromModel=function(e,t,r,n){t.autoUpdateTextureStatus=!1;var i=r.getModel(e+"Material"),a=i.get("detailTexture"),s=rt.firstNotNull(i.get("textureTiling"),1),o=rt.firstNotNull(i.get("textureOffset"),0);typeof s=="number"&&(s=[s,s]),typeof o=="number"&&(o=[o,o]);var l=s[0]>1||s[1]>1?$.Texture.REPEAT:$.Texture.CLAMP_TO_EDGE,c={anisotropic:8,wrapS:l,wrapT:l};if(e==="realistic"){var u=i.get("roughness"),h=i.get("metalness");h!=null?isNaN(h)&&(t.setTextureImage("metalnessMap",h,n,c),h=rt.firstNotNull(i.get("metalnessAdjust"),.5)):h=0,u!=null?isNaN(u)&&(t.setTextureImage("roughnessMap",u,n,c),u=rt.firstNotNull(i.get("roughnessAdjust"),.5)):u=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",a,n,c),t.setTextureImage("normalMap",d,n,c),t.set({roughness:u,metalness:h,detailUvRepeat:s,detailUvOffset:o})}else if(e==="lambert")t.setTextureImage("detailMap",a,n,c),t.set({detailUvRepeat:s,detailUvOffset:o});else if(e==="color")t.setTextureImage("detailMap",a,n,c),t.set({detailUvRepeat:s,detailUvOffset:o});else if(e==="hatching"){var f=i.get("hatchingTextures")||[];f.length<6;for(var v=0;v<6;v++)t.setTextureImage("hatch"+(v+1),f[v],n,{anisotropic:8,wrapS:$.Texture.REPEAT,wrapT:$.Texture.REPEAT});t.set({detailUvRepeat:s,detailUvOffset:o})}};$.updateVertexAnimation=function(e,t,r,n){var i=n.get("animation"),a=n.get("animationDurationUpdate"),s=n.get("animationEasingUpdate"),o=r.shadowDepthMaterial;if(i&&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=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var r=this.zr;e.scene.traverse(function(n){n.__zr=r,n.addAnimatorsToZr&&n.addAnimatorsToZr(r)})}};function ps(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)}ce.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(ps,this),e.layer=null,this._viewsToDispose.push(e))}};ce.prototype.removeViewsAll=function(){this.views.forEach(function(e){e.scene.traverse(ps,this),e.layer=null,this._viewsToDispose.push(e)},this),this.views.length=0};ce.prototype.resize=function(e,t){var r=this.renderer;r.resize(e,t)};ce.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)};ce.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)};ce.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)};ce.prototype.needsRefresh=function(){this.zr.refresh()};ce.prototype.refresh=function(e){this._backgroundColor=e?k.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t20)){e=e.event;var n=this.pickObject(e.offsetX,e.offsetY);n&&(this._dispatchEvent(e.type,e,n),this._dispatchDataEvent(e.type,e,n));var i=this._clickToSetFocusPoint(e);if(i){var a=i.view.setDOFFocusOnPoint(i.distance);a&&this.zr.refresh()}}}};ce.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,r=t.viewport,n=this.views.length-1;n>=0;n--){var i=this.views[n];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var a=this._picking.pick(e.offsetX,e.offsetY,!0);if(a)return a.view=i,a}}t.viewport=r};ce.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})};ce.prototype.pickObject=function(e,t){for(var r=[],n=this.renderer,i=n.viewport,a=0;a=0&&(u.dataIndex=this._lastDataIndex,u.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(c,"mouseout",t)),o=!0):s!=null&&s!==this._lastEventData&&(this._lastEventData!=null&&(u.eventData=this._lastEventData,this.zr.handler.dispatchToElement(c,"mouseout",t)),o=!0),this._lastEventData=s,this._lastDataIndex=i,this._lastSeriesIndex=a),u.eventData=s,u.dataIndex=i,u.seriesIndex=a,(s!=null||parseInt(i,10)>=0&&parseInt(a,10)>=0)&&(this.zr.handler.dispatchToElement(c,e,t),o&&this.zr.handler.dispatchToElement(c,"mouseover",t))};ce.prototype._dispatchToView=function(e,t){for(var r=0;r=0&&(Ju(t),t.coordinateSystem==="mapbox"&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))}),Kr(e.xAxis3D),Kr(e.yAxis3D),Kr(e.zAxis3D),Kr(e.grid3D),Tr(e.geo3D)}function xs(e){this._layers={},this._zr=e}xs.prototype.update=function(e,t){var r=this,n=t.getZr();if(!n.getWidth()||!n.getHeight()){console.warn("Dom has no width or height");return}function i(o){n.setSleepAfterStill(0);var l;o.coordinateSystem&&o.coordinateSystem.model,l=o.get("zlevel");var c=r._layers,u=c[l];if(!u){if(u=c[l]=new gs("gl-"+l,n),n.painter.isSingleCanvas()){u.virtual=!0;var h=new vo({z:1e4,style:{image:u.renderer.canvas},silent:!0});u.__hostImage=h,n.add(h)}n.painter.insertLayer(l,u)}return u.__hostImage&&u.__hostImage.setStyle({width:u.renderer.getWidth(),height:u.renderer.getHeight()}),u}function a(o,l){o&&o.traverse(function(c){c.isRenderable&&c.isRenderable()&&(c.ignorePicking=c.$ignorePicking!=null?c.$ignorePicking:l)})}for(var s in this._layers)this._layers[s].removeViewsAll();e.eachComponent(function(o,l){if(o!=="series"){var c=t.getViewOfComponentModel(l),u=l.coordinateSystem;if(c.__ecgl__){var h;if(u){if(!u.viewGL){console.error("Can't find viewGL in coordinateSystem of component "+l.id);return}h=u.viewGL}else{if(!l.viewGL){console.error("Can't find viewGL of component "+l.id);return}h=u.viewGL}var h=u.viewGL,d=i(l);d.addView(h),c.afterRender&&c.afterRender(l,e,t,d),a(c.groupGL,l.get("silent"))}}}),e.eachSeries(function(o){var l=t.getViewOfSeriesModel(o),c=o.coordinateSystem;if(l.__ecgl__){if(c&&!c.viewGL&&!l.viewGL){console.error("Can't find viewGL of series "+l.id);return}var u=c&&c.viewGL||l.viewGL,h=i(o);h.addView(u),l.afterRender&&l.afterRender(o,e,t,h),a(l.groupGL,o.get("silent"))}})};uo(function(e){var t=e.getZr(),r=t.painter.dispose;t.painter.dispose=function(){typeof this.eachOtherLayer=="function"&&this.eachOtherLayer(function(n){n instanceof gs&&n.dispose()}),r.call(this)},t.painter.getRenderedCanvas=function(n){if(n=n||{},this._singleCanvas)return this._layers[0].dom;var i=document.createElement("canvas"),a=n.pixelRatio||this.dpr;i.width=this.getWidth()*a,i.height=this.getHeight()*a;var s=i.getContext("2d");s.dpr=a,s.clearRect(0,0,i.width,i.height),n.backgroundColor&&(s.fillStyle=n.backgroundColor,s.fillRect(0,0,i.width,i.height));var o=this.storage.getDisplayList(!0),l={},c,u=this;function h(_,m){var p=u._zlevelList;_==null&&(_=-1/0);for(var y,g=0;g_&&x0&&this._notFirst?this.animateTo({alpha:c,beta:u,center:h,distance:a,orthographicSize:s,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(c),this.setBeta(u),this.setCenter(h),this.setOrthographicSize(s)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(e){var t=this.zr,r=this,n={},i={};return e.distance!=null&&(n.distance=this.getDistance(),i.distance=e.distance),e.orthographicSize!=null&&(n.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),e.alpha!=null&&(n.alpha=this.getAlpha(),i.alpha=e.alpha),e.beta!=null&&(n.beta=this.getBeta(),i.beta=e.beta),e.center!=null&&(n.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(n).when(e.duration||1e3,i).during(function(){n.alpha!=null&&r.setAlpha(n.alpha),n.beta!=null&&r.setBeta(n.beta),n.distance!=null&&r.setDistance(n.distance),n.center!=null&&r.setCenter(n.center),n.orthographicSize!=null&&r.setOrthographicSize(n.orthographicSize),r._needsUpdate=!0})).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},_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,n=r/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-n/2,t.right=n/2,t.top=r/2,t.bottom=-r/2},_updatePan:function(e){var t=this._panVelocity,r=this._distance,n=this.getCamera(),i=n.worldTransform.y,a=n.worldTransform.x;this._center.scaleAndAdd(a,-t.x*r/200).scaleAndAdd(i,-t.y*r/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new P,r=this._theta+Math.PI/2,n=this._phi+Math.PI/2,i=Math.sin(r);t.x=i*Math.cos(n),t.y=-Math.cos(r),t.z=i*Math.sin(n),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout(function(){t._rotating=!0},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===Ea[this.rotateMouseButton]?this._mode="rotate":e.event.button===Ea[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=Aa(this.panSensitivity),r=Aa(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,n=e.offsetY;if(!(this.viewGL&&!this.viewGL.containPoint(r,n))){var i;this._projection==="perspective"?i=Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):i=Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*i*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(ys.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}});const ah=ys,Mi={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()}},yn={vec2:H,vec3:T,vec4:D,mat2:ye,mat2d:Ae,mat3:ee,mat4:C,quat:j};var zn=yn.vec3,Sa=[[0,0],[1,1]],Ts=Ee.extend(function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new Ee.Attribute("position","float",3,"POSITION"),positionPrev:new Ee.Attribute("positionPrev","float",3),positionNext:new Ee.Attribute("positionNext","float",3),prevPositionPrev:new Ee.Attribute("prevPositionPrev","float",3),prevPosition:new Ee.Attribute("prevPosition","float",3),prevPositionNext:new Ee.Attribute("prevPositionNext","float",3),offset:new Ee.Attribute("offset","float",1),color:new Ee.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,n){var i=zn.dist(e,t)+zn.dist(r,t)+zn.dist(n,r),a=1/(i+1)*this.segmentScale;return a},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?a*2:a*2+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:a*2},getLineVertexCount:function(){return this.getPolylineVertexCount(Sa)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Sa)},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,n,i,a){a==null&&(a=1);for(var s=e[0],o=e[1],l=e[2],c=t[0],u=t[1],h=t[2],d=r[0],f=r[1],v=r[2],_=n[0],m=n[1],p=n[2],y=this._getCubicCurveApproxStep(e,t,r,n),g=y*y,x=g*y,E=3*y,S=3*g,R=6*g,w=6*x,M=s-c*2+d,F=o-u*2+f,b=l-h*2+v,U=(c-d)*3-s+_,I=(u-f)*3-o+m,N=(h-v)*3-l+p,G=s,B=o,Y=l,O=(c-s)*E+M*S+U*x,he=(u-o)*E+F*S+I*x,V=(h-l)*E+b*S+N*x,xe=M*R+U*w,ae=F*R+I*w,ve=b*R+N*w,_e=U*w,Ie=I*w,Be=N*w,Re=0,ze=0,Ye=Math.ceil(1/y),Fe=new Float32Array((Ye+1)*3),Fe=[],nt=0,ze=0;ze1&&(G=O>0?Math.min(G,_):Math.max(G,_),B=he>0?Math.min(B,m):Math.max(B,m),Y=V>0?Math.min(Y,p):Math.max(Y,p));return this.addPolyline(Fe,i,a)},addLine:function(e,t,r,n){return this.addPolyline([e,t],r,n)},addPolyline:function(e,t,r,n,i){if(e.length){var a=typeof e[0]!="number";if(i==null&&(i=a?e.length:e.length/3),!(i<2)){n==null&&(n=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===i,o=this.attributes.position,l=this.attributes.positionPrev,c=this.attributes.positionNext,u=this.attributes.color,h=this.attributes.offset,d=this.indices,f=this._vertexOffset,v,_;r=Math.max(r,.01);for(var m=n;m1&&(o.copy(f,f-1),u.copy(f,f-1),f++):(m0&&(c.set(f-2,v),c.set(f-1,v)),o.set(f,v),o.set(f+1,v),u.set(f,_),u.set(f+1,_),h.set(f,r/2),h.set(f+1,-r/2),f+=2),this.useNativeLine)u.set(f,_),o.set(f,v),f++;else if(m>0){var g=this._triangleOffset*3,d=this.indices;d[g]=f-4,d[g+1]=f-3,d[g+2]=f-2,d[g+3]=f-3,d[g+4]=f-1,d[g+5]=f-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,E=this._vertexOffset+i*2;l.copy(x,x+2),l.copy(x+1,x+3),c.copy(E-1,E-3),c.copy(E-2,E-4)}return this._vertexOffset=f,this._vertexOffset}}},setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=es&&(i=this._x=0,a+=this._rowHeight+l,this._y=a,this._rowHeight=0),this._x+=t+l,this._rowHeight=Math.max(this._rowHeight,r),a+r+l>o)return null;e.x+=this.offsetX*this.dpr+i,e.y+=this.offsetY*this.dpr+a,this._zr.add(e);var c=[this.offsetX/this.width,this.offsetY/this.height],u=[[i/s+c[0],a/o+c[1]],[(i+t)/s+c[0],(a+r)/o+c[1]]];return u},_fitElement:function(e,t,r){var n=e.getBoundingRect(),i=t/n.width,a=r/n.height;e.x=-n.x*i,e.y=-n.y*a,e.scaleX=i,e.scaleY=a,e.update()}};function ai(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 ie({image:t,flipY:!1});var r=this;this._zr=_o(t);var n=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){n.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},this._dpr=e.devicePixelRatio,this._coords={},this.onupdate=e.onupdate,this._gap=e.gap,this._textureAtlasNodes=[new un(this._zr,0,0,e.width,e.height,this._gap,this._dpr)],this._nodeWidth=e.width,this._nodeHeight=e.height,this._currentNodeIdx=0}ai.prototype={clear:function(){for(var e=0;e=e)){var a=(n+this._nodeWidth)*this._dpr,s=(i+this._nodeHeight)*this._dpr;try{this._zr.resize({width:a,height:s})}catch{this._canvas.width=a,this._canvas.height=s}var o=new un(this._zr,n,i,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(o),o}},add:function(e,t,r){if(this._coords[e.id])return this._coords[e.id];var n=this._getCurrentNode().add(e,t,r);if(!n){var i=this._expand();if(!i)return;n=i.add(e,t,r)}return this._coords[e.id]=n,n},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]},dispose:function(){this._zr.dispose()}};function si(){}si.prototype={constructor:si,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new k.DirectionalLight({shadowBias:.005}),this.ambientLight=new k.AmbientLight,e.add(this.mainLight),e.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(e){var t=this.mainLight,r=this.ambientLight,n=e.getModel("light"),i=n.getModel("main"),a=n.getModel("ambient");t.intensity=i.get("intensity"),r.intensity=a.get("intensity"),t.color=k.parseColor(i.get("color")).slice(0,3),r.color=k.parseColor(a.get("color")).slice(0,3);var s=i.get("alpha")||0,o=i.get("beta")||0;t.position.setArray(k.directionFromAlphaBeta(s,o)),t.lookAt(k.Vector3.ZERO),t.castShadow=i.get("shadow"),t.shadowResolution=k.getShadowResolution(i.get("shadowQuality"))},updateAmbientCubemap:function(e,t,r){var n=t.getModel("light.ambientCubemap"),i=n.get("texture");if(i){this._cubemapLightsCache=this._cubemapLightsCache||{};var a=this._cubemapLightsCache[i];if(!a){var s=this;a=this._cubemapLightsCache[i]=k.createAmbientCubemap(n.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 n=t.get("environment"),i=this;function a(){return i._skybox=i._skybox||new Nr,i._skybox}var s=a();if(n&&n!=="none")if(n==="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 n=="object"&&n.colorStops||typeof n=="string"&&ka(n)){this._isSkyboxFromAmbientCubemap=!1;var l=new k.Texture2D({anisotropic:8,flipY:!1});s.setEnvironmentMap(l);var c=l.image=document.createElement("canvas");c.width=c.height=16;var u=c.getContext("2d"),h=new Wa({shape:{x:0,y:0,width:16,height:16},style:{fill:n}});mo(u,h),s.attachScene(this._scene)}else{this._isSkyboxFromAmbientCubemap=!1;var l=k.loadTexture(n,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&&n!=="auto"&&!(n.match&&n.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 It=yn.vec3,Es=Ee.extend(function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new Ee.Attribute("position","float",3,"POSITION"),normal:new Ee.Attribute("normal","float",3,"NORMAL"),color:new Ee.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(e){var t=this.attributes,r=this.getQuadVertexCount()*e,n=this.getQuadTriangleCount()*e;this.vertexCount!==r&&(t.position.init(r),t.normal.init(r),t.color.init(r)),this.triangleCount!==n&&(this.indices=r>65535?new Uint32Array(n*3):new Uint16Array(n*3))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=It.create(),t=It.create(),r=It.create(),n=[0,3,1,3,2,1];return function(i,a){var s=this.attributes.position,o=this.attributes.normal,l=this.attributes.color;It.sub(e,i[1],i[0]),It.sub(t,i[2],i[1]),It.cross(r,e,t),It.normalize(r,r);for(var c=0;c<4;c++)s.set(this._vertexOffset+c,i[c]),l.set(this._vertexOffset+c,a),o.set(this._vertexOffset+c,r);for(var u=this._faceOffset*3,c=0;c<6;c++)this.indices[u+c]=n[c]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});Ir(Es.prototype,Mi);const sh=Es;var oi=rt.firstNotNull,oh={x:0,y:2,z:1};function lh(e,t,r,n){var i=[0,0,0],a=n<0?r.getExtentMin():r.getExtentMax();i[oh[r.dim]]=a,e.position.setArray(i),e.rotation.identity(),t.distance=-Math.abs(a),t.normal.set(0,0,0),r.dim==="x"?(e.rotation.rotateY(n*Math.PI/2),t.normal.x=-n):r.dim==="z"?(e.rotation.rotateX(-n*Math.PI/2),t.normal.y=-n):(n>0&&e.rotation.rotateY(Math.PI),t.normal.z=-n)}function Tn(e,t,r){this.rootNode=new k.Node;var n=new k.Mesh({geometry:new Li({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new k.Mesh({geometry:new sh,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(n),this.faceInfo=e,this.plane=new k.Plane,this.linesMesh=n,this.quadsMesh=i}Tn.prototype.update=function(e,t,r){var n=e.coordinateSystem,i=[n.getAxis(this.faceInfo[0]),n.getAxis(this.faceInfo[1])],a=this.linesMesh.geometry,s=this.quadsMesh.geometry;a.convertToDynamicArray(!0),s.convertToDynamicArray(!0),this._updateSplitLines(a,i,e,r),this._udpateSplitAreas(s,i,e,r),a.convertToTypedArray(),s.convertToTypedArray();var o=n.getAxis(this.faceInfo[2]);lh(this.rootNode,this.plane,o,this.faceInfo[3])};Tn.prototype._updateSplitLines=function(e,t,r,n){var i=n.getDevicePixelRatio();t.forEach(function(a,s){var o=a.model,l=t[1-s].getExtent();if(!a.scale.isBlank()){var c=o.getModel("splitLine",r.getModel("splitLine"));if(c.get("show")){var u=c.getModel("lineStyle"),h=u.get("color"),d=oi(u.get("opacity"),1),f=oi(u.get("width"),1);h=Ar(h)?h:[h];for(var v=a.getTicksCoords({tickModel:c}),_=0,m=0;m65535?new Uint32Array(r*3):new Uint16Array(r*3))},setSpriteAlign:function(e,t,r,n,i){r==null&&(r="left"),n==null&&(n="top");var a,s,o,l;switch(i=i||0,r){case"left":a=i,o=t[0]+i;break;case"center":case"middle":a=-t[0]/2,o=t[0]/2;break;case"right":a=-t[0]-i,o=-i;break}switch(n){case"bottom":s=i,l=t[1]+i;break;case"middle":s=-t[1]/2,l=t[1]/2;break;case"top":s=-t[1]-i,l=-i;break}var c=e*4,u=this.attributes.offset;u.set(c,[a,l]),u.set(c+1,[o,l]),u.set(c+2,[o,s]),u.set(c+3,[a,s])},addSprite:function(e,t,r,n,i,a){var s=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,r,n,i,a);for(var o=0;on[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"),n=e.getAxis("z"),i=n.getExtentMax(),a=n.getExtentMin(),s=t.getExtentMin(),o=t.getExtentMax(),l=r.getExtentMax(),c=r.getExtentMin(),u=this._axes[0].rootNode,h=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,v=f[4].rootNode.invisible?c:l,_=f[2].rootNode.invisible?i:a,m=f[0].rootNode.invisible?s:o,p=f[2].rootNode.invisible?i:a,y=f[0].rootNode.invisible?o:s,g=f[4].rootNode.invisible?c:l;u.rotation.identity(),h.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,u.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,h.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),u.position.set(0,_,v),h.position.set(m,p,0),d.position.set(y,0,g),u.update(),h.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new k.Vector4,new k.Vector4],r=new k.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach(function(n){var i=n.axisLineCoords;n.labelsMesh.geometry;for(var a=0;ar.y?"bottom":"top"):(h="middle",u=l>r.x?"left":"right"),n.setSpriteAlign(u,h,this._api)},this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){var t=this._model.coordinateSystem,r=t.dataToPoint(e),n=this._axisPointerLineMesh,i=n.geometry,a=this._model.getModel("axisPointer"),s=this._api.getDevicePixelRatio();i.convertToDynamicArray(!0);function o(w){return rt.firstNotNull(w.model.get("axisPointer.show"),a.get("show"))}function l(w){var M=w.model.getModel("axisPointer",a),F=M.getModel("lineStyle"),b=k.parseColor(F.get("color")),U=ba(F.get("width"),1),I=ba(F.get("opacity"),1);return b[3]*=I,{color:b,lineWidth:U}}for(var c=0;c 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 Mt=["px","nx","py","ny","pz","nz"];L.import(_h);function kn(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 n=e.material.get("alphaCutoff");return n||0}return 0}else return r==="uvRepeat"?e.material.get("uvRepeat"):r==="uvOffset"?e.material.get("uvOffset"):t.get(r)}function Ra(e,t){var r=e.material,n=t.material;return r.get("diffuseMap")!==n.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(n.get("alphaCutoff")||0)}var ut=qe.extend(function(){return{softShadow:ut.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 Ue,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new bs}},function(){this._gaussianPassH=new ke({fragment:L.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new ke({fragment:L.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 ke({fragment:L.source("clay.sm.debug_depth")})},{render:function(e,t,r,n){r||(r=t.getMainCamera()),this.trigger("beforerender",this,e,t,r),this._renderShadowPass(e,t,r,n),this.trigger("afterrender",this,e,t,r)},renderDebug:function(e,t){e.saveClear();var r=e.viewport,n=0,i=0,a=t||r.width/4,s=a;this.softShadow===ut.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(n,i,a*l.width/l.height,s),this._outputDepthPass.setUniform("depthMap",l),this._outputDepthPass.render(e),n+=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===ut.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 n=0;n4){console.warn("Support at most 4 cascade");continue}v.shadowCascade>1&&(d=v),this.renderDirectionalLightShadow(e,t,r,v,u,c,l)}else v.type==="SPOT_LIGHT"?this.renderSpotLightShadow(e,t,v,o,s):v.type==="POINT_LIGHT"&&this.renderPointLightShadow(e,t,v,h);this._shadowMapNumber[v.type]++}for(var _ in this._shadowMapNumber)for(var m=this._shadowMapNumber[_],p=_+"_SHADOWMAP_COUNT",f=0;f0?g.define("fragment",p,m):g.isDefined("fragment",p)&&g.undefine("fragment",p))}for(var f=0;f0){var S=l.map(E);if(x.directionalLightShadowMaps={value:l,type:"tv"},x.directionalLightMatrices={value:c,type:"m4v"},x.directionalLightShadowMapSizes={value:S,type:"1fv"},d){var R=u.slice(),w=u.slice();R.pop(),w.shift(),R.reverse(),w.reverse(),c.reverse(),x.shadowCascadeClipsNear={value:R,type:"1fv"},x.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var M=s.map(E),x=t.shadowUniforms;x.spotLightShadowMaps={value:s,type:"tv"},x.spotLightMatrices={value:o,type:"m4v"},x.spotLightShadowMapSizes={value:M,type:"1fv"}}h.length>0&&(x.pointLightShadowMaps={value:h,type:"tv"})},renderDirectionalLightShadow:function(){var e=new Si,t=new z,r=new Ve,n=new z,i=new z,a=new z,s=new z;return function(o,l,c,u,h,d,f){var v=this._getDepthMaterial(u),_={getMaterial:function(ve){return ve.shadowDepthMaterial||v},isMaterialChanged:Ra,getUniform:kn,ifRender:function(ve){return ve.castShadow},sortCompare:Er.opaqueSortCompare};if(!l.viewBoundingBoxLastFrame.isFinite()){var m=l.getBoundingBox();l.viewBoundingBoxLastFrame.copy(m).applyTransform(c.viewMatrix)}var p=Math.min(-l.viewBoundingBoxLastFrame.min.z,c.far),y=Math.max(-l.viewBoundingBoxLastFrame.max.z,c.near),g=this._getDirectionalLightCamera(u,l,c),x=a.array;s.copy(g.projectionMatrix),C.invert(i.array,g.worldTransform.array),C.multiply(i.array,i.array,c.worldTransform.array),C.multiply(x,s.array,i.array);for(var E=[],S=c instanceof Me,R=(c.near+c.far)/(c.near-c.far),w=2*c.near*c.far/(c.near-c.far),M=0;M<=u.shadowCascade;M++){var F=y*Math.pow(p/y,M/u.shadowCascade),b=y+(p-y)*M/u.shadowCascade,U=F*u.cascadeSplitLogFactor+b*(1-u.cascadeSplitLogFactor);E.push(U),h.push(-(-U*R+w)/-U)}var I=this._getTexture(u,u.shadowCascade);f.push(I);var N=o.viewport,G=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),G.clear(G.COLOR_BUFFER_BIT|G.DEPTH_BUFFER_BIT);for(var M=0;MF?M>b?v[S>0?"px":"nx"]=!0:v[w>0?"pz":"nz"]=!0:F>b?v[R>0?"py":"ny"]=!0:v[w>0?"pz":"nz"]=!0}for(var x=0;x0){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])}}});const Or=ph;var gh=qe.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=t.COLOR_ATTACHMENT0&&l<=t.COLOR_ATTACHMENT0+8&&u.push(l);c.drawBuffersEXT(u)}e.saveClear(),e.clearBit=A.DEPTH_BUFFER_BIT|A.COLOR_BUFFER_BIT,r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),n.unbind(e)}this.trigger("afterrender",r),this._rendering=!1,this._rendered=!0}});const Eh=Th;var Ah=Or.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}});const Sh=Ah;var wh=Or.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 ke({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var r=e.gl;for(var n in this.inputLinks){var i=this.inputLinks[n],a=i.node.getOutput(e,i.pin);this.pass.setUniform(n,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 c=this.outputs[o],u=this._compositor.allocateTexture(l);this._outputTextures[o]=u;var h=c.attachment||r.COLOR_ATTACHMENT0;typeof h=="string"&&(h=r[h]),s[h]=u}this._compositor.getFrameBuffer().bind(e);for(var h in s)this._compositor.getFrameBuffer().attach(s[h],h);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}for(var n in this.inputLinks){var i=this.inputLinks[n];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var r=this.outputs[e],n=r.parameters,i=r._parametersCopy;if(i||(i=r._parametersCopy={}),n)for(var a in n)a!=="width"&&a!=="height"&&(i[a]=n[a]);var s,o;return typeof n.width=="function"?s=n.width.call(this,t):s=n.width,typeof n.height=="function"?o=n.height.call(this,t):o=n.height,s=Math.ceil(s),o=Math.ceil(o),(i.width!==s||i.height!==o)&&this._outputTextures[e]&&this._outputTextures[e].dispose(t),i.width=s,i.height=o,i},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(){Or.prototype.clear.call(this),this.pass.material.disableTexturesAll()}});const bh=wh,Ch="@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",Cs="@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",Rh="@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",Rs="\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",Mh="@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",Ms="@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",Ls="@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",Ns="@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",Ps="\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",Ds="@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",Lh="@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",Os="@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",Is="@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 Nh(e){e.import(Ch),e.import(Cs),e.import(Rh),e.import(Rs),e.import(Mh),e.import(Ms),e.import(Ls),e.import(Ns),e.import(Ps),e.import(Ds),e.import(Lh),e.import(Os),e.import(Is)}Nh(L);var Ph=/^#source\((.*?)\)/;function Dh(e,t){var r=new yh;t=t||{};var n={textures:{},parameters:{}},i=function(o,l){for(var c=0;c0;)r=r+n*(i%t),i=Math.floor(i/t),n=n/t;return r}const zh="@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";L.import(zh);function Fs(e){for(var t=new Uint8Array(e*e*4),r=0,n=new P,i=0;i=1?.95:0,weight2:n>=1?.05:1}),f.render(e)),c.attach(o),h.setUniform("texture",this._physicallyCorrect?this._currentTexture:s),h.render(e),c.attach(l),d.setUniform("texture",o),d.render(e),c.unbind(e),this._physicallyCorrect){var p=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=p}};Ct.prototype.getTargetTexture=function(){return this._texture3};Ct.prototype.setParameter=function(e,t){e==="maxIteration"?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)};Ct.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=an.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};Ct.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")};Ct.prototype.isFinished=function(e){return this._physicallyCorrect?e>this._totalSamples/this._samplePerFrame:!0};Ct.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 Na=[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],kh="@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";L.import(kh);function Wn(e,t,r,n,i){var a=e.gl;t.setUniform(a,"1i",r,i),a.activeTexture(a.TEXTURE0+i),n.isRenderable()?n.bind(e):n.unbind(e)}function Wh(e,t,r,n,i){var a,s,o,l,c=e.gl;return function(u,h,d){if(!(l&&l.material===u.material)){var f=u.material,v=u.__program,_=f.get("roughness");_==null&&(_=1);var m=f.get("normalMap")||t,p=f.get("roughnessMap"),y=f.get("bumpMap"),g=f.get("uvRepeat"),x=f.get("uvOffset"),E=f.get("detailUvRepeat"),S=f.get("detailUvOffset"),R=!!y&&f.isTextureEnabled("bumpMap"),w=!!p&&f.isTextureEnabled("roughnessMap"),M=f.isDefined("fragment","DOUBLE_SIDED");y=y||r,p=p||n,d!==h?(h.set("normalMap",m),h.set("bumpMap",y),h.set("roughnessMap",p),h.set("useBumpMap",R),h.set("useRoughnessMap",w),h.set("doubleSide",M),g!=null&&h.set("uvRepeat",g),x!=null&&h.set("uvOffset",x),E!=null&&h.set("detailUvRepeat",E),S!=null&&h.set("detailUvOffset",S),h.set("roughness",_)):(v.setUniform(c,"1f","roughness",_),a!==m&&Wn(e,v,"normalMap",m,0),s!==y&&y&&Wn(e,v,"bumpMap",y,1),o!==p&&p&&Wn(e,v,"roughnessMap",p,2),g!=null&&v.setUniform(c,"2f","uvRepeat",g),x!=null&&v.setUniform(c,"2f","uvOffset",x),E!=null&&v.setUniform(c,"2f","detailUvRepeat",E),S!=null&&v.setUniform(c,"2f","detailUvOffset",S),v.setUniform(c,"1i","useBumpMap",+R),v.setUniform(c,"1i","useRoughnessMap",+w),v.setUniform(c,"1i","doubleSide",+M)),a=m,s=y,o=p,l=u}}}function fr(e){this._depthTex=new ie({format:q.DEPTH_COMPONENT,type:q.UNSIGNED_INT}),this._normalTex=new ie({type:q.HALF_FLOAT}),this._framebuffer=new Ue,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,Ue.DEPTH_ATTACHMENT),this._normalMaterial=new wt({shader:new L(L.source("ecgl.normal.vertex"),L.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=Vt.createBlank("#000"),this._defaultBumpMap=Vt.createBlank("#000"),this._defaultRoughessMap=Vt.createBlank("#000"),this._debugPass=new ke({fragment:L.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}fr.prototype.getDepthTexture=function(){return this._depthTex};fr.prototype.getNormalTexture=function(){return this._normalTex};fr.prototype.update=function(e,t,r){var n=e.getWidth(),i=e.getHeight(),a=this._depthTex,s=this._normalTex,o=this._normalMaterial;a.width=n,a.height=i,s.width=n,s.height=i;var l=t.getRenderList(r).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,r,{getMaterial:function(){return o},ifRender:function(c){return c.renderNormal},beforeRender:Wh(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)};fr.prototype.renderDebug=function(e){this._debugPass.render(e)};fr.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)};function Fr(e){e=e||{},this._edgePass=new ke({fragment:L.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new ie({type:q.HALF_FLOAT}),this._frameBuffer=new Ue,this._frameBuffer.attach(this._targetTexture)}Fr.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),s=this._targetTexture;s.width=i,s.height=a;var o=this._frameBuffer;o.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(e),o.unbind(e)};Fr.prototype.getTargetTexture=function(){return this._targetTexture};Fr.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)};Fr.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)};const Xh={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]},$h="@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",jh="@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";L.import(Cs);L.import(Rs);L.import(Ms);L.import(Ls);L.import(Ns);L.import(Ps);L.import(Ds);L.import(Os);L.import(Is);L.import($h);L.import(jh);function Us(e,t){return{color:{parameters:{width:e,height:t}}}}var Di=["composite","FXAA"];function J(){this._width,this._height,this._dpr,this._sourceTexture=new ie({type:q.HALF_FLOAT}),this._depthTexture=new ie({format:q.DEPTH_COMPONENT,type:q.UNSIGNED_INT}),this._framebuffer=new Ue,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,Ue.DEPTH_ATTACHMENT),this._normalPass=new fr,this._compositor=Dh(Xh);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(n){return this._compositor.getNodeByName(n)},this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=Di.map(function(n){return this._compositor.getNodeByName(n)},this);var r={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new bt(r),this._ssrPass=new Ct(r),this._edgePass=new Fr(r)}J.prototype.resize=function(n,i,r){r=r||1;var n=n*r,i=i*r,a=this._sourceTexture,s=this._depthTexture;a.width=n,a.height=i,s.width=n,s.height=i;var o={getWidth:function(){return n},getHeight:function(){return i},getDevicePixelRatio:function(){return r}};function l(c,u){if(typeof c[u]=="function"){var h=c[u].__original||c[u];c[u]=function(d){return h.call(this,o)},c[u].__original=h}}this._compositor.nodes.forEach(function(c){for(var u in c.outputs){var h=c.outputs[u].parameters;h&&(l(h,"width"),l(h,"height"))}for(var d in c.parameters)l(c.parameters,d)}),this._width=n,this._height=i,this._dpr=r};J.prototype.getWidth=function(){return this._width};J.prototype.getHeight=function(){return this._height};J.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR};J.prototype._getPrevNode=function(e){for(var t=Di.indexOf(e.name)-1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t-=1,r=this._finalNodesChain[t];return r};J.prototype._getNextNode=function(e){for(var t=Di.indexOf(e.name)+1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t+=1,r=this._finalNodesChain[t];return r};J.prototype._addChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(e.inputs.texture=t.name,r?(e.outputs=Us(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))};J.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(r?(t.outputs=Us(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))};J.prototype.updateNormal=function(e,t,r,n){this._ifRenderNormalPass()&&this._normalPass.update(e,t,r)};J.prototype.updateSSAO=function(e,t,r,n){this._ssaoPass.update(e,r,n)};J.prototype.enableSSAO=function(){this._enableSSAO=!0};J.prototype.disableSSAO=function(){this._enableSSAO=!1};J.prototype.enableSSR=function(){this._enableSSR=!0};J.prototype.disableSSR=function(){this._enableSSR=!1};J.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()};J.prototype.getSourceFrameBuffer=function(){return this._framebuffer};J.prototype.getSourceTexture=function(){return this._sourceTexture};J.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)};J.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)};J.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()};J.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()};J.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()};J.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()};J.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0};J.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1};J.prototype.enableEdge=function(){this._enableEdge=!0};J.prototype.disableEdge=function(){this._enableEdge=!1};J.prototype.setBloomIntensity=function(e){this._compositeNode.setParameter("bloomIntensity",e)};J.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}};J.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._haltonSequence.length},render:function(e,t,r){var n=this._blendPass;this._frame===0?(n.setUniform("weight1",0),n.setUniform("weight2",1)):(n.setUniform("weight1",.9),n.setUniform("weight2",.1)),n.setUniform("texture1",this._prevFrameTex),n.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),n.render(e),this._blendFb.unbind(e),r||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}};function pe(e){e=e||"perspective",this.layer=null,this.scene=new Pt,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(e),this._compositor=new J,this._temporalSS=new ci,this._shadowMapPass=new mh;for(var t=[],r=0,n=0;n<30;n++){for(var i=[],a=0;a<6;a++)i.push(ur(r,2)*4-2),i.push(ur(r,3)*4-2),r++;t.push(i)}this._pcfKernels=t,this.scene.on("beforerender",function(s,o,l){this.needsTemporalSS()&&this._temporalSS.jitterProjection(s,l)},this)}pe.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),e==="perspective"?this.camera instanceof Me||(this.camera=new Me,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof Pr||(this.camera=new Pr,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3};pe.prototype.setViewport=function(e,t,r,n,i){this.camera instanceof Me&&(this.camera.aspect=r/n),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=r,this.viewport.height=n,this.viewport.devicePixelRatio=i,this._compositor.resize(r*i,n*i),this._temporalSS.resize(r*i,n*i)};pe.prototype.containPoint=function(e,t){var r=this.viewport,n=this.layer.renderer.getHeight();return t=n-t,e>=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var Pa=new Ze;pe.prototype.castRay=function(e,t,r){var n=this.layer.renderer,i=n.viewport;return n.viewport=this.viewport,n.screenToNDC(e,t,Pa),this.camera.castRay(Pa,r),n.viewport=i,r};pe.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;t30};pe.prototype._doRender=function(e,t,r){var n=this.scene,i=this.camera;r=r||0,this._updateTransparent(e,n,i,r),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,n,i,!0)),this._updateShadowPCFKernel(r);var a=e.clearColor;if(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,n,i,this._temporalSS.getFrame())),this._updateSSAO(e,n,i,this._temporalSS.getFrame()),this._enablePostEffect){var s=this._compositor.getSourceFrameBuffer();s.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(n,i,!0,!0),s.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,n,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,n,i,null,0))}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(n,i,!0,!0),e.restoreClear(),s.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)}else e.setViewport(this.viewport),e.render(n,i,!0,!0)};pe.prototype._updateTransparent=function(e,t,r,n){for(var i=new P,a=new z,s=r.getWorldPosition(),o=t.getRenderList(r).transparent,l=0;lthis.camera.far||el&&o.push({pivot:Math.floor((c+l)/2),left:l,right:c});var l=a[s].pivot+1,c=a[s].right;c>l&&o.push({pivot:Math.floor((c+l)/2),left:l,right:c})}a=this._parts=o}else for(var s=0;s=2e4},doSortTriangles:function(e,t){var r=this.indices;if(t===0){var n=this.attributes.position,e=e.array;(!this._triangleZList||this._triangleZList.length!==this.triangleCount)&&(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new r.constructor(r.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i=0,a,s=0;s"+d.join("
")}var i=e.getData(),a=e.getRawValue(t),s=Ar(a)?n(a):Hr(Bi(a)),o=i.getName(t),l=ui(i,t);wo(l)&&l.colorStops&&(l=(l.colorStops[0]||{}).color),l=l||"transparent";var c=bo(l),u=e.name;return u==="\0-"&&(u=""),u=u?Hr(u)+(r?": ":"
"):"",r?c+u+s:u+c+(o?Hr(o)+": "+s:s)}function hf(e,t,r){r=r||e.getSource();var n=t||Ro(e.get("coordinateSystem"))||["x","y","z"],i=Mo(r,{dimensionsDefine:r.dimensionsDefine||e.get("dimensions"),encodeDefine:r.encodeDefine||e.get("encode"),coordDimensions:n.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"&&i.forEach(function(o){if(n.indexOf(o.coordDim)>=0){var l=e.getReferringComponents(o.coordDim+"Axis3D").models[0];l&&l.get("type")==="category"&&(o.ordinalMeta=l.getOrdinalMeta())}});var a=Lo.enableDataStack(e,i,{byIndex:!0,stackedCoordDimension:"z"}),s=new No(i,e);return s.setCalculationInfo(a),s.initData(r),s}var ks=Po.extend({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(e){return uf(this,e)},getInitialData:function(e,t){var r=e.data;function n(Y){return!(isNaN(Y.min)||isNaN(Y.max)||isNaN(Y.step))}function i(Y){var O=$a;return Math.max(O(Y.min),O(Y.max),O(Y.step))+1}if(!r)if(e.parametric){var x=e.parametricEquation||{},E=x.u||{},S=x.v||{};["u","v"].forEach(function(O){n(x[O])}),["x","y","z"].forEach(function(O){x[O]});var R=Math.floor((E.max+E.step-E.min)/E.step),w=Math.floor((S.max+S.step-S.min)/S.step);r=new Float32Array(R*w*5);for(var M=i(E),F=i(S),d=0,f=0;f0;this._updateSurfaceMesh(this._surfaceMesh,e,u,f);var v=this._surfaceMesh.material;f?(v.define("WIREFRAME_QUAD"),v.set("wireframeLineWidth",d),v.set("wireframeLineColor",k.parseColor(h.get("lineStyle.color")))):v.undefine("WIREFRAME_QUAD"),this._initHandler(e,r),this._updateAnimation(e)},_updateAnimation:function(e){k.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new k.Mesh({geometry:new k.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new k.Material({shader:new k.Shader(k.Shader.source("ecgl.sm.depth.vertex"),k.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,lf),e},_initHandler:function(e,t){var r=e.getData(),n=this._surfaceMesh,i=e.coordinateSystem;function a(o,l){for(var c=1/0,u=-1,h=[],d=0;d=0){var c=[];n.geometry.attributes.position.get(l,c);for(var u=i.pointToData(c),h=1/0,d=-1,f=[],v=0;v65535?Uint32Array:Uint16Array)((v-1)*(_-1)*6),S=function(lt,qt,_t){_t[1]=lt*_+qt,_t[0]=lt*_+qt+1,_t[3]=(lt+1)*_+qt+1,_t[2]=(lt+1)*_+qt},R=!1;if(l){var w=[],M=[],F=0;p?u.init(i.vertexCount):u.value=null;for(var b=[[],[],[]],U=[],I=[],N=Ht.create(),G=function(lt,qt,_t){var En=qt*3;return _t[0]=lt[En],_t[1]=lt[En+1],_t[2]=lt[En+2],_t},B=new Float32Array(s.length),Y=new Float32Array(s.length/3*4),O=0;O0;){if(Math.floor(o/u)===o/u)return[u,o/u];u--}return u=Math.floor(Math.sqrt(o)),[u,u]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}});function _f(e){e.registerChartView(vf),e.registerSeriesModel(ff),e.registerLayout(function(t,r){t.eachSeriesByType("surface",function(n){var i=n.coordinateSystem;!i||i.type;var a=n.getData(),s=new Float32Array(3*a.count()),o=[NaN,NaN,NaN];if(i&&i.type==="cartesian3D"){var l=i.dimensions,c=l.map(function(u){return n.coordDimToDataDim(u)[0]});a.each(c,function(u,h,d,f){var v;a.hasValue(f)?v=i.dataToPoint([u,h,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 mf=Object.defineProperty,pf=Object.getOwnPropertyDescriptor,jt=(e,t,r,n)=>{for(var i=n>1?void 0:n?pf(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&mf(t,r,i),i};Oo([Io,Bo,sf,_f]);let Tt=class extends Et(At,Cr,Qs){get chart(){var e,t;return(t=(e=this.$refs.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:150}},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,n=this.bed_mesh.mesh_min[0],i=this.bed_mesh.mesh_max[0],a=this.bed_mesh.mesh_min[1],s=this.bed_mesh.mesh_max[1],o=(i-n)/(t-1),l=(s-a)/(r-1),c=[];let u=0;this.bed_mesh.probed_matrix.forEach(h=>{let d=0;h.forEach(f=>{c.push([n+o*d,a+l*u,f]),d++}),u++}),e.data=c,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,n=this.bed_mesh.mesh_min[0],i=this.bed_mesh.mesh_max[0],a=this.bed_mesh.mesh_min[1],s=this.bed_mesh.mesh_max[1],o=(i-n)/(t-1),l=(s-a)/(r-1),c=[];let u=0;this.bed_mesh.mesh_matrix.forEach(h=>{let d=0;h.forEach(f=>{c.push([n+o*d,a+l*u,f]),d++}),u++}),e.data=c,e.dataShape=[r,t]}return e}get seriesFlat(){var r,n,i,a;const e={type:"surface",name:"flat",data:[],itemStyle:{color:[1,1,1,1],opacity:.5},wireframe:{show:this.wireframe}},t=(n=(r=this.$store.state.printer.configfile)==null?void 0:r.settings)==null?void 0:n.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=(i=t.mesh_min)!=null?i:[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 c=s[0],u=s[1],h=parseFloat(o[0]),d=parseFloat(l[0]),f=parseFloat(o[1]),v=parseFloat(l[1]),_=(d-h)/(c-1),m=(v-f)/(u-1),p=[];for(let y=0;y".concat(e.seriesName,"")),Object.keys(e.encode).sort().forEach(r=>{const n=e.data[e.encode[r][0]].toFixed(r==="z"?3:1);t.push("".concat(r.toUpperCase(),": ").concat(n," mm"))}),t.join("
")}beforeDestroy(){typeof window>"u"||this.chart&&this.chart.dispose()}};jt([Ke({type:Boolean,default:!1})],Tt.prototype,"showProbed",2);jt([Ke({type:Boolean,default:!1})],Tt.prototype,"showMesh",2);jt([Ke({type:Boolean,default:!1})],Tt.prototype,"showFlat",2);jt([Ke({type:Boolean,default:!1})],Tt.prototype,"wireframe",2);jt([Ke({type:Boolean,default:!1})],Tt.prototype,"scaleGradient",2);jt([Ke({type:Number,default:1})],Tt.prototype,"scaleZMax",2);Tt=jt([vt],Tt);var gf=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("e-chart",{ref:"heightmap",staticStyle:{height:"600px",width:"100%",overflow:"hidden"},attrs:{option:e.chartOptions,"init-options":{renderer:"canvas"}}})},xf=[];const Fa={};var yf=St(Tt,gf,xf,!1,Tf,null,null,null);function Tf(e){for(let t in Fa)this[t]=Fa[t]}const Ef=function(){return yf.exports}();var Af=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r(Wt,{attrs:{"card-class":"heightmap-map-panel",title:e.$t("Heightmap.Heightmap"),icon:e.mdiGrid},scopedSlots:e._u([{key:"buttons",fn:function(){return[r(Pe,{staticClass:"d-none d-sm-flex",attrs:{icon:"",tile:"",disabled:e.printerIsPrinting,color:e.homedAxes.includes("xyz")?"primary":"warning",loading:e.loadings.includes("homeAll"),title:e.$t("Heightmap.TitleHomeAll"),ripple:!0},on:{click:e.homePrinter}},[r(gt,[e._v(e._s(e.mdiHome))])],1),e.is_active?r(Pe,{staticClass:"d-none d-sm-flex",attrs:{text:"",tile:"",loading:e.loadings.includes("bedMeshClear"),title:e.$t("Heightmap.TitleClear")},on:{click:e.clearBedMesh}},[e._v(" "+e._s(e.$t("Heightmap.Clear"))+" ")]):e._e(),r(Pe,{staticClass:"d-none d-sm-flex",attrs:{text:"",tile:"",loading:e.loadings.includes("bedMeshCalibrate"),disabled:e.printerIsPrinting,title:e.$t("Heightmap.TitleCalibrate")},on:{click:function(n){e.calibrateDialog=!0}}},[e._v(" "+e._s(e.$t("Heightmap.Calibrate"))+" ")])]},proxy:!0}])},[r(ft,{staticClass:"d-sm-none text-center pb-0"},[r(to,{staticClass:"v-btn-toggle",attrs:{tile:"",name:"controllers"}},[r(Pe,{staticClass:"px-2 minwidth-0",attrs:{text:"",small:"",disabled:e.printerIsPrinting,color:e.homedAxes.includes("xyz")?"primary":"warning",loading:e.loadings.includes("homeAll"),title:e.$t("Heightmap.TitleHomeAll")},on:{click:e.homePrinter}},[r(gt,{attrs:{color:e.homedAxes.includes("xyz")?"primary":"warning",small:""}},[e._v(" "+e._s(e.mdiHome)+" ")])],1),e.bed_mesh?r(Pe,{staticClass:"px-2 minwidth-0",attrs:{text:"",small:"",color:"primary",loading:e.loadings.includes("bedMeshClear"),title:e.$t("Heightmap.TitleClear")},on:{click:e.clearBedMesh}},[e._v(" "+e._s(e.$t("Heightmap.Clear"))+" ")]):e._e(),r(Pe,{staticClass:"px-2 minwidth-0",attrs:{text:"",small:"",color:"primary",loading:e.loadings.includes("bedMeshCalibrate"),disabled:e.printerIsPrinting,title:e.$t("Heightmap.TitleCalibrate")},on:{click:function(n){e.calibrateDialog=!0}}},[e._v(" "+e._s(e.$t("Heightmap.Calibrate"))+" ")])],1)],1),e.is_active?[r(ft,{staticClass:"py-0 px-0"},[r(ht,[r(we,{},[r(Ef,{attrs:{"show-probed":e.showProbed,"show-mesh":e.showMesh,"show-flat":e.showFlat,wireframe:e.wireframe,"scale-gradient":e.scaleGradient,"scale-z-max":e.scaleZMax}})],1)],1),r(ht,[r(we,{staticClass:"col-12 col-sm-auto pt-0 pb-0 pl-lg-6 d-flex justify-center justify-sm-start"},[r(ro,{staticClass:"mt-0 ml-5",attrs:{label:e.$t("Heightmap.ScaleGradient")},model:{value:e.scaleGradient,callback:function(n){e.scaleGradient=n},expression:"scaleGradient"}})],1),r(we,{staticClass:"d-flex justify-center pt-0 pb-6 pb-lg-3"},[r(Ur,{staticClass:"mx-3 mt-0",attrs:{label:e.$t("Heightmap.Probed"),"hide-details":""},model:{value:e.showProbed,callback:function(n){e.showProbed=n},expression:"showProbed"}}),r(Ur,{staticClass:"mx-3 mt-0",attrs:{label:e.$t("Heightmap.Mesh"),"hide-details":""},model:{value:e.showMesh,callback:function(n){e.showMesh=n},expression:"showMesh"}}),r(Ur,{staticClass:"mx-3 mt-0",attrs:{label:e.$t("Heightmap.Flat"),"hide-details":""},model:{value:e.showFlat,callback:function(n){e.showFlat=n},expression:"showFlat"}}),r(Ur,{staticClass:"mx-3 mt-0",attrs:{label:e.$t("Heightmap.Wireframe"),"hide-details":""},model:{value:e.wireframe,callback:function(n){e.wireframe=n},expression:"wireframe"}})],1)],1)],1),r(nr),r(ft,{staticClass:"pt-0 pb-3"},[r(ht,[r(we,[r(no,{staticClass:"mt-4",attrs:{label:e.$t("Heightmap.ScaleZMax"),min:e.heightmapRangeLimit[0],max:e.heightmapRangeLimit[1],step:.1,ticks:"always","hide-details":""},model:{value:e.scaleZMax,callback:function(n){e.scaleZMax=n},expression:"scaleZMax"}})],1)],1)],1)]:[r(ft,{staticClass:"text-center py-3 font-italic"},[e._v(" "+e._s(e.$t("Heightmap.NoBedMeshHasBeenLoadedYet"))+" ")])],r(Qa,{attrs:{show:e.calibrateDialog},on:{close:function(n){e.calibrateDialog=!1}}})],2)},Sf=[];const Ua={};var wf=St(Kn,Af,Sf,!1,bf,null,null,null);function bf(e){for(let t in Ua)this[t]=Ua[t]}const Cf=function(){return wf.exports}();var Rf=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",[r(ht,[e.klipperReadyForGui?[r(we,{staticClass:"col-12 col-md-8 pb-0"},[r(Cf)],1),r(we,{staticClass:"col-12 col-md-4"},[r(El),r(hl)],1)]:[r(we,[r(io,{staticClass:"mx-auto mt-6",attrs:{dense:"",text:"",type:"warning",elevation:"2","max-width":"500",icon:e.mdiLockOutline}},[e._v(" "+e._s(e.$t("Heightmap.ErrorKlipperNotReady"))+" ")])],1)]],2)],1)},Mf=[];const Ha={};var Lf=St(qn,Rf,Mf,!1,Nf,null,null,null);function Nf(e){for(let t in Ha)this[t]=Ha[t]}const Ff=function(){return Lf.exports}();export{Ff as default};