@rings-webgpu/core 1.0.40 → 1.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rings.es.js CHANGED
@@ -7888,7 +7888,7 @@ else if (typeof exports === 'object')
7888
7888
  `;class td{compute;constructor(){this.compute=new Fe(ed)}generateBRDFLUTTexture(){let e=new Te(256,256,oe.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);this.compute.setStorageTexture("brdflutTexture",e),this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let t=k.beginCommandEncoder();return k.computeCommand(t,[this.compute]),k.endCommandEncoder(t),e}}class ci{id;guiTexture;uvRec=new be(0,0,1,1);uvBorder=new be(0,0,0,0);offsetSize=new be(0,0,4,4);borderSize=new be(0,0,0,0);trimSize=new de;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||_.res.defaultGUITexture}}class Fr{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=_.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,Fr._maxUid++,this._staticId=Fr._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class wb{fntCache={};fntData={};addFontData(e,t,a){this.fntData[`${e}${t}`]=a}getFontData(e,t){return this.fntData[`${e}${t}`]}addFnt(e,t,a,r){let i=`${e}${t}`;this.fntCache[i]||(this.fntCache[i]={}),this.fntCache[i][a]=r}getFnt(e,t,a){let r=`${e}${t}`,i=this.fntCache[r];return i?i[a]:this.fntCache[" "]}}let fi=new wb;class ad{face="";size=0;bold=!1;italic=!1;stretchH=0;spacing="";outline=0;lineHeight=0;base=0;scaleW=0;scaleH=0;pages=0;packed=0;alphaChnl=0;redChnl=0;greenChnl=0;blueChnl=0;count=0;fontPage=[];fontChar={};constructor(){}}class rd{id=0;file=""}class id{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class ir extends it{static format=je.TEXT;static parseSprite(e,t){for(const a in t.fontChar)if(Object.prototype.hasOwnProperty.call(t.fontChar,a)){const r=t.fontChar[a];let i=new ci;i.id=r.id.toString(),i.offsetSize.set(0,0,r.width,r.height),i.trimSize.set(r.width,r.height),i.width=r.width,i.height=r.height,i.xadvance=r.xadvance,i.xoffset=r.xoffset,i.yoffset=r.yoffset,i.guiTexture=e[r.page],i.uvRec.set(r.x/t.scaleW,(t.scaleH-(r.y+r.height))/t.scaleH,r.width/t.scaleW,r.height/t.scaleH),fi.addFnt(t.face,t.size,i.id,i)}}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}async parseString(e){let t=this.getNewLine(e),a=e,r=new ad;a.trim().split(t).forEach((i,n)=>{if(n<2)ir.readLineProperty(i,r);else if(n<r.pages+2){let o=new rd;ir.readLineProperty(i,o),r.fontPage.push(o)}else if(n<r.pages+3)ir.readLineProperty(i,r);else if(r.count>0){let o=new id;ir.readLineProperty(i,o),r.fontChar[o.id]=o,r.count--}}),a="",this.data=r,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
7889
7889
  `)!=-1?`\r
7890
7890
  `:e.indexOf("\r")!=-1?"\r":`
7891
- `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await _.res.loadTexture(r,null,!0);let i=_.res.getTexture(r),n=new Fr(i);e.push(n)}ir.parseSprite(e,t),t.fontChar[" "]||ir.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ci,r=e.size*.5,i=e.lineHeight*.5;a.id=" ",a.offsetSize.set(0,0,e.size,e.size),a.trimSize.set(r,i),a.width=r,a.height=i,a.xadvance=0,a.xoffset=0,a.yoffset=0,a.guiTexture=t,a.uvRec.set(0,0,1e-6,1e-6),fi.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function Ib(s,e){let t=new ci;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new Fr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function sd(s,e,t){let a=new ci;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class nd{_spriteMap=new Map;_spriteList=[];textureSize=new de;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=sd(e,t,a);return this._spriteMap.set(r.id,r),this._spriteList.push(r),r}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class od extends it{static format=je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await _.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new nd(this._json.size),t=new Fr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);_.res.addAtlas(this.baseUrl,e),this.data=e}}var qt=Uint8Array,di=Uint16Array,Rb=Int32Array,ld=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),cd=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Qb=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fd=function(s,e){for(var t=new di(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new Rb(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},dd=fd(ld,2),hd=dd.b,Tb=dd.r;hd[28]=258,Tb[258]=28;for(var Mb=fd(cd,0),Nb=Mb.b,wo=new di(32768),Ke=0;Ke<32768;++Ke){var gr=(Ke&43690)>>1|(Ke&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,wo[Ke]=((gr&65280)>>8|(gr&255)<<8)>>1}for(var Pi=(function(s,e,t){for(var a=s.length,r=0,i=new di(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new di(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new di(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[wo[d]>>l]=c}else for(o=new di(a),r=0;r<a;++r)s[r]&&(o[r]=wo[n[s[r]-1]++]>>15-s[r]);return o}),Vi=new qt(288),Ke=0;Ke<144;++Ke)Vi[Ke]=8;for(var Ke=144;Ke<256;++Ke)Vi[Ke]=9;for(var Ke=256;Ke<280;++Ke)Vi[Ke]=7;for(var Ke=280;Ke<288;++Ke)Vi[Ke]=8;for(var ud=new qt(32),Ke=0;Ke<32;++Ke)ud[Ke]=5;var Pb=Pi(Vi,9,1),Vb=Pi(ud,5,1),Io=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},va=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ro=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Ob=function(s){return(s+7)/8|0},Qo=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new qt(s.subarray(e,t))},Lb=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ca=function(s,e,t){var a=new Error(e||Lb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},Gb=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new qt(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new qt(r*3));var c=function(ie){var le=t.length;if(ie>le){var ge=new qt(Math.max(le*2,ie));ge.set(t),t=ge}},f=e.f||0,d=e.p||0,h=e.b||0,u=e.l,m=e.d,g=e.m,p=e.n,D=r*8;do{if(!u){f=va(s,d,1);var A=va(s,d+1,3);if(d+=3,A)if(A==1)u=Pb,m=Vb,g=9,p=5;else if(A==2){var y=va(s,d,31)+257,S=va(s,d+10,15)+4,F=y+va(s,d+5,31)+1;d+=14;for(var C=new qt(F),w=new qt(19),E=0;E<S;++E)w[Qb[E]]=va(s,d+E*3,7);d+=S*3;for(var Q=Io(w),T=(1<<Q)-1,j=Pi(w,Q,1),E=0;E<F;){var ue=j[va(s,d,T)];d+=ue&15;var B=ue>>4;if(B<16)C[E++]=B;else{var ee=0,N=0;for(B==16?(N=3+va(s,d,3),d+=2,ee=C[E-1]):B==17?(N=3+va(s,d,7),d+=3):B==18&&(N=11+va(s,d,127),d+=7);N--;)C[E++]=ee}}var M=C.subarray(0,y),O=C.subarray(y);g=Io(M),p=Io(O),u=Pi(M,g,1),m=Pi(O,p,1)}else ca(1);else{var B=Ob(d)+4,v=s[B-4]|s[B-3]<<8,U=B+v;if(U>r){l&&ca(0);break}o&&c(h+v),t.set(s.subarray(B,U),h),e.b=h+=v,e.p=d=U*8,e.f=f;continue}if(d>D){l&&ca(0);break}}o&&c(h+131072);for(var W=(1<<g)-1,ae=(1<<p)-1,z=d;;z=d){var ee=u[Ro(s,d)&W],K=ee>>4;if(d+=ee&15,d>D){l&&ca(0);break}if(ee||ca(2),K<256)t[h++]=K;else if(K==256){z=d,u=null;break}else{var $=K-254;if(K>264){var E=K-257,re=ld[E];$=va(s,d,(1<<re)-1)+hd[E],d+=re}var ce=m[Ro(s,d)&ae],Ae=ce>>4;ce||ca(3),d+=ce&15;var O=Nb[Ae];if(Ae>3){var re=cd[Ae];O+=Ro(s,d)&(1<<re)-1,d+=re}if(d>D){l&&ca(0);break}o&&c(h+131072);var Qe=h+$;if(h<O){var Ve=i-O,H=Math.min(O,Qe);for(Ve+h<0&&ca(3);h<H;++h)t[h]=a[Ve+h]}for(;h<Qe;++h)t[h]=t[h-O]}}e.l=u,e.p=z,e.b=h,e.f=f,u&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return h!=t.length&&n?Qo(t,0,h):t.subarray(0,h)},zb=new qt(0),Oa=function(s,e){return s[e]|s[e+1]<<8},xa=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},To=function(s,e){return xa(s,e)+xa(s,e+4)*4294967296};function Wb(s,e){return Gb(s,{i:2},e&&e.out,e&&e.dictionary)}var Mo=typeof TextDecoder<"u"&&new TextDecoder,Jb=0;try{Mo.decode(zb,{stream:!0}),Jb=1}catch{}var jb=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:Qo(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function bd(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(Mo)return Mo.decode(s);var r=jb(s),i=r.s,t=r.r;return t.length&&ca(8),i}}var Zb=function(s,e){return e+30+Oa(s,e+26)+Oa(s,e+28)},Yb=function(s,e,t){var a=Oa(s,e+28),r=bd(s.subarray(e+46,e+46+a),!(Oa(s,e+8)&2048)),i=e+46+a,n=xa(s,e+20),o=t&&n==4294967295?Xb(s,i):[n,xa(s,e+24),xa(s,e+42)],l=o[0],c=o[1],f=o[2];return[Oa(s,e+10),l,c,r,i+Oa(s,e+30)+Oa(s,e+32),f]},Xb=function(s,e){for(;Oa(s,e)!=1;e+=4+Oa(s,e+2));return[To(s,e+12),To(s,e+4),To(s,e+20)]};function Hb(s,e){for(var t={},a=s.length-22;xa(s,a)!=101010256;--a)(!a||s.length-a>65558)&&ca(13);var r=Oa(s,a+8);if(!r)return{};var i=xa(s,a+16),n=i==4294967295||r==65535;if(n){var o=xa(s,a-12);n=xa(s,o)==101075792,n&&(r=xa(s,o+32),i=xa(s,o+48))}for(var l=0;l<r;++l){var c=Yb(s,i,n),f=c[0],d=c[1],h=c[2],u=c[3],m=c[4],g=c[5],p=Zb(s,g);i=m,f?f==8?t[u]=Wb(s.subarray(p,p+d),{out:new qt(h)}):ca(14,"unknown compression type "+f):t[u]=Qo(s,p,p+d)}return t}class Bt extends vt{constructor(){super(),this.shader=new qi,this.baseMap=_.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Nr extends Le{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),d=new Uint16Array(i*r*2*3),h=0,u=0,m=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,p=n*Math.cos(g),D=n*Math.sin(g);for(e=0;e<=i;++e){var A=2*Math.PI*e/i,B=D*Math.cos(A),v=D*Math.sin(A),U=1/Math.sqrt(B*B+p*p+v*v);if(l[h++]=B,l[h++]=p,l[h++]=v,c[u++]=B*U,c[u++]=p*U,c[u++]=v*U,f[m++]=e/i,f[m++]=t/r,e>0&&t>0){var y=(i+1)*t+e,S=(i+1)*t+e-1,F=(i+1)*(t-1)+e-1,C=(i+1)*(t-1)+e;t==r?(d[a++]=y,d[a++]=F,d[a++]=C):t==1?(d[a++]=y,d[a++]=S,d[a++]=F):(d[a++]=y,d[a++]=S,d[a++]=F,d[a++]=y,d[a++]=F,d[a++]=C)}}}this.setIndices(d),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class _s extends ne{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),_s.register3DRepresentation)this.marker=_s.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ne;const e=this.marker.addComponent(he);e.geometry=new Nr(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new J(0,1,0,1):new J(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Bs extends ne{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new _s(t);this.addChild(a)}this.entityChildren=this.entityChildren.sort((t,a)=>t.positionIndex-a.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),Bs.register3DRepresentation?(this.line=Bs.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new J(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Le,r=new Float32Array(e.length*3);for(let c=0;c<e.length;c++)r[c*3]=e[c].x,r[c*3+1]=e[c].y,r[c*3+2]=e[c].z;const i=new Uint16Array((e.length-1)*2);for(let c=0;c<e.length-1;c++)i[c*2]=c,i[c*2+1]=c+1;a.setIndices(i),a.setAttribute(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new ne,o=n.addComponent(he),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=De.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class gd extends it{static format=je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Hb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(bd(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new Bs(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class pd{_texturePool;_materialPool;_prefabPool;_gltfPool;_geometryPool;_atlasList;_obj;constructor(){this._texturePool=new Map,this._materialPool=new Map,this._prefabPool=new Map,this._geometryPool=new Map,this._gltfPool=new Map,this._atlasList=new Map,this._obj=new Map}getGltf(e){return this._gltfPool.get(e)}addObj(e,t){this._obj.set(e,t)}getObj(e){return this._obj.get(e)}addTexture(e,t){this._texturePool.set(e,t)}getTexture(e){return this._texturePool.get(e)}addGeometry(e,t){this._geometryPool.set(e,t)}getGeometry(e){return this._geometryPool.get(e)}addMat(e,t){return this._materialPool.set(e,t)}getMat(e){return this._materialPool.get(e)}addPrefab(e,t){this._prefabPool.set(e,t)}getPrefab(e){return this._prefabPool.get(e).instantiate()}addAtlas(e,t){t.name=e,this._atlasList.set(e,t)}getAtlas(e){return this._atlasList.get(e)}getGUISprite(e){for(let t of this._atlasList.values()){let a=t.getSprite(e);if(a)return a}return null}async load(e,t,a){return(await new It().load(e,t,a)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new It;r==".gltf"?a=await i.load(e,xt,t):a=await i.load(e,_o,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new It;r==".obj"&&(a=await i.load(e,Ds,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,So,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,Eo,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}destroyTexture(e){const t=this._texturePool.get(e);return t?ke.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(d=>{l.push(d),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new xo;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Os;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Gs;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let a=new Bo;return await a.load(e),this._texturePool.set(e[0],a),a}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Bo;return await a.loadStd(e),a}async loadJSON(e,t){return await new It().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new It().load(e,ir,t,a),n=i.data;return fi.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new It().load(e,od,t,e)).data}async loadKMZ(e,t){return(await new It().load(e,gd,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let d=new Fi;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new td().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Os,this.defaultSky.createFromTexture(128,this.blackTexture),ke.getInstance().attached(this.defaultSky,this),ke.getInstance().attached(t,this),ke.getInstance().attached(this.normalTexture,this),ke.getInstance().attached(this.maskTexture,this),ke.getInstance().attached(this.whiteTexture,this),ke.getInstance().attached(this.blackTexture,this),ke.getInstance().attached(this.redTexture,this),ke.getInstance().attached(this.blueTexture,this),ke.getInstance().attached(this.greenTexture,this),ke.getInstance().attached(this.yellowTexture,this),ke.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new Fr(this.whiteTexture),this.defaultGUISprite=new ci(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new ta}}class md extends et{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.removePost(a)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let a=this.transform.view3D;_.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Kb="1.0.39";class _{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new J(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",Kb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Re.init(R.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,ve.getGBufferFrame(ve.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Y.init(),Ha.init(),xe.init(),Mt.init(),jt.init(),this.res=new pd,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Sl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new bf(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(md).addPost(so),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let a=performance.now();await new Promise(r=>{setTimeout(()=>{e+=performance.now()-a,r(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){We.delta=e-We.time,We.time=e,We.frame+=1,Sr.tick(We.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=I.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Oe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=I.device.createCommandEncoder();for(const n of Oe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}I.device.queue.submit([r.finish()]);for(const n of Oe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of Oe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),Re.updateAllContinueTransform(0,R.useCount,16),xe.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Oe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let zs=`
7891
+ `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await _.res.loadTexture(r,null,!0);let i=_.res.getTexture(r),n=new Fr(i);e.push(n)}ir.parseSprite(e,t),t.fontChar[" "]||ir.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ci,r=e.size*.5,i=e.lineHeight*.5;a.id=" ",a.offsetSize.set(0,0,e.size,e.size),a.trimSize.set(r,i),a.width=r,a.height=i,a.xadvance=0,a.xoffset=0,a.yoffset=0,a.guiTexture=t,a.uvRec.set(0,0,1e-6,1e-6),fi.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function Ib(s,e){let t=new ci;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new Fr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function sd(s,e,t){let a=new ci;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class nd{_spriteMap=new Map;_spriteList=[];textureSize=new de;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=sd(e,t,a);return this._spriteMap.set(r.id,r),this._spriteList.push(r),r}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class od extends it{static format=je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await _.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new nd(this._json.size),t=new Fr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);_.res.addAtlas(this.baseUrl,e),this.data=e}}var qt=Uint8Array,di=Uint16Array,Rb=Int32Array,ld=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),cd=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Qb=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fd=function(s,e){for(var t=new di(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new Rb(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},dd=fd(ld,2),hd=dd.b,Tb=dd.r;hd[28]=258,Tb[258]=28;for(var Mb=fd(cd,0),Nb=Mb.b,wo=new di(32768),Ke=0;Ke<32768;++Ke){var gr=(Ke&43690)>>1|(Ke&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,wo[Ke]=((gr&65280)>>8|(gr&255)<<8)>>1}for(var Pi=(function(s,e,t){for(var a=s.length,r=0,i=new di(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new di(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new di(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[wo[d]>>l]=c}else for(o=new di(a),r=0;r<a;++r)s[r]&&(o[r]=wo[n[s[r]-1]++]>>15-s[r]);return o}),Vi=new qt(288),Ke=0;Ke<144;++Ke)Vi[Ke]=8;for(var Ke=144;Ke<256;++Ke)Vi[Ke]=9;for(var Ke=256;Ke<280;++Ke)Vi[Ke]=7;for(var Ke=280;Ke<288;++Ke)Vi[Ke]=8;for(var ud=new qt(32),Ke=0;Ke<32;++Ke)ud[Ke]=5;var Pb=Pi(Vi,9,1),Vb=Pi(ud,5,1),Io=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},va=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ro=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Ob=function(s){return(s+7)/8|0},Qo=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new qt(s.subarray(e,t))},Lb=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ca=function(s,e,t){var a=new Error(e||Lb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},Gb=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new qt(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new qt(r*3));var c=function(ie){var le=t.length;if(ie>le){var ge=new qt(Math.max(le*2,ie));ge.set(t),t=ge}},f=e.f||0,d=e.p||0,h=e.b||0,u=e.l,m=e.d,g=e.m,p=e.n,D=r*8;do{if(!u){f=va(s,d,1);var A=va(s,d+1,3);if(d+=3,A)if(A==1)u=Pb,m=Vb,g=9,p=5;else if(A==2){var y=va(s,d,31)+257,S=va(s,d+10,15)+4,F=y+va(s,d+5,31)+1;d+=14;for(var C=new qt(F),w=new qt(19),E=0;E<S;++E)w[Qb[E]]=va(s,d+E*3,7);d+=S*3;for(var Q=Io(w),T=(1<<Q)-1,j=Pi(w,Q,1),E=0;E<F;){var ue=j[va(s,d,T)];d+=ue&15;var B=ue>>4;if(B<16)C[E++]=B;else{var ee=0,N=0;for(B==16?(N=3+va(s,d,3),d+=2,ee=C[E-1]):B==17?(N=3+va(s,d,7),d+=3):B==18&&(N=11+va(s,d,127),d+=7);N--;)C[E++]=ee}}var M=C.subarray(0,y),O=C.subarray(y);g=Io(M),p=Io(O),u=Pi(M,g,1),m=Pi(O,p,1)}else ca(1);else{var B=Ob(d)+4,v=s[B-4]|s[B-3]<<8,U=B+v;if(U>r){l&&ca(0);break}o&&c(h+v),t.set(s.subarray(B,U),h),e.b=h+=v,e.p=d=U*8,e.f=f;continue}if(d>D){l&&ca(0);break}}o&&c(h+131072);for(var W=(1<<g)-1,ae=(1<<p)-1,z=d;;z=d){var ee=u[Ro(s,d)&W],K=ee>>4;if(d+=ee&15,d>D){l&&ca(0);break}if(ee||ca(2),K<256)t[h++]=K;else if(K==256){z=d,u=null;break}else{var $=K-254;if(K>264){var E=K-257,re=ld[E];$=va(s,d,(1<<re)-1)+hd[E],d+=re}var ce=m[Ro(s,d)&ae],Ae=ce>>4;ce||ca(3),d+=ce&15;var O=Nb[Ae];if(Ae>3){var re=cd[Ae];O+=Ro(s,d)&(1<<re)-1,d+=re}if(d>D){l&&ca(0);break}o&&c(h+131072);var Qe=h+$;if(h<O){var Ve=i-O,H=Math.min(O,Qe);for(Ve+h<0&&ca(3);h<H;++h)t[h]=a[Ve+h]}for(;h<Qe;++h)t[h]=t[h-O]}}e.l=u,e.p=z,e.b=h,e.f=f,u&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return h!=t.length&&n?Qo(t,0,h):t.subarray(0,h)},zb=new qt(0),Oa=function(s,e){return s[e]|s[e+1]<<8},xa=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},To=function(s,e){return xa(s,e)+xa(s,e+4)*4294967296};function Wb(s,e){return Gb(s,{i:2},e&&e.out,e&&e.dictionary)}var Mo=typeof TextDecoder<"u"&&new TextDecoder,Jb=0;try{Mo.decode(zb,{stream:!0}),Jb=1}catch{}var jb=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:Qo(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function bd(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(Mo)return Mo.decode(s);var r=jb(s),i=r.s,t=r.r;return t.length&&ca(8),i}}var Zb=function(s,e){return e+30+Oa(s,e+26)+Oa(s,e+28)},Yb=function(s,e,t){var a=Oa(s,e+28),r=bd(s.subarray(e+46,e+46+a),!(Oa(s,e+8)&2048)),i=e+46+a,n=xa(s,e+20),o=t&&n==4294967295?Xb(s,i):[n,xa(s,e+24),xa(s,e+42)],l=o[0],c=o[1],f=o[2];return[Oa(s,e+10),l,c,r,i+Oa(s,e+30)+Oa(s,e+32),f]},Xb=function(s,e){for(;Oa(s,e)!=1;e+=4+Oa(s,e+2));return[To(s,e+12),To(s,e+4),To(s,e+20)]};function Hb(s,e){for(var t={},a=s.length-22;xa(s,a)!=101010256;--a)(!a||s.length-a>65558)&&ca(13);var r=Oa(s,a+8);if(!r)return{};var i=xa(s,a+16),n=i==4294967295||r==65535;if(n){var o=xa(s,a-12);n=xa(s,o)==101075792,n&&(r=xa(s,o+32),i=xa(s,o+48))}for(var l=0;l<r;++l){var c=Yb(s,i,n),f=c[0],d=c[1],h=c[2],u=c[3],m=c[4],g=c[5],p=Zb(s,g);i=m,f?f==8?t[u]=Wb(s.subarray(p,p+d),{out:new qt(h)}):ca(14,"unknown compression type "+f):t[u]=Qo(s,p,p+d)}return t}class Bt extends vt{constructor(){super(),this.shader=new qi,this.baseMap=_.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Nr extends Le{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),d=new Uint16Array(i*r*2*3),h=0,u=0,m=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,p=n*Math.cos(g),D=n*Math.sin(g);for(e=0;e<=i;++e){var A=2*Math.PI*e/i,B=D*Math.cos(A),v=D*Math.sin(A),U=1/Math.sqrt(B*B+p*p+v*v);if(l[h++]=B,l[h++]=p,l[h++]=v,c[u++]=B*U,c[u++]=p*U,c[u++]=v*U,f[m++]=e/i,f[m++]=t/r,e>0&&t>0){var y=(i+1)*t+e,S=(i+1)*t+e-1,F=(i+1)*(t-1)+e-1,C=(i+1)*(t-1)+e;t==r?(d[a++]=y,d[a++]=F,d[a++]=C):t==1?(d[a++]=y,d[a++]=S,d[a++]=F):(d[a++]=y,d[a++]=S,d[a++]=F,d[a++]=y,d[a++]=F,d[a++]=C)}}}this.setIndices(d),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class _s extends ne{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),_s.register3DRepresentation)this.marker=_s.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ne;const e=this.marker.addComponent(he);e.geometry=new Nr(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new J(0,1,0,1):new J(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Bs extends ne{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new _s(t);this.addChild(a)}this.entityChildren=this.entityChildren.sort((t,a)=>t.positionIndex-a.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),Bs.register3DRepresentation?(this.line=Bs.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new J(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Le,r=new Float32Array(e.length*3);for(let c=0;c<e.length;c++)r[c*3]=e[c].x,r[c*3+1]=e[c].y,r[c*3+2]=e[c].z;const i=new Uint16Array((e.length-1)*2);for(let c=0;c<e.length-1;c++)i[c*2]=c,i[c*2+1]=c+1;a.setIndices(i),a.setAttribute(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new ne,o=n.addComponent(he),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=De.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class gd extends it{static format=je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Hb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(bd(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new Bs(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class pd{_texturePool;_materialPool;_prefabPool;_gltfPool;_geometryPool;_atlasList;_obj;constructor(){this._texturePool=new Map,this._materialPool=new Map,this._prefabPool=new Map,this._geometryPool=new Map,this._gltfPool=new Map,this._atlasList=new Map,this._obj=new Map}getGltf(e){return this._gltfPool.get(e)}addObj(e,t){this._obj.set(e,t)}getObj(e){return this._obj.get(e)}addTexture(e,t){this._texturePool.set(e,t)}getTexture(e){return this._texturePool.get(e)}addGeometry(e,t){this._geometryPool.set(e,t)}getGeometry(e){return this._geometryPool.get(e)}addMat(e,t){return this._materialPool.set(e,t)}getMat(e){return this._materialPool.get(e)}addPrefab(e,t){this._prefabPool.set(e,t)}getPrefab(e){return this._prefabPool.get(e).instantiate()}addAtlas(e,t){t.name=e,this._atlasList.set(e,t)}getAtlas(e){return this._atlasList.get(e)}getGUISprite(e){for(let t of this._atlasList.values()){let a=t.getSprite(e);if(a)return a}return null}async load(e,t,a){return(await new It().load(e,t,a)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new It;r==".gltf"?a=await i.load(e,xt,t):a=await i.load(e,_o,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new It;r==".obj"&&(a=await i.load(e,Ds,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,So,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,Eo,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}destroyTexture(e){const t=this._texturePool.get(e);return t?ke.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(d=>{l.push(d),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new xo;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Os;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Gs;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let a=new Bo;return await a.load(e),this._texturePool.set(e[0],a),a}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Bo;return await a.loadStd(e),a}async loadJSON(e,t){return await new It().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new It().load(e,ir,t,a),n=i.data;return fi.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new It().load(e,od,t,e)).data}async loadKMZ(e,t){return(await new It().load(e,gd,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let d=new Fi;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new td().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Os,this.defaultSky.createFromTexture(128,this.blackTexture),ke.getInstance().attached(this.defaultSky,this),ke.getInstance().attached(t,this),ke.getInstance().attached(this.normalTexture,this),ke.getInstance().attached(this.maskTexture,this),ke.getInstance().attached(this.whiteTexture,this),ke.getInstance().attached(this.blackTexture,this),ke.getInstance().attached(this.redTexture,this),ke.getInstance().attached(this.blueTexture,this),ke.getInstance().attached(this.greenTexture,this),ke.getInstance().attached(this.yellowTexture,this),ke.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new Fr(this.whiteTexture),this.defaultGUISprite=new ci(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new ta}}class md extends et{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.removePost(a)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let a=this.transform.view3D;_.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Kb="1.0.42";class _{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new J(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",Kb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Re.init(R.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,ve.getGBufferFrame(ve.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Y.init(),Ha.init(),xe.init(),Mt.init(),jt.init(),this.res=new pd,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Sl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new bf(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(md).addPost(so),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let a=performance.now();await new Promise(r=>{setTimeout(()=>{e+=performance.now()-a,r(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){We.delta=e-We.time,We.time=e,We.frame+=1,Sr.tick(We.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=I.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Oe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=I.device.createCommandEncoder();for(const n of Oe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}I.device.queue.submit([r.finish()]);for(const n of Oe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of Oe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),Re.updateAllContinueTransform(0,R.useCount,16),xe.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Oe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let zs=`
7892
7892
  struct BloomCfg{
7893
7893
  downSampleStep: f32,
7894
7894
  downSampleBlurSize: f32,
@@ -11786,7 +11786,7 @@ fn frag(){
11786
11786
  ${this.fs}
11787
11787
  `}class Wo extends vt{_scissorRect;_screenSize=new de(1024,768);_scissorEnable=!1;constructor(e){super(),Y.register("GUI_shader_view",zo.GUI_shader_view),Y.register("GUI_shader_world",zo.GUI_shader_world);let t=new At;this.addColorPass(t,fe.COLOR,e),this.addColorPass(t,fe.UI,e),this.shader=t}addColorPass(e,t,a){let r=a==fa.View?"GUI_shader_view":"GUI_shader_world",i=new qe(r,r);i.passType=t,i.setShaderEntry("VertMain","FragMain"),i.setUniformVector4("scissorRect",new be),i.setUniformVector2("screenSize",this._screenSize),i.setUniformFloat("scissorCornerRadius",0),i.setUniformFloat("scissorFadeOutSize",0),i.setUniformFloat("pixelRatio",1),i.setUniformVector3("v3",b.ZERO);let n=i.shaderState;n.depthWriteEnabled=!1,i.blendMode=De.NORMAL,i.depthCompare=a==fa.View?ft.always:ft.less_equal,i.cullMode=Lt.back,e.addRenderPass(i)}setPanelRatio(e){this.shader.setUniformFloat("pixelRatio",e)}setScissorRect(e,t,a,r){this._scissorRect||=new be,this._scissorRect.set(e,t,a,r),this.shader.setUniformVector4("scissorRect",this._scissorRect)}setScissorEnable(e){this._scissorEnable!=e&&(this._scissorEnable=e,e?this.shader.setDefine("SCISSOR_ENABLE",!0):this.shader.deleteDefine("SCISSOR_ENABLE"),this.shader.noticeValueChange())}setScissorCorner(e,t){this.shader.setUniformFloat("scissorCornerRadius",e),this.shader.setUniformFloat("scissorFadeOutSize",t)}setScreenSize(e,t){return this._screenSize.set(e,t),this.shader.setUniformVector2("screenSize",this._screenSize),this}setTextures(e){for(let t=0;t<7;t++){let a=e[t]||_.res.whiteTexture;this.shader.setTexture(`tex_${t}`,a),this.setVideoTextureDefine(t,a.isVideoTexture)}}_videoTextureFlags={};setVideoTextureDefine(e,t){let a=!1;t!=this._videoTextureFlags[e]&&(t?this.shader.setDefine(`VideoTexture${e}`,!0):this.shader.deleteDefine(`VideoTexture${e}`),this._videoTextureFlags[e]=t,a=!0),a&&this.shader.noticeValueChange()}set envMap(e){}set shadowMap(e){}set baseMap(e){}set normalMap(e){}set emissiveMap(e){}set irradianceMap(e){}set irradianceDepthMap(e){}}class bh extends he{_guiGeometry;init(e){super.init(),this.addRendererMask(Ne.UI),this.removeRendererMask(Ne.Default),this.castGI=!1,this.castShadow=!1,this.alwaysRender=!0,this._ignoreEnvMap=this._ignorePrefilterMap=!0}get geometry(){return super.geometry}set geometry(e){super.geometry=e,this._guiGeometry=e}nodeUpdate(e,t,a,r){for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t),l=this._guiGeometry.getPositionBuffer(),c=this._guiGeometry.getSpriteBuffer(),f=this._guiGeometry.getColorBuffer();if(o)for(let d=0;d<o.length;d++){const h=o[d];h.pipeline||(h.setStorageBuffer("vPositionBuffer",l),h.setStorageBuffer("vSpriteBuffer",c),h.setStorageBuffer("vColorBuffer",f))}}super.nodeUpdate(e,t,a,r)}onUpdate(e){}}class gh{_use;_unUse;constructor(){this._use=[],this._unUse=[]}pushBack(e){let t=this._use.indexOf(e);t!=-1&&(this._use.splice(t,1),this._unUse.push(e))}getUseList(){return this._use}getOne(e,t){let a;return this._unUse.length>0?(a=this._unUse[0],this._unUse.splice(0,1),this._use.push(a),a):(a=new e(t),this._use.push(a),a)}hasFree(){return this._unUse.length>0}}let Ji;class Ja{x=0;y=0;z=0;width=1;height=1;_globalX=0;_globalY=0;_globalWidth=0;_globalHeight=0;_visible=!0;_offsetX=0;_offsetY=0;_sprite=_.res.defaultGUISprite;_color=new J(1,1,1,1);_imageType=hi.Simple;dirtyAttributes=ot.MAX;cacheTextureId=-1;static textPool;static get quadPool(){return this.textPool||=new gh,this.textPool}static recycleQuad(e){e.sprite=null,e.dirtyAttributes=ot.MAX,e.x=0,e.y=0,e.z=-1,e.cacheTextureId=-1,Ja.quadPool.pushBack(e)}static spawnQuad(){return Ja.quadPool.getOne(Ja)}get imageType(){return this._imageType}set imageType(e){this._imageType=e,this.setAttrChange(ot.SPRITE|ot.POSITION)}get color(){return this._color}set color(e){this._color.copyFrom(e),this.setAttrChange(ot.COLOR)}get visible(){return this._visible}set visible(e){e!=this._visible&&(this._visible=e,this.setAttrChange(ot.SPRITE))}get sprite(){return this._sprite}set sprite(e){this._sprite!=e&&(this._sprite=e,this.setAttrChange(ot.SPRITE|ot.POSITION))}get left(){return this._globalX-this._offsetX}get right(){return this.left+this._globalWidth}get top(){return this._globalY-this._offsetY}get bottom(){return this.top+this._globalHeight}setSize(e,t){this.width=e,this.height=t,this.setAttrChange(ot.POSITION)}setXY(e,t){this.x=e,this.y=t,this.setAttrChange(ot.POSITION)}setAttrChange(e){this.dirtyAttributes=this.dirtyAttributes|e}applyTransform(e){this.setAttrChange(ot.POSITION);let t=this._sprite,a=e.getWorldMatrix();(this.x!=0||this.y!=0)&&(a=this.getQuadMatrix(a));let r=a.getScaleX(),i=a.getScaleY(),n=t.isSliced&&this._imageType==hi.Sliced;if(this._offsetX=e.width*.5*r,this._offsetY=e.height*.5*i,n)this._globalWidth=r*(e.width-(t.offsetSize.z-t.trimSize.x)),this._globalHeight=i*(e.height-(t.offsetSize.w-t.trimSize.y)),this._globalX=a.tx+t.offsetSize.x*r,this._globalY=a.ty+t.offsetSize.y*i;else{let o=this.width/t.offsetSize.z,l=this.height/t.offsetSize.w;this._globalWidth=r*t.trimSize.x*o,this._globalHeight=i*t.trimSize.y*l,this._globalX=a.tx+t.offsetSize.x*o*r,this._globalY=a.ty+t.offsetSize.y*l*i}return this}getQuadMatrix(e){return Ji||=new Gr,Ji.identity(),Ji.setTranslate(this.x,this.y),Ji.mul(e),Ji}writeToGeometry(e,t){return e.fillQuad(this,t),this.dirtyAttributes=ot.NONE,this}}class Jo extends et{_uiTransform;_visible=!0;destroy(){this._uiTransform.setNeedUpdateUIPanel(),super.destroy()}get uiTransform(){return this._uiTransform}get visible(){return this._visible}set visible(e){this._visible!=e&&(this._visible=e,this.onUIComponentVisible?.(this._visible))}init(e){super.init?.(e),this._uiTransform=this.object3D.getOrAddComponent(or),this._uiTransform.setNeedUpdateUIPanel()}copyComponent(e){return this.visible=e.visible,this}}class ji extends Jo{_mainQuads;_shadowRender;_shadowSource;isUIShadow;isShadowless;needUpdateShadow;init(e){super.init?.(e),this._mainQuads=[]}destroy(){this.detachQuads(),this._shadowRender?.setShadowSource(null),this._shadowSource?.setShadowRenderer(null),super.destroy(),this._shadowRender=null,this._shadowSource=null}start(){super.start?.(),this.isUIShadow?this.autoBindShadow(null,this):this.isShadowless||this.autoBindShadow(this,null),this.setShadowDirty()}setShadowDirty(){this._shadowRender&&(this._shadowRender.needUpdateShadow=!0)}get mainQuads(){return this._mainQuads}setShadowRenderer(e){this._shadowRender=e}setShadowSource(e){this._shadowSource=e}getShadowRender(){return this._shadowRender}autoBindShadow(e,t){let a=this.object3D.components.values();if(!e)for(let r of a){let i=r;if(!(i.isShadowless||i.isUIShadow)&&i.mainQuads){e=i;break}}if(!t)for(let r of a){let i=r;if(i.isUIShadow&&i.mainQuads){t=i;break}}return e&&t?(e.setShadowRenderer(t),t.setShadowSource(e),!0):!1}recycleQuad(e){if(e&&this._mainQuads){let t=this._mainQuads.indexOf(e);t>=0?(this._mainQuads.splice(t,1),Ja.recycleQuad(e)):e=null}return e}attachQuad(e){return this._mainQuads&&this._mainQuads.push(e),this}detachQuads(){if(this._mainQuads)for(;this._mainQuads.length>0;){let e=this._mainQuads.shift();this.recycleQuad(e)}return this}copyComponent(e){return super.copyComponent(e),this.isUIShadow=e.isUIShadow,this.isShadowless=e.isShadowless,this}}class zr extends ji{init(e){super.init?.(e),this.attachQuad(Ja.spawnQuad()),this.sprite=_.res.defaultGUISprite}cloneTo(e){e.getOrAddComponent(zr).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.sprite=e.sprite,this.color=e.color,this.imageType=e.imageType,this}set sprite(e){e||=_.res.defaultGUISprite;for(let t of this._mainQuads)t.sprite=e,t.setSize(this._uiTransform.width,this._uiTransform.height);this.setShadowDirty()}onTransformResize(){this.applyTransformSize()}applyTransformSize(){for(let e of this._mainQuads)e.setSize(this._uiTransform.width,this._uiTransform.height);this.setShadowDirty()}get sprite(){return this._mainQuads[0].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}get color(){return this._mainQuads[0].color}set color(e){for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get imageType(){return this._mainQuads[0].imageType}set imageType(e){for(let t of this._mainQuads)t.imageType=e;this.setShadowDirty()}}class hs extends zr{space=fa.World;needUpdateGeometry=!0;panelOrder=0;needSortOnCameraZ;_billboard;_rebuild;scissorEnable=!1;scissorCornerRadius=0;scissorFadeOutSize=0;_uiRenderer;_geometry;_maxCount=128;panelRatio=1;isUIPanel=!0;cloneTo(e){e.getOrAddComponent(hs).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.panelOrder=e.panelOrder,this.needSortOnCameraZ=e.needSortOnCameraZ,this.cullMode=e.cullMode,this.billboard=e.billboard,this.scissorEnable=e.scissorEnable,this.scissorCornerRadius=e.scissorCornerRadius,this.scissorFadeOutSize=e.scissorFadeOutSize,this}init(e){super.init(e),this._uiTransform.resize(I.canvas.width,I.canvas.height),this.create(this.space),this.visible=!1}updateDrawCallSegment(e,t,a){this._geometry.updateSubGeometry(e,t,a);let r=this._uiRenderer.material,i=this._uiRenderer.materials[e];if(!i){i=new Wo(this.space);let n=this._uiRenderer.materials.slice();n.push(i),this._uiRenderer.materials=n,i.cullMode=r.cullMode,i.depthCompare=r.depthCompare}}create(e){this._maxCount=this.space==fa.World?Pr.quadMaxCountForWorld:Pr.quadMaxCountForView,this._uiRenderer=this.object3D.addComponent(bh),this._geometry=this._uiRenderer.geometry=new dh(this._maxCount).create(),this._uiRenderer.material=new Wo(e),this._uiRenderer.renderOrder=Pr.SortOrderStartWorld,this._rebuild=new uh,this.object3D.bound=new Ce(new b,new b(1,1,1).multiplyScalar(Number.MAX_VALUE*.1))}get quadMaxCount(){return this._maxCount}get renderer(){return this._uiRenderer}set billboard(e){this.space==fa.View&&(e=pr.None,console.warn("Cannot enable billboard in view space")),e==pr.BillboardXYZ||e==pr.BillboardY?(this._billboard=this.object3D.getOrAddComponent(fs),this._billboard.type=e):(this.object3D.removeComponent(fs),this._billboard=null)}get billboard(){return this._billboard?this._billboard.type:pr.None}set cullMode(e){if(this.space==fa.World)for(let t of this._uiRenderer.materials)t.cullMode=e;else console.warn("Cannot change cullMode in view space")}get cullMode(){return this._uiRenderer.material.cullMode}onUpdate(e){super.onUpdate?.(e),this.rebuildGUIMesh(e)}_collectTransform=[];rebuildGUIMesh(e){let t=this,a=t._collectTransform;if(a.length=0,t.object3D.getComponents(or,a),a.length>0){t._rebuild.build(a,t,t.needUpdateGeometry);for(const o of a)o.needUpdateQuads=!1}let r=t.object3D.getComponentFromParent(ds),i=r?r.index:0;t._uiRenderer.enable=a.length>0;let n=t.isViewPanel?Pr.SortOrderStartView:Pr.SortOrderStartWorld;if(t._uiRenderer.renderOrder=i*Pr.SortOrderCanvasSpan+n+t.panelOrder,t._uiRenderer.needSortOnCameraZ=t.needSortOnCameraZ,this.space==fa.View){let o=I.canvas.clientWidth,l=I.canvas.clientHeight,c=this._uiTransform.width,f=this._uiTransform.height;this.panelRatio=this.updateGUIPixelRatio(o,l,c,f)}else this.panelRatio=1;for(let o of t._uiRenderer.materials){let l=o;if(l.setPanelRatio(this.panelRatio),l.setScreenSize(I.canvas.clientWidth,I.canvas.clientHeight),l.setScissorEnable(t.scissorEnable),t.scissorEnable){let c=t.mainQuads[0];l.setScissorRect(c.left,c.bottom,c.right,c.top),l.setScissorCorner(t.scissorCornerRadius,t.scissorFadeOutSize)}}t.needUpdateGeometry=!1}updateGUIPixelRatio(e,t,a,r){let i=a/r,n=e/t,o=1;return i<n?o=t/r:o=e/a,o}}class bn extends hs{isViewPanel=!0;space=fa.View;constructor(){super()}cloneTo(e){e.getOrAddComponent(bn).copyComponent(this)}}class gn extends hs{isWorldPanel=!0;space=fa.World;_depthTest=!0;constructor(){super()}cloneTo(e){e.getOrAddComponent(gn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.depthTest=e.depthTest,this}get depthTest(){return this._depthTest}set depthTest(e){if(this._depthTest!=e){this._depthTest=e;let t=this.depthTest?ft.less_equal:ft.always;for(let a of this._uiRenderer.materials)a.depthCompare=t}}}let ph;class or extends et{useParentPivot=!1;parent;pivotX=.5;pivotY=.5;_width=100;_height=100;_localVisible=!0;_globalVisible=!0;_uiInteractiveList;get uiInteractiveList(){return this._uiInteractiveList}constructor(){super(),this._localMatrix=new Gr,this._worldMatrix=new Gr}init(e){super.init(e),this.transform.eventDispatcher.addEventListener(this.transform.eventLocalChange.type,this.onTransformChange,this),this.onParentChange(null,this.object3D.parent?.object3D)}onTransformChange(e){this.onChange=!0}addUIInteractive(e){return this._uiInteractiveList||=[],this._uiInteractiveList.push(e),this}removeUIInteractive(e){if(this._uiInteractiveList){let t=this._uiInteractiveList.indexOf(e);if(t>=0)return this._uiInteractiveList.slice(t,1),e}return null}get globalVisible(){return this._globalVisible}set visible(e){if(this._localVisible!=e){this._localVisible=e;let t=this.parent?this.parent._globalVisible:!0;this.onUITransformVisible(this._localVisible&&t)}}get visible(){return this._localVisible}onUITransformVisible(e){let t=this._localVisible&&e;t!=this._globalVisible&&(this._globalVisible=t,this.object3D.components.forEach((a,r)=>{let i=a;if(i.onUITransformVisible)if(i==this)for(let n of this.object3D.entityChildren){let o=n.getComponent(or);o&&o.onUITransformVisible(this._globalVisible)}else i.onUITransformVisible(this._globalVisible)}))}onParentChange(e,t){this.parent?.setNeedUpdateUIPanel(),this.parent=t?.getComponent(or),this.parent?.setNeedUpdateUIPanel()}get width(){return this._width}get height(){return this._height}resize(e,t){if(this._width!=e||this._height!=t){this._width=e,this._height=t,this.onChange=!0;for(let a of this.object3D.components.values())a.onTransformResize?.();return!0}return!1}get x(){return this.object3D.x}set x(e){e!=this.object3D.x&&(this.object3D.x=e,this.onChange=!0)}get y(){return this.object3D.y}set y(e){e!=this.object3D.y&&(this.object3D.y=e,this.onChange=!0)}setXY(e,t){let a=this.object3D.localPosition;a.set(e,t,a.z),this.object3D.localPosition=a,this.onChange=!0}get z(){return this.object3D.z}set z(e){e!=this.object3D.z&&(this.object3D.z=e,this.onChange=!0)}get scaleX(){return this.object3D.scaleX}set scaleX(e){this.onChange=!0,this.object3D.scaleX=e}get scaleY(){return this.object3D.scaleY}set scaleY(e){this.onChange=!0,this.object3D.scaleY=e}get scaleZ(){return this.object3D.scaleZ}set scaleZ(e){this.onChange=!0,this.object3D.scaleZ=e}_localMatrix;_worldMatrix;_onChange=!0;needUpdateQuads=!0;get onChange(){return this._onChange}_tempTransforms=[];set onChange(e){if(this._onChange!=e&&(this._onChange=e,e)){this._tempTransforms.length=0;let t=this.object3D.getComponents(or,this._tempTransforms,!0);for(let a of t)a._onChange=!0,a.needUpdateQuads=!0}}onEnable(){this.setNeedUpdateUIPanel(),this.onChange=!0}onDisable(){this.setNeedUpdateUIPanel(),this.onChange=!0}setNeedUpdateUIPanel(){let e;e=this.object3D.getComponentFromParent(gn),e||(e=this.object3D.getComponentFromParent(bn)),e&&(e.needUpdateGeometry=!0)}cloneTo(e){let t=e.getOrAddComponent(or);t.visible=this.visible,t.x=this.x,t.y=this.y,t.z=this.z,t.resize(this.width,this.height),t.pivotX=this.pivotX,t.pivotY=this.pivotY,t.scaleX=this.scaleX,t.scaleY=this.scaleY}matrix(){let e=this._localMatrix,t=this.object3D.rotationZ;return this.parent?(e.updateScaleAndRotation(this.object3D.scaleX,this.object3D.scaleY,t,t),e.tx=this.object3D.x,e.ty=this.object3D.y):e.updateScaleAndRotation(1,1,0,0),(this.pivotX!=.5||this.pivotY!=.5)&&(ph||=new Gr().identity(),e.mul(ph.setTo(1,0,0,1,-(this.pivotX-.5)*this.width,-(this.pivotY-.5)*this.height))),e}getWorldMatrix(){let e=this,t=e._worldMatrix;return this._onChange&&(t.copyFrom(e.matrix()),e.parent&&t.mul(e.parent.getWorldMatrix()),e._onChange=!1),t}beforeDestroy(e){this.transform.eventDispatcher.addEventListener(this.transform.eventLocalChange.type,this.onTransformChange,this),super.beforeDestroy?.(e)}}class mh{_ray;_mouseCode;_clickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_view;init(e){this._view=e,this._ray=new ua,this._clickEvent=new yt(yt.PICK_CLICK_GUI),this._outEvent=new yt(yt.PICK_OUT_GUI),this._overEvent=new yt(yt.PICK_OVER_GUI),this._upEvent=new yt(yt.PICK_UP_GUI),this._downEvent=new yt(yt.PICK_DOWN_GUI),_.inputSystem.addEventListener(Z.POINTER_DOWN,this.onTouchDown,this,null,1),_.inputSystem.addEventListener(Z.POINTER_UP,this.onTouchUp,this,null,1),_.inputSystem.addEventListener(Z.POINTER_MOVE,this.onTouchMove,this,null,1),_.inputSystem.addEventListener(Z.POINTER_CLICK,this.onTouchClick,this,null,1)}_lastDownTarget;_lastOverTarget;onTouchClick(e){this._lastOverTarget&&e.stopImmediatePropagation()}onTouchMove(e){this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);if(t){e.stopImmediatePropagation();let a=t.collider;a!=this._lastOverTarget&&(a.mouseStyle=at.OVER,Object.assign(this._overEvent,e),this._overEvent.type=yt.PICK_OVER_GUI,this._overEvent.target=a.object3D,this._overEvent.data=t,a.object3D.dispatchEvent(this._overEvent),this._lastOverTarget&&(this._lastOverTarget.mouseStyle=at.NORMAL,Object.assign(this._outEvent,e),this._outEvent.type=yt.PICK_OUT_GUI,this._outEvent.target=a.object3D,this._outEvent.data=t,this._lastOverTarget.object3D.dispatchEvent(this._outEvent))),this._lastOverTarget=a}else this._lastOverTarget&&(this._lastOverTarget.mouseStyle=at.NORMAL,Object.assign(this._outEvent,e),this._outEvent.type=yt.PICK_OUT_GUI,this._outEvent.target=this._lastOverTarget.object3D,this._outEvent.data=t,this._lastOverTarget.object3D.dispatchEvent(this._outEvent),this._lastOverTarget=null)}_lastDownPosition=new de;_calcDistanceVec2=new de;_lastDownTime=0;_clickTimeSpan=200;_clickDistanceSpan=10;onTouchDown(e){this._lastDownTime=We.time,this._lastDownPosition.set(e.mouseX,e.mouseY),this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);t&&e.stopImmediatePropagation();let a=t?t.collider:null;a&&(a.mouseStyle=at.DOWN,Object.assign(this._downEvent,e),this._downEvent.type=yt.PICK_DOWN_GUI,this._downEvent.target=a.object3D,this._downEvent.data=t,a.object3D.dispatchEvent(this._downEvent)),this._lastDownTarget=a}onTouchUp(e){this._calcDistanceVec2.set(e.mouseX,e.mouseY),this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);t&&e.stopImmediatePropagation();let a=t?t.collider:null;this._lastDownTarget&&this._lastDownTarget.enable&&(this._lastDownTarget.mouseStyle=at.NORMAL),a&&a==this._lastDownTarget&&We.time-this._lastDownTime<=this._clickTimeSpan&&(this._calcDistanceVec2.set(e.mouseX,e.mouseY),this._calcDistanceVec2.distance(this._lastDownPosition)<=this._clickDistanceSpan&&(Object.assign(this._clickEvent,e),this._clickEvent.type=yt.PICK_CLICK_GUI,this._clickEvent.target=a.object3D,this._clickEvent.data=t,a.object3D.dispatchEvent(this._clickEvent))),this._lastDownTarget=null}_colliderOut=[];_transformList=[];_sortWorldPanelList=[];_iteractive2PanelDict=new Map;collectEntities(){return this._colliderOut.length=0,this._sortWorldPanelList.length=0,this._iteractive2PanelDict.clear(),this._view.canvasList.slice().reverse().forEach(t=>{if(t&&t.transform&&t.transform.parent){let a=t.object3D.getComponentsByProperty("isUIPanel",!0,!0);a.sort((r,i)=>{let n=r._uiRenderer.__renderOrder,o=i._uiRenderer.__renderOrder;return n>o?-1:1});for(let r of a){this._transformList.length=0,r.object3D.getComponents(or,this._transformList),this._transformList.reverse();for(const i of this._transformList){let n=i.uiInteractiveList;if(n&&n.length>0)for(let o of n)this._colliderOut.push(o),this._iteractive2PanelDict.set(o,r)}}}}),this._colliderOut}pick(e){this._ray=this._view.camera.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY);let t=new de(_.inputSystem.mouseX,_.inputSystem.mouseY),a=new de(I.canvas.clientWidth,I.canvas.clientHeight),r;for(const i of e)if(i.interactive&&i.enable&&i.interactiveVisible){let n=this._iteractive2PanelDict.get(i);if(r=i.rayPick(this._ray,n,t,a),r)return r.collider=i,r}return null}}var Ah=(s=>(s[s.COLLINEAR=0]="COLLINEAR",s[s.LINES_INTERSECT=1]="LINES_INTERSECT",s[s.SEGMENTS_INTERSECT=2]="SEGMENTS_INTERSECT",s[s.A_BISECTS_B=3]="A_BISECTS_B",s[s.B_BISECTS_A=4]="B_BISECTS_A",s[s.PARALELL=5]="PARALELL",s))(Ah||{}),Dh=(s=>(s[s.ON_LINE=0]="ON_LINE",s[s.LEFT_SIDE=1]="LEFT_SIDE",s[s.RIGHT_SIDE=2]="RIGHT_SIDE",s))(Dh||{});class Ut{static cacluteLine0=new Ut(null,null);static cacluteLine1=new Ut(null,null);start;end;color=new J(1,1,1,1);_normal;_normalCalculated=!1;constructor(e,t){this.start=e,this.end=t}set(e,t){this.start=e,this.end=t}getCenter(){let e=b.HELP_0;return this.start.subtract(this.end,e),e.scaleBy(.5),e.add(this.end),e}inverse(){let e=this.start;this.start=this.end,this.end=e}equals(e){return this.start==e.start&&this.end==e.end||this.start==e.end&&this.end==e.start}toArray(){return[this.start.x,this.start.y,this.start.z,this.end.x,this.end.y,this.end.z]}static getLines(e){let t=[];for(let a=0;a<e.length;a++){let r=a,i=Pn(a+1,e.length),n=e[r],o=e[i];t.push(new Ut(n,o))}return t}intersection(e,t=null){var a=(e.end.z-e.start.z)*(this.end.x-this.start.x)-(e.end.x-e.start.x)*(this.end.z-this.start.z),r=(e.end.x-e.start.x)*(this.start.z-e.start.z)-(e.end.z-e.start.z)*(this.start.x-e.start.x),i=(e.start.x-this.start.x)*(this.end.z-this.start.z)-(e.start.z-this.start.z)*(this.end.x-this.start.x);if(a==0)return r==0&&i==0?0:5;r=r/a,i=i/a;var n=this.start.x+r*(this.end.x-this.start.x),o=this.start.z+r*(this.end.z-this.start.z);return t!=null&&(t.x=n,t.y=0,t.z=o),r>=0&&r<=1&&i>=0&&i<=1?2:i>=0&&i<=1?3:r>=0&&r<=1?4:1}getDirection(){var e=this.end.subtract(this.start),t=new b(e.x,e.y);return t.normalize()}copyFrom(e){this.start||(this.start=new b),this.end||(this.end=new b),this.start.copyFrom(e.start),this.end.copyFrom(e.end)}static IsEqual(e,t){return Math.abs(e-t)<1e-7}static squreDistanceSegmentToSegment(e,t,a){let r=e.start,i=e.end,n=t.start,o=t.end,l=r.x,c=r.y,f=r.z,d=i.x,h=i.y,u=i.z,m=n.x,g=n.y,p=n.z,D=o.x,A=o.y,B=o.z,v=d-l,U=h-c,y=u-f,S=D-m,F=A-g,C=B-p,w=l-m,E=c-g,Q=f-p,T=v*v+U*U+y*y,j=v*S+U*F+y*C,ue=S*S+F*F+C*C,ee=v*w+U*E+y*Q,N=S*w+F*E+C*Q,M=T*ue-j*j,O=M,W=M,ae=0,z=0;this.IsEqual(M,0)?(ae=0,O=1,z=N,W=ue):(ae=j*N-ue*ee,z=T*N-j*ee,ae<0?(ae=0,z=N,W=ue):ae>O&&(ae=O,z=N+j,W=ue)),z<0?(z=0,-ee<0?ae=0:-ee>T?ae=O:(ae=-ee,O=T)):z>W&&(z=W,-ee+j<0?ae=0:-ee+j>T?ae=O:(ae=-ee+j,O=T));let K=0,$=0;this.IsEqual(ae,0)?K=0:K=ae/O,this.IsEqual(z,0)?$=0:$=z/W;let re=w+K*v-$*S,ce=E+K*U-$*F,Ae=Q+K*y-$*C;return re*re+ce*ce+Ae*Ae}isNear(e,t=0,a){let r=b.HELP_0,i=b.HELP_1;r.copyFrom(e.origin),i.copyFrom(e.direction),i.scaleBy(9999),i.add(r,i),Ut.cacluteLine0.set(r,i),Ut.cacluteLine1.copyFrom(this),a&&(a.perspectiveMultiplyPoint3(Ut.cacluteLine1.start,Ut.cacluteLine1.start),a.perspectiveMultiplyPoint3(Ut.cacluteLine1.end,Ut.cacluteLine1.end));let n=Ut.squreDistanceSegmentToSegment(Ut.cacluteLine0,Ut.cacluteLine1,a);return n+1e-4<=t?(e.length=n,!0):(e.length=-999999,!1)}}class us{static ID=-1;v1;v2;v3;u1;u2;u3;n1;n2;n3;t0;t;u;v;min=new b;max=new b;id=0;constructor(e,t,a){this.id=us.ID+++200,e&&t&&a&&this.set(e,t,a)}set(e,t,a){this.v1=e,this.v2=t,this.v3=a;let r=this.min,i=this.max;return r.x=Math.min(this.v1.x,this.v2.x,this.v3.x),r.y=Math.min(this.v1.y,this.v2.y,this.v3.y),r.z=Math.min(this.v1.z,this.v2.z,this.v3.z),i.x=Math.max(this.v1.x,this.v2.x,this.v3.x),i.y=Math.max(this.v1.y,this.v2.y,this.v3.y),i.z=Math.max(this.v1.z,this.v2.z,this.v3.z),this}getNormal(){let e=this.v1,t=this.v2,a=this.v3,r=new b(t.x-e.x,t.y-e.y,t.z-e.z),n=new b(a.x-e.x,a.y-e.y,a.z-e.z).crossProduct(r);return n.normalize(),n}turnBack(){let e=this.v3;this.v3=this.v1,this.v1=e}getLines(){let e=this.v1,t=this.v2,a=this.v3;return[new Ut(e,t),new Ut(t,a),new Ut(a,e)]}equals(e){let t=this.getLines(),a=e.getLines(),r=0;for(let i=0;i<t.length;i++)for(let n=0;n<a.length;n++)t[i].equals(a[n])&&r++;return r==3}getCenter(){let e=this.min,t=this.max,a=new b;return a.x=(e.x+t.x)*.5,a.y=(e.y+t.y)*.5,a.z=(e.z+t.z)*.5,a}intersects(e){var t=this.max,a=this.min,r=e.max,i=e.min;return a.x<=r.x&&t.x>=i.x&&a.y<=r.y&&t.y>=i.y&&a.z<=r.z&&t.z>=i.z}sign2D(e,t,a){return(e.x-a.x)*(t.z-a.z)-(t.x-a.x)*(e.z-a.z)}pointInTriangle2D(e){let t=this.v1,a=this.v2,r=this.v3,i,n,o,l,c;return i=this.sign2D(e,t,a),n=this.sign2D(e,a,r),o=this.sign2D(e,r,t),l=i<0||n<0||o<0,c=i>0||n>0||o>0,!(l&&c)}toArray(){return[this.v1.x,this.v1.y,this.v1.z,this.v2.x,this.v2.y,this.v2.z,this.v3.x,this.v3.y,this.v3.z]}}class _h{static _pt0;static _pt1;static _pt2;static _pt3;static _hitPoint;static _worldMatrix;static _ray;static _triangle;static _isInit;static init(){this._pt0=new b,this._pt1=new b,this._pt2=new b,this._pt3=new b,this._ray=new ua,this._triangle=new us,this._hitPoint=new b,this._worldMatrix=new R}static rayPick(e,t,a,r,i,n,o){this._isInit||(this.init(),this._isInit=!0);let l=this._worldMatrix;if(r==fa.World){let c;this.calculateHotArea_World(n,this._pt0,this._pt1,this._pt2,this._pt3),l.copyFrom(o).invert();let f=this._ray;if(f.copy(e).applyMatrix(l),this._triangle.set(this._pt0,this._pt1,this._pt2),c=f.intersectTriangle(f.origin,f.direction,this._triangle),c||(this._triangle.set(this._pt1,this._pt2,this._pt3),c=f.intersectTriangle(f.origin,f.direction,this._triangle)),c)return{distance:0,intersectPoint:c}}else{this.calculateHotArea_View(n,i,this._pt0,this._pt1,this._pt2,this._pt3);let c=a.x,f=a.y,d=Math.min(this._pt0.x,this._pt1.x,this._pt2.x,this._pt3.x)+c*.5,h=Math.min(this._pt0.y,this._pt1.y,this._pt2.y,this._pt3.y)+f*.5,u=Math.max(this._pt0.x,this._pt1.x,this._pt2.x,this._pt3.x)+c*.5,m=Math.max(this._pt0.y,this._pt1.y,this._pt2.y,this._pt3.y)+f*.5;return t.x<=u&&t.x>=d&&t.y<=m&&t.y>=h?(this._hitPoint.set(t.x,t.y,0),{distance:0,intersectPoint:this._hitPoint}):null}return null}static calculateHotArea_View(e,t,a,r,i,n){let o=e.getWorldMatrix(),l=o.getScaleX(),c=o.getScaleY(),f=e.width*.5*l,d=e.height*.5*c;a.set(-f,-d,0),r.set(f,-d,0),i.set(-f,d,0),n.set(f,d,0);let h=o.tx;a.x+=h,r.x+=h,i.x+=h,n.x+=h,h=o.ty,a.y-=h,r.y-=h,i.y-=h,n.y-=h,a.multiplyScalar(t),r.multiplyScalar(t),i.multiplyScalar(t),n.multiplyScalar(t)}static calculateHotArea_World(e,t,a,r,i){let n=e.getWorldMatrix(),o=n.getScaleX(),l=n.getScaleY(),c=e.width*.5*o,f=e.height*.5*l;t.set(-c,f,0),a.set(c,f,0),r.set(-c,-f,0),i.set(c,-f,0);let d=n.tx;t.x+=d,a.x+=d,r.x+=d,i.x+=d,d=n.ty,t.y+=d,a.y+=d,r.y+=d,i.y+=d}}var Bh=(s=>(s[s.UpperLeft=0]="UpperLeft",s[s.UpperCenter=1]="UpperCenter",s[s.UpperRight=2]="UpperRight",s[s.MiddleLeft=3]="MiddleLeft",s[s.MiddleCenter=4]="MiddleCenter",s[s.MiddleRight=5]="MiddleRight",s[s.LowerLeft=6]="LowerLeft",s[s.LowerCenter=7]="LowerCenter",s[s.LowerRight=8]="LowerRight",s))(Bh||{}),vh=(s=>(s[s.Upper=0]="Upper",s[s.Middle=1]="Middle",s[s.Lower=2]="Lower",s))(vh||{}),xh=(s=>(s[s.Left=0]="Left",s[s.Center=1]="Center",s[s.Right=2]="Right",s))(xh||{});class Uh{charList=[];quadList=[];width=0;index=0}class yh{layout(e){let t=[],a=e.originSize,r=fi.getFontData(e.font,a),i=e.fontSize/a;return this.makeTextLine(e.uiTransform,e.alignment,t,e.font,r,e.text,i,a,e.lineSpacing),t}makeTextLine(e,t,a,r,i,n,o,l,c){let f=-1,d=0,h=l*o,u=h*.5,m=e.width/o,g=e.height/o,p=0,D=e.height,A=()=>{d=0,f++;let y=new Uh;return y.index=f,a.push(y),y},B=(y,S)=>{const F=y.charCodeAt(0).toString();let C=fi.getFnt(r,l,F),w=null;return C?(w=Ja.spawnQuad(),w.sprite=C,w.x=(d+C.xoffset)*o-p,w.y=(i.base-C.height-C.yoffset-i.base)*o+D,w.width=C.offsetSize.width*o,w.height=C.offsetSize.height*o,d+=C.xadvance):y==`
11788
11788
  `||(y==" "?d+=h:d+=u),S.width=d,S.quadList.push(w),S.charList.push(y),w},v=()=>{let y=this.getAlignment(t);switch(y.v){case 0:for(let S=0,F=a.length;S<F;S++){let C=a[S];if(S>0){let w=S*h*c;for(let E=0,Q=C.quadList.length;E<Q;E++){let T=C.quadList[E];T&&(T.y-=w)}}}break;case 1:for(let S=0,F=a.length;S<F;S++){let C=a[S],w=(g-F*l*c)*.5*o+S*h*c;for(let E=0,Q=C.quadList.length;E<Q;E++){let T=C.quadList[E];T&&(T.y-=w)}}break;case 2:for(let S=0,F=a.length;S<F;S++){let C=a[S],w=(g-F*l*c)*o+S*h*c;for(let E=0,Q=C.quadList.length;E<Q;E++){let T=C.quadList[E];T&&(T.y-=w)}}break}switch(y.h){case 0:break;case 1:for(let S=0,F=a.length;S<F;S++){let C=a[S],w=(m-C.width)*.5*o;for(let E=0,Q=C.quadList.length;E<Q;E++){let T=C.quadList[E];T&&(T.x+=w)}}break;case 2:for(let S=0,F=a.length;S<F;S++){let C=a[S],w=(m-C.width)*o;for(let E=0,Q=C.quadList.length;E<Q;E++){let T=C.quadList[E];T&&(T.x+=w)}}break}};(()=>{let y=null,S=n.length;for(let F=0;F<S;F++){y||=A();let C=n.charAt(F);C==`
11789
- `||C==" "?y=null:(B(C,y),y.width+u>=m&&(y=A()))}})(),v()}getAlignment(e){let t={v:0,h:0};switch(e){case 1:t.v=0,t.h=1;break;case 0:t.v=0,t.h=0;break;case 2:t.v=0,t.h=2;break;case 4:t.v=1,t.h=1;break;case 3:t.v=1,t.h=0;break;case 5:t.v=1,t.h=2;break;case 7:t.v=2,t.h=1;break;case 6:t.v=2,t.h=0;break;case 8:t.v=2,t.h=2;break}return t}}class pn extends Jo{_style=at.NORMAL;_interactive=!1;set interactive(e){this._interactive=e}get interactive(){return this._interactive}set mouseStyle(e){this._style=e}get interactiveVisible(){return this._uiTransform.globalVisible&&this._visible}init(e){super.init(e),this._uiTransform.addUIInteractive(this)}destroy(){this._uiTransform.removeUIInteractive(this),super.destroy()}rayPick(e,t,a,r){return _h.rayPick(e,a,r,t.space,t.panelRatio,this._uiTransform,t.transform.worldMatrix)}cloneTo(e){e.getOrAddComponent(pn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.enable=e._enable,this.interactive=e._interactive,this.mouseStyle=e._style,this}}var Ch=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=1]="COLOR",s[s.SPRITE=2]="SPRITE",s))(Ch||{});class bl extends pn{_spriteMap;_colorMap;_image;_isCreateImage;_transition=2;init(e){super.init(e),this._interactive=!0,this._spriteMap=new Map,this._colorMap=new Map,this._image=this.object3D.getComponent(zr),this._isCreateImage=this._image==null,this._image||(this._image=this.object3D.addComponent(zr)),this.imageType=hi.Sliced}onEnable(){this.mouseStyle=at.NORMAL}onDisable(){this.mouseStyle=at.DISABLE}set transition(e){this._transition!=e&&(this._transition=e,this.validateStyle(this._style,!0))}get transition(){return this._transition}get imageType(){return this._image.imageType}set imageType(e){this._image.imageType=e}setStyleColor(e,t){return this._colorMap.set(e,t),this._style==e&&this.validateStyle(this._style,!0),this}getStyleColor(e){return this._colorMap.get(e)}set mouseStyle(e){super.mouseStyle=e,this.validateStyle(e,!0)}get normalSprite(){return this._spriteMap.get(at.NORMAL)}set normalSprite(e){this._spriteMap.set(at.NORMAL,e),this._style==at.NORMAL&&this.validateStyle(this._style,!0)}get overSprite(){return this._spriteMap.get(at.OVER)}set overSprite(e){this._spriteMap.set(at.OVER,e),this._style==at.OVER&&this.validateStyle(this._style,!0)}set downSprite(e){this._spriteMap.set(at.DOWN,e),this._style==at.DOWN&&this.validateStyle(this._style,!0)}get downSprite(){return this._spriteMap.get(at.DOWN)}set disableSprite(e){this._spriteMap.set(at.DISABLE,e),this._style==at.DISABLE&&this.validateStyle(this._style,!0)}get disableSprite(){return this._spriteMap.get(at.DISABLE)}validateStyle(e,t){if(this._transition&2){let a=this._spriteMap.get(e);this._image.sprite=a}if(this._transition&1){let a=this._colorMap.get(e);a&&(this._image.color=a)}}cloneTo(e){e.getOrAddComponent(bl).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.imageType=e.imageType,this.transition=e.transition,e._spriteMap.forEach((t,a)=>{t&&this._spriteMap.set(a,t)}),e._colorMap.forEach((t,a)=>{t&&this._colorMap.set(a,t.clone())}),this.mouseStyle=e.mouseStyle,this}destroy(){this._isCreateImage&&this._image&&(this.object3D.removeComponent(zr),this._image=null),super.destroy()}}class gl extends ji{_count=0;constructor(){super()}init(e){super.init?.(e),this._count=e?e.count:1;for(let t=0;t<this._count;t++)this.attachQuad(Ja.spawnQuad());this._uiTransform.resize(0,0)}getQuad(e){return this._mainQuads[e]}cloneTo(e){e.addComponent(gl,{count:this._count}).copyComponent(this)}copyComponent(e){super.copyComponent(e);for(let t=0;t<e._count;t++)this.setSprite(t,e.getSprite(t)),this.setColor(t,e.getColor(t)),this.setImageType(t,e.getImageType(t));return this}setSprite(e,t){this._mainQuads[e].sprite=t||_.res.defaultGUISprite,this.setShadowDirty()}getSprite(e){return this._mainQuads[e].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}getColor(e){return this._mainQuads[e].color}setColor(e,t){this._mainQuads[e].color=t,this.setShadowDirty()}getImageType(e){return this._mainQuads[e].imageType}setImageType(e,t){this._mainQuads[e].imageType=t,this.setShadowDirty()}setSize(e,t,a){this._mainQuads[e].setSize(t,a),this.setShadowDirty()}setXY(e,t,a){this._mainQuads[e].setXY(t,a),this.setShadowDirty()}getXY(e,t){t||=new de;let a=this._mainQuads[e];return t.x=a.x,t.y=a.y,t}}class pl extends ji{_shadowQuality=1;_shadowOffset;_shadowRadius;_shadowColor;_subShadowColor;needUpdateShadow=!1;init(e){super.init?.(e),this._shadowRadius=2,this._shadowQuality=1,this._shadowOffset=new de(4,-4),this._shadowColor=new J(.1,.1,.1,.8),this._subShadowColor=this._shadowColor.clone(),this.isUIShadow=!0}cloneTo(e){e.getOrAddComponent(pl).copyComponent(this)}copyComponent(e){return super.copyComponent(this),this._shadowColor=e._shadowColor,this._shadowOffset=e._shadowOffset,this._shadowRadius=e._shadowRadius,this._shadowQuality=e.shadowQuality,this}get shadowColor(){return this._shadowColor}set shadowColor(e){this._shadowColor.copyFrom(e),this.needUpdateShadow=!0}set shadowQuality(e){e=Be(e,0,4),this._shadowQuality!=e&&(this._shadowQuality=e,this.needUpdateShadow=!0)}get shadowQuality(){return this._shadowQuality}set shadowOffset(e){this._shadowOffset=e,this.needUpdateShadow=!0}get shadowOffset(){return this._shadowOffset||=new de(4,-4),this._shadowOffset}set shadowRadius(e){this._shadowRadius!=e&&(this._shadowRadius=e,this.applyShadow())}get shadowRadius(){return this._shadowRadius}onUpdate(e){this.needUpdateShadow&&(this.applyShadow(),this.needUpdateShadow=!1)}applyShadow(){if(this.detachQuads(),this._shadowSource&&this._shadowQuality>0){let e=this._shadowSource.mainQuads;if(e.length>0)for(let t of e)this.createQuadShadow(t)}this._uiTransform.setNeedUpdateUIPanel()}createQuadShadow(e){let t=this._shadowQuality,a=Math.PI*2;this._subShadowColor.copyFrom(this._shadowColor),this._subShadowColor.a=1/Math.max(1,t);for(let r=0;r<t;r++){let i=Ja.spawnQuad(),n=0,o=0;if(r==0)i.color=this._shadowColor;else{let l=a*(r-1)/(t-1);n=Math.sin(l)*this._shadowRadius,o=Math.cos(l)*this._shadowRadius,i.color=this._subShadowColor}i.setXY(n+this._shadowOffset.x+e.x,o+this._shadowOffset.y+e.y),i.setSize(e.width,e.height),i.sprite=e.sprite,i.visible=e.visible,i.imageType=e.imageType,this.attachQuad(i)}}}class ml extends ji{_font="\u5FAE\u8F6F\u96C5\u9ED1";_fontSize=14;_originSize=42;_alignment=0;_lineSpacing=1;_text="";_color=new J(1,1,1,1);constructor(){super()}cloneTo(e){e.getOrAddComponent(ml).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this._font=e._font,this._fontSize=e._fontSize,this._originSize=e._originSize,this._alignment=e._alignment,this._lineSpacing=e._lineSpacing,this._color.copyFrom(e._color),this.text=e.text,this}get originSize(){return this._originSize}get font(){return this._font}set font(e){this._font=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!=e&&(this._fontSize=e,this.layoutText())}get text(){return this._text}set text(e){this._text!=e&&(e||(e=""),this._text=e,this.layoutText())}textLine=null;layoutProxy=new yh;layoutText(){this.detachQuads(),this.textLine=this.layoutProxy.layout(this);for(let e=0,t=this.textLine.length;e<t;e++){let a=this.textLine[e];for(let r=0,i=a.quadList.length;r<i;r++){let n=a.quadList[r];n&&this.attachQuad(n)}}this.color=this._color,this._uiTransform.setNeedUpdateUIPanel(),this.onUIComponentVisible(this._visible),this.setShadowDirty()}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t&&(t.visible=!e);this.setShadowDirty()}onTransformResize(){this.layoutText()}get color(){return this._color}set color(e){this._color.copyFrom(e);for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get alignment(){return this._alignment}set alignment(e){this._alignment!=e&&(this._alignment=e,this.layoutText())}get lineSpacing(){return this._lineSpacing}set lineSpacing(e){this._lineSpacing!=e&&(this._lineSpacing=e,this.layoutText())}}var Lg=Object.getOwnPropertyDescriptor,Gg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Lg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let js=class extends Ri{constructor(){super()}init(){super.init(),this.lightData.lightType=ht.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+zt())}get range(){return this.lightData.range}set range(s){this.lightData.range=s,this.onChange()}get at(){return this.lightData.linear}set at(s){this.lightData.linear=s,this.onChange()}get radius(){return this.lightData.radius}set radius(s){this.lightData.radius=s,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(s){this.lightData.quadratic=s,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(s){let e=s.scene.getChildByName("graphic3D");if(!e)return;let t=e.createCustomShape(`PointLight_${this.object3D.instanceID}`,this.transform);t.buildAxis(),t.buildCircle(b.ZERO,this.range,32,b.X_AXIS),t.buildCircle(b.ZERO,this.range,32,b.Y_AXIS),t.buildCircle(b.ZERO,this.range,32,b.Z_AXIS)}debug(){}debugDraw(s){}};js=Gg([Ot(js,"Light")],js);var zg=Object.getOwnPropertyDescriptor,Wg=(s,e,t,a)=>{for(var r=a>1?void 0:a?zg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let mi=class extends Ba{_fatLineMaterial=null;_fatLineGeometry=null;_cachedResolution=new de(0,0);constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(mi).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this}set geometry(s){super.geometry=s,this._fatLineGeometry=s,s&&(this.instanceCount=s.instanceCount,this._fatLineMaterial&&s.instanceBuffer&&this._fatLineMaterial.setInstanceBuffer(s.instanceBuffer))}get geometry(){return this._fatLineGeometry}set material(s){this.materials=[s],this._fatLineMaterial=s,this._fatLineGeometry&&this._fatLineGeometry.instanceBuffer&&s.setInstanceBuffer(this._fatLineGeometry.instanceBuffer)}get material(){return this._fatLineMaterial}nodeUpdate(s,e,t,a){if(this._fatLineMaterial&&this.object3D){this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);const r=I.presentationSize[0],i=I.presentationSize[1];r>0&&i>0&&(this._cachedResolution.x!==r||this._cachedResolution.y!==i)&&(this._cachedResolution.set(r,i),this._fatLineMaterial.resolution=this._cachedResolution.clone())}super.nodeUpdate(s,e,t,a)}destroy(s){super.destroy(s)}};mi=Wg([Ot(mi,"FatLineRenderer")],mi);var Jg=Object.getOwnPropertyDescriptor,jg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Jg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Zi=class extends Ba{totalCount=0;size=new de;localBoundBox=new Ce;get worldBoundBox(){const s=new Ce;s.makeEmpty();const t=this.object3D.transform.worldMatrix.rawData,a=this.localBoundBox.min,r=this.localBoundBox.max,i=[[a.x,a.y,a.z],[r.x,a.y,a.z],[a.x,r.y,a.z],[r.x,r.y,a.z],[a.x,a.y,r.z],[r.x,a.y,r.z],[a.x,r.y,r.z],[r.x,r.y,r.z]];for(const[n,o,l]of i){const c=t[0]*n+t[4]*o+t[8]*l+t[12],f=t[1]*n+t[5]*o+t[9]*l+t[13],d=t[2]*n+t[6]*o+t[10]*l+t[14];s.expandByPoint(new b(c,f,d))}return s}splatColor;transformA;transformB;texParams;_texParamDirty=!0;splatOrder;gsplatMaterial;_colorData;_transformAData;_transformBData;_orderData;_positions;_splatSetFlags;_validCount=0;_sortWorker;_lastSentTime=0;_minIntervalMs=16;_centersSent=!1;_lastViewMatrixHash=0;_lastCameraSpeed=0;_adaptiveSorting=!0;_lastPixelCullParams="";_texturesInitialized=!1;_minPixelCoverage=4;_maxPixelCoverage=0;_maxPixelCullDistance=0;_batchSize=128;instanceCount=0;_pendingUpdates=new Set;_autoFlushThreshold=100;_frameCount=0;constructor(){super()}initCount(s,e=128){if(s<=0)throw new Error("Total count must be greater than 0");this.totalCount=s,this._batchSize=e,this.size=this.evalTextureSize(s);const t=this.size.x|0,a=this.size.y|0,r=t*a;this._colorData=new Uint8Array(r*4),this._colorData.fill(0),this._transformAData=new Uint32Array(r*4),this._transformAData.fill(0),this._transformBData=new Array(r*4).fill(0),this._orderData=new Uint32Array(r);for(let i=0;i<r;i++)this._orderData[i]=i<s?i:s>0?s-1:0;this._positions=new Float32Array(s*3),this._positions.fill(0),this.localBoundBox.makeEmpty(),this._splatSetFlags=new Array(s).fill(!1),this._validCount=0,this.texParams=new Float32Array([this._validCount,this.size.x,0,1]),this.splatColor=new Fi().create(t,a,this._colorData,!1),this.splatColor.name="splatColor",this.splatColor.minFilter="nearest",this.splatColor.magFilter="nearest",this.splatColor.mipmapFilter="nearest",this.splatColor.addressModeU="clamp-to-edge",this.splatColor.addressModeV="clamp-to-edge",this.transformA=new Hn().create(t,a,this._transformAData),this.transformA.name="transformA",this.transformA.minFilter="nearest",this.transformA.magFilter="nearest",this.transformA.addressModeU="clamp-to-edge",this.transformA.addressModeV="clamp-to-edge",this.transformB=new Ts().create(t,a,this._transformBData,!1),this.transformB.name="transformB",this.transformB.minFilter="nearest",this.transformB.magFilter="nearest",this.transformB.mipmapFilter="nearest",this.transformB.addressModeU="clamp-to-edge",this.transformB.addressModeV="clamp-to-edge",this.splatOrder=new Qs().create(t,a,this._orderData),this.splatOrder.name="splatOrder",this.splatOrder.minFilter="nearest",this.splatOrder.magFilter="nearest",this.splatOrder.addressModeU="clamp-to-edge",this.splatOrder.addressModeV="clamp-to-edge",this.gsplatMaterial=new Yn,this.geometry=new Xn(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}setSplatData(s,e){if(s<0||s>=this.totalCount)throw new Error(`Index ${s} out of range [0, ${this.totalCount})`);const t=this._splatSetFlags[s];this._positions[s*3+0]=e.position[0],this._positions[s*3+1]=e.position[1],this._positions[s*3+2]=e.position[2],this.localBoundBox.expandByPoint(new b(e.position[0],e.position[1],e.position[2]));const a=.28209479177387814;let r=.5,i=.5,n=.5;e.sh&&e.sh.coeffs&&e.sh.coeffs.length>=3&&(r=.5+e.sh.coeffs[0]*a,i=.5+e.sh.coeffs[1]*a,n=.5+e.sh.coeffs[2]*a);const o=e.opacity!==void 0?1/(1+Math.exp(-e.opacity)):1,l=s*4;this._colorData[l+0]=Math.max(0,Math.min(255,Math.floor(r*255))),this._colorData[l+1]=Math.max(0,Math.min(255,Math.floor(i*255))),this._colorData[l+2]=Math.max(0,Math.min(255,Math.floor(n*255))),this._colorData[l+3]=Math.max(0,Math.min(255,Math.floor(o*255))),this.updateTransformData(s,e),t||(this._splatSetFlags[s]=!0,this._validCount++),this._pendingUpdates.add(s)}updateTransformData(s,e){const t=s*4,a=new ArrayBuffer(4),r=new Float32Array(a),i=new Uint32Array(a),n=$e=>(r[0]=$e,i[0]),o=e.position[0],l=e.position[1],c=e.position[2];this._transformAData[t+0]=n(o),this._transformAData[t+1]=n(l),this._transformAData[t+2]=n(c);let f=0,d=0,h=0,u=1;if(e.rotation){f=e.rotation[0],d=e.rotation[1],h=e.rotation[2],u=e.rotation[3];const $e=1/Math.hypot(f,d,h,u);f*=$e,d*=$e,h*=$e,u*=$e}let m=1,g=1,p=1;e.scale&&(m=Math.exp(e.scale[0]),g=Math.exp(e.scale[1]),p=Math.exp(e.scale[2]));const D=f+f,A=d+d,B=h+h,v=f*D,U=f*A,y=f*B,S=d*A,F=d*B,C=h*B,w=u*D,E=u*A,Q=u*B,T=1-(S+C),j=U+Q,ue=y-E,ee=U-Q,N=1-(v+C),M=F+w,O=y+E,W=F-w,ae=1-(v+S),z=T*m,K=j*m,$=ue*m,re=ee*g,ce=N*g,Ae=M*g,Qe=O*p,Ve=W*p,H=ae*p,ie=z*z+re*re+Qe*Qe,le=z*K+re*ce+Qe*Ve,ge=z*$+re*Ae+Qe*H,Ie=K*K+ce*ce+Ve*Ve,me=K*$+ce*Ae+Ve*H,ye=$*$+Ae*Ae+H*H,Se=t;this._transformBData[Se+0]=ie,this._transformBData[Se+1]=le,this._transformBData[Se+2]=ge,this._transformBData[Se+3]=ye;const Me=Ka(Ie)&65535,Ze=Ka(me)&65535;this._transformAData[t+3]=Me|Ze<<16}flushUpdates(){if(this._pendingUpdates.size===0)return;const s=this.size.x|0,e=this.size.y|0,t=Array.from(this._pendingUpdates);if(t.length===0)return;let a=e,r=0;for(const o of t){const l=Math.floor(o/s);l<a&&(a=l),l>r&&(r=l)}const i=r-a+1;i/e<.5&&i<e?(this.splatColor.updateTexture(s,e,this._colorData,a,i),this.transformA.updateTexture(s,e,this._transformAData,a,i),this.transformB.updateTexture(s,e,this._transformBData,!1,a,i)):(this.splatColor.updateTexture(s,e,this._colorData),this.transformA.updateTexture(s,e,this._transformAData),this.transformB.updateTexture(s,e,this._transformBData,!1)),this.updatePendingWorldPositions(),this._pendingUpdates.clear()}setAutoFlushThreshold(s){this._autoFlushThreshold=Math.max(1,s)}getStreamingStats(){return{totalCount:this.totalCount,validCount:this._validCount,pendingUpdates:this._pendingUpdates.size,progress:this.totalCount>0?this._validCount/this.totalCount*100:0}}updateWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}updatePendingWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}scheduleOrder(s){if(this._validCount===0)return;const e=this.object3D.transform.localChange;e&&this.updateWorldPositions();const t=s.rawData,a=t[2],r=t[6],i=t[10],n=-(t[0]*t[12]+t[1]*t[13]+t[2]*t[14]),o=-(t[4]*t[12]+t[5]*t[13]+t[6]*t[14]),l=-(t[8]*t[12]+t[9]*t[13]+t[10]*t[14]),c=performance.now(),f=(c-this._lastSentTime)/1e3,d=Math.floor(n*1e3)^Math.floor(o*1e3)^Math.floor(l*1e3),h=Math.floor(a*1e3)^Math.floor(r*1e3)^Math.floor(i*1e3),u=d^h;if(u===this._lastViewMatrixHash&&!e&&this._centersSent)return;let m=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const p=Math.abs(u-this._lastViewMatrixHash)/Math.max(f,.001);p<1e3?m=this._minIntervalMs:p<1e4?m=this._minIntervalMs*.5:m=this._minIntervalMs*.2,this._lastCameraSpeed=p}if(!(c-this._lastSentTime<m)){if(this._lastViewMatrixHash=u,this._lastSentTime=c,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=U=>{const y=U.data.order,S=this._orderData.buffer;this._sortWorker.postMessage({order:S},[S]);const F=new Uint32Array(y),C=this.size.x*this.size.y,w=Math.min(this._validCount,F.length);if((!this._orderData||this._orderData.length!==C)&&(this._orderData=new Uint32Array(C)),this._orderData.set(F.subarray(0,w),0),w<C){const T=this._validCount>0?this._validCount-1:0;this._orderData.fill(T,w,C)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const E=Math.max(0,Math.min(this._validCount,U.data.count|0));this.setCount(E),this._updateTexParams();const Q=Math.ceil(E/this._batchSize);this.instanceCount=Q};const g=new Float32Array(this._validCount*3);let p=0;const D=this.object3D.transform.worldMatrix,A=this._positions,B=D.rawData;for(let U=0;U<this._validCount;U++)if(this._splatSetFlags[U]){const y=U*3,S=A[y+0],F=A[y+1],C=A[y+2];g[p*3+0]=B[0]*S+B[4]*F+B[8]*C+B[12],g[p*3+1]=B[1]*S+B[5]*F+B[9]*C+B[13],g[p*3+2]=B[2]*S+B[6]*F+B[10]*C+B[14],p++}const v=new Uint32Array(this.totalCount);for(let U=0;U<this.totalCount;U++)v[U]=U<this._validCount?U:this._validCount>0?this._validCount-1:0;this._sortWorker.postMessage({order:v.buffer,centers:g.buffer},[v.buffer,g.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const g=new Float32Array(this._validCount*3);let p=0;const D=this.object3D.transform.worldMatrix,A=this._positions,B=D.rawData;for(let v=0;v<this._validCount;v++)if(this._splatSetFlags[v]){const U=v*3,y=A[U+0],S=A[U+1],F=A[U+2];g[p*3+0]=B[0]*y+B[4]*S+B[8]*F+B[12],g[p*3+1]=B[1]*y+B[5]*S+B[9]*F+B[13],g[p*3+2]=B[2]*y+B[6]*S+B[10]*F+B[14],p++}this._sortWorker.postMessage({type:"centers",centers:g.buffer},[g.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:n,y:o,z:l},cameraDirection:{x:-a,y:-r,z:-i}})}}createSortWorker(){function s(){let n,o,l,c,f=!1;const d={x:0,y:0,z:0},h={x:0,y:0,z:0},u={x:0,y:0,z:0},m={x:0,y:0,z:0};let g,p;const D=(B,v,U)=>{for(;B<=v;){const y=v+B>>1,S=U(y);if(S>0)B=y+1;else if(S<0)v=y-1;else return y}return~B},A=()=>{if(!n||!o||!l||!c)return;const B=l.x,v=l.y,U=l.z,y=c.x,S=c.y,F=c.z,C=.001;if(!f&&Math.abs(B-d.x)<C&&Math.abs(v-d.y)<C&&Math.abs(U-d.z)<C&&Math.abs(y-h.x)<C&&Math.abs(S-h.y)<C&&Math.abs(F-h.z)<C)return;f=!1,d.x=B,d.y=v,d.z=U,h.x=y,h.y=S,h.z=F;const w=o.length/3;g?.length!==w&&(g=new Uint32Array(w));let E,Q;for(let M=0;M<8;++M){const O=(M&1?u.x:m.x)-B,W=(M&2?u.y:m.y)-v,ae=(M&4?u.z:m.z)-U,z=O*y+W*S+ae*F;M===0?E=Q=z:(E=Math.min(E,z),Q=Math.max(Q,z))}p?p.fill(0):p=new Uint32Array(65537);const T=Q-E,j=T<1e-6?0:1/T*2**16;for(let M=0;M<w;++M){const O=M*3,W=o[O+0]-B,ae=o[O+1]-v,z=o[O+2]-U,K=W*y+ae*S+z*F,$=Math.floor((K-E)*j);g[M]=$,p[$]++}for(let M=1;M<65537;M++)p[M]+=p[M-1];for(let M=0;M<w;M++){const O=g[M],W=--p[O];n[W]=M}const ue=M=>g[n[M]]/j+E,ee=()=>{const M=D(0,w-1,O=>-ue(O));return Math.min(w,Math.abs(M))},N=ue(w-1)>=0?ee():w;self.postMessage({order:n.buffer,count:N},[n.buffer]),n=null};self.onmessage=B=>{if(B.data.order&&(n=new Uint32Array(B.data.order)),B.data.centers){o=new Float32Array(B.data.centers),u.x=m.x=o[0],u.y=m.y=o[1],u.z=m.z=o[2];const v=o.length/3;for(let U=1;U<v;++U){const y=o[U*3+0],S=o[U*3+1],F=o[U*3+2];u.x=Math.min(u.x,y),u.y=Math.min(u.y,S),u.z=Math.min(u.z,F),m.x=Math.max(m.x,y),m.y=Math.max(m.y,S),m.z=Math.max(m.z,F)}f=!0}B.data.cameraPosition&&(l=B.data.cameraPosition),B.data.cameraDirection&&(c=B.data.cameraDirection),A()}}const e=`(${s.toString()})()`,t=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(t);return new Worker(a)}setVisBoost(s){this.texParams[3]=Math.max(0,s),this._texParamDirty=!0}setCount(s){this.texParams[0]=Math.max(0,s),this._texParamDirty=!0}_updateTexParams(){this._texParamDirty&&(this.gsplatMaterial.setTexParams(this.texParams),this._texParamDirty=!1)}setSortThrottle(s){this._minIntervalMs=Math.max(0,s|0)}setAdaptiveSorting(s){this._adaptiveSorting=s}setPixelCulling(s,e=0,t=0){this._minPixelCoverage=Math.max(0,s),this._maxPixelCoverage=Math.max(0,e),this._maxPixelCullDistance=Math.max(0,t)}getPixelCullingStats(){return{minPixels:this._minPixelCoverage,maxPixels:this._maxPixelCoverage,maxPixelCullDistance:this._maxPixelCullDistance,maxEnabled:this._maxPixelCoverage>0,distanceEnabled:this._maxPixelCullDistance>0}}getBatchingStats(){return{enabled:!0,batchSize:this._batchSize,instanceCount:this.instanceCount,splatCount:this._validCount,reduction:this._validCount>0?(1-this.instanceCount/this._validCount)*100:0}}evalTextureSize(s){let e=Math.ceil(Math.sqrt(s));const t=64;e=Math.ceil(e/t)*t;const a=Math.ceil(s/e);return new de(e,a)}nodeUpdate(s,e,t,a){this._validCount>0&&s?.camera&&this._frameCount>=60&&s.camera.viewMatrix&&this.scheduleOrder(s.camera.viewMatrix),this._pendingUpdates.size>0&&this._frameCount>=60&&this.flushUpdates(),this._frameCount>=60&&this._pendingUpdates.size===0&&(this._frameCount=0),this._frameCount++,this._updateTexParams();const r=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(r);const i=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;i!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=i),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(s,e,t,a)}renderPass(s,e,t){const a=t.encoder;for(let r of this.materials){const i=r.getPass(e);if(!(!i||i.length===0))for(const n of i){if(!n.pipeline)continue;n.apply(this.geometry,t.rendererPassState||t),k.bindPipeline(a,n),k.bindGeometryBuffer(a,this.geometry);const l=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?k.drawIndexed(a,l.indexCount,this.instanceCount,l.indexStart,0,0):k.drawIndexed(a,l.indexCount,1,l.indexStart,0,0)}}}destroy(s){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(s),this.splatColor=null),this.transformA&&(this.transformA.destroy(s),this.transformA=null),this.transformB&&(this.transformB.destroy(s),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(s),this.splatOrder=null),this._positions=null,this._orderData=null,this._colorData=null,this._transformAData=null,this._transformBData=null,this.texParams=null,this._splatSetFlags=null,this._pendingUpdates.clear(),super.destroy(s)}};Zi=jg([Ot(Zi,"GSplatStreamRenderer")],Zi);class Sh extends ne{index=0;drawCallFrame=-1;constructor(){super()}}var jo=(s=>(s[s.CastGI=0]="CastGI",s[s.ReceiveGI=1]="ReceiveGI",s[s.CastDepth=2]="CastDepth",s[s.Other=3]="Other",s))(jo||{});class Fh extends vt{static count=0;constructor(e=0,t=0){super(),Y.register("GIProbeShader",jd);let a=new At,r=new qe("GIProbeShader","GIProbeShader");r.passType=fe.COLOR,a.addRenderPass(r),r.setDefine("USE_BRDF",!0),r.setShaderEntry("VertMain","FragMain"),r.setUniformVector4("probeUniform",new be(t,e,0,0));let i=r.shaderState;i.acceptShadow=!1,i.castShadow=!1,i.receiveEnv=!1,i.acceptGI=!1,i.useLight=!1,a.setTexture("baseMap",_.res.whiteTexture),a.setTexture("normalMap",_.res.normalTexture),a.setTexture("emissiveMap",_.res.blackTexture),this.shader=a}}class Zg extends et{_probes;_volume;_debugMr=[];init(e){e||=_.views[0]?.scene,_.setting.gi.enable=!0,this._volume=xe.getLightEntries(e).irradianceVolume,this.initProbe(e)}initProbe(e){let t=this._volume.setting.probeXCount,a=this._volume.setting.probeYCount,r=this._volume.setting.probeZCount,i=new Nr(4,16,16),n=new b;this._probes=[];for(let o=0;o<t;o++)for(let l=0;l<a;l++)for(let c=0;c<r;c++){let f=o+c*t+l*(t*r),d=new Sh;d.index=f,d.name=`${o}_${l}_${c}`;let h=d.addComponent(he);h.material=new Fh(jo.CastGI,f),h.geometry=i,h.castGI=!1,h.castShadow=!1,this._debugMr.push(h),this.object3D.addChild(d),this._volume.calcPosition(o,l,c,n),d.x=n.x,d.y=n.y,d.z=n.z,this._probes[f]=d,this._debugMr.push(h)}for(let o=0;o<this._probes.length;o++)q.instance.addGIProbe(e,this._probes[o]);this.object3D.transform.enable=!1,this._volume.setting.debug&&this.debug()}debug(){}debugProbeRay(e,t){const a=_.setting.gi.rayNumber;let r=new se(0,-.7071067811865475,.7071067811865475,0);for(let i=0;i<a;i++){let n=e*a+i,o=new b(-t[n*4+0],-t[n*4+1],-t[n*4+2],0);r.transformVector(o,o);let l=t[n*4+3],c=this._probes[e].transform.worldPosition.clone(),f=o.scaleBy(l);f.add(c,f)}}changeProbesVolumeData(){this._volume.setVolumeDataChange()}changeProbesPosition(){this._volume.setVolumeDataChange();let e=this._volume.setting.probeXCount,t=this._volume.setting.probeYCount,a=this._volume.setting.probeZCount,r=new b;for(let i=0;i<e;i++)for(let n=0;n<t;n++)for(let o=0;o<a;o++){let l=i+o*e+n*(e*a),c=this._probes[l];this._volume.calcPosition(i,n,o,r),c.x=r.x,c.y=r.y,c.z=r.z}}onUpdate(){_.setting.gi.maxDistance=_.setting.gi.probeSpace*1.5;let e=this.transform.scene3D.view.camera,t=b.distance(e.transform.worldPosition,e.transform.targetPos)/300;if(this._debugMr&&this._debugMr.length>0)for(let a=0;a<this._debugMr.length;a++){const r=this._debugMr[a].transform;r.scaleX=t,r.scaleY=t,r.scaleZ=t}}}class Yg extends Ba{_keyRenderGroup;_keyBufferGroup;_keyIdsGroup;constructor(){super()}init(e){this._keyRenderGroup=new Map,this._keyBufferGroup=new Map,this._keyIdsGroup=new Map}start(){let e=[];this.object3D.getComponents(he,e,!0);for(let t=0;t<e.length;t++){const a=e[t];a.transform.updateWorldMatrix(!0),a.enable=!1;let r=a.geometry.instanceID;for(let i=0;i<a.materials.length;i++){const n=a.materials[i];r+=n.instanceID}if(this._keyRenderGroup.has(r))this._keyRenderGroup.get(r).push(a),this._keyIdsGroup.get(r).push(a.transform.worldMatrix.index);else{let i=new Pe(e.length);i.visibility=GPUShaderStage.VERTEX,this._keyRenderGroup.set(r,[a]),this._keyBufferGroup.set(r,i),this._keyIdsGroup.set(r,[a.transform.worldMatrix.index])}}this._keyBufferGroup.forEach((t,a)=>{let r=this._keyIdsGroup.get(a),i=this._keyBufferGroup.get(a);i.setInt32Array("matrixIDs",new Int32Array(r)),i.apply()})}reset(){this._keyRenderGroup.size>0&&(this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this.start())}nodeUpdate(e,t,a,r){this._keyRenderGroup.forEach((i,n)=>{let o=this._keyBufferGroup.get(n),l=i[0];for(let c=0;c<l.materials.length;c++){let d=l.materials[c].getPass(t);if(d)for(let h=0;h<d.length;h++){const u=d[h];u.setDefine("USE_INSTANCEDRAW",!0),u.setStorageBuffer("instanceDrawID",o)}}l.nodeUpdate(e,t,a,r)})}renderPass(e,t,a){this._keyRenderGroup.forEach((r,i)=>{let n=r[0];n.instanceCount=r.length,this.renderItem(e,t,n,a)})}renderItem(e,t,a,r){let i=a.transform._worldMatrix;for(let n=0;n<a.materials.length;n++){let l=a.materials[n].getPass(t);if(!(!l||l.length==0))for(let c=0;c<l.length;c++){let f=l[c];k.bindGeometryBuffer(r.encoder,a.geometry);const d=f;d.shaderState.splitTexture&&(r.endRenderPass(),Mt.WriteSplitColorTexture(a.instanceID),r.beginOpaqueRenderPass(),k.bindCamera(r.encoder,e.camera),k.bindGeometryBuffer(r.encoder,a.geometry)),k.bindPipeline(r.encoder,d);let g=a.geometry.subGeometries[n].lodLevels[a.lodLevel];a.instanceCount>0?k.drawIndexed(r.encoder,g.indexCount,a.instanceCount,g.indexStart,0,0):k.drawIndexed(r.encoder,g.indexCount,1,g.indexStart,0,i.index)}}}beforeDestroy(e){this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this._keyRenderGroup=this._keyBufferGroup=this._keyIdsGroup=void 0,Oe.removeWaitStart(this.object3D,this)}}var Xg=Object.getOwnPropertyDescriptor,Hg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Xg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Zs=class extends he{constructor(){super()}get geometry(){return null}set geometry(s){}cloneTo(s){}set meshURL(s){let e=_.res.getGeometry(s);e?this.geometry=e:console.error("no geometry set",s)}};Zs=Hg([Ot(Zs,"MeshFilter")],Zs);var Kg=Object.getOwnPropertyDescriptor,qg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Kg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Yi=class extends he{skinJointsName;mInverseBindMatrixData;mInverseBindMatrixBuffer;mSkeletonAnimation;mJointIndexTableBuffer;constructor(){super(),this.addRendererMask(Ne.SkinnedMesh)}start(){if(super.start(),this.skeletonAnimation=this.object3D.getComponent(mr),!this.skeletonAnimation){let s=this.object3D.parentObject.parentObject.getComponentsInChild(mr);s.length>0&&(this.skeletonAnimation=s[0]);let e=this.object3D;for(;!this.skeletonAnimation&&e;)this.skeletonAnimation=e.getComponentFromParent(mr),e.parent&&(e=e.parent.object3D)}}onEnable(){super.onEnable()}get skeletonAnimation(){return this.mSkeletonAnimation}set skeletonAnimation(s){if(this.mSkeletonAnimation=s,!!s&&!this.mJointIndexTableBuffer){let e=this.mSkeletonAnimation.getJointIndexTable(this.skinJointsName);this.mJointIndexTableBuffer=new Pe(e.length*4,0,new Float32Array(e)),this.mJointIndexTableBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}}get skinInverseBindMatrices(){return this.mInverseBindMatrixData}set skinInverseBindMatrices(s){this.mInverseBindMatrixData=s;var e=new Float32Array(s.length*16);for(let t=0;t<s.length;t++){let a=t*16,r=s[t];e.set(r,a)}this.mInverseBindMatrixBuffer=new Pe(e.byteLength,0,e),this.mInverseBindMatrixBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}get inverseBindMatrixBuffer(){return this.mInverseBindMatrixBuffer}get jointIndexTableBuffer(){return this.mJointIndexTableBuffer.buffer}cloneTo(s){let e=s.addComponent(Yi);e.geometry=this.geometry,e.material=this.material.clone(),e.castShadow=this.castShadow,e.castGI=this.castGI,e.receiveShadow=this.receiveShadow,e.rendererMask=this.rendererMask,e.skinJointsName=this.skinJointsName,e.skinInverseBindMatrices=this.skinInverseBindMatrices,e.mJointIndexTableBuffer=this.mJointIndexTableBuffer}nodeUpdate(s,e,t,a){for(let r=0;r<this.materials.length;r++){let n=this.materials[r].getPass(e);if(n)for(let o=0;o<n.length;o++){const l=n[o];!l.pipeline&&this.mSkeletonAnimation&&(l.setStorageBuffer("jointsMatrixIndexTable",this.mSkeletonAnimation.jointMatrixIndexTableBuffer),l.setStorageBuffer("jointsInverseMatrix",this.mInverseBindMatrixBuffer),l.setStorageBuffer("jointsIndexMapingTable",this.mJointIndexTableBuffer))}}super.nodeUpdate(s,e,t,a)}};Yi=qg([Ot(Yi,"SkinnedMeshRenderer")],Yi);class $g extends gt{radius=2.5;height=10;constructor(){super(),this._shapeType=ui.Capsule}}class mn extends gt{mesh;static triangle;_pickRet;constructor(){super(),this._shapeType=ui.Mesh}rayPick(e,t){if(this.mesh){mn.triangle||=new us(new b,new b,new b);let a=this.mesh.getAttribute(G.position),r=this.mesh.getAttribute(G.indices),i=gt.helpMatrix;i.copyFrom(t).invert();let n=gt.helpRay.copy(e);if(n.applyMatrix(i),n.intersectBox(this.mesh.bounds),!n.intersectBox(this.mesh.bounds,gt.v3_help_0))return null;if(r&&a&&r.data.length>0){let l=a.data;for(let c=0,f=r.data.length/3;c<f;c++){let d=c*3;const h=r.data[d+0]*3,u=r.data[d+1]*3,m=r.data[d+2]*3;let g=mn.triangle,p=g.v1.set(l[h+0],l[h+1],l[h+2]),D=g.v2.set(l[u+0],l[u+1],l[u+2]),A=g.v3.set(l[m+0],l[m+1],l[m+2]);g.set(p,D,A);let B=n.intersectTriangle(n.origin,n.direction,g);if(B){this._pickRet||={intersectPoint:new b,distance:0},this._pickRet.intersectPoint=B,this._pickRet.distance=b.distance(n.origin,B);let v=this.mesh.getAttribute(G.normal);if(v){let U=v.data,y=new b(U[h],U[h+1],U[h+2]);t.transformVector(y,y),y.normalize(),this._pickRet.normal=y}return this._pickRet}}}}return null}}class ep extends gt{_pickRet;box;radius=.5;constructor(e){super(),this._shapeType=ui.Sphere,this.radius=e,this.box=new Lr(new b,1)}rayPick(e,t){this.box.setFromCenterAndSize(this.center,this.radius);let r=gt.helpMatrix;r.copyFrom(t).invert();let i=gt.helpRay.copy(e);i.applyMatrix(r);let n=i.intersectSphere(i.origin,i.direction,this.box.center,this.box.radius);return n?(this._pickRet||(this._pickRet={intersect:!1,intersectPoint:new b,distance:0}),this._pickRet.intersect=!0,this._pickRet.intersectPoint=n,this._pickRet.distance=b.distance(i.origin,gt.v3_help_0),this._pickRet):null}}class tp extends ne{_envMap;skyObject;envMapChange=!0;view;constructor(){super(),this.transform.scene3D=this,this.skyObject=new ne,this.addChild(this.skyObject),this._isScene3D=!0,this.envMap||=_.res.defaultSky}get envMap(){return this._envMap}set envMap(e){this._envMap!=e&&(this.envMapChange=!0),this._envMap=e,q.instance.sky&&"map"in q.instance.sky&&(q.instance.sky.map=e)}get exposure(){return q.instance.sky&&"exposure"in q.instance.sky?q.instance.sky.exposure:0}set exposure(e){q.instance.sky&&"exposure"in q.instance.sky&&(q.instance.sky.exposure=e,_.setting.sky.skyExposure=e)}get roughness(){if(q.instance.sky&&"roughness"in q.instance.sky)return q.instance.sky.roughness}set roughness(e){q.instance.sky&&"roughness"in q.instance.sky&&(q.instance.sky.roughness=e)}}class kh{_computeShader;_outBuffer;constructor(){}init(){let e=ve.getGBufferFrame(ve.colorPass_GBuffer);this._computeShader=new Fe(kd),this._outBuffer=new ni(32),this._computeShader.setStorageBuffer("outBuffer",this._outBuffer),this._computeShader.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture())}compute(e){let t=xe.getCameraGroup(e.camera);this._computeShader.setStorageBuffer("globalUniform",t.uniformGPUBuffer);let a=k.beginCommandEncoder();k.computeCommand(a,[this._computeShader]),k.endCommandEncoder(a),this._outBuffer.readBuffer()}getPickMeshID(){var e=this._outBuffer.outFloat32Array[0]+.1;return Math.floor(e)}getPickWorldPosition(e){e||=new b;var t=this._outBuffer.outFloat32Array[4],a=this._outBuffer.outFloat32Array[5],r=this._outBuffer.outFloat32Array[6];return e.set(t,a,r),e}getPickWorldNormal(e){e||=new b;var t=this._outBuffer.outFloat32Array[8],a=this._outBuffer.outFloat32Array[9],r=this._outBuffer.outFloat32Array[10];return e.set(t*2-1,a*2-1,r*2-1).normalize(),e}getPickScreenUV(e){e||=new de;var t=this._outBuffer.outFloat32Array[2],a=this._outBuffer.outFloat32Array[3];return e.set(t,a),e}}class Eh extends Za{ray;isTouching=!1;_mouseCode;_pickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_mouseMove;_pickCompute;_lastDownTarget;mouseEnableMap;_view;constructor(e){super(),this._view=e,this.init()}init(){this.ray=new ua,this.mouseEnableMap=new Map,this._pickEvent=new Z(Z.PICK_CLICK),this._outEvent=new Z(Z.PICK_OUT),this._overEvent=new Z(Z.PICK_OVER),this._mouseMove=new Z(Z.PICK_MOVE),this._upEvent=new Z(Z.PICK_UP),this._downEvent=new Z(Z.PICK_DOWN)}start(){_.setting.pick.enable&&(_.inputSystem.addEventListener(Z.POINTER_DOWN,this.onTouchStart,this),_.inputSystem.addEventListener(Z.POINTER_UP,this.onTouchEnd,this),_.inputSystem.addEventListener(Z.POINTER_CLICK,this.onTouchOnce,this),_.inputSystem.addEventListener(Z.POINTER_RIGHT_CLICK,this.onTouchOnce,this),_.inputSystem.addEventListener(Z.POINTER_MOVE,this.onTouchMove,this)),_.setting.pick.mode=="pixel"&&(this._pickCompute=new kh,this._pickCompute.init())}stop(){_.inputSystem.removeEventListener(Z.POINTER_DOWN,this.onTouchStart,this),_.inputSystem.removeEventListener(Z.POINTER_UP,this.onTouchEnd,this),_.inputSystem.removeEventListener(Z.POINTER_CLICK,this.onTouchOnce,this),_.inputSystem.removeEventListener(Z.POINTER_RIGHT_CLICK,this.onTouchOnce,this),_.inputSystem.removeEventListener(Z.POINTER_MOVE,this.onTouchMove,this)}onTouchStart(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);this._lastDownTarget=t,t&&(Object.assign(this._downEvent,e),this._downEvent.type=Z.PICK_DOWN,this._downEvent.target=t.object3D,this._downEvent.data=this.getPickInfo(),this.dispatchEvent(this._downEvent),t.object3D.containEventListener(Z.PICK_DOWN)&&t.object3D.dispatchEvent(this._downEvent))}onTouchEnd(e){this.isTouching=!1,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._upEvent,e),this._upEvent.type=Z.PICK_UP,this._upEvent.target=t.object3D,this._upEvent.data=this.getPickInfo(),this.dispatchEvent(this._upEvent),t.object3D.containEventListener(Z.PICK_UP)&&t.object3D.dispatchEvent(this._upEvent))}_lastFocus;getPickInfo(){if(_.setting.pick.mode=="pixel")return{worldPos:this._pickCompute.getPickWorldPosition(),worldNormal:this._pickCompute.getPickWorldNormal(),screenUv:this._pickCompute.getPickScreenUV(),meshID:this._pickCompute.getPickMeshID()};{let e=this._interestList[0];return{worldPos:e.intersectPoint,worldNormal:e.normal,meshID:e.collider.transform.worldMatrix.index,distance:e.distance}}}onTouchMove(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._mouseMove,e),this._mouseMove.type=Z.PICK_MOVE,this._mouseMove.target=t.object3D,this._mouseMove.data=this.getPickInfo(),this.dispatchEvent(this._mouseMove),t.object3D.containEventListener(Z.PICK_MOVE)&&t.object3D.dispatchEvent(this._mouseMove)),t!=this._lastFocus&&(this._lastFocus&&this._lastFocus.object3D&&(Object.assign(this._outEvent,e),this._outEvent.type=Z.PICK_OUT,this._outEvent.target=this._lastFocus.object3D,this._outEvent.data=this.getPickInfo(),this.dispatchEvent(this._outEvent),this._lastFocus.object3D.containEventListener(Z.PICK_OUT)&&this._lastFocus.object3D.dispatchEvent(this._outEvent)),t&&(Object.assign(this._overEvent,e),this._overEvent.type=Z.PICK_OVER,this._overEvent.target=t.object3D,this._overEvent.data=this.getPickInfo(),this.dispatchEvent(this._overEvent),t.object3D.containEventListener(Z.PICK_OVER)&&t.object3D.dispatchEvent(this._overEvent))),this._lastFocus=t}onTouchOnce(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);if(t){let a=this.getPickInfo();Object.assign(this._pickEvent,e),this._pickEvent.type=Z.PICK_CLICK,this._pickEvent.target=t.object3D,this._pickEvent.data=a,this.dispatchEvent(this._pickEvent),t===this._lastDownTarget&&t.object3D.containEventListener(Z.PICK_CLICK)&&t.object3D.dispatchEvent(this._pickEvent)}this._lastDownTarget=null}findNearestObj(e,t){return e.sort((a,r)=>a.distance>r.distance?1:-1),e[0]?.collider}_interestList=[];pick(e){if(this._interestList.length=0,_.setting.pick.mode=="pixel"){this._pickCompute.compute(this._view);let t=this._pickCompute.getPickMeshID(),a=this.mouseEnableMap.get(t);if(a){let r=this._pickCompute.getPickWorldPosition(),i=b.distance(r,this.ray.origin);this._interestList.push({distance:i,collider:a,intersectPoint:r})}}else if(_.setting.pick.mode=="bound"){this.ray=e.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY);let t,a=Oe.componentsEnablePickerList.get(this._view);if(a)for(const r of a){let i=r[0];i.enable&&(t=i.rayPick(this.ray),t&&(t.collider=i,this._interestList.push(t)))}}}}class ap extends ys{_camera;_scene;_viewPort;_enablePick=!1;_enable=!0;pickFire;guiPick;canvasList;constructor(e=0,t=0,a=0,r=0){super(),this.canvasList=[],this._viewPort=new be(e,t,a,r)}get enable(){return this._enable}set enable(e){this._enable=e}get enablePick(){return this._enablePick}set enablePick(e){this._enablePick!=e&&(this.pickFire=new Eh(this),this.pickFire.start()),this._enablePick=e}get scene(){return this._scene}set scene(e){this._scene=e,e.view=this,jt.createBuffer(this),e&&this.canvasList.forEach(t=>{t&&e.addChild(t.object3D)})}get camera(){return this._camera}set camera(e){this._camera=e}get viewPort(){return this._viewPort}set viewPort(e){this._viewPort=e}enableUICanvas(e=0){let t=this.canvasList[e];if(!t){let a=new ne;a.name="Canvas "+e,t=a.addComponent(ds),t.index=e,this.canvasList[e]=t}return this.scene.addChild(t.object3D),this.guiPick||(this.guiPick=new mh,this.guiPick.init(this)),t}disableUICanvas(e=0){let t=this.canvasList[e];t&&t.object3D&&t.object3D.removeFromParent()}}class rp{normal;fixNormal;center;rotateShape;distance=0;index;constructor(e){this.index=e,this.rotateShape=[]}}class ip extends Le{vScale;uNegate;sections;build(e,t,a,r=1,i=!0){if(a.length<2)throw new Error("path length is not enough");return this.vScale=r,this.uNegate=i,e=e.slice(),t&&e.push(e[0]),this.sections=this.buildSections(e,a),this.buildGeometry(e,this.sections),this.bounds=new Ce(b.ZERO.clone(),new b(100,100,100)),this}buildSections(e,t){let a,r,i,n=[],o=t.length;for(let c=0;c<o;c++){let f=new rp(c);a=t[c],r=t[c+1],f.center=a.clone(),r==null?(f.normal=i.clone(),f.distance=0):(i=r.subtract(a),f.distance=i.length,f.normal=i.normalize()),n.push(f)}n[0].fixNormal=n[0].normal.clone();for(let c=1;c<o;c++){let f=n[c-1],d=n[c];d.fixNormal=d.normal.add(f.normal).normalize()}let l=new R().identity();for(let c=0;c<o;c++){let f=n[c],d,h;if(c==0)d=b.UP,h=e;else{let u=n[c-1];d=u.fixNormal,h=u.rotateShape}R.fromToRotation(d,f.fixNormal,l);for(let u=0,m=e.length;u<m;u++){let g=l.multiplyPoint3(h[u]);f.rotateShape.push(g)}}return n}buildGeometry(e,t){let a=t.length,r=e.length,i=a*r,n=a-1,o=new Float32Array(i*3),l=new Float32Array(i*3),c=new Float32Array(i*2),f=new Uint32Array(n*(r-1)*6),d=r-1,h=0,u=0,m=[0];for(let p=1;p<r;p++)u+=e[p-1].subtract(e[p]).length,m.push(u);for(let p=0;p<a;p++){let D=t[p];for(let A=0;A<r;A++){let B=(p*r+A)*3,v=D.rotateShape[A].add(D.center);o[B]=v.x,o[B+1]=v.y,o[B+2]=v.z,l[B+1]=1;let U=(p*r+A)*2,y=m[A]/u;c[U]=this.uNegate?1-y:y,c[U+1]=h*this.vScale}h+=D.distance}let g=0;for(let p=0;p<n;p++){let D=p*r;for(let A=0;A<d;A++){let B=A,v=A+1,U=B+r,y=v+r;f[g++]=B+D,f[g++]=v+D,f[g++]=U+D,f[g++]=v+D,f[g++]=y+D,f[g++]=U+D}}return this.setIndices(f),this.setAttribute(G.position,o),this.setAttribute(G.normal,l),this.setAttribute(G.uv,c),this.setAttribute(G.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.computeNormals(),this}}class wh extends Le{_instanceBuffer;_instanceData;_instanceCount=0;constructor(){super(),this.initBaseGeometry()}initBaseGeometry(){const e=new Float32Array([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=new Float32Array([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2]),a=new Uint16Array([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]);this.setIndices(a),this.setAttribute(G.position,e),this.setAttribute(G.uv,t),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:e.length/3,firstStart:0,index:0,topology:0})}setPositions(e){const t=e instanceof Float32Array?e:new Float32Array(e),r=t.length/3-1;if(r<=0)return console.warn("FatLineGeometry: Need at least 2 points"),this;const i=new Float32Array(r*16);for(let n=0;n<r;n++){const o=n*3,l=(n+1)*3;i[n*16+0]=t[o+0],i[n*16+1]=t[o+1],i[n*16+2]=t[o+2],i[n*16+3]=0,i[n*16+4]=t[l+0],i[n*16+5]=t[l+1],i[n*16+6]=t[l+2],i[n*16+7]=0,i[n*16+8]=1,i[n*16+9]=1,i[n*16+10]=1,i[n*16+11]=0,i[n*16+12]=1,i[n*16+13]=1,i[n*16+14]=1,i[n*16+15]=0}return this._instanceData=i,this._instanceCount=r,this.computeBoundingBox(t),this}setColors(e){const t=e instanceof Float32Array?e:new Float32Array(e);if(!this._instanceData)return console.warn("FatLineGeometry: Must call setPositions() before setColors()"),this;const r=t.length/3-1;if(r!==this._instanceCount)return console.warn("FatLineGeometry: Color array length doesn't match segment count"),this;for(let i=0;i<r;i++){const n=i*3,o=(i+1)*3;this._instanceData[i*16+8]=t[n+0],this._instanceData[i*16+9]=t[n+1],this._instanceData[i*16+10]=t[n+2],this._instanceData[i*16+12]=t[o+0],this._instanceData[i*16+13]=t[o+1],this._instanceData[i*16+14]=t[o+2]}return this}computeBoundingBox(e){const t=new b(1/0,1/0,1/0),a=new b(-1/0,-1/0,-1/0);for(let i=0;i<e.length;i+=3){const n=e[i],o=e[i+1],l=e[i+2];t.x=Math.min(t.x,n),t.y=Math.min(t.y,o),t.z=Math.min(t.z,l),a.x=Math.max(a.x,n),a.y=Math.max(a.y,o),a.z=Math.max(a.z,l)}const r=b.sub(a,t);this.bounds=new Ce(b.ZERO.clone(),r),this.bounds.setFromMinMax(t,a)}get instanceData(){return this._instanceData}get instanceCount(){return this._instanceCount}get instanceBuffer(){return!this._instanceBuffer&&this._instanceData&&(this._instanceBuffer=new Pe(this._instanceData.byteLength),this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply()),this._instanceBuffer}updateInstanceBuffer(){this._instanceBuffer&&this._instanceData&&(this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply())}}class sp{name;offset;size;arrayStride;stepMode;attributes}class np{name;format;offset;shaderLocation;stride}var Ih=(s=>(s[s.position=3]="position",s[s.normal=3]="normal",s[s.TANGENT=4]="TANGENT",s[s.uv=2]="uv",s[s.TEXCOORD_1=2]="TEXCOORD_1",s[s.color=4]="color",s[s.joints0=4]="joints0",s[s.weights0=4]="weights0",s[s.joints1=4]="joints1",s[s.weights1=4]="weights1",s[s.vIndex=1]="vIndex",s[s.weight=1]="weight",s[s.a_morphPositions_0=3]="a_morphPositions_0",s))(Ih||{});class op{get data(){return null}entity}class Rh{min=0;max=0;set(e,t){return this.max=t,this.min=e,this}copy(e){return this.max=e.max,this.min=e.min,this}isInterestRange(e){return!(this.max>e.min||e.max<this.min)}}class Qh{_spaceDesc;getRange(e){return this._spaceDesc[e]}initSpace(e){this._spaceDesc={};for(let t of e)(this._spaceDesc[t]=new Rh).set(-Number.MAX_VALUE,Number.MAX_VALUE);return this}isContain(e,t){let a=this._spaceDesc[e];return t>=a.min&&t<a.max}isInterestRange(e,t){let a=this._spaceDesc[e];return a?t.isInterestRange(a):!1}splitSpace(e,t,a){let r=this._spaceDesc[e];return t?r.max=a:r.min=a,this}copySpace(e){for(let t in e._spaceDesc){let a=e._spaceDesc[t];this._spaceDesc[t].copy(a)}return this}}class bs{static MaxEntityCountInLeaf=4;static MaxLayer=10;static ClearLeafLayer=bs.MaxLayer-4}class gs{static UUID=0;uuid="0";constructor(){this.uuid=(gs.UUID++).toString()}}class lp{map={};_count=0;get count(){return this._count}push(e){return this.map[e.uuid]?!1:(this.map[e.uuid]=e,this._count++,!0)}remove(e){return this.map[e]?(delete this.map[e],this._count--,!0):!1}}class yr extends gs{_dimensionIndex=0;_dimensions;_dimension;_left;_right;_space;_parent;_entities;layer;get dimension(){return this._dimension}constructor(e=0){super(),this.layer=e,yr.nodeCount++}initNode(e,t,a){return this._dimensions=t,this._dimensionIndex=a,this._dimension=t[a],this._space=new Qh().initSpace(t),e&&this._space.copySpace(e._space),this._parent=e,this._entities=new lp,this}updateEntity(e){if(e.isInNode(this,this._dimension)&&(e.attachTreeNode(this),this.autoSplit(),this._left&&this._right)){let t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t];e.isInNode(this._right,a)?this._right.updateEntity(e):e.isInNode(this._left,a)&&this._left.updateEntity(e)}}buildRoot(e){for(const t of e)t.entity.attachTreeNode(this);this.autoSplit()}_splitEntityList=[];autoSplit(){if(this._entities.count>bs.MaxEntityCountInLeaf&&!this._right&&!this._left&&this.layer<bs.MaxLayer){let e=this._splitEntityList,t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t],r=0;for(const i in this._entities.map){let n=this._entities.map[i];r+=n.centerValue(a),e.push(n)}r/=this._entities.count,this._left=new yr(this.layer+1),this._right=new yr(this.layer+1),this._left.initNode(this,this._dimensions,t),this._right.initNode(this,this._dimensions,t),this._left.setSpace(!0,r),this._right.setSpace(!1,r);for(let i of e)i.isInNode(this._right,a)?i.attachTreeNode(this._right):i.isInNode(this._left,a)&&i.attachTreeNode(this._left)}this._left&&this._left.autoSplit(),this._right&&this._right.autoSplit()}setSpace(e,t){return this._parent&&this._space.splitSpace(this._dimension,e,t),this}isEmpty(){return this._left==null&&this._right==null&&this._entities.count==0}pushEntity(e){return this._entities.push(e)}removeEntity(e){return this._entities.remove(e.uuid)}static nodeCount=0;autoClear(){let e=this;for(;e&&e.layer>bs.ClearLeafLayer&&e.clearLeaf();)e=e._parent}clearLeaf(){let e=!this._left&&!this._right,t=!e&&this._left.isEmpty()&&this._right.isEmpty();return t&&(this._left=this._right=null,yr.nodeCount-=2),e||t}isContain(e){return this._space.isContain(this._dimension,e)}static rangeBox=new Ce(new b(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),new b(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE));nodeIntersectsBox(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=yr.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),i.intersectsBox(e)}nodeIntersectsRay(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=yr.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),!0}pointCast(e,t=0,a){if(a=a||[],this._entities.count>0){let r=this._entities.map;for(let i in r){let n=r[i],o=n.entityContainPoint(e);!o&&t>0&&(o=n.squareDistanceTo(e,this._dimensions)<=t),o&&a.push(n)}}this._left&&this._left.isContain(e[this._left.dimension])&&this._left.pointCast(e,t,a),this._right&&this._right.isContain(e[this._right.dimension])&&this._right.pointCast(e,t,a)}boxCast(e,t){if(t=t||[],this._entities.count>0){let a=this._entities.map;for(let r in a){let i=a[r];i.entityIntersectsBox(e)&&t.push(i)}}this._left&&this._left.nodeIntersectsBox(e)&&this._left.boxCast(e,t),this._right&&this._right.nodeIntersectsBox(e)&&this._right.boxCast(e,t)}pointIntersect=new b;rayCast(e,t,a){t=t||[],a=a||[];let r=this.pointIntersect;if(this._entities.count>0){let i=this._entities.map;for(let n in i){let o=i[n];o.entityIntersectsRay(e,r)&&(a.push(new b().copyFrom(r)),t.push(o))}}this._left&&this._left.nodeIntersectsRay(e)&&this._left.rayCast(e,t,a),this._right&&this._right.nodeIntersectsRay(e)&&this._right.rayCast(e,t,a)}}class cp extends gs{userData;node;constructor(e){super(),this.userData=e}centerValue(e){return 0}isInNode(e,t){return!1}entityContainPoint(e){return!1}squareDistanceTo(e,t){return Number.MAX_VALUE}entityIntersectsBox(e){return!1}entityIntersectsRay(e,t){return!1}attachTreeNode(e){return this.node&&this.detachTreeNode(),this.node=e,this.node.pushEntity(this)}detachTreeNode(){let e=this.node.removeEntity(this);return this.node=null,e}updateNode(e){let t=this.node;t&&this.detachTreeNode(),e.updateEntity(this),t&&t.autoClear()}}class Nt{minPosX=0;minPosY=0;maxPosX=0;maxPosY=0;testID=0;points;offsetPosition;static TINY=1e-6;constructor(){this.points=new Array,this.offsetPosition=new b(0,0,0,0),this.clear()}setAABox(e,t,a,r){this.minPosX=e-a/2-Nt.TINY,this.maxPosX=e+a/2+Nt.TINY,this.minPosY=t-r/2-Nt.TINY,this.maxPosY=t+r/2+Nt.TINY,this.offsetPosition.setTo(0,0,0)}setOffset(e){this.maxPosX+=e.x-this.offsetPosition.x,this.minPosX+=e.x-this.offsetPosition.x,this.minPosY+=e.z-this.offsetPosition.z,this.maxPosY+=e.z-this.offsetPosition.z,this.offsetPosition.copyFrom(e)}setContainRect(e,t,a,r){this.minPosX>e&&(this.minPosX=e),this.minPosY>t&&(this.minPosY=t),this.maxPosX<a&&(this.maxPosX=a),this.maxPosY<r&&(this.maxPosY=r)}clear(){var e=1e9;this.minPosX=this.minPosY=e,this.maxPosX=this.maxPosY=-e,this.points.length=0,this.testID=0,this.offsetPosition.setTo(0,0,0)}addPoint(e){this.points.indexOf(e)==-1&&(e.x<this.minPosX&&(this.minPosX=e.x-Nt.TINY),e.x>this.maxPosX&&(this.maxPosX=e.x+Nt.TINY),e.z<this.minPosY&&(this.minPosY=e.z-Nt.TINY),e.z>this.maxPosY&&(this.maxPosY=e.z+Nt.TINY),this.points.push(e))}clone(){var e=new Nt;return e.minPosX=this.minPosX,e.minPosY=this.minPosY,e.maxPosX=this.maxPosX,e.maxPosY=this.maxPosY,e}get radius(){return Math.sqrt((this.maxPosY-this.minPosY)*(this.maxPosY-this.minPosY)+(this.maxPosX-this.minPosX)*(this.maxPosX-this.minPosX))}get sideX(){return this.maxPosX-this.minPosX}get sideY(){return this.maxPosY-this.minPosY}get centreX(){return(this.maxPosX-this.minPosX)*.5+this.minPosX}get centreY(){return(this.maxPosY-this.minPosY)*.5+this.minPosY}overlapTest(e){return!(this.minPosY>=e.maxPosY||this.maxPosY<=e.minPosY||this.minPosX>=e.maxPosX||this.maxPosX<=e.minPosX)}isPointInside(e){return e.x>=this.minPosX&&e.x<=this.maxPosX&&e.z>=this.minPosY&&e.z<=this.maxPosY}isIntersectLineSegment(e,t,a,r){var i=!1,n=t-r,o=a-e,l=e*r-a*t,c=(-l-n*this.minPosX)/o;c<=this.maxPosY&&c>=this.minPosY&&(i=!0),c=(-l-n*this.maxPosX)/o,c<=this.maxPosY&&c>=this.minPosY&&(i=!0);var f=(-l-o*this.minPosY)/n;return f<=this.maxPosX&&f>=this.minPosX&&(i=!0),f=(-l-o*this.maxPosY)/n,f<=this.maxPosX&&f>=this.minPosX&&(i=!0),i}}class kr{static NUM_CHILDREN=4;childCellIndices;nodeIndices;aabb;points;constructor(e){this.childCellIndices=new Array,this.childCellIndices.length=kr.NUM_CHILDREN,this.nodeIndices=new Array,this.clear(),e?this.aabb=e.clone():this.aabb=new Nt}isLeaf(){return this.childCellIndices[0]==-1}clear(){for(var e=0;e<kr.NUM_CHILDREN;e++)this.childCellIndices[e]=-1;this.nodeIndices.splice(0,this.nodeIndices.length)}}class Th{_cells;_rootCell;_quadNodes;_aabb;_cellsToTest;_testID;constructor(){this._testID=0,this._cells=new Array,this._quadNodes=new Array,this._cellsToTest=new Array,this._aabb=new Nt}getQuadNode(e){return this._quadNodes[e]}clear(){this._cells.length=0,this._quadNodes.length=0}initNodes(e){this.clear();for(var t=0,a=e.length;t<a;)e[t].calcGlobalQuadAABB(),this._quadNodes.push(e[t]),t++}buildQuadTree(e,t){this._aabb.clear();for(var a of this._quadNodes)if(a.isTriangle)for(var r of a.aabb.points)this._aabb.addPoint(r);else this._aabb.setContainRect(a.aabb.minPosX,a.aabb.minPosY,a.aabb.maxPosX,a.aabb.maxPosY);this._cells.length=0,this._rootCell=new kr(this._aabb),this._cells.push(this._rootCell);for(var i=this._quadNodes.length,n=0;n<i;n++)this._cells[0].nodeIndices[n]=n;var o=new Array;o.push(0);for(var l,c,f;o.length!=0;)if(c=o.pop(),!(this._cells[c].nodeIndices.length<=e||this._cells[c].aabb.radius<t)){for(n=0;n<kr.NUM_CHILDREN;n++){this._cells[c].childCellIndices[n]=this._cells.length,o.push(this._cells.length),this._cells.push(new kr(this.createAABox(this._cells[c].aabb,n))),f=this._cells[this._cells.length-1],i=this._cells[c].nodeIndices.length;for(var d=0;d<i;d++)l=this._cells[c].nodeIndices[d],this.doesNodeIntersectCell(this._quadNodes[l],f)&&f.nodeIndices.push(l)}this._cells[c].nodeIndices.length=0}}createAABox(e,t){var a=e.centreX,r=e.centreY,i=e.sideX,n=e.sideY,o=new Nt;switch(t){case 0:o.setAABox(a+i/4,r+n/4,i/2,n/2);break;case 1:o.setAABox(a-i/4,r+n/4,i/2,n/2);break;case 2:o.setAABox(a-i/4,r-n/4,i/2,n/2);break;case 3:o.setAABox(a+i/4,r-n/4,i/2,n/2);break;default:o.setAABox(a+i/4,r-n/4,i/2,n/2);break}return o}doesNodeIntersectCell(e,t){var a=e.aabb;if(!a.overlapTest(t.aabb))return!1;if(!e.isTriangle)return!0;var r=a.points,i=r[0],n=r[1],o=r[2];if(t.aabb.isPointInside(i)||t.aabb.isPointInside(n)||t.aabb.isPointInside(o))return!0;var l=this.pointInTriangle(t.aabb.minPosX,t.aabb.minPosY,i,n,o)||this.pointInTriangle(t.aabb.minPosX,t.aabb.maxPosY,i,n,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.maxPosY,i,n,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.minPosY,i,n,o);return l?!0:(l=t.aabb.isIntersectLineSegment(i.x,i.z,n.x,n.z)||t.aabb.isIntersectLineSegment(i.x,i.z,o.x,o.z)||t.aabb.isIntersectLineSegment(n.x,n.z,o.x,o.z),l)}getNodesIntersectingtAABox(e,t){if(this._cells.length==0)return 0;this._cellsToTest.length=0,this._cellsToTest.push(0),this.incrementTestCounter();for(var a,r,i,n,o=0;this._cellsToTest.length!=0;)if(a=this._cellsToTest.pop(),i=this._cells[a],!!t.overlapTest(i.aabb))if(i.isLeaf())for(r=i.nodeIndices.length,o=0;o<r;o++)n=this.getQuadNode(i.nodeIndices[o]).aabb,n.testID!=this._testID&&(n.testID=this._testID,t.overlapTest(n)&&e.push(i.nodeIndices[o]));else for(o=0;o<kr.NUM_CHILDREN;o++)this._cellsToTest.push(i.childCellIndices[o]);return e.length}pointInTriangle(e,t,a,r,i){var n=a,o=r,l=i,c=n.z-o.z,f=o.x-n.x,d=n.x*o.z-o.x*n.z,h=o.z-l.z,u=l.x-o.x,m=o.x*l.z-l.x*o.z,g=l.z-n.z,p=n.x-l.x,D=l.x*n.z-n.x*l.z,A=!1,B=c*e+f*t+d,v=h*e+u*t+m,U=g*e+p*t+D;const y=.01;return(B>=-y&&v>=-y&&U>=-y||B<=y&&v<=y&&U<=y)&&(A=!0),A}incrementTestCounter(){if(++this._testID,this._testID==0){for(var e=this._quadNodes.length,t=0;t<e;t++)this._quadNodes[t].aabb.testID=0;this._testID=1}}logDeep=0;logTree(e){if(!(e<0)){this.logDeep++;for(var t=this._cells[e],a="",r=0;r<this.logDeep-1;r++)a+="-|";console.log(a+"i="+e+" "+t.aabb.minPosX.toFixed(2)+" "+t.aabb.maxPosX.toFixed(2)+" "+t.aabb.minPosY.toFixed(2)+" "+t.aabb.maxPosY.toFixed(2));var i;for(i=0;i<t.nodeIndices.length;i++)if(t.nodeIndices[i]>=0){var n=this._quadNodes[t.nodeIndices[i]];console.log(a+" t="+t.nodeIndices[i]+" "+n.aabb.minPosX.toFixed(2)+" "+n.aabb.maxPosX.toFixed(2)+" "+n.aabb.minPosY.toFixed(2)+" "+n.aabb.maxPosY.toFixed(2))}for(i=0;i<t.childCellIndices.length;i++)t.childCellIndices[i]>=0&&this.logTree(t.childCellIndices[i]);this.logDeep--}}}class Mh{_maxNodesPerCell;_minCellSize;_quadTree;_collisionNodesIdx;_segBox;_collisionNodes;constructor(e=10,t=500){this._maxNodesPerCell=e,this._minCellSize=t,this._segBox=new Nt,this._collisionNodesIdx=new Array,this._collisionNodes=new Array}createQuadTree(e){this._quadTree=new Th,this._quadTree.initNodes(e),this._quadTree.buildQuadTree(this._maxNodesPerCell,this._minCellSize)}getNodesByAABB(e,t,a,r){this._segBox.clear(),this._segBox.maxPosX=a,this._segBox.maxPosY=r,this._segBox.minPosX=e,this._segBox.minPosY=t,this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var i,n=0;n<this._collisionNodesIdx.length;n++)i=this._quadTree.getQuadNode(this._collisionNodesIdx[n]),this._collisionNodes.push(i);return this._collisionNodes}getTriangleAtPoint(e,t=5){this._segBox.clear(),this._segBox.setAABox(e.x,e.z,1,1),this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var a=4294967295,r=0,i,n,o,l,c=0;c<this._collisionNodesIdx.length;c++)n=this._quadTree.getQuadNode(this._collisionNodesIdx[c]),l=n.aabb,b.pointInsideTriangle(e,l.points[0],l.points[1],l.points[2])&&(o=n,r=Math.abs(o.plane.distance(e)),!(r>t)&&(n==null||r<=a)&&(i=o,a=r));return i}}var Ys=(s=>(s[s.MOUSE_LEFT=0]="MOUSE_LEFT",s[s.MOUSE_MID=1]="MOUSE_MID",s[s.MOUSE_RIGHT=2]="MOUSE_RIGHT",s))(Ys||{});class fp extends pt{static LOADER_PROGRESS="loaderProgress";static LOADER_COMPLETE="loaderComplete"}class dp extends pt{static ADDED="added";static REMOVED="removed";static CHILD_ADD_EVENT="childAddEvent";static CHILD_REMOVED="childRemoved"}class hp extends pt{static SHOW="show";static HIDE="hide";static UPDATE="update"}class up{static merge(e,t,a,r){let i=0,n=0;i=Math.max(e.width,i),i=Math.max(t.width,i),i=Math.max(a.width,i),i=Math.max(r.width,i),n=Math.max(e.height,n),n=Math.max(t.height,n),n=Math.max(a.height,n),n=Math.max(r.height,n);let o=new Te(i,n,oe.rgba8unorm),l=new Fe(yd);l.setSamplerTexture("textureR",e),l.setSamplerTexture("textureG",t),l.setSamplerTexture("textureB",a),l.setSamplerTexture("textureA",r),l.setStorageTexture("outTex",o),l.workerSizeX=Math.ceil(i/8),l.workerSizeY=Math.ceil(n/8);let c=k.beginCommandEncoder();return k.computeCommand(c,[l]),k.endCommandEncoder(c),o}}class Nh{computeShader;setInputes(e,t,a){this.computeShader=new Fe(Ld(e,t,a,8,8,1));for(let r=0;r<t.length;r++)this.computeShader.setSamplerTexture(`source${r}Map`,t[r]);for(let r=0;r<a.length;r++)this.computeShader.setStorageTexture(`dest${r}Map`,a[r]);e&&this.computeShader.setSamplerTexture("colorMap",e),this.computeShader.workerSizeX=a[0].width/8,this.computeShader.workerSizeY=a[0].height/8,this.computeShader.workerSizeZ=1}}class Ph{sourceShader;compute;needUpdate=!0;constructor(e,t){this.sourceShader=t,this.compute=new Fe(e),this.init()}init(){}onUpdate(){this.onFrame&&this.onFrame(),this.onOnce&&this.needUpdate&&(this.needUpdate=!1,this.onFrame())}}class Vh extends Ph{constructor(e){super(Ed,e)}init(){let e=new Te(256,256,oe.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);return this.compute.setStorageTexture("sssMap",e),this.sourceShader.setTexture("lutMap",e),e}onFrame(){this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let e=k.beginCommandEncoder();k.computeCommand(e,[this.compute]),k.endCommandEncoder(e)}}class bp{gpuBuffer;probes;memoryDo;_probeInfoList;initDataUniform(e){this.memoryDo=new cr,this.probes=e,this._probeInfoList=[],this.memoryDo.destroy(),this.memoryDo.allocation(e.length*17*4);for(let a=0;a<e.length;a++){var t=17;let r=this.memoryDo.allocation_node(t*4);this._probeInfoList.push(r);let i=e[a].transform.worldPosition;r.setArray(0,[i.x,i.y,i.z])}this.gpuBuffer=I.device.createBuffer({size:this.memoryDo.shareDataBuffer.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE,label:"ProbeBuffer",mappedAtCreation:!1})}updateGPUBuffer(){const e=this.memoryDo.shareDataBuffer;let t=this.memoryDo.shareDataBuffer.byteLength,a=0;const r=5e3*64;for(;a<t;)I.device.queue.writeBuffer(this.gpuBuffer,a,e,a,Math.floor(Math.min(r,t-a))),a+=r}}class gp extends Ya{constructor(e,t,a=0){super(),this.bufferType=Aa.StructStorageGPUBuffer,this.createBufferByStruct(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|a,e,t)}}class pp{static codeMax=`
11789
+ `||C==" "?y=null:(B(C,y),y.width+u>=m&&(y=A()))}})(),v()}getAlignment(e){let t={v:0,h:0};switch(e){case 1:t.v=0,t.h=1;break;case 0:t.v=0,t.h=0;break;case 2:t.v=0,t.h=2;break;case 4:t.v=1,t.h=1;break;case 3:t.v=1,t.h=0;break;case 5:t.v=1,t.h=2;break;case 7:t.v=2,t.h=1;break;case 6:t.v=2,t.h=0;break;case 8:t.v=2,t.h=2;break}return t}}class pn extends Jo{_style=at.NORMAL;_interactive=!1;set interactive(e){this._interactive=e}get interactive(){return this._interactive}set mouseStyle(e){this._style=e}get interactiveVisible(){return this._uiTransform.globalVisible&&this._visible}init(e){super.init(e),this._uiTransform.addUIInteractive(this)}destroy(){this._uiTransform.removeUIInteractive(this),super.destroy()}rayPick(e,t,a,r){return _h.rayPick(e,a,r,t.space,t.panelRatio,this._uiTransform,t.transform.worldMatrix)}cloneTo(e){e.getOrAddComponent(pn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.enable=e._enable,this.interactive=e._interactive,this.mouseStyle=e._style,this}}var Ch=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=1]="COLOR",s[s.SPRITE=2]="SPRITE",s))(Ch||{});class bl extends pn{_spriteMap;_colorMap;_image;_isCreateImage;_transition=2;init(e){super.init(e),this._interactive=!0,this._spriteMap=new Map,this._colorMap=new Map,this._image=this.object3D.getComponent(zr),this._isCreateImage=this._image==null,this._image||(this._image=this.object3D.addComponent(zr)),this.imageType=hi.Sliced}onEnable(){this.mouseStyle=at.NORMAL}onDisable(){this.mouseStyle=at.DISABLE}set transition(e){this._transition!=e&&(this._transition=e,this.validateStyle(this._style,!0))}get transition(){return this._transition}get imageType(){return this._image.imageType}set imageType(e){this._image.imageType=e}setStyleColor(e,t){return this._colorMap.set(e,t),this._style==e&&this.validateStyle(this._style,!0),this}getStyleColor(e){return this._colorMap.get(e)}set mouseStyle(e){super.mouseStyle=e,this.validateStyle(e,!0)}get normalSprite(){return this._spriteMap.get(at.NORMAL)}set normalSprite(e){this._spriteMap.set(at.NORMAL,e),this._style==at.NORMAL&&this.validateStyle(this._style,!0)}get overSprite(){return this._spriteMap.get(at.OVER)}set overSprite(e){this._spriteMap.set(at.OVER,e),this._style==at.OVER&&this.validateStyle(this._style,!0)}set downSprite(e){this._spriteMap.set(at.DOWN,e),this._style==at.DOWN&&this.validateStyle(this._style,!0)}get downSprite(){return this._spriteMap.get(at.DOWN)}set disableSprite(e){this._spriteMap.set(at.DISABLE,e),this._style==at.DISABLE&&this.validateStyle(this._style,!0)}get disableSprite(){return this._spriteMap.get(at.DISABLE)}validateStyle(e,t){if(this._transition&2){let a=this._spriteMap.get(e);this._image.sprite=a}if(this._transition&1){let a=this._colorMap.get(e);a&&(this._image.color=a)}}cloneTo(e){e.getOrAddComponent(bl).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.imageType=e.imageType,this.transition=e.transition,e._spriteMap.forEach((t,a)=>{t&&this._spriteMap.set(a,t)}),e._colorMap.forEach((t,a)=>{t&&this._colorMap.set(a,t.clone())}),this.mouseStyle=e.mouseStyle,this}destroy(){this._isCreateImage&&this._image&&(this.object3D.removeComponent(zr),this._image=null),super.destroy()}}class gl extends ji{_count=0;constructor(){super()}init(e){super.init?.(e),this._count=e?e.count:1;for(let t=0;t<this._count;t++)this.attachQuad(Ja.spawnQuad());this._uiTransform.resize(0,0)}getQuad(e){return this._mainQuads[e]}cloneTo(e){e.addComponent(gl,{count:this._count}).copyComponent(this)}copyComponent(e){super.copyComponent(e);for(let t=0;t<e._count;t++)this.setSprite(t,e.getSprite(t)),this.setColor(t,e.getColor(t)),this.setImageType(t,e.getImageType(t));return this}setSprite(e,t){this._mainQuads[e].sprite=t||_.res.defaultGUISprite,this.setShadowDirty()}getSprite(e){return this._mainQuads[e].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}getColor(e){return this._mainQuads[e].color}setColor(e,t){this._mainQuads[e].color=t,this.setShadowDirty()}getImageType(e){return this._mainQuads[e].imageType}setImageType(e,t){this._mainQuads[e].imageType=t,this.setShadowDirty()}setSize(e,t,a){this._mainQuads[e].setSize(t,a),this.setShadowDirty()}setXY(e,t,a){this._mainQuads[e].setXY(t,a),this.setShadowDirty()}getXY(e,t){t||=new de;let a=this._mainQuads[e];return t.x=a.x,t.y=a.y,t}}class pl extends ji{_shadowQuality=1;_shadowOffset;_shadowRadius;_shadowColor;_subShadowColor;needUpdateShadow=!1;init(e){super.init?.(e),this._shadowRadius=2,this._shadowQuality=1,this._shadowOffset=new de(4,-4),this._shadowColor=new J(.1,.1,.1,.8),this._subShadowColor=this._shadowColor.clone(),this.isUIShadow=!0}cloneTo(e){e.getOrAddComponent(pl).copyComponent(this)}copyComponent(e){return super.copyComponent(this),this._shadowColor=e._shadowColor,this._shadowOffset=e._shadowOffset,this._shadowRadius=e._shadowRadius,this._shadowQuality=e.shadowQuality,this}get shadowColor(){return this._shadowColor}set shadowColor(e){this._shadowColor.copyFrom(e),this.needUpdateShadow=!0}set shadowQuality(e){e=Be(e,0,4),this._shadowQuality!=e&&(this._shadowQuality=e,this.needUpdateShadow=!0)}get shadowQuality(){return this._shadowQuality}set shadowOffset(e){this._shadowOffset=e,this.needUpdateShadow=!0}get shadowOffset(){return this._shadowOffset||=new de(4,-4),this._shadowOffset}set shadowRadius(e){this._shadowRadius!=e&&(this._shadowRadius=e,this.applyShadow())}get shadowRadius(){return this._shadowRadius}onUpdate(e){this.needUpdateShadow&&(this.applyShadow(),this.needUpdateShadow=!1)}applyShadow(){if(this.detachQuads(),this._shadowSource&&this._shadowQuality>0){let e=this._shadowSource.mainQuads;if(e.length>0)for(let t of e)this.createQuadShadow(t)}this._uiTransform.setNeedUpdateUIPanel()}createQuadShadow(e){let t=this._shadowQuality,a=Math.PI*2;this._subShadowColor.copyFrom(this._shadowColor),this._subShadowColor.a=1/Math.max(1,t);for(let r=0;r<t;r++){let i=Ja.spawnQuad(),n=0,o=0;if(r==0)i.color=this._shadowColor;else{let l=a*(r-1)/(t-1);n=Math.sin(l)*this._shadowRadius,o=Math.cos(l)*this._shadowRadius,i.color=this._subShadowColor}i.setXY(n+this._shadowOffset.x+e.x,o+this._shadowOffset.y+e.y),i.setSize(e.width,e.height),i.sprite=e.sprite,i.visible=e.visible,i.imageType=e.imageType,this.attachQuad(i)}}}class ml extends ji{_font="\u5FAE\u8F6F\u96C5\u9ED1";_fontSize=14;_originSize=42;_alignment=0;_lineSpacing=1;_text="";_color=new J(1,1,1,1);constructor(){super()}cloneTo(e){e.getOrAddComponent(ml).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this._font=e._font,this._fontSize=e._fontSize,this._originSize=e._originSize,this._alignment=e._alignment,this._lineSpacing=e._lineSpacing,this._color.copyFrom(e._color),this.text=e.text,this}get originSize(){return this._originSize}get font(){return this._font}set font(e){this._font=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!=e&&(this._fontSize=e,this.layoutText())}get text(){return this._text}set text(e){this._text!=e&&(e||(e=""),this._text=e,this.layoutText())}textLine=null;layoutProxy=new yh;layoutText(){this.detachQuads(),this.textLine=this.layoutProxy.layout(this);for(let e=0,t=this.textLine.length;e<t;e++){let a=this.textLine[e];for(let r=0,i=a.quadList.length;r<i;r++){let n=a.quadList[r];n&&this.attachQuad(n)}}this.color=this._color,this._uiTransform.setNeedUpdateUIPanel(),this.onUIComponentVisible(this._visible),this.setShadowDirty()}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t&&(t.visible=!e);this.setShadowDirty()}onTransformResize(){this.layoutText()}get color(){return this._color}set color(e){this._color.copyFrom(e);for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get alignment(){return this._alignment}set alignment(e){this._alignment!=e&&(this._alignment=e,this.layoutText())}get lineSpacing(){return this._lineSpacing}set lineSpacing(e){this._lineSpacing!=e&&(this._lineSpacing=e,this.layoutText())}}var Lg=Object.getOwnPropertyDescriptor,Gg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Lg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let js=class extends Ri{constructor(){super()}init(){super.init(),this.lightData.lightType=ht.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+zt())}get range(){return this.lightData.range}set range(s){this.lightData.range=s,this.onChange()}get at(){return this.lightData.linear}set at(s){this.lightData.linear=s,this.onChange()}get radius(){return this.lightData.radius}set radius(s){this.lightData.radius=s,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(s){this.lightData.quadratic=s,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(s){let e=s.scene.getChildByName("graphic3D");if(!e)return;let t=e.createCustomShape(`PointLight_${this.object3D.instanceID}`,this.transform);t.buildAxis(),t.buildCircle(b.ZERO,this.range,32,b.X_AXIS),t.buildCircle(b.ZERO,this.range,32,b.Y_AXIS),t.buildCircle(b.ZERO,this.range,32,b.Z_AXIS)}debug(){}debugDraw(s){}};js=Gg([Ot(js,"Light")],js);var zg=Object.getOwnPropertyDescriptor,Wg=(s,e,t,a)=>{for(var r=a>1?void 0:a?zg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let mi=class extends Ba{_fatLineMaterial=null;_fatLineGeometry=null;_cachedResolution=new de(0,0);constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(mi).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this}set geometry(s){super.geometry=s,this._fatLineGeometry=s,s&&(this.instanceCount=s.instanceCount,this._fatLineMaterial&&s.instanceBuffer&&this._fatLineMaterial.setInstanceBuffer(s.instanceBuffer))}get geometry(){return this._fatLineGeometry}set material(s){this.materials=[s],this._fatLineMaterial=s,this._fatLineGeometry&&this._fatLineGeometry.instanceBuffer&&s.setInstanceBuffer(this._fatLineGeometry.instanceBuffer)}get material(){return this._fatLineMaterial}nodeUpdate(s,e,t,a){if(this._fatLineMaterial&&this.object3D){this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);const r=I.presentationSize[0],i=I.presentationSize[1];r>0&&i>0&&(this._cachedResolution.x!==r||this._cachedResolution.y!==i)&&(this._cachedResolution.set(r,i),this._fatLineMaterial.resolution=this._cachedResolution.clone())}super.nodeUpdate(s,e,t,a)}destroy(s){super.destroy(s)}};mi=Wg([Ot(mi,"FatLineRenderer")],mi);var Jg=Object.getOwnPropertyDescriptor,jg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Jg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Zi=class extends Ba{totalCount=0;size=new de;localBoundBox=new Ce;get worldBoundBox(){const s=new Ce;s.makeEmpty();const t=this.object3D.transform.worldMatrix.rawData,a=this.localBoundBox.min,r=this.localBoundBox.max,i=[[a.x,a.y,a.z],[r.x,a.y,a.z],[a.x,r.y,a.z],[r.x,r.y,a.z],[a.x,a.y,r.z],[r.x,a.y,r.z],[a.x,r.y,r.z],[r.x,r.y,r.z]];for(const[n,o,l]of i){const c=t[0]*n+t[4]*o+t[8]*l+t[12],f=t[1]*n+t[5]*o+t[9]*l+t[13],d=t[2]*n+t[6]*o+t[10]*l+t[14];s.expandByPoint(new b(c,f,d))}return s}splatColor;transformA;transformB;texParams;_texParamDirty=!0;splatOrder;gsplatMaterial;_colorData;_transformAData;_transformBData;_orderData;_positions;_splatSetFlags;_validCount=0;_sortWorker;_lastSentTime=0;_minIntervalMs=16;_centersSent=!1;_lastViewMatrixHash=0;_lastCameraSpeed=0;_adaptiveSorting=!0;_lastPixelCullParams="";_texturesInitialized=!1;_minPixelCoverage=4;_maxPixelCoverage=0;_maxPixelCullDistance=0;_batchSize=128;instanceCount=0;_pendingUpdates=new Set;_autoFlushThreshold=100;_frameCount=0;constructor(){super()}initCount(s,e=128){if(s<=0)throw new Error("Total count must be greater than 0");this.totalCount=s,this._batchSize=e,this.size=this.evalTextureSize(s);const t=this.size.x|0,a=this.size.y|0,r=t*a;this._colorData=new Uint8Array(r*4),this._colorData.fill(0),this._transformAData=new Uint32Array(r*4),this._transformAData.fill(0),this._transformBData=new Array(r*4).fill(0),this._orderData=new Uint32Array(r);for(let i=0;i<r;i++)this._orderData[i]=i<s?i:s>0?s-1:0;this._positions=new Float32Array(s*3),this._positions.fill(0),this.localBoundBox.makeEmpty(),this._splatSetFlags=new Array(s).fill(!1),this._validCount=0,this.texParams=new Float32Array([this._validCount,this.size.x,0,1]),this.splatColor=new Fi().create(t,a,this._colorData,!1),this.splatColor.name="splatColor",this.splatColor.minFilter="nearest",this.splatColor.magFilter="nearest",this.splatColor.mipmapFilter="nearest",this.splatColor.addressModeU="clamp-to-edge",this.splatColor.addressModeV="clamp-to-edge",this.transformA=new Hn().create(t,a,this._transformAData),this.transformA.name="transformA",this.transformA.minFilter="nearest",this.transformA.magFilter="nearest",this.transformA.addressModeU="clamp-to-edge",this.transformA.addressModeV="clamp-to-edge",this.transformB=new Ts().create(t,a,this._transformBData,!1),this.transformB.name="transformB",this.transformB.minFilter="nearest",this.transformB.magFilter="nearest",this.transformB.mipmapFilter="nearest",this.transformB.addressModeU="clamp-to-edge",this.transformB.addressModeV="clamp-to-edge",this.splatOrder=new Qs().create(t,a,this._orderData),this.splatOrder.name="splatOrder",this.splatOrder.minFilter="nearest",this.splatOrder.magFilter="nearest",this.splatOrder.addressModeU="clamp-to-edge",this.splatOrder.addressModeV="clamp-to-edge",this.gsplatMaterial=new Yn,this.geometry=new Xn(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}setSplatData(s,e){if(s<0||s>=this.totalCount)throw new Error(`Index ${s} out of range [0, ${this.totalCount})`);const t=this._splatSetFlags[s];this._positions[s*3+0]=e.position[0],this._positions[s*3+1]=e.position[1],this._positions[s*3+2]=e.position[2],this.localBoundBox.expandByPoint(new b(e.position[0],e.position[1],e.position[2]));const a=.28209479177387814;let r=.5,i=.5,n=.5;e.sh&&e.sh.coeffs&&e.sh.coeffs.length>=3&&(r=.5+e.sh.coeffs[0]*a,i=.5+e.sh.coeffs[1]*a,n=.5+e.sh.coeffs[2]*a);const o=e.opacity!==void 0?1/(1+Math.exp(-e.opacity)):1,l=s*4;this._colorData[l+0]=Math.max(0,Math.min(255,Math.floor(r*255))),this._colorData[l+1]=Math.max(0,Math.min(255,Math.floor(i*255))),this._colorData[l+2]=Math.max(0,Math.min(255,Math.floor(n*255))),this._colorData[l+3]=Math.max(0,Math.min(255,Math.floor(o*255))),this.updateTransformData(s,e),t||(this._splatSetFlags[s]=!0,this._validCount++),this._pendingUpdates.add(s)}updateTransformData(s,e){const t=s*4,a=new ArrayBuffer(4),r=new Float32Array(a),i=new Uint32Array(a),n=$e=>(r[0]=$e,i[0]),o=e.position[0],l=e.position[1],c=e.position[2];this._transformAData[t+0]=n(o),this._transformAData[t+1]=n(l),this._transformAData[t+2]=n(c);let f=0,d=0,h=0,u=1;if(e.rotation){f=e.rotation[0],d=e.rotation[1],h=e.rotation[2],u=e.rotation[3];const $e=1/Math.hypot(f,d,h,u);f*=$e,d*=$e,h*=$e,u*=$e}let m=1,g=1,p=1;e.scale&&(m=Math.exp(e.scale[0]),g=Math.exp(e.scale[1]),p=Math.exp(e.scale[2]));const D=f+f,A=d+d,B=h+h,v=f*D,U=f*A,y=f*B,S=d*A,F=d*B,C=h*B,w=u*D,E=u*A,Q=u*B,T=1-(S+C),j=U+Q,ue=y-E,ee=U-Q,N=1-(v+C),M=F+w,O=y+E,W=F-w,ae=1-(v+S),z=T*m,K=j*m,$=ue*m,re=ee*g,ce=N*g,Ae=M*g,Qe=O*p,Ve=W*p,H=ae*p,ie=z*z+re*re+Qe*Qe,le=z*K+re*ce+Qe*Ve,ge=z*$+re*Ae+Qe*H,Ie=K*K+ce*ce+Ve*Ve,me=K*$+ce*Ae+Ve*H,ye=$*$+Ae*Ae+H*H,Se=t;this._transformBData[Se+0]=ie,this._transformBData[Se+1]=le,this._transformBData[Se+2]=ge,this._transformBData[Se+3]=ye;const Me=Ka(Ie)&65535,Ze=Ka(me)&65535;this._transformAData[t+3]=Me|Ze<<16}flushUpdates(){if(this._pendingUpdates.size===0)return;const s=this.size.x|0,e=this.size.y|0,t=Array.from(this._pendingUpdates);if(t.length===0)return;let a=e,r=0;for(const o of t){const l=Math.floor(o/s);l<a&&(a=l),l>r&&(r=l)}const i=r-a+1;i/e<.5&&i<e?(this.splatColor.updateTexture(s,e,this._colorData,a,i),this.transformA.updateTexture(s,e,this._transformAData,a,i),this.transformB.updateTexture(s,e,this._transformBData,!1,a,i)):(this.splatColor.updateTexture(s,e,this._colorData),this.transformA.updateTexture(s,e,this._transformAData),this.transformB.updateTexture(s,e,this._transformBData,!1)),this.updatePendingWorldPositions(),this._pendingUpdates.clear()}setAutoFlushThreshold(s){this._autoFlushThreshold=Math.max(1,s)}getStreamingStats(){return{totalCount:this.totalCount,validCount:this._validCount,pendingUpdates:this._pendingUpdates.size,progress:this.totalCount>0?this._validCount/this.totalCount*100:0}}updateWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}updatePendingWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}scheduleOrder(s){if(this._validCount===0)return;const e=this.object3D.transform.localChange;e&&this.updateWorldPositions();const t=s.rawData,a=t[2],r=t[6],i=t[10],n=-(t[0]*t[12]+t[1]*t[13]+t[2]*t[14]),o=-(t[4]*t[12]+t[5]*t[13]+t[6]*t[14]),l=-(t[8]*t[12]+t[9]*t[13]+t[10]*t[14]),c=performance.now(),f=(c-this._lastSentTime)/1e3,d=Math.floor(n*1e3)^Math.floor(o*1e3)^Math.floor(l*1e3),h=Math.floor(a*1e3)^Math.floor(r*1e3)^Math.floor(i*1e3),u=d^h;if(u===this._lastViewMatrixHash&&!e&&this._centersSent)return;let m=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const p=Math.abs(u-this._lastViewMatrixHash)/Math.max(f,.001);p<1e3?m=this._minIntervalMs:p<1e4?m=this._minIntervalMs*.5:m=this._minIntervalMs*.2,this._lastCameraSpeed=p}if(!(c-this._lastSentTime<m)){if(this._lastViewMatrixHash=u,this._lastSentTime=c,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=U=>{const y=U.data.order,S=this._orderData.buffer;this._sortWorker.postMessage({order:S},[S]);const F=new Uint32Array(y),C=this.size.x*this.size.y,w=Math.min(this._validCount,F.length);if((!this._orderData||this._orderData.length!==C)&&(this._orderData=new Uint32Array(C)),this._orderData.set(F.subarray(0,w),0),w<C){const T=this._validCount>0?this._validCount-1:0;this._orderData.fill(T,w,C)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const E=Math.max(0,Math.min(this._validCount,U.data.count|0));this.setCount(E),this._updateTexParams();const Q=Math.ceil(E/this._batchSize);this.instanceCount=Q};const g=new Float32Array(this._validCount*3);let p=0;const D=this.object3D.transform.worldMatrix,A=this._positions,B=D.rawData;for(let U=0;U<this._validCount;U++)if(this._splatSetFlags[U]){const y=U*3,S=A[y+0],F=A[y+1],C=A[y+2];g[p*3+0]=B[0]*S+B[4]*F+B[8]*C+B[12],g[p*3+1]=B[1]*S+B[5]*F+B[9]*C+B[13],g[p*3+2]=B[2]*S+B[6]*F+B[10]*C+B[14],p++}const v=new Uint32Array(this.totalCount);for(let U=0;U<this.totalCount;U++)v[U]=U<this._validCount?U:this._validCount>0?this._validCount-1:0;this._sortWorker.postMessage({order:v.buffer,centers:g.buffer},[v.buffer,g.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const g=new Float32Array(this._validCount*3);let p=0;const D=this.object3D.transform.worldMatrix,A=this._positions,B=D.rawData;for(let v=0;v<this._validCount;v++)if(this._splatSetFlags[v]){const U=v*3,y=A[U+0],S=A[U+1],F=A[U+2];g[p*3+0]=B[0]*y+B[4]*S+B[8]*F+B[12],g[p*3+1]=B[1]*y+B[5]*S+B[9]*F+B[13],g[p*3+2]=B[2]*y+B[6]*S+B[10]*F+B[14],p++}this._sortWorker.postMessage({type:"centers",centers:g.buffer},[g.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:n,y:o,z:l},cameraDirection:{x:-a,y:-r,z:-i}})}}createSortWorker(){function s(){let n,o,l,c,f=!1;const d={x:0,y:0,z:0},h={x:0,y:0,z:0},u={x:0,y:0,z:0},m={x:0,y:0,z:0};let g,p;const D=(B,v,U)=>{for(;B<=v;){const y=v+B>>1,S=U(y);if(S>0)B=y+1;else if(S<0)v=y-1;else return y}return~B},A=()=>{if(!n||!o||!l||!c)return;const B=l.x,v=l.y,U=l.z,y=c.x,S=c.y,F=c.z,C=.001;if(!f&&Math.abs(B-d.x)<C&&Math.abs(v-d.y)<C&&Math.abs(U-d.z)<C&&Math.abs(y-h.x)<C&&Math.abs(S-h.y)<C&&Math.abs(F-h.z)<C)return;f=!1,d.x=B,d.y=v,d.z=U,h.x=y,h.y=S,h.z=F;const w=o.length/3;g?.length!==w&&(g=new Uint32Array(w));let E,Q;for(let M=0;M<8;++M){const O=(M&1?u.x:m.x)-B,W=(M&2?u.y:m.y)-v,ae=(M&4?u.z:m.z)-U,z=O*y+W*S+ae*F;M===0?E=Q=z:(E=Math.min(E,z),Q=Math.max(Q,z))}p?p.fill(0):p=new Uint32Array(65537);const T=Q-E,j=T<1e-6?0:1/T*2**16;for(let M=0;M<w;++M){const O=M*3,W=o[O+0]-B,ae=o[O+1]-v,z=o[O+2]-U,K=W*y+ae*S+z*F,$=Math.floor((K-E)*j);g[M]=$,p[$]++}for(let M=1;M<65537;M++)p[M]+=p[M-1];for(let M=0;M<w;M++){const O=g[M],W=--p[O];n[W]=M}const ue=M=>g[n[M]]/j+E,ee=()=>{const M=D(0,w-1,O=>-ue(O));return Math.min(w,Math.abs(M))},N=ue(w-1)>=0?ee():w;self.postMessage({order:n.buffer,count:N},[n.buffer]),n=null};self.onmessage=B=>{if(B.data.order&&(n=new Uint32Array(B.data.order)),B.data.centers){o=new Float32Array(B.data.centers),u.x=m.x=o[0],u.y=m.y=o[1],u.z=m.z=o[2];const v=o.length/3;for(let U=1;U<v;++U){const y=o[U*3+0],S=o[U*3+1],F=o[U*3+2];u.x=Math.min(u.x,y),u.y=Math.min(u.y,S),u.z=Math.min(u.z,F),m.x=Math.max(m.x,y),m.y=Math.max(m.y,S),m.z=Math.max(m.z,F)}f=!0}B.data.cameraPosition&&(l=B.data.cameraPosition),B.data.cameraDirection&&(c=B.data.cameraDirection),A()}}const e=`(${s.toString()})()`,t=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(t);return new Worker(a)}setVisBoost(s){this.texParams[3]=Math.max(0,s),this._texParamDirty=!0}setCount(s){this.texParams[0]=Math.max(0,s),this._texParamDirty=!0}_updateTexParams(){this._texParamDirty&&(this.gsplatMaterial.setTexParams(this.texParams),this._texParamDirty=!1)}setSortThrottle(s){this._minIntervalMs=Math.max(0,s|0)}setAdaptiveSorting(s){this._adaptiveSorting=s}setPixelCulling(s,e=0,t=0){this._minPixelCoverage=Math.max(0,s),this._maxPixelCoverage=Math.max(0,e),this._maxPixelCullDistance=Math.max(0,t)}getPixelCullingStats(){return{minPixels:this._minPixelCoverage,maxPixels:this._maxPixelCoverage,maxPixelCullDistance:this._maxPixelCullDistance,maxEnabled:this._maxPixelCoverage>0,distanceEnabled:this._maxPixelCullDistance>0}}getBatchingStats(){return{enabled:!0,batchSize:this._batchSize,instanceCount:this.instanceCount,splatCount:this._validCount,reduction:this._validCount>0?(1-this.instanceCount/this._validCount)*100:0}}evalTextureSize(s){let e=Math.ceil(Math.sqrt(s));const t=64;e=Math.ceil(e/t)*t;const a=Math.ceil(s/e);return new de(e,a)}nodeUpdate(s,e,t,a){this._validCount>0&&s?.camera&&s.camera.viewMatrix&&this.scheduleOrder(s.camera.viewMatrix),this._pendingUpdates.size>0&&this._frameCount>=60&&this.flushUpdates(),this._frameCount>=60&&this._pendingUpdates.size===0&&(this._frameCount=0),this._frameCount++,this._updateTexParams();const r=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(r);const i=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;i!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=i),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(s,e,t,a)}renderPass(s,e,t){const a=t.encoder;for(let r of this.materials){const i=r.getPass(e);if(!(!i||i.length===0))for(const n of i){if(!n.pipeline)continue;n.apply(this.geometry,t.rendererPassState||t),k.bindPipeline(a,n),k.bindGeometryBuffer(a,this.geometry);const l=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?k.drawIndexed(a,l.indexCount,this.instanceCount,l.indexStart,0,0):k.drawIndexed(a,l.indexCount,1,l.indexStart,0,0)}}}destroy(s){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(s),this.splatColor=null),this.transformA&&(this.transformA.destroy(s),this.transformA=null),this.transformB&&(this.transformB.destroy(s),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(s),this.splatOrder=null),this._positions=null,this._orderData=null,this._colorData=null,this._transformAData=null,this._transformBData=null,this.texParams=null,this._splatSetFlags=null,this._pendingUpdates.clear(),super.destroy(s)}};Zi=jg([Ot(Zi,"GSplatStreamRenderer")],Zi);class Sh extends ne{index=0;drawCallFrame=-1;constructor(){super()}}var jo=(s=>(s[s.CastGI=0]="CastGI",s[s.ReceiveGI=1]="ReceiveGI",s[s.CastDepth=2]="CastDepth",s[s.Other=3]="Other",s))(jo||{});class Fh extends vt{static count=0;constructor(e=0,t=0){super(),Y.register("GIProbeShader",jd);let a=new At,r=new qe("GIProbeShader","GIProbeShader");r.passType=fe.COLOR,a.addRenderPass(r),r.setDefine("USE_BRDF",!0),r.setShaderEntry("VertMain","FragMain"),r.setUniformVector4("probeUniform",new be(t,e,0,0));let i=r.shaderState;i.acceptShadow=!1,i.castShadow=!1,i.receiveEnv=!1,i.acceptGI=!1,i.useLight=!1,a.setTexture("baseMap",_.res.whiteTexture),a.setTexture("normalMap",_.res.normalTexture),a.setTexture("emissiveMap",_.res.blackTexture),this.shader=a}}class Zg extends et{_probes;_volume;_debugMr=[];init(e){e||=_.views[0]?.scene,_.setting.gi.enable=!0,this._volume=xe.getLightEntries(e).irradianceVolume,this.initProbe(e)}initProbe(e){let t=this._volume.setting.probeXCount,a=this._volume.setting.probeYCount,r=this._volume.setting.probeZCount,i=new Nr(4,16,16),n=new b;this._probes=[];for(let o=0;o<t;o++)for(let l=0;l<a;l++)for(let c=0;c<r;c++){let f=o+c*t+l*(t*r),d=new Sh;d.index=f,d.name=`${o}_${l}_${c}`;let h=d.addComponent(he);h.material=new Fh(jo.CastGI,f),h.geometry=i,h.castGI=!1,h.castShadow=!1,this._debugMr.push(h),this.object3D.addChild(d),this._volume.calcPosition(o,l,c,n),d.x=n.x,d.y=n.y,d.z=n.z,this._probes[f]=d,this._debugMr.push(h)}for(let o=0;o<this._probes.length;o++)q.instance.addGIProbe(e,this._probes[o]);this.object3D.transform.enable=!1,this._volume.setting.debug&&this.debug()}debug(){}debugProbeRay(e,t){const a=_.setting.gi.rayNumber;let r=new se(0,-.7071067811865475,.7071067811865475,0);for(let i=0;i<a;i++){let n=e*a+i,o=new b(-t[n*4+0],-t[n*4+1],-t[n*4+2],0);r.transformVector(o,o);let l=t[n*4+3],c=this._probes[e].transform.worldPosition.clone(),f=o.scaleBy(l);f.add(c,f)}}changeProbesVolumeData(){this._volume.setVolumeDataChange()}changeProbesPosition(){this._volume.setVolumeDataChange();let e=this._volume.setting.probeXCount,t=this._volume.setting.probeYCount,a=this._volume.setting.probeZCount,r=new b;for(let i=0;i<e;i++)for(let n=0;n<t;n++)for(let o=0;o<a;o++){let l=i+o*e+n*(e*a),c=this._probes[l];this._volume.calcPosition(i,n,o,r),c.x=r.x,c.y=r.y,c.z=r.z}}onUpdate(){_.setting.gi.maxDistance=_.setting.gi.probeSpace*1.5;let e=this.transform.scene3D.view.camera,t=b.distance(e.transform.worldPosition,e.transform.targetPos)/300;if(this._debugMr&&this._debugMr.length>0)for(let a=0;a<this._debugMr.length;a++){const r=this._debugMr[a].transform;r.scaleX=t,r.scaleY=t,r.scaleZ=t}}}class Yg extends Ba{_keyRenderGroup;_keyBufferGroup;_keyIdsGroup;constructor(){super()}init(e){this._keyRenderGroup=new Map,this._keyBufferGroup=new Map,this._keyIdsGroup=new Map}start(){let e=[];this.object3D.getComponents(he,e,!0);for(let t=0;t<e.length;t++){const a=e[t];a.transform.updateWorldMatrix(!0),a.enable=!1;let r=a.geometry.instanceID;for(let i=0;i<a.materials.length;i++){const n=a.materials[i];r+=n.instanceID}if(this._keyRenderGroup.has(r))this._keyRenderGroup.get(r).push(a),this._keyIdsGroup.get(r).push(a.transform.worldMatrix.index);else{let i=new Pe(e.length);i.visibility=GPUShaderStage.VERTEX,this._keyRenderGroup.set(r,[a]),this._keyBufferGroup.set(r,i),this._keyIdsGroup.set(r,[a.transform.worldMatrix.index])}}this._keyBufferGroup.forEach((t,a)=>{let r=this._keyIdsGroup.get(a),i=this._keyBufferGroup.get(a);i.setInt32Array("matrixIDs",new Int32Array(r)),i.apply()})}reset(){this._keyRenderGroup.size>0&&(this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this.start())}nodeUpdate(e,t,a,r){this._keyRenderGroup.forEach((i,n)=>{let o=this._keyBufferGroup.get(n),l=i[0];for(let c=0;c<l.materials.length;c++){let d=l.materials[c].getPass(t);if(d)for(let h=0;h<d.length;h++){const u=d[h];u.setDefine("USE_INSTANCEDRAW",!0),u.setStorageBuffer("instanceDrawID",o)}}l.nodeUpdate(e,t,a,r)})}renderPass(e,t,a){this._keyRenderGroup.forEach((r,i)=>{let n=r[0];n.instanceCount=r.length,this.renderItem(e,t,n,a)})}renderItem(e,t,a,r){let i=a.transform._worldMatrix;for(let n=0;n<a.materials.length;n++){let l=a.materials[n].getPass(t);if(!(!l||l.length==0))for(let c=0;c<l.length;c++){let f=l[c];k.bindGeometryBuffer(r.encoder,a.geometry);const d=f;d.shaderState.splitTexture&&(r.endRenderPass(),Mt.WriteSplitColorTexture(a.instanceID),r.beginOpaqueRenderPass(),k.bindCamera(r.encoder,e.camera),k.bindGeometryBuffer(r.encoder,a.geometry)),k.bindPipeline(r.encoder,d);let g=a.geometry.subGeometries[n].lodLevels[a.lodLevel];a.instanceCount>0?k.drawIndexed(r.encoder,g.indexCount,a.instanceCount,g.indexStart,0,0):k.drawIndexed(r.encoder,g.indexCount,1,g.indexStart,0,i.index)}}}beforeDestroy(e){this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this._keyRenderGroup=this._keyBufferGroup=this._keyIdsGroup=void 0,Oe.removeWaitStart(this.object3D,this)}}var Xg=Object.getOwnPropertyDescriptor,Hg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Xg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Zs=class extends he{constructor(){super()}get geometry(){return null}set geometry(s){}cloneTo(s){}set meshURL(s){let e=_.res.getGeometry(s);e?this.geometry=e:console.error("no geometry set",s)}};Zs=Hg([Ot(Zs,"MeshFilter")],Zs);var Kg=Object.getOwnPropertyDescriptor,qg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Kg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Yi=class extends he{skinJointsName;mInverseBindMatrixData;mInverseBindMatrixBuffer;mSkeletonAnimation;mJointIndexTableBuffer;constructor(){super(),this.addRendererMask(Ne.SkinnedMesh)}start(){if(super.start(),this.skeletonAnimation=this.object3D.getComponent(mr),!this.skeletonAnimation){let s=this.object3D.parentObject.parentObject.getComponentsInChild(mr);s.length>0&&(this.skeletonAnimation=s[0]);let e=this.object3D;for(;!this.skeletonAnimation&&e;)this.skeletonAnimation=e.getComponentFromParent(mr),e.parent&&(e=e.parent.object3D)}}onEnable(){super.onEnable()}get skeletonAnimation(){return this.mSkeletonAnimation}set skeletonAnimation(s){if(this.mSkeletonAnimation=s,!!s&&!this.mJointIndexTableBuffer){let e=this.mSkeletonAnimation.getJointIndexTable(this.skinJointsName);this.mJointIndexTableBuffer=new Pe(e.length*4,0,new Float32Array(e)),this.mJointIndexTableBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}}get skinInverseBindMatrices(){return this.mInverseBindMatrixData}set skinInverseBindMatrices(s){this.mInverseBindMatrixData=s;var e=new Float32Array(s.length*16);for(let t=0;t<s.length;t++){let a=t*16,r=s[t];e.set(r,a)}this.mInverseBindMatrixBuffer=new Pe(e.byteLength,0,e),this.mInverseBindMatrixBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}get inverseBindMatrixBuffer(){return this.mInverseBindMatrixBuffer}get jointIndexTableBuffer(){return this.mJointIndexTableBuffer.buffer}cloneTo(s){let e=s.addComponent(Yi);e.geometry=this.geometry,e.material=this.material.clone(),e.castShadow=this.castShadow,e.castGI=this.castGI,e.receiveShadow=this.receiveShadow,e.rendererMask=this.rendererMask,e.skinJointsName=this.skinJointsName,e.skinInverseBindMatrices=this.skinInverseBindMatrices,e.mJointIndexTableBuffer=this.mJointIndexTableBuffer}nodeUpdate(s,e,t,a){for(let r=0;r<this.materials.length;r++){let n=this.materials[r].getPass(e);if(n)for(let o=0;o<n.length;o++){const l=n[o];!l.pipeline&&this.mSkeletonAnimation&&(l.setStorageBuffer("jointsMatrixIndexTable",this.mSkeletonAnimation.jointMatrixIndexTableBuffer),l.setStorageBuffer("jointsInverseMatrix",this.mInverseBindMatrixBuffer),l.setStorageBuffer("jointsIndexMapingTable",this.mJointIndexTableBuffer))}}super.nodeUpdate(s,e,t,a)}};Yi=qg([Ot(Yi,"SkinnedMeshRenderer")],Yi);class $g extends gt{radius=2.5;height=10;constructor(){super(),this._shapeType=ui.Capsule}}class mn extends gt{mesh;static triangle;_pickRet;constructor(){super(),this._shapeType=ui.Mesh}rayPick(e,t){if(this.mesh){mn.triangle||=new us(new b,new b,new b);let a=this.mesh.getAttribute(G.position),r=this.mesh.getAttribute(G.indices),i=gt.helpMatrix;i.copyFrom(t).invert();let n=gt.helpRay.copy(e);if(n.applyMatrix(i),n.intersectBox(this.mesh.bounds),!n.intersectBox(this.mesh.bounds,gt.v3_help_0))return null;if(r&&a&&r.data.length>0){let l=a.data;for(let c=0,f=r.data.length/3;c<f;c++){let d=c*3;const h=r.data[d+0]*3,u=r.data[d+1]*3,m=r.data[d+2]*3;let g=mn.triangle,p=g.v1.set(l[h+0],l[h+1],l[h+2]),D=g.v2.set(l[u+0],l[u+1],l[u+2]),A=g.v3.set(l[m+0],l[m+1],l[m+2]);g.set(p,D,A);let B=n.intersectTriangle(n.origin,n.direction,g);if(B){this._pickRet||={intersectPoint:new b,distance:0},this._pickRet.intersectPoint=B,this._pickRet.distance=b.distance(n.origin,B);let v=this.mesh.getAttribute(G.normal);if(v){let U=v.data,y=new b(U[h],U[h+1],U[h+2]);t.transformVector(y,y),y.normalize(),this._pickRet.normal=y}return this._pickRet}}}}return null}}class ep extends gt{_pickRet;box;radius=.5;constructor(e){super(),this._shapeType=ui.Sphere,this.radius=e,this.box=new Lr(new b,1)}rayPick(e,t){this.box.setFromCenterAndSize(this.center,this.radius);let r=gt.helpMatrix;r.copyFrom(t).invert();let i=gt.helpRay.copy(e);i.applyMatrix(r);let n=i.intersectSphere(i.origin,i.direction,this.box.center,this.box.radius);return n?(this._pickRet||(this._pickRet={intersect:!1,intersectPoint:new b,distance:0}),this._pickRet.intersect=!0,this._pickRet.intersectPoint=n,this._pickRet.distance=b.distance(i.origin,gt.v3_help_0),this._pickRet):null}}class tp extends ne{_envMap;skyObject;envMapChange=!0;view;constructor(){super(),this.transform.scene3D=this,this.skyObject=new ne,this.addChild(this.skyObject),this._isScene3D=!0,this.envMap||=_.res.defaultSky}get envMap(){return this._envMap}set envMap(e){this._envMap!=e&&(this.envMapChange=!0),this._envMap=e,q.instance.sky&&"map"in q.instance.sky&&(q.instance.sky.map=e)}get exposure(){return q.instance.sky&&"exposure"in q.instance.sky?q.instance.sky.exposure:0}set exposure(e){q.instance.sky&&"exposure"in q.instance.sky&&(q.instance.sky.exposure=e,_.setting.sky.skyExposure=e)}get roughness(){if(q.instance.sky&&"roughness"in q.instance.sky)return q.instance.sky.roughness}set roughness(e){q.instance.sky&&"roughness"in q.instance.sky&&(q.instance.sky.roughness=e)}}class kh{_computeShader;_outBuffer;constructor(){}init(){let e=ve.getGBufferFrame(ve.colorPass_GBuffer);this._computeShader=new Fe(kd),this._outBuffer=new ni(32),this._computeShader.setStorageBuffer("outBuffer",this._outBuffer),this._computeShader.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture())}compute(e){let t=xe.getCameraGroup(e.camera);this._computeShader.setStorageBuffer("globalUniform",t.uniformGPUBuffer);let a=k.beginCommandEncoder();k.computeCommand(a,[this._computeShader]),k.endCommandEncoder(a),this._outBuffer.readBuffer()}getPickMeshID(){var e=this._outBuffer.outFloat32Array[0]+.1;return Math.floor(e)}getPickWorldPosition(e){e||=new b;var t=this._outBuffer.outFloat32Array[4],a=this._outBuffer.outFloat32Array[5],r=this._outBuffer.outFloat32Array[6];return e.set(t,a,r),e}getPickWorldNormal(e){e||=new b;var t=this._outBuffer.outFloat32Array[8],a=this._outBuffer.outFloat32Array[9],r=this._outBuffer.outFloat32Array[10];return e.set(t*2-1,a*2-1,r*2-1).normalize(),e}getPickScreenUV(e){e||=new de;var t=this._outBuffer.outFloat32Array[2],a=this._outBuffer.outFloat32Array[3];return e.set(t,a),e}}class Eh extends Za{ray;isTouching=!1;_mouseCode;_pickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_mouseMove;_pickCompute;_lastDownTarget;mouseEnableMap;_view;constructor(e){super(),this._view=e,this.init()}init(){this.ray=new ua,this.mouseEnableMap=new Map,this._pickEvent=new Z(Z.PICK_CLICK),this._outEvent=new Z(Z.PICK_OUT),this._overEvent=new Z(Z.PICK_OVER),this._mouseMove=new Z(Z.PICK_MOVE),this._upEvent=new Z(Z.PICK_UP),this._downEvent=new Z(Z.PICK_DOWN)}start(){_.setting.pick.enable&&(_.inputSystem.addEventListener(Z.POINTER_DOWN,this.onTouchStart,this),_.inputSystem.addEventListener(Z.POINTER_UP,this.onTouchEnd,this),_.inputSystem.addEventListener(Z.POINTER_CLICK,this.onTouchOnce,this),_.inputSystem.addEventListener(Z.POINTER_RIGHT_CLICK,this.onTouchOnce,this),_.inputSystem.addEventListener(Z.POINTER_MOVE,this.onTouchMove,this)),_.setting.pick.mode=="pixel"&&(this._pickCompute=new kh,this._pickCompute.init())}stop(){_.inputSystem.removeEventListener(Z.POINTER_DOWN,this.onTouchStart,this),_.inputSystem.removeEventListener(Z.POINTER_UP,this.onTouchEnd,this),_.inputSystem.removeEventListener(Z.POINTER_CLICK,this.onTouchOnce,this),_.inputSystem.removeEventListener(Z.POINTER_RIGHT_CLICK,this.onTouchOnce,this),_.inputSystem.removeEventListener(Z.POINTER_MOVE,this.onTouchMove,this)}onTouchStart(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);this._lastDownTarget=t,t&&(Object.assign(this._downEvent,e),this._downEvent.type=Z.PICK_DOWN,this._downEvent.target=t.object3D,this._downEvent.data=this.getPickInfo(),this.dispatchEvent(this._downEvent),t.object3D.containEventListener(Z.PICK_DOWN)&&t.object3D.dispatchEvent(this._downEvent))}onTouchEnd(e){this.isTouching=!1,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._upEvent,e),this._upEvent.type=Z.PICK_UP,this._upEvent.target=t.object3D,this._upEvent.data=this.getPickInfo(),this.dispatchEvent(this._upEvent),t.object3D.containEventListener(Z.PICK_UP)&&t.object3D.dispatchEvent(this._upEvent))}_lastFocus;getPickInfo(){if(_.setting.pick.mode=="pixel")return{worldPos:this._pickCompute.getPickWorldPosition(),worldNormal:this._pickCompute.getPickWorldNormal(),screenUv:this._pickCompute.getPickScreenUV(),meshID:this._pickCompute.getPickMeshID()};{let e=this._interestList[0];return{worldPos:e.intersectPoint,worldNormal:e.normal,meshID:e.collider.transform.worldMatrix.index,distance:e.distance}}}onTouchMove(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._mouseMove,e),this._mouseMove.type=Z.PICK_MOVE,this._mouseMove.target=t.object3D,this._mouseMove.data=this.getPickInfo(),this.dispatchEvent(this._mouseMove),t.object3D.containEventListener(Z.PICK_MOVE)&&t.object3D.dispatchEvent(this._mouseMove)),t!=this._lastFocus&&(this._lastFocus&&this._lastFocus.object3D&&(Object.assign(this._outEvent,e),this._outEvent.type=Z.PICK_OUT,this._outEvent.target=this._lastFocus.object3D,this._outEvent.data=this.getPickInfo(),this.dispatchEvent(this._outEvent),this._lastFocus.object3D.containEventListener(Z.PICK_OUT)&&this._lastFocus.object3D.dispatchEvent(this._outEvent)),t&&(Object.assign(this._overEvent,e),this._overEvent.type=Z.PICK_OVER,this._overEvent.target=t.object3D,this._overEvent.data=this.getPickInfo(),this.dispatchEvent(this._overEvent),t.object3D.containEventListener(Z.PICK_OVER)&&t.object3D.dispatchEvent(this._overEvent))),this._lastFocus=t}onTouchOnce(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);if(t){let a=this.getPickInfo();Object.assign(this._pickEvent,e),this._pickEvent.type=Z.PICK_CLICK,this._pickEvent.target=t.object3D,this._pickEvent.data=a,this.dispatchEvent(this._pickEvent),t===this._lastDownTarget&&t.object3D.containEventListener(Z.PICK_CLICK)&&t.object3D.dispatchEvent(this._pickEvent)}this._lastDownTarget=null}findNearestObj(e,t){return e.sort((a,r)=>a.distance>r.distance?1:-1),e[0]?.collider}_interestList=[];pick(e){if(this._interestList.length=0,_.setting.pick.mode=="pixel"){this._pickCompute.compute(this._view);let t=this._pickCompute.getPickMeshID(),a=this.mouseEnableMap.get(t);if(a){let r=this._pickCompute.getPickWorldPosition(),i=b.distance(r,this.ray.origin);this._interestList.push({distance:i,collider:a,intersectPoint:r})}}else if(_.setting.pick.mode=="bound"){this.ray=e.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY);let t,a=Oe.componentsEnablePickerList.get(this._view);if(a)for(const r of a){let i=r[0];i.enable&&(t=i.rayPick(this.ray),t&&(t.collider=i,this._interestList.push(t)))}}}}class ap extends ys{_camera;_scene;_viewPort;_enablePick=!1;_enable=!0;pickFire;guiPick;canvasList;constructor(e=0,t=0,a=0,r=0){super(),this.canvasList=[],this._viewPort=new be(e,t,a,r)}get enable(){return this._enable}set enable(e){this._enable=e}get enablePick(){return this._enablePick}set enablePick(e){this._enablePick!=e&&(this.pickFire=new Eh(this),this.pickFire.start()),this._enablePick=e}get scene(){return this._scene}set scene(e){this._scene=e,e.view=this,jt.createBuffer(this),e&&this.canvasList.forEach(t=>{t&&e.addChild(t.object3D)})}get camera(){return this._camera}set camera(e){this._camera=e}get viewPort(){return this._viewPort}set viewPort(e){this._viewPort=e}enableUICanvas(e=0){let t=this.canvasList[e];if(!t){let a=new ne;a.name="Canvas "+e,t=a.addComponent(ds),t.index=e,this.canvasList[e]=t}return this.scene.addChild(t.object3D),this.guiPick||(this.guiPick=new mh,this.guiPick.init(this)),t}disableUICanvas(e=0){let t=this.canvasList[e];t&&t.object3D&&t.object3D.removeFromParent()}}class rp{normal;fixNormal;center;rotateShape;distance=0;index;constructor(e){this.index=e,this.rotateShape=[]}}class ip extends Le{vScale;uNegate;sections;build(e,t,a,r=1,i=!0){if(a.length<2)throw new Error("path length is not enough");return this.vScale=r,this.uNegate=i,e=e.slice(),t&&e.push(e[0]),this.sections=this.buildSections(e,a),this.buildGeometry(e,this.sections),this.bounds=new Ce(b.ZERO.clone(),new b(100,100,100)),this}buildSections(e,t){let a,r,i,n=[],o=t.length;for(let c=0;c<o;c++){let f=new rp(c);a=t[c],r=t[c+1],f.center=a.clone(),r==null?(f.normal=i.clone(),f.distance=0):(i=r.subtract(a),f.distance=i.length,f.normal=i.normalize()),n.push(f)}n[0].fixNormal=n[0].normal.clone();for(let c=1;c<o;c++){let f=n[c-1],d=n[c];d.fixNormal=d.normal.add(f.normal).normalize()}let l=new R().identity();for(let c=0;c<o;c++){let f=n[c],d,h;if(c==0)d=b.UP,h=e;else{let u=n[c-1];d=u.fixNormal,h=u.rotateShape}R.fromToRotation(d,f.fixNormal,l);for(let u=0,m=e.length;u<m;u++){let g=l.multiplyPoint3(h[u]);f.rotateShape.push(g)}}return n}buildGeometry(e,t){let a=t.length,r=e.length,i=a*r,n=a-1,o=new Float32Array(i*3),l=new Float32Array(i*3),c=new Float32Array(i*2),f=new Uint32Array(n*(r-1)*6),d=r-1,h=0,u=0,m=[0];for(let p=1;p<r;p++)u+=e[p-1].subtract(e[p]).length,m.push(u);for(let p=0;p<a;p++){let D=t[p];for(let A=0;A<r;A++){let B=(p*r+A)*3,v=D.rotateShape[A].add(D.center);o[B]=v.x,o[B+1]=v.y,o[B+2]=v.z,l[B+1]=1;let U=(p*r+A)*2,y=m[A]/u;c[U]=this.uNegate?1-y:y,c[U+1]=h*this.vScale}h+=D.distance}let g=0;for(let p=0;p<n;p++){let D=p*r;for(let A=0;A<d;A++){let B=A,v=A+1,U=B+r,y=v+r;f[g++]=B+D,f[g++]=v+D,f[g++]=U+D,f[g++]=v+D,f[g++]=y+D,f[g++]=U+D}}return this.setIndices(f),this.setAttribute(G.position,o),this.setAttribute(G.normal,l),this.setAttribute(G.uv,c),this.setAttribute(G.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.computeNormals(),this}}class wh extends Le{_instanceBuffer;_instanceData;_instanceCount=0;constructor(){super(),this.initBaseGeometry()}initBaseGeometry(){const e=new Float32Array([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=new Float32Array([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2]),a=new Uint16Array([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]);this.setIndices(a),this.setAttribute(G.position,e),this.setAttribute(G.uv,t),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:e.length/3,firstStart:0,index:0,topology:0})}setPositions(e){const t=e instanceof Float32Array?e:new Float32Array(e),r=t.length/3-1;if(r<=0)return console.warn("FatLineGeometry: Need at least 2 points"),this;const i=new Float32Array(r*16);for(let n=0;n<r;n++){const o=n*3,l=(n+1)*3;i[n*16+0]=t[o+0],i[n*16+1]=t[o+1],i[n*16+2]=t[o+2],i[n*16+3]=0,i[n*16+4]=t[l+0],i[n*16+5]=t[l+1],i[n*16+6]=t[l+2],i[n*16+7]=0,i[n*16+8]=1,i[n*16+9]=1,i[n*16+10]=1,i[n*16+11]=0,i[n*16+12]=1,i[n*16+13]=1,i[n*16+14]=1,i[n*16+15]=0}return this._instanceData=i,this._instanceCount=r,this.computeBoundingBox(t),this}setColors(e){const t=e instanceof Float32Array?e:new Float32Array(e);if(!this._instanceData)return console.warn("FatLineGeometry: Must call setPositions() before setColors()"),this;const r=t.length/3-1;if(r!==this._instanceCount)return console.warn("FatLineGeometry: Color array length doesn't match segment count"),this;for(let i=0;i<r;i++){const n=i*3,o=(i+1)*3;this._instanceData[i*16+8]=t[n+0],this._instanceData[i*16+9]=t[n+1],this._instanceData[i*16+10]=t[n+2],this._instanceData[i*16+12]=t[o+0],this._instanceData[i*16+13]=t[o+1],this._instanceData[i*16+14]=t[o+2]}return this}computeBoundingBox(e){const t=new b(1/0,1/0,1/0),a=new b(-1/0,-1/0,-1/0);for(let i=0;i<e.length;i+=3){const n=e[i],o=e[i+1],l=e[i+2];t.x=Math.min(t.x,n),t.y=Math.min(t.y,o),t.z=Math.min(t.z,l),a.x=Math.max(a.x,n),a.y=Math.max(a.y,o),a.z=Math.max(a.z,l)}const r=b.sub(a,t);this.bounds=new Ce(b.ZERO.clone(),r),this.bounds.setFromMinMax(t,a)}get instanceData(){return this._instanceData}get instanceCount(){return this._instanceCount}get instanceBuffer(){return!this._instanceBuffer&&this._instanceData&&(this._instanceBuffer=new Pe(this._instanceData.byteLength),this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply()),this._instanceBuffer}updateInstanceBuffer(){this._instanceBuffer&&this._instanceData&&(this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply())}}class sp{name;offset;size;arrayStride;stepMode;attributes}class np{name;format;offset;shaderLocation;stride}var Ih=(s=>(s[s.position=3]="position",s[s.normal=3]="normal",s[s.TANGENT=4]="TANGENT",s[s.uv=2]="uv",s[s.TEXCOORD_1=2]="TEXCOORD_1",s[s.color=4]="color",s[s.joints0=4]="joints0",s[s.weights0=4]="weights0",s[s.joints1=4]="joints1",s[s.weights1=4]="weights1",s[s.vIndex=1]="vIndex",s[s.weight=1]="weight",s[s.a_morphPositions_0=3]="a_morphPositions_0",s))(Ih||{});class op{get data(){return null}entity}class Rh{min=0;max=0;set(e,t){return this.max=t,this.min=e,this}copy(e){return this.max=e.max,this.min=e.min,this}isInterestRange(e){return!(this.max>e.min||e.max<this.min)}}class Qh{_spaceDesc;getRange(e){return this._spaceDesc[e]}initSpace(e){this._spaceDesc={};for(let t of e)(this._spaceDesc[t]=new Rh).set(-Number.MAX_VALUE,Number.MAX_VALUE);return this}isContain(e,t){let a=this._spaceDesc[e];return t>=a.min&&t<a.max}isInterestRange(e,t){let a=this._spaceDesc[e];return a?t.isInterestRange(a):!1}splitSpace(e,t,a){let r=this._spaceDesc[e];return t?r.max=a:r.min=a,this}copySpace(e){for(let t in e._spaceDesc){let a=e._spaceDesc[t];this._spaceDesc[t].copy(a)}return this}}class bs{static MaxEntityCountInLeaf=4;static MaxLayer=10;static ClearLeafLayer=bs.MaxLayer-4}class gs{static UUID=0;uuid="0";constructor(){this.uuid=(gs.UUID++).toString()}}class lp{map={};_count=0;get count(){return this._count}push(e){return this.map[e.uuid]?!1:(this.map[e.uuid]=e,this._count++,!0)}remove(e){return this.map[e]?(delete this.map[e],this._count--,!0):!1}}class yr extends gs{_dimensionIndex=0;_dimensions;_dimension;_left;_right;_space;_parent;_entities;layer;get dimension(){return this._dimension}constructor(e=0){super(),this.layer=e,yr.nodeCount++}initNode(e,t,a){return this._dimensions=t,this._dimensionIndex=a,this._dimension=t[a],this._space=new Qh().initSpace(t),e&&this._space.copySpace(e._space),this._parent=e,this._entities=new lp,this}updateEntity(e){if(e.isInNode(this,this._dimension)&&(e.attachTreeNode(this),this.autoSplit(),this._left&&this._right)){let t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t];e.isInNode(this._right,a)?this._right.updateEntity(e):e.isInNode(this._left,a)&&this._left.updateEntity(e)}}buildRoot(e){for(const t of e)t.entity.attachTreeNode(this);this.autoSplit()}_splitEntityList=[];autoSplit(){if(this._entities.count>bs.MaxEntityCountInLeaf&&!this._right&&!this._left&&this.layer<bs.MaxLayer){let e=this._splitEntityList,t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t],r=0;for(const i in this._entities.map){let n=this._entities.map[i];r+=n.centerValue(a),e.push(n)}r/=this._entities.count,this._left=new yr(this.layer+1),this._right=new yr(this.layer+1),this._left.initNode(this,this._dimensions,t),this._right.initNode(this,this._dimensions,t),this._left.setSpace(!0,r),this._right.setSpace(!1,r);for(let i of e)i.isInNode(this._right,a)?i.attachTreeNode(this._right):i.isInNode(this._left,a)&&i.attachTreeNode(this._left)}this._left&&this._left.autoSplit(),this._right&&this._right.autoSplit()}setSpace(e,t){return this._parent&&this._space.splitSpace(this._dimension,e,t),this}isEmpty(){return this._left==null&&this._right==null&&this._entities.count==0}pushEntity(e){return this._entities.push(e)}removeEntity(e){return this._entities.remove(e.uuid)}static nodeCount=0;autoClear(){let e=this;for(;e&&e.layer>bs.ClearLeafLayer&&e.clearLeaf();)e=e._parent}clearLeaf(){let e=!this._left&&!this._right,t=!e&&this._left.isEmpty()&&this._right.isEmpty();return t&&(this._left=this._right=null,yr.nodeCount-=2),e||t}isContain(e){return this._space.isContain(this._dimension,e)}static rangeBox=new Ce(new b(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),new b(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE));nodeIntersectsBox(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=yr.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),i.intersectsBox(e)}nodeIntersectsRay(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=yr.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),!0}pointCast(e,t=0,a){if(a=a||[],this._entities.count>0){let r=this._entities.map;for(let i in r){let n=r[i],o=n.entityContainPoint(e);!o&&t>0&&(o=n.squareDistanceTo(e,this._dimensions)<=t),o&&a.push(n)}}this._left&&this._left.isContain(e[this._left.dimension])&&this._left.pointCast(e,t,a),this._right&&this._right.isContain(e[this._right.dimension])&&this._right.pointCast(e,t,a)}boxCast(e,t){if(t=t||[],this._entities.count>0){let a=this._entities.map;for(let r in a){let i=a[r];i.entityIntersectsBox(e)&&t.push(i)}}this._left&&this._left.nodeIntersectsBox(e)&&this._left.boxCast(e,t),this._right&&this._right.nodeIntersectsBox(e)&&this._right.boxCast(e,t)}pointIntersect=new b;rayCast(e,t,a){t=t||[],a=a||[];let r=this.pointIntersect;if(this._entities.count>0){let i=this._entities.map;for(let n in i){let o=i[n];o.entityIntersectsRay(e,r)&&(a.push(new b().copyFrom(r)),t.push(o))}}this._left&&this._left.nodeIntersectsRay(e)&&this._left.rayCast(e,t,a),this._right&&this._right.nodeIntersectsRay(e)&&this._right.rayCast(e,t,a)}}class cp extends gs{userData;node;constructor(e){super(),this.userData=e}centerValue(e){return 0}isInNode(e,t){return!1}entityContainPoint(e){return!1}squareDistanceTo(e,t){return Number.MAX_VALUE}entityIntersectsBox(e){return!1}entityIntersectsRay(e,t){return!1}attachTreeNode(e){return this.node&&this.detachTreeNode(),this.node=e,this.node.pushEntity(this)}detachTreeNode(){let e=this.node.removeEntity(this);return this.node=null,e}updateNode(e){let t=this.node;t&&this.detachTreeNode(),e.updateEntity(this),t&&t.autoClear()}}class Nt{minPosX=0;minPosY=0;maxPosX=0;maxPosY=0;testID=0;points;offsetPosition;static TINY=1e-6;constructor(){this.points=new Array,this.offsetPosition=new b(0,0,0,0),this.clear()}setAABox(e,t,a,r){this.minPosX=e-a/2-Nt.TINY,this.maxPosX=e+a/2+Nt.TINY,this.minPosY=t-r/2-Nt.TINY,this.maxPosY=t+r/2+Nt.TINY,this.offsetPosition.setTo(0,0,0)}setOffset(e){this.maxPosX+=e.x-this.offsetPosition.x,this.minPosX+=e.x-this.offsetPosition.x,this.minPosY+=e.z-this.offsetPosition.z,this.maxPosY+=e.z-this.offsetPosition.z,this.offsetPosition.copyFrom(e)}setContainRect(e,t,a,r){this.minPosX>e&&(this.minPosX=e),this.minPosY>t&&(this.minPosY=t),this.maxPosX<a&&(this.maxPosX=a),this.maxPosY<r&&(this.maxPosY=r)}clear(){var e=1e9;this.minPosX=this.minPosY=e,this.maxPosX=this.maxPosY=-e,this.points.length=0,this.testID=0,this.offsetPosition.setTo(0,0,0)}addPoint(e){this.points.indexOf(e)==-1&&(e.x<this.minPosX&&(this.minPosX=e.x-Nt.TINY),e.x>this.maxPosX&&(this.maxPosX=e.x+Nt.TINY),e.z<this.minPosY&&(this.minPosY=e.z-Nt.TINY),e.z>this.maxPosY&&(this.maxPosY=e.z+Nt.TINY),this.points.push(e))}clone(){var e=new Nt;return e.minPosX=this.minPosX,e.minPosY=this.minPosY,e.maxPosX=this.maxPosX,e.maxPosY=this.maxPosY,e}get radius(){return Math.sqrt((this.maxPosY-this.minPosY)*(this.maxPosY-this.minPosY)+(this.maxPosX-this.minPosX)*(this.maxPosX-this.minPosX))}get sideX(){return this.maxPosX-this.minPosX}get sideY(){return this.maxPosY-this.minPosY}get centreX(){return(this.maxPosX-this.minPosX)*.5+this.minPosX}get centreY(){return(this.maxPosY-this.minPosY)*.5+this.minPosY}overlapTest(e){return!(this.minPosY>=e.maxPosY||this.maxPosY<=e.minPosY||this.minPosX>=e.maxPosX||this.maxPosX<=e.minPosX)}isPointInside(e){return e.x>=this.minPosX&&e.x<=this.maxPosX&&e.z>=this.minPosY&&e.z<=this.maxPosY}isIntersectLineSegment(e,t,a,r){var i=!1,n=t-r,o=a-e,l=e*r-a*t,c=(-l-n*this.minPosX)/o;c<=this.maxPosY&&c>=this.minPosY&&(i=!0),c=(-l-n*this.maxPosX)/o,c<=this.maxPosY&&c>=this.minPosY&&(i=!0);var f=(-l-o*this.minPosY)/n;return f<=this.maxPosX&&f>=this.minPosX&&(i=!0),f=(-l-o*this.maxPosY)/n,f<=this.maxPosX&&f>=this.minPosX&&(i=!0),i}}class kr{static NUM_CHILDREN=4;childCellIndices;nodeIndices;aabb;points;constructor(e){this.childCellIndices=new Array,this.childCellIndices.length=kr.NUM_CHILDREN,this.nodeIndices=new Array,this.clear(),e?this.aabb=e.clone():this.aabb=new Nt}isLeaf(){return this.childCellIndices[0]==-1}clear(){for(var e=0;e<kr.NUM_CHILDREN;e++)this.childCellIndices[e]=-1;this.nodeIndices.splice(0,this.nodeIndices.length)}}class Th{_cells;_rootCell;_quadNodes;_aabb;_cellsToTest;_testID;constructor(){this._testID=0,this._cells=new Array,this._quadNodes=new Array,this._cellsToTest=new Array,this._aabb=new Nt}getQuadNode(e){return this._quadNodes[e]}clear(){this._cells.length=0,this._quadNodes.length=0}initNodes(e){this.clear();for(var t=0,a=e.length;t<a;)e[t].calcGlobalQuadAABB(),this._quadNodes.push(e[t]),t++}buildQuadTree(e,t){this._aabb.clear();for(var a of this._quadNodes)if(a.isTriangle)for(var r of a.aabb.points)this._aabb.addPoint(r);else this._aabb.setContainRect(a.aabb.minPosX,a.aabb.minPosY,a.aabb.maxPosX,a.aabb.maxPosY);this._cells.length=0,this._rootCell=new kr(this._aabb),this._cells.push(this._rootCell);for(var i=this._quadNodes.length,n=0;n<i;n++)this._cells[0].nodeIndices[n]=n;var o=new Array;o.push(0);for(var l,c,f;o.length!=0;)if(c=o.pop(),!(this._cells[c].nodeIndices.length<=e||this._cells[c].aabb.radius<t)){for(n=0;n<kr.NUM_CHILDREN;n++){this._cells[c].childCellIndices[n]=this._cells.length,o.push(this._cells.length),this._cells.push(new kr(this.createAABox(this._cells[c].aabb,n))),f=this._cells[this._cells.length-1],i=this._cells[c].nodeIndices.length;for(var d=0;d<i;d++)l=this._cells[c].nodeIndices[d],this.doesNodeIntersectCell(this._quadNodes[l],f)&&f.nodeIndices.push(l)}this._cells[c].nodeIndices.length=0}}createAABox(e,t){var a=e.centreX,r=e.centreY,i=e.sideX,n=e.sideY,o=new Nt;switch(t){case 0:o.setAABox(a+i/4,r+n/4,i/2,n/2);break;case 1:o.setAABox(a-i/4,r+n/4,i/2,n/2);break;case 2:o.setAABox(a-i/4,r-n/4,i/2,n/2);break;case 3:o.setAABox(a+i/4,r-n/4,i/2,n/2);break;default:o.setAABox(a+i/4,r-n/4,i/2,n/2);break}return o}doesNodeIntersectCell(e,t){var a=e.aabb;if(!a.overlapTest(t.aabb))return!1;if(!e.isTriangle)return!0;var r=a.points,i=r[0],n=r[1],o=r[2];if(t.aabb.isPointInside(i)||t.aabb.isPointInside(n)||t.aabb.isPointInside(o))return!0;var l=this.pointInTriangle(t.aabb.minPosX,t.aabb.minPosY,i,n,o)||this.pointInTriangle(t.aabb.minPosX,t.aabb.maxPosY,i,n,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.maxPosY,i,n,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.minPosY,i,n,o);return l?!0:(l=t.aabb.isIntersectLineSegment(i.x,i.z,n.x,n.z)||t.aabb.isIntersectLineSegment(i.x,i.z,o.x,o.z)||t.aabb.isIntersectLineSegment(n.x,n.z,o.x,o.z),l)}getNodesIntersectingtAABox(e,t){if(this._cells.length==0)return 0;this._cellsToTest.length=0,this._cellsToTest.push(0),this.incrementTestCounter();for(var a,r,i,n,o=0;this._cellsToTest.length!=0;)if(a=this._cellsToTest.pop(),i=this._cells[a],!!t.overlapTest(i.aabb))if(i.isLeaf())for(r=i.nodeIndices.length,o=0;o<r;o++)n=this.getQuadNode(i.nodeIndices[o]).aabb,n.testID!=this._testID&&(n.testID=this._testID,t.overlapTest(n)&&e.push(i.nodeIndices[o]));else for(o=0;o<kr.NUM_CHILDREN;o++)this._cellsToTest.push(i.childCellIndices[o]);return e.length}pointInTriangle(e,t,a,r,i){var n=a,o=r,l=i,c=n.z-o.z,f=o.x-n.x,d=n.x*o.z-o.x*n.z,h=o.z-l.z,u=l.x-o.x,m=o.x*l.z-l.x*o.z,g=l.z-n.z,p=n.x-l.x,D=l.x*n.z-n.x*l.z,A=!1,B=c*e+f*t+d,v=h*e+u*t+m,U=g*e+p*t+D;const y=.01;return(B>=-y&&v>=-y&&U>=-y||B<=y&&v<=y&&U<=y)&&(A=!0),A}incrementTestCounter(){if(++this._testID,this._testID==0){for(var e=this._quadNodes.length,t=0;t<e;t++)this._quadNodes[t].aabb.testID=0;this._testID=1}}logDeep=0;logTree(e){if(!(e<0)){this.logDeep++;for(var t=this._cells[e],a="",r=0;r<this.logDeep-1;r++)a+="-|";console.log(a+"i="+e+" "+t.aabb.minPosX.toFixed(2)+" "+t.aabb.maxPosX.toFixed(2)+" "+t.aabb.minPosY.toFixed(2)+" "+t.aabb.maxPosY.toFixed(2));var i;for(i=0;i<t.nodeIndices.length;i++)if(t.nodeIndices[i]>=0){var n=this._quadNodes[t.nodeIndices[i]];console.log(a+" t="+t.nodeIndices[i]+" "+n.aabb.minPosX.toFixed(2)+" "+n.aabb.maxPosX.toFixed(2)+" "+n.aabb.minPosY.toFixed(2)+" "+n.aabb.maxPosY.toFixed(2))}for(i=0;i<t.childCellIndices.length;i++)t.childCellIndices[i]>=0&&this.logTree(t.childCellIndices[i]);this.logDeep--}}}class Mh{_maxNodesPerCell;_minCellSize;_quadTree;_collisionNodesIdx;_segBox;_collisionNodes;constructor(e=10,t=500){this._maxNodesPerCell=e,this._minCellSize=t,this._segBox=new Nt,this._collisionNodesIdx=new Array,this._collisionNodes=new Array}createQuadTree(e){this._quadTree=new Th,this._quadTree.initNodes(e),this._quadTree.buildQuadTree(this._maxNodesPerCell,this._minCellSize)}getNodesByAABB(e,t,a,r){this._segBox.clear(),this._segBox.maxPosX=a,this._segBox.maxPosY=r,this._segBox.minPosX=e,this._segBox.minPosY=t,this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var i,n=0;n<this._collisionNodesIdx.length;n++)i=this._quadTree.getQuadNode(this._collisionNodesIdx[n]),this._collisionNodes.push(i);return this._collisionNodes}getTriangleAtPoint(e,t=5){this._segBox.clear(),this._segBox.setAABox(e.x,e.z,1,1),this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var a=4294967295,r=0,i,n,o,l,c=0;c<this._collisionNodesIdx.length;c++)n=this._quadTree.getQuadNode(this._collisionNodesIdx[c]),l=n.aabb,b.pointInsideTriangle(e,l.points[0],l.points[1],l.points[2])&&(o=n,r=Math.abs(o.plane.distance(e)),!(r>t)&&(n==null||r<=a)&&(i=o,a=r));return i}}var Ys=(s=>(s[s.MOUSE_LEFT=0]="MOUSE_LEFT",s[s.MOUSE_MID=1]="MOUSE_MID",s[s.MOUSE_RIGHT=2]="MOUSE_RIGHT",s))(Ys||{});class fp extends pt{static LOADER_PROGRESS="loaderProgress";static LOADER_COMPLETE="loaderComplete"}class dp extends pt{static ADDED="added";static REMOVED="removed";static CHILD_ADD_EVENT="childAddEvent";static CHILD_REMOVED="childRemoved"}class hp extends pt{static SHOW="show";static HIDE="hide";static UPDATE="update"}class up{static merge(e,t,a,r){let i=0,n=0;i=Math.max(e.width,i),i=Math.max(t.width,i),i=Math.max(a.width,i),i=Math.max(r.width,i),n=Math.max(e.height,n),n=Math.max(t.height,n),n=Math.max(a.height,n),n=Math.max(r.height,n);let o=new Te(i,n,oe.rgba8unorm),l=new Fe(yd);l.setSamplerTexture("textureR",e),l.setSamplerTexture("textureG",t),l.setSamplerTexture("textureB",a),l.setSamplerTexture("textureA",r),l.setStorageTexture("outTex",o),l.workerSizeX=Math.ceil(i/8),l.workerSizeY=Math.ceil(n/8);let c=k.beginCommandEncoder();return k.computeCommand(c,[l]),k.endCommandEncoder(c),o}}class Nh{computeShader;setInputes(e,t,a){this.computeShader=new Fe(Ld(e,t,a,8,8,1));for(let r=0;r<t.length;r++)this.computeShader.setSamplerTexture(`source${r}Map`,t[r]);for(let r=0;r<a.length;r++)this.computeShader.setStorageTexture(`dest${r}Map`,a[r]);e&&this.computeShader.setSamplerTexture("colorMap",e),this.computeShader.workerSizeX=a[0].width/8,this.computeShader.workerSizeY=a[0].height/8,this.computeShader.workerSizeZ=1}}class Ph{sourceShader;compute;needUpdate=!0;constructor(e,t){this.sourceShader=t,this.compute=new Fe(e),this.init()}init(){}onUpdate(){this.onFrame&&this.onFrame(),this.onOnce&&this.needUpdate&&(this.needUpdate=!1,this.onFrame())}}class Vh extends Ph{constructor(e){super(Ed,e)}init(){let e=new Te(256,256,oe.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);return this.compute.setStorageTexture("sssMap",e),this.sourceShader.setTexture("lutMap",e),e}onFrame(){this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let e=k.beginCommandEncoder();k.computeCommand(e,[this.compute]),k.endCommandEncoder(e)}}class bp{gpuBuffer;probes;memoryDo;_probeInfoList;initDataUniform(e){this.memoryDo=new cr,this.probes=e,this._probeInfoList=[],this.memoryDo.destroy(),this.memoryDo.allocation(e.length*17*4);for(let a=0;a<e.length;a++){var t=17;let r=this.memoryDo.allocation_node(t*4);this._probeInfoList.push(r);let i=e[a].transform.worldPosition;r.setArray(0,[i.x,i.y,i.z])}this.gpuBuffer=I.device.createBuffer({size:this.memoryDo.shareDataBuffer.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE,label:"ProbeBuffer",mappedAtCreation:!1})}updateGPUBuffer(){const e=this.memoryDo.shareDataBuffer;let t=this.memoryDo.shareDataBuffer.byteLength,a=0;const r=5e3*64;for(;a<t;)I.device.queue.writeBuffer(this.gpuBuffer,a,e,a,Math.floor(Math.min(r,t-a))),a+=r}}class gp extends Ya{constructor(e,t,a=0){super(),this.bufferType=Aa.StructStorageGPUBuffer,this.createBufferByStruct(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|a,e,t)}}class pp{static codeMax=`
11790
11790
  @group(0) @binding(0) var inputTexture : texture_2d<f32>;
11791
11791
  @group(0) @binding(1) var inputTextureSampler : sampler;
11792
11792
  @group(0) @binding(2) var outputTexture : texture_storage_2d<rgba8unorm, write>;
@@ -11824,5 +11824,5 @@ fn frag(){
11824
11824
  `).filter(Boolean);let i=2,n=!1;for(const o of r){const l=o.split(/\s{2,}|\s*:/).filter(Boolean);if(l.length>=2){const c=l[0].trim().toUpperCase(),f=l[1].trim().toUpperCase();if(c==="VERS"||c==="VERSION"){const d=f.match(/(\d+\.?\d*)/);d&&(i=+d[1])}else(c==="WRAP"||c==="WRAP.")&&(n=f==="YES"||f==="Y")}}return{version:i,wrap:n}}parseWellParams(e){const t=Jt.parseSection(e,"W");if(!t)return{};const r=Jt.removeComment(t).split(`
11825
11825
  `).filter(Boolean),i={};for(const n of r){const o=Jt.parseParameterLine(n);o.mnemonic&&(i[o.mnemonic]={unit:o.unit,value:Jt.convertToValue(o.value),description:o.description})}return i}parseCurveParams(e){const t=Jt.parseSection(e,"C");if(!t)return{};const r=Jt.removeComment(t).split(`
11826
11826
  `).filter(Boolean),i={};for(const n of r){const o=Jt.parseParameterLine(n);o.mnemonic&&(i[o.mnemonic]={unit:o.unit,value:o.value,description:o.description})}return i}parseHeaders(e){const t=Jt.parseSection(e,"C");if(!t)throw new Error("LASLoader: ~CURVE section not found");const r=Jt.removeComment(t).split(`
11827
- `).filter(Boolean),i=[];for(const n of r){const o=Jt.parseParameterLine(n);o.mnemonic&&i.push(o.mnemonic)}if(i.length===0)throw new Error("LASLoader: No headers found in ~CURVE section");return i}parseData(e,t,a){const r=e.match(/~A(?:[\x20-\x7E])*(?:\r\n|\r|\n)([\s\S]*?)(?=~|$)/);if(!r||!r[1])throw new Error("LASLoader: ~A data section not found");const i=r[1].trim();if(!i)throw new Error("LASLoader: Data section is empty");const n=i.split(/\s+/).filter(c=>c.trim().length>0).map(c=>Jt.convertToValue(c.trim()));if(n.length===0)throw new Error("LASLoader: No data values found");const o=Math.floor(n.length/t.length);if(o===0)throw new Error("LASLoader: Insufficient data values");const l=[];for(let c=0;c<o;c++){const f=[];for(let d=0;d<t.length;d++){const h=c*t.length+d;h<n.length&&f.push(n[h])}f.length===t.length&&l.push(f)}return l}}var Di=(s=>(s.PointCloud="pointcloud",s.Curve="curve",s.WellTrajectory="trajectory",s))(Di||{}),jp=Object.getOwnPropertyDescriptor,Zp=(s,e,t,a)=>{for(var r=a>1?void 0:a?jp(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Ki=class extends At{constructor(){super();const s=new qe("FatLine_VS","FatLine_FS");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);const e=s.shaderState;e.acceptShadow=!1,e.castShadow=!1,e.receiveEnv=!1,e.acceptGI=!1,e.useLight=!1,e.cullMode=Lt.none,e.depthWriteEnabled=!0,this.setDefault()}setDefault(){this.setUniformColor("baseColor",new J(1,1,1,1)),this.setUniformFloat("lineWidth",1),this.setUniformFloat("opacity",1),this.setUniformVector2("resolution",new de(1920,1080));const s=new R;this.getDefaultColorShader().setUniform("modelMatrix",s.rawData)}};Ki=Zp([Na(Ki,"FatLineShader")],Ki);class qh extends vt{constructor(){super(),this.shader=new Ki,this.transparent=!0}setInstanceBuffer(e){this.shader.setStorageBuffer("instances",e)}setModelMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set lineWidth(e){this.shader.setUniformFloat("lineWidth",e)}get lineWidth(){return this.shader.getUniformFloat("lineWidth")}set opacity(e){this.shader.setUniformFloat("opacity",e)}get opacity(){return this.shader.getUniformFloat("opacity")}set resolution(e){this.shader.setUniformVector2("resolution",e)}get resolution(){return this.shader.getUniformVector2("resolution")}}class Yp extends it{static format=je.BIN;visualizationMode=Di.PointCloud;async parseBuffer(e){const a=await new Kh().parse(e);await this.createVisualization(a)}async createVisualization(e){if("format"in e&&e.format==="binary")this.data=this.createBinaryPointCloudVisualization(e);else{const t=e;let a;switch(this.visualizationMode){case Di.PointCloud:a=this.createPointCloudVisualization(t);break;case Di.Curve:a=this.createCurveVisualization(t);break;case Di.WellTrajectory:a=this.createWellTrajectoryVisualization(t);break;default:a=this.createPointCloudVisualization(t)}a.lasData=t,a.wellParams=t.wellParams,a.curveParams=t.curveParams,this.data=a}}createBinaryPointCloudVisualization(e){const t=new ne;t.name="LASPointCloud";const a=new ne;a.name="LASPointCloudRoot",t.addChild(a);const r=a.addComponent(qa);return r.initFromData(e.positions,e.colors,e.numPoints),r.setPointShape("circle"),r.setPointSize(4),t.lasFormat="binary",t.lasVersion=e.version,t.numPoints=e.numPoints,t.pointDataFormat=e.pointDataFormat,t.bbox=e.bbox,t}verification(){if(this.data)return!0;throw new Error("LASParser: Parse failed")}createPointCloudVisualization(e){const{headers:t,data:a,nullValue:r}=e,i=t.findIndex(D=>D.toUpperCase()==="DEPTH"||D.toUpperCase()==="DEPT");if(i<0)throw new Error("LASParser: DEPTH column not found");const n=t.map((D,A)=>A).filter(D=>D!==i).slice(0,2),o=a.filter(D=>!D.some(A=>A===r||A===+r));if(o.length===0)throw new Error("LASParser: No valid data points after filtering");const l=o.length,c=new Float32Array(l*3),f=new Uint8Array(l*4);let d=1/0,h=-1/0,u=1/0,m=-1/0;if(n.length>0){const D=o.map(A=>+A[n[0]]).filter(A=>!isNaN(A));if(d=Math.min(...D),h=Math.max(...D),n.length>1){const A=o.map(B=>+B[n[1]]).filter(B=>!isNaN(B));u=Math.min(...A),m=Math.max(...A)}}for(let D=0;D<o.length;D++){const A=o[D],B=D*3,v=D*4;if(c[B+2]=+A[i],n.length>0){const U=+A[n[0]],y=h!==d?(U-d)/(h-d):0;if(c[B+0]=y*10,n.length>1){const S=+A[n[1]],F=m!==u?(S-u)/(m-u):0;c[B+1]=F*10}else c[B+1]=0}else c[B+0]=0,c[B+1]=0;if(n.length>0){const U=+A[n[0]],y=h!==d?(U-d)/(h-d):0;this.mapValueToColor(y,f,v)}else f[v+0]=255,f[v+1]=255,f[v+2]=255,f[v+3]=255}const g=new ne;g.name="LASPointCloud";const p=g.addComponent(qa);return p.initFromData(c,f,l),p.setPointShape("circle"),p.setPointSize(4),g}createCurveVisualization(e){const{headers:t,data:a,nullValue:r}=e,i=t.findIndex(D=>D.toUpperCase()==="DEPTH"||D.toUpperCase()==="DEPT");if(i<0)throw new Error("LASParser: DEPTH column not found");const n=t.map((D,A)=>A).find(D=>D!==i);if(n===void 0)throw new Error("LASParser: No curve column found");const o=a.filter(D=>{const A=+D[i],B=+D[n];return!isNaN(A)&&!isNaN(B)&&B!==r&&B!==+r});if(o.length===0)throw new Error("LASParser: No valid data points");const l=o.map(D=>+D[n]),c=Math.min(...l),d=Math.max(...l)-c,h=new Float32Array(o.length*3);for(let D=0;D<o.length;D++){const A=o[D],B=D*3,v=+A[i],U=+A[n];h[B+2]=v;const y=d>0?(U-c)/d:0;h[B+0]=y*10,h[B+1]=0}const u=new wh;u.setPositions(h);const m=new qh;m.baseColor=new J(1,0,0,1),m.lineWidth=2;const g=new ne;g.name=`LASCurve_${t[n]}`;const p=g.addComponent(mi);return p.geometry=u,p.material=m,g}createWellTrajectoryVisualization(e){throw new Error("LASParser: Well trajectory visualization not yet implemented")}normalizeValue(e,t,a){const r=t.map(o=>+o[a]).filter(o=>!isNaN(o)),i=Math.min(...r),n=Math.max(...r);return n!==i?(e-i)/(n-i):0}mapValueToColor(e,t,a){const r=Math.floor(e*255),i=Math.floor((1-e)*255);t[a+0]=r,t[a+1]=0,t[a+2]=i,t[a+3]=255}}class Al extends it{static format=je.BIN;static cloudImageProcessParam="";async parseBuffer(e){switch(Hi(e).mode){case ya.Splat:{const a=Ho(e),r={count:a.vertexCount,position:a.position,rotation:a.rotation,scale:a.scale,opacity:a.opacity,sh:a.sh};r.bbox=Zo(a.position);const i=new ne;i.name="GaussianSplat",i.addComponent(ii).initAsset(r),this.data=i;break}case ya.PointCloud:{const a=Xh(e),r=new ne;r.name="PLYPointCloud";const i=new ne;i.name="PLYPointCloudRoot",r.addChild(i);const n=i.addComponent(qa);if(a.color)n.initFromData(a.position,a.color,a.vertexCount);else{const o=new Uint8Array(a.vertexCount*4);o.fill(255),n.initFromData(a.position,o,a.vertexCount)}n.setPointShape("circle"),n.setPointSize(4),this.data=r;break}case ya.Mesh:{const a=Yh(e),r=new ne;r.name="PLYMesh";const i=new Map;if(a.triangleTexnumbers&&a.triangleTexnumbers.length>0)for(let o=0;o<a.triangleTexnumbers.length;o++){const l=a.triangleTexnumbers[o];i.has(l)||i.set(l,[]),i.get(l).push(o)}else{const o=a.indices.length/3,l=[];for(let c=0;c<o;c++)l.push(c);i.set(0,l)}const n=new Map;if(a.textureFiles&&a.textureFiles.length>0){const o=[];for(let l=0;l<a.textureFiles.length;l++){const c=new ta,f=wt.normalizePath(this.baseUrl+a.textureFiles[l]);o.push(_.res.loadTexture(f+Al.cloudImageProcessParam).then(d=>{c.baseMap=d,n.set(l,c)}))}await Promise.all(o)}n.size===0&&n.set(0,new ta);for(const[o,l]of i){const c=[];for(const m of l){const g=m*3;c.push(a.indices[g+0],a.indices[g+1],a.indices[g+2])}const f=new Le;f.setAttribute(G.position,a.position),f.setAttribute(G.normal,a.normal),a.uv&&f.setAttribute(G.uv,a.uv),a.color&&f.setAttribute(G.color,a.color),f.setIndices(new Uint32Array(c)),f.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let d=n.get(o);d||(d=n.values().next().value||new ta);const h=new ne;h.name=`PLYMesh_Texture_${o}`;const u=h.addComponent(he);u.geometry=f,u.material=d,r.addChild(h)}this.data=r;break}}}verification(){return!!this.data}}class $h{async parse(e){const t=new DataView(e),a=li(t);console.assert(a==="pnts");const r=t.getUint32(4,!0);console.assert(r===1);const i=t.getUint32(8,!0);console.assert(i===e.byteLength);const n=t.getUint32(12,!0),o=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0),f=28,d=new Mi(e,f,n,o),h=f+n+o,u=d.header.POINTS_LENGTH||0,m=new Ls(e,u,h,l,c);return{version:r,featureTable:d,batchTable:m}}}class eu extends $h{async parse(e){const t=await super.parse(e),{featureTable:a,batchTable:r}=t,i=a.header.POINTS_LENGTH;if(!i||i<=0)throw new Error("PNTSLoader: POINTS_LENGTH must be defined and greater than zero");const o=a.header.extensions?.["3DTILES_draco_point_compression"];let l,c;if(o){const u=await this.parseDraco(a,o,i);l=u.positions,c=u.colors,u.normals}else l=this.parsePositions(a,i),c=this.parseColors(a,i),this.parseNormals(a,i);const f=new ne,d=f.addComponent(qa);d.initFromData(l,c,i),d.setPointShape("circle"),d.setPointSize(4);const h=a.getData("RTC_CENTER",1,"FLOAT","VEC3");return h&&f.transform.localPosition.set(h[0],h[1],h[2]),f.batchTable=r,f.featureTable=a,f}parsePositions(e,t){let a=e.getData("POSITION",t,"FLOAT","VEC3");if(a)return a;const r=e.getData("POSITION_QUANTIZED",t,"UNSIGNED_SHORT","VEC3");if(!r)throw new Error("PNTSLoader: Either POSITION or POSITION_QUANTIZED must be defined");const i=e.getData("QUANTIZED_VOLUME_SCALE",1,"FLOAT","VEC3"),n=e.getData("QUANTIZED_VOLUME_OFFSET",1,"FLOAT","VEC3");if(!i||!n)throw new Error("PNTSLoader: QUANTIZED_VOLUME_SCALE and QUANTIZED_VOLUME_OFFSET must be defined for quantized positions");const o=new Float32Array(t*3),l=65535;for(let c=0;c<t;c++){const f=c*3;o[f+0]=r[f+0]/l*i[0]+n[0],o[f+1]=r[f+1]/l*i[1]+n[1],o[f+2]=r[f+2]/l*i[2]+n[2]}return o}parseColors(e,t){let a=e.getData("RGBA",t,"UNSIGNED_BYTE","VEC4");if(a)return a;const r=e.getData("RGB",t,"UNSIGNED_BYTE","VEC3");if(r){const l=new Uint8Array(t*4);for(let c=0;c<t;c++){const f=c*3,d=c*4;l[d+0]=r[f+0],l[d+1]=r[f+1],l[d+2]=r[f+2],l[d+3]=255}return l}const i=e.getData("RGB565",t,"UNSIGNED_SHORT","SCALAR");if(i){const l=new Uint8Array(t*4);for(let c=0;c<t;c++){const f=this.decodeRGB565(i[c]),d=c*4;l[d+0]=f[0],l[d+1]=f[1],l[d+2]=f[2],l[d+3]=255}return l}const n=e.getData("CONSTANT_RGBA",1,"UNSIGNED_BYTE","VEC4");if(n){const l=new Uint8Array(t*4);for(let c=0;c<t;c++){const f=c*4;l[f+0]=n[0],l[f+1]=n[1],l[f+2]=n[2],l[f+3]=n[3]}return l}const o=new Uint8Array(t*4);return o.fill(255),o}parseNormals(e,t){let a=e.getData("NORMAL",t,"FLOAT","VEC3");if(a)return a;const r=e.getData("NORMAL_OCT16P",t,"UNSIGNED_BYTE","VEC2");return r?this.decodeOctNormals(r,t):null}decodeRGB565(e){const t=(e>>11&31)<<3,a=(e>>5&63)<<2,r=(e&31)<<3;return[t,a,r]}decodeOctNormals(e,t){const a=new Float32Array(t*3);for(let r=0;r<t;r++){const i=r*2,n=e[i]/255,o=e[i+1]/255,l=n*2-1,c=o*2-1,f=1-Math.abs(l)-Math.abs(c);let d,h;f<0?(d=(l>=0?1:-1)*(1-Math.abs(c)),h=(c>=0?1:-1)*(1-Math.abs(l))):(d=l,h=c);const u=Math.sqrt(d*d+h*h+f*f),m=r*3;a[m+0]=d/u,a[m+1]=h/u,a[m+2]=f/u}return a}async parseDraco(e,t,a){throw new Error("Draco compression not yet implemented")}}class tu extends it{static format=je.BIN;async parseBuffer(e){const a=await new eu().parse(e),r=new ne;r.name="PNTS",r.addChild(a),this.data=r}verification(){if(this.data)return!0;throw new Error("PNTSParser: Parse failed")}}class Ko{boneName;bonePath;parentBoneName;boneID;parentBoneID;instanceID;parentInstanceID;t;q;s;formBytes(e){this.boneName=e.readUTF(),this.bonePath=e.readUTF(),this.parentBoneName=e.readUTF(),this.boneID=e.readInt32(),this.parentBoneID=e.readInt32(),this.instanceID=e.readUTF(),this.parentInstanceID=e.readUTF(),this.t=e.readVector3(),this.q=e.readQuaternion(),this.s=e.readVector3()}}class qo{name;count;boneData;boneMap;formBytes(e){this.boneData=[],this.boneMap=new Map,this.name=e.readUTF(),this.count=e.readInt32();for(let t=0;t<this.count;t++){let a=new Ko;a.formBytes(e.readBytesArray()),this.boneData[t]=a,this.boneMap.set(a.boneName,a)}}}class au extends it{static format=je.BIN;static parser(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new qo;i.formBytes(e.readBytesArray()),_.res.addObj(i.name,i)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}G.position,G.normal,G.color,G.TANGENT,G.uv,G.TEXCOORD_1,G.TEXCOORD_2,G.TEXCOORD_2,G.TEXCOORD_4,G.TEXCOORD_5,G.TEXCOORD_6,G.TEXCOORD_7,G.joints0,G.weights0;var X=(s=>(s[s.single=0]="single",s[s.boolean=1]="boolean",s[s.int=2]="int",s[s.int16=3]="int16",s[s.int32=4]="int32",s[s.float=5]="float",s[s.long=6]="long",s[s.uint=7]="uint",s[s.uint32=8]="uint32",s[s.uint64=9]="uint64",s[s.double=10]="double",s[s.string=11]="string",s[s.singleArray=12]="singleArray",s[s.stringArray=13]="stringArray",s[s.floatArray=14]="floatArray",s[s.vector2=15]="vector2",s[s.vector3=16]="vector3",s[s.vector4=17]="vector4",s[s.color=18]="color",s[s.color32=19]="color32",s[s.animationCurve=20]="animationCurve",s[s.quaternion=21]="quaternion",s[s.matrix4x4=22]="matrix4x4",s[s.mesh=23]="mesh",s[s.texture=24]="texture",s[s.material=25]="material",s[s.materials=26]="materials",s[s.skeleton=27]="skeleton",s[s.animClip=28]="animClip",s[s.vector2Int=29]="vector2Int",s[s.int32List=30]="int32List",s[s.colorList=31]="colorList",s[s.color32List=32]="color32List",s))(X||{});class Hs{static GetMaterial(e){let t=e,a=t.split("/");t=a[a.length-1],a=t.split("."),t=a[a.length-1];let r=El(t);if(r){let i=new vt;return i.shader=new r,i}else throw new Error("not found shader, shader name is "+t)}static applyMaterialTexture(e,t){for(let a=0;a<t.length;a++){const r=t[a];r.property in e?e[r.property]=r.texture:r.property in e.shader?e.shader[r.property]=r.texture:e.setTexture(r.property,r.texture)}}static applyMaterialProperties(e,t){for(let a=0;a<t.length;a++){const r=t[a],i=r.key;switch(r.type){case X.color:case X.color32:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformColor(i,n)}break;case X.single:case X.float:case X.int:case X.int16:case X.int32:case X.uint:case X.uint32:case X.uint64:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case X.singleArray:{let n=r.getValue()[0];i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case X.vector2:case X.vector2Int:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector2(i,n)}break;case X.vector3:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector3(i,n)}break;case X.vector4:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector4(i,n)}break}}}}class Wa{static parser(e){switch(e.readInt32()){case X.single:return{t:X.single,v:e.readFloat32()};case X.boolean:return{t:X.boolean,v:e.readBoolean()};case X.int:return{t:X.int,v:e.readInt32()};case X.int16:return{t:X.int16,v:e.readInt16()};case X.int32:return{t:X.int32,v:e.readInt32()};case X.float:return{t:X.float,v:e.readFloat32()};case X.long:return{t:X.long,v:e.readFloat64()};case X.uint:return{t:X.uint,v:e.readUnit32()};case X.uint32:return{t:X.uint32,v:e.readUnit32()};case X.uint64:return{t:X.uint64,v:e.readUnit32()};case X.double:return{t:X.double,v:e.readFloat64()};case X.string:return{t:X.string,v:e.readUTF()};case X.singleArray:return{t:X.singleArray,v:e.readFloatArray()};case X.stringArray:return{t:X.stringArray,v:e.readStringArray()};case X.floatArray:return{t:X.floatArray,v:e.readFloatArray()};case X.vector2:return{t:X.vector2,v:e.readVector2()};case X.vector3:return{t:X.vector3,v:e.readVector3()};case X.vector4:return{t:X.vector4,v:e.readVector4()};case X.color:return{t:X.color,v:e.readColor()};case X.color32:return{t:X.color32,v:e.readColor()};case X.animationCurve:return{t:X.animationCurve,v:null};case X.quaternion:return{t:X.quaternion,v:e.readQuaternion()};case X.matrix4x4:return{t:X.matrix4x4,v:null};case X.mesh:{let o=e.readUTF(),l=_.res.getGeometry(o);return{t:X.mesh,v:l}}case X.texture:{let o=e.readUTF(),l=_.res.getTexture(o);return{t:X.texture,v:l}}case X.material:{let o=e.readUTF(),l=_.res.getMat(o);return{t:X.material,v:l}}case X.materials:{let o=e.readStringArray(),l=[];for(let c=0;c<o.length;c++){const f=o[c];let d=_.res.getMat(f);l.push(d)}return{t:X.materials,v:l}}case X.skeleton:break;case X.animClip:{let o=[],l=e.readInt32();for(let c=0;c<l;c++){let f=new fl;f.formBytes(e),o.push(f)}return{t:X.animClip,v:o}}case X.vector2Int:return{t:X.vector2Int,v:e.readVector2int()};case X.int32List:return{t:X.int32List,v:e.readInt32List()};case X.colorList:let a=e.readInt32(),r=[];for(let o=0;o<a;o++){const l=Wa.parser(e).v;r.push(l)}return{t:X.colorList,v:r};case X.color32List:let i=e.readInt32(),n=[];for(let o=0;o<i;o++){const l=Wa.parser(e).v;n.push(l)}return{t:X.color32List,v:n}}}}class $o{key;type;_data;getValue(){return this._data}formBytes(e){this.key=e.readUTF();let{t,v:a}=Wa.parser(e);this.type=t,this._data=a}}class ru{property;name;texture;texelSize;wrapModeU;wrapModeV;wrapModeW;wrapMode;anisoLevel;dimension;filterMode}class iu extends it{static format=je.TEXT;static parserMaterial(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=e.readBytesArray(),n=i.readUTF(),o=i.readUTF();i.readUTF();let l=i.readStringArray();i.readVector4(),i.readVector4();let c=i.readUTF(),f=[],d=[],h=i.readInt32();for(let g=0;g<h;g++){let p=new $o;p.formBytes(i),f.push(p)}let u=i.readInt32();for(let g=0;g<u;g++){let p=i.readBytesArray(),D=new ru;D.property=p.readUTF(),D.name=p.readUTF(),D.texture=_.res.getTexture(D.name),D.texelSize=p.readVector2(),D.wrapModeU=p.readUnit32(),D.wrapModeV=p.readUnit32(),D.wrapModeW=p.readUnit32(),D.wrapMode=p.readUnit32(),D.anisoLevel=p.readUnit32(),D.dimension=p.readUnit32(),D.filterMode=p.readUnit32(),d.push(D)}let m=Hs.GetMaterial(c);m.name=n;for(let g=0;g<l.length;g++){const p=l[g];m.shader.setDefine(p,!0)}Hs.applyMaterialTexture(m,d),Hs.applyMaterialProperties(m,f),_.res.addMat(o,m)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class el{shapeName;shapeIndex;frameCount;blendPositionList=new Float32Array;blendNormalList=new Float32Array;formBytes(e){let t=e.readBytesArray();this.shapeName=t.readUTF(),this.shapeIndex=t.readInt32(),this.frameCount=t.readInt32();let a=t.readInt32();this.blendPositionList=t.readFloat32Array(a*3);let r=t.readInt32();this.blendNormalList=t.readFloat32Array(r*3)}}class tl{vertexCount;shapeNames;shapeIndexs;blendCount;blendShapePropertyDatas;blendShapeMap;formBytes(e){this.blendShapeMap=new Map,this.blendShapePropertyDatas=[];let t=e.readBytesArray();this.vertexCount=t.readInt32(),this.shapeNames=t.readStringArray(),this.shapeIndexs=t.readIntArray(),this.blendCount=t.readInt32();for(let a=0;a<this.blendCount;a++){let r=new el;r.formBytes(t),this.blendShapePropertyDatas.push(r),this.blendShapeMap.set(r.shapeName,r)}return e}}class su{name;meshName;meshID;vertexCount;vertexStrip;vertexBuffer;indices;attributes;bones;bindPose;blendShapeData}class nu extends it{static format=je.BIN;async parseBuffer(e){}static parserMeshs(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new su,n=e.readBytesArray();i.meshName=n.readUTF(),i.meshID=n.readUTF(),n.readFloat32()>0,n.readFloat32()>0,n.readFloat32()>0;let o=n.readFloat32()>0,l=n.readFloat32()>0;o&&(i.bones=n.readStringArray(),i.bindPose=n.readMatrix44Array()),l&&(i.blendShapeData=new tl,i.blendShapeData.formBytes(n));let c=n.readBytesArray(),f=n.readBytesArray(),d=c.readInt32(),h=0,u=[];for(let A=0;A<d;A++)u[A]={},u[A].att=Xp[c.readUTF()],u[A].dim=c.readInt32(),h+=u[A].dim,u[A].format=c.readUTF();i.vertexCount=c.readInt32(),i.vertexBuffer=f.getFloat32Array();let m=n.readInt32Array(),g=[],p=n.readInt32();for(let A=0;A<p;A++){let B=n.readInt32(),v=n.readInt32(),U=n.readInt32(),y=n.readInt32(),S=n.readInt32(),F=n.readInt32();n.readVector3(),n.readVector3();let C={indexStart:v,indexCount:U,vertexStart:y,vertexCount:F,firstStart:S,topology:B,index:A};g.push(C)}m.length>65535?i.indices=new Uint32Array(m):i.indices=new Uint16Array(m);let D=new Le;if(D.vertexDim=h,D.geometryType=kt.compose_bin,D.setIndices(i.indices),D.setAttribute(G.all,i.vertexBuffer),o&&(D.skinNames=i.bones,D.bindPose=i.bindPose),l){D.blendShapeData=i.blendShapeData,D.morphTargetsRelative=!0,D.morphTargetDictionary={};for(let A=0;A<i.blendShapeData.blendCount;A++){D.setAttribute("a_morphPositions_"+A,i.blendShapeData.blendShapePropertyDatas[A].blendPositionList),D.setAttribute("a_morphNormals_"+A,i.blendShapeData.blendShapePropertyDatas[A].blendNormalList);for(let B=0;B<i.blendShapeData.blendCount;B++){let v=i.blendShapeData.shapeNames[B],U=i.blendShapeData.shapeIndexs[B];D.morphTargetDictionary[v]=U}}}for(let A=0;A<u.length;A++){const B=u[A].att;D.setAttribute(B,null)}for(let A=0;A<g.length;A++){const B=g[A];D.addSubGeometry(B)}D.name=i.meshName,_.res.addGeometry(i.meshID,D)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}let Xp={Position:G.position,Normal:G.normal,Color:G.color,Tangent:G.TANGENT,TexCoord0:G.uv,TexCoord1:G.TEXCOORD_1,TexCoord2:G.TEXCOORD_2,TexCoord3:G.TEXCOORD_2,TexCoord4:G.TEXCOORD_4,TexCoord5:G.TEXCOORD_5,TexCoord6:G.TEXCOORD_6,TexCoord7:G.vIndex,BlendIndices:G.joints0,BlendWeight:G.weights0};class Dn extends DataView{get buffer(){return super.buffer}get byteOffset(){return super.byteOffset}get byteLength(){return super.byteLength}getInt16(e,t){return super.getInt16(e,t)}getInt32(e,t){return super.getInt32(e,t)}getFloat32(e,t){return super.getFloat32(e,t)}getFloat64(e,t){return super.getFloat64(e,t)}getUint8(e){return super.getUint8(e)}getUint32(e,t){return super.getUint32(e,t)}getInt8(e){return super.getInt8(e)}getUint16(e,t){return super.getUint16(e,t)}position=0;littleEndian=!0;constructor(e,t,a){super(e,t,a),this.position=0,this.position+=this.byteOffset}readUTF(){let e=this.readInt32(),t=e%4;t>0&&t<4&&(t=4-t);let a="",r=new Int8Array(this.buffer,this.position,e);return this.position+=e*Int8Array.BYTES_PER_ELEMENT,a+=String.fromCharCode.apply(null,r),this.position+=t*Int8Array.BYTES_PER_ELEMENT,a}readStringArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readUTF());return e}readByte(){let e=this.buffer[this.position];return this.position+=1,e}readBoolean(){let e=this.readInt32();return this.position+=4,e==1}readBytes(e){let t=new DataView(this.buffer,this.position,e);return this.position+=e,t.buffer}readBytesArray(){let e=this.readInt32(),t=new Dn(this.buffer.slice(this.position,this.position+e));return this.position+=e,t}readUnit8(){let e=this.getUint8(this.position);return this.position+=Uint8Array.BYTES_PER_ELEMENT,e}readUnit16(){let e=this.getUint16(this.position);return this.position+=Uint16Array.BYTES_PER_ELEMENT,e}readUnit32(){let e=this.getUint32(this.position);return this.position+=Uint32Array.BYTES_PER_ELEMENT,e}readInt8(){let e=this.getInt8(this.position);return this.position+=Int8Array.BYTES_PER_ELEMENT,e}readInt16(){let e=this.getInt16(this.position,this.littleEndian);return this.position+=Int16Array.BYTES_PER_ELEMENT,e}readInt32(){let e=this.getInt32(this.position,this.littleEndian);return this.position+=Int32Array.BYTES_PER_ELEMENT,e}readFloat32(){let e=this.getFloat32(this.position,this.littleEndian);return this.position+=Float32Array.BYTES_PER_ELEMENT,e}readFloat64(){let e=this.getFloat64(this.position,this.littleEndian);return this.position+=Float64Array.BYTES_PER_ELEMENT,e}readInt32Array(){let e=this.readInt32(),t=new Int32Array(this.buffer,this.position,e);return t=t.slice(0,e),this.position+=t.byteLength,t}readInt32List(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++)t.push(this.readInt32());return t}readFloatArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readFloat32();t.push(r)}return t}readIntArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readInt32();t.push(r)}return t}readVector2int(){let e=new de;return e.x=this.readInt32(),e.y=this.readInt32(),e}readVector2(){let e=new de;return e.x=this.readFloat32(),e.y=this.readFloat32(),e}readVector3(){let e=new b;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e}readVector3Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector3());return e}readVector4(){let e=new be;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readVector4Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector4());return e}readColor(){let e=new J;return e.r=this.readFloat32(),e.g=this.readFloat32(),e.b=this.readFloat32(),e.a=this.readFloat32(),e}readColorArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readColor());return e}readQuaternion(){let e=new se;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readQuaternionArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readQuaternion());return e}readMatrix44(){let e=new R,t=e.rawData;return t[0]=this.readFloat32(),t[1]=this.readFloat32(),t[2]=this.readFloat32(),t[3]=this.readFloat32(),t[4]=this.readFloat32(),t[5]=this.readFloat32(),t[6]=this.readFloat32(),t[7]=this.readFloat32(),t[8]=this.readFloat32(),t[9]=this.readFloat32(),t[10]=this.readFloat32(),t[11]=this.readFloat32(),t[12]=this.readFloat32(),t[13]=this.readFloat32(),t[14]=this.readFloat32(),t[15]=this.readFloat32(),e}readMatrix44Array(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readMatrix44();t.push(r)}return t}readFloat32Array(e){let t=new DataView(this.buffer),a=new Float32Array(e);for(let r=0;r<e;r++)a[r]=t.getFloat32(this.position+r*Float32Array.BYTES_PER_ELEMENT,this.littleEndian);return this.position+=e*Float32Array.BYTES_PER_ELEMENT,a}getFloat32Array(){let e=new Float32Array(this.buffer,this.byteOffset,this.byteLength/Float32Array.BYTES_PER_ELEMENT);return e=e.slice(0,this.byteLength),e}}class ou extends it{static format=je.TEXT;static async parserTexture(e,t,a){let r=e.readInt32(),i=[];for(let o=0;o<r;o++){let l=e.readUTF();lu.useWebp?(l=l.replace("png","webp"),l=l.replace("jpb","webp"),i.push(t.baseUrl+"webp/"+l)):i.push(t.baseUrl+l)}let n=await _.res.loadBitmapTextures(i,_.setting.loader.numConcurrent,a,!0);for(const o of n)_.res.addTexture(o.name,o)}verification(){if(this.data)return!0;throw new Error("verify failed.")}}var Hp=Object.getOwnPropertyDescriptor,Kp=(s,e,t,a)=>{for(var r=a>1?void 0:a?Hp(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Ks=class extends At{constructor(){super(),Y.register("PBRLitSSSShader",Zd);let s=new qe("PBRLitSSSShader","PBRLitSSSShader");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!0,e.castShadow=!0,e.receiveEnv=!0,e.acceptGI=!0,e.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefine("USE_CUSTOMUNIFORM",!0),this.setDefault(),this.computes=[new Vh(this)]}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(1,1,1)),this.setUniformVector4("materialF0",new be(.04,.04,.04,1)),this.setUniformColor("specularColor",new J(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new J(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformColor("skinColor",new J(1,0,0)),this.setUniformFloat("skinPower",3.4),this.setUniformFloat("skinColorIns",.5),this.setUniformFloat("curveFactor",1)}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _SSSMap(s){this.setTexture("sssMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SkinColor(s){this.setUniformColor("skinColor",s)}set _SkinPower(s){this.setUniformFloat("skinPower",s)}set _SkinColorIns(s){this.setUniformFloat("skinColorIns",s)}set curveFactor(s){this.setUniformFloat("curveFactor",s)}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};Ks=Kp([Na(Ks,"LitSSSShader")],Ks);var qp=Object.getOwnPropertyDescriptor,$p=(s,e,t,a)=>{for(var r=a>1?void 0:a?qp(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let qs=class extends At{constructor(){super();let s=new qe("PBRLItShader","PBRLItShader");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!0,e.castShadow=!0,e.receiveEnv=!0,e.acceptGI=!0,e.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(0,0,0)),this.setUniformVector4("materialF0",new be(.04,.04,.04,1)),this.setUniformColor("specularColor",new J(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new J(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this._MainTex=_.res.grayTexture,this._BumpMap=_.res.normalTexture,this._MaskTex=_.res.maskTexture}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};qs=$p([Na(qs,"LitShader")],qs);class _n{comName;data;static parser(e){let t=e.readBytesArray(),a=new _n;a.comName=t.readUTF(),a.data=[];let r=t.readInt32();for(let i=0;i<r;i++){let n=new $o;n.formBytes(t),a.data.push(n)}return a}}class xs{name;parentName;position;rotation;scale;comDatas;child;static parser(e){let t=e.readBytesArray(),a=new xs;a.name=t.readUTF(),a.parentName=t.readUTF(),a.position=t.readVector3(),a.rotation=t.readQuaternion(),a.scale=t.readVector3(),a.comDatas=[],a.child=[];let r=t.readInt32();for(let n=0;n<r;n++){const o=_n.parser(t);a.comDatas.push(o)}let i=t.readInt32();for(let n=0;n<i;n++){const o=xs.parser(t);a.child.push(o)}return a}}class lu extends it{static useWebp=!0;static format=je.BIN;avatarDic;nodeData;async parseBuffer(e){this.avatarDic={};let t=new Dn(e,0);await ou.parserTexture(t,this,this.loaderFunctions),au.parser(t,this),nu.parserMeshs(t,this),iu.parserMaterial(t,this),this.nodeData=this.parserPrefabNode(t),this.data=this.data=this.parserNodeTree(this.nodeData)}parserPrefabNode(e){return xs.parser(e)}parserNodeTree(e){let t=new ne;if(t.localPosition=b.serialize(e.position),t.localQuaternion=se.serialize(e.rotation),t.localScale=b.serialize(e.scale),t.name=e.name,e.comDatas)for(let a=0;a<e.comDatas.length;a++){const r=e.comDatas[a];let i=null,n=kl(r.comName);if(n){i=t.getOrAddComponent(n);for(let o=0;o<r.data.length;o++){const l=r.data[o];l.key in i&&(i[l.key]=l.getValue())}}}if(e.child&&e.child.length>0)for(let a=0;a<e.child.length;a++){let r=this.parserNodeTree(e.child[a]);t.addChild(r)}return t}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class em{static getNumber(e){return parseFloat(e)}static getInt(e){return parseInt(e)}static getBoolean(e){return e=="true"}static getNumberArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(",");for(let r=0;r<a.length;r++)parseFloat(a[r]);return t}static getStringArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(","),r=[];for(let i=0;i<a.length;i++){const n=a[i];r.push(n)}return r}static getVector2(e){}static getVector3(e){}static getVector4(e){}static getQuaternion(e){}static getColor(e){}}var tm=Object.getOwnPropertyDescriptor,am=(s,e,t,a)=>{for(var r=a>1?void 0:a?tm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let qi=class extends At{constructor(){super();let s=new qe("UnLit","UnLit");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!1,e.castShadow=!1,e.receiveEnv=!1,e.acceptGI=!1,e.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};qi=am([Na(qi,"UnLitShader")],qi);var rm=Object.getOwnPropertyDescriptor,im=(s,e,t,a)=>{for(var r=a>1?void 0:a?rm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let $i=class extends At{constructor(){super(),Y.register("VertexAttributeIndexShader",Wd),Y.register("UnLitTextureArray",Yd);let s=new qe("UnLitTextureArray","UnLitTextureArray");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!1,e.castShadow=!1,e.receiveEnv=!1,e.acceptGI=!1,e.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};$i=im([Na($i,"UnLitTexArrayShader")],$i);const _r=-1,Br=0,al=1,cu=2,La=3,sm=6378137,nm=1/298.257223563,om=6356752314245179e-9,lm=Symbol("PLUGIN_REGISTERED");class rl{boundingVolume;geometricError;refine;content;contents;transform;extensions;extras;parent=null;children=[];loadingState=Br;used=!1;visible=!1;active=!1;inFrustum=!1;error=1/0;distanceFromCamera=1/0;depth=0;depthFromRenderedParent=0;lastFrameVisited=-1;isLeaf=!1;allChildrenReady=!1;hasContent=!1;hasRenderableContent=!1;hasUnrenderableContent=!1;childrenProcessed=0;usedLastFrame=!1;priority;canTraverse=!1;canTraverseFrame=-1;basePath="";cached={};constructor(e,t=null){if(this.boundingVolume=e.boundingVolume,this.geometricError=e.geometricError,this.refine=e.refine,this.content=e.content,this.contents=e.contents,this.transform=e.transform,this.extensions=e.extensions,this.extras=e.extras,this.parent=t,this.depth=t?t.depth+1:0,this.depthFromRenderedParent=t?.hasContent?0:t?t.depthFromRenderedParent+1:0,this.hasContent=!!(this.content||this.contents&&this.contents.length>0),this.content?.uri){const a=this.content.uri.toLowerCase();this.hasUnrenderableContent=a.endsWith("tileset.json"),this.hasRenderableContent=!this.hasUnrenderableContent}else this.contents&&this.contents.length>0&&(this.hasRenderableContent=!0)}addChild(e){e.parent=this,e.depth=this.depth+1,e.depthFromRenderedParent=this.hasContent?0:this.depthFromRenderedParent+1,this.children.push(e)}resetFrameState(e){this.lastFrameVisited!==e&&(this.lastFrameVisited=e,this.used=!1,this.inFrustum=!1,this.isLeaf=!1,this.visible=!1,this.active=!1,this.error=1/0,this.distanceFromCamera=1/0,this.allChildrenReady=!1)}}const fu=2**30;class du{minSize=6e3;maxSize=8e3;minBytesSize=.3*fu;maxBytesSize=.4*fu;unloadPercent=.05;autoMarkUnused=!0;_itemSet=new Map;_itemList=[];_usedSet=new Set;_callbacks=new Map;_unloadingHandle=-1;_cachedBytes=0;_bytesMap=new Map;_loadedSet=new Set;_unloadPriorityCallback=null;set unloadPriorityCallback(e){this._unloadPriorityCallback=e}get unloadPriorityCallback(){return this._unloadPriorityCallback}isFull(){return this._itemSet.size>=this.maxSize||this._cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this._bytesMap.get(e)||0}setMemoryUsage(e,t){if(!this._itemSet.has(e))return;const a=this._bytesMap.get(e)||0;this._cachedBytes-=a,this._bytesMap.set(e,t),this._cachedBytes+=t}add(e,t){return this._itemSet.has(e)||this.isFull()?!1:(this._itemList.push(e),this._usedSet.add(e),this._itemSet.set(e,Date.now()),this._callbacks.set(e,t),this._loadedSet.add(e),!0)}has(e){return this._itemSet.has(e)}remove(e){if(!this._itemSet.has(e))return!1;const t=this._bytesMap.get(e)||0;this._cachedBytes-=t,this._bytesMap.delete(e);const a=this._callbacks.get(e);a&&a(e);const r=this._itemList.indexOf(e);return r!==-1&&this._itemList.splice(r,1),this._usedSet.delete(e),this._itemSet.delete(e),this._callbacks.delete(e),this._loadedSet.delete(e),!0}markUsed(e){this._itemSet.has(e)&&(this._usedSet.add(e),this._itemSet.set(e,Date.now()))}markUnused(e){this._usedSet.delete(e)}scheduleUnload(){this._unloadingHandle===-1&&(this._unloadingHandle=requestAnimationFrame(()=>{this._unloadingHandle=-1,this._performUnload()}))}_performUnload(){if(!(this._itemSet.size>this.minSize||this._cachedBytes>this.minBytesSize))return;this.autoMarkUnused&&this._itemSet.forEach((o,l)=>{this._usedSet.has(l)||this.markUnused(l)});const t=[];this._itemList.forEach(o=>{this._usedSet.has(o)||t.push(o)}),this._unloadPriorityCallback&&t.sort(this._unloadPriorityCallback);const a=Math.floor(this._itemSet.size*(1-this.unloadPercent)),r=this._cachedBytes-(this._cachedBytes-this.minBytesSize);let i=0,n=0;for(let o=0;o<t.length;o++){const l=t[o];if(this._itemSet.size-i<=a&&this._cachedBytes-n<=r)break;const c=this._bytesMap.get(l)||0;this.remove(l)&&(i++,n+=c)}}clear(){Array.from(this._itemSet.keys()).forEach(t=>this.remove(t))}getStats(){return{size:this._itemSet.size,bytes:this._cachedBytes,usedCount:this._usedSet.size}}}class il{maxJobs=6;priorityCallback=null;_items=[];_callbacks=new Map;_currJobs=0;get running(){return this._items.length!==0||this._currJobs!==0}sort(){this.priorityCallback&&this._items.sort(this.priorityCallback)}has(e){return this._callbacks.has(e)}add(e,t){if(this._callbacks.has(e))return this._callbacks.get(e).promise;let a,r;const i=new Promise((o,l)=>{a=o,r=l}),n={callback:t,promise:i,resolve:a,reject:r};return this._items.unshift(e),this._callbacks.set(e,n),i}remove(e){const t=this._items.indexOf(e);if(t!==-1){const a=this._callbacks.get(e);a&&(a.promise.catch(()=>{}),a.reject(new Error("PriorityQueue: Item removed."))),this._items.splice(t,1),this._callbacks.delete(e)}}removeByFilter(e){const t=[];this._items.forEach(a=>{e(a)&&t.push(a)}),t.forEach(a=>this.remove(a))}update(){this._tryRunJobs()}_tryRunJobs(){this.sort();const e=this.maxJobs;let t=0;const a=()=>{this._currJobs--};for(;e>this._currJobs&&this._items.length>0&&t<e;){this._currJobs++,t++;const r=this._items.shift(),i=this._callbacks.get(r);this._callbacks.delete(r),Promise.resolve(i.callback(r)).then(()=>{i.resolve(),a()}).catch(n=>{i.reject(n),a()})}}clear(){Array.from(this._items).forEach(t=>this.remove(t))}getStats(){return{queued:this._items.length,running:this._currJobs}}}function hu(s,e=null,t=null){const a=[];for(a.push(s),a.push(null),a.push(0);a.length>0;){const r=a.pop(),i=a.pop(),n=a.pop();if(e&&e(n,i,r)===!0){t&&t(n,i,r);return}const o=n.children;if(o&&o.length>0)for(let l=o.length-1;l>=0;l--)a.push(o[l]),a.push(n),a.push(r+1);if(t&&t(n,i,r)===!0)return}}function cm(s,e){let t=s;for(;t;){const a=t.depth,r=t.parent;e(t,r,a),t=r}}const $s={inView:!1,error:1/0,distanceFromCamera:1/0},uu=!0;function bu(s){return s===La||s===_r}function vr(s,e){return s.lastFrameVisited===e&&s.used}function gu(s){return s.childrenProcessed===s.children.length}function sl(s){return s.hasUnrenderableContent||s.parent!==null&&s.parent.geometricError<s.geometricError}function nl(s,e){s.lastFrameVisited!==e.frameCount&&(s.usedLastFrame=s.used,s.lastFrameVisited=e.frameCount,s.used=!1,s.inFrustum=!1,s.isLeaf=!1,s.visible=!1,s.active=!1,s.error=1/0,s.distanceFromCamera=1/0,s.allChildrenReady=!1,e.calculateTileViewError(s,$s),s.inFrustum=$s.inView,s.error=$s.error,s.distanceFromCamera=$s.distanceFromCamera)}function ol(s,e,t=!1){s.used||(t||(s.used=!0,e.stats.used++),e.markTileUsed(s),s.inFrustum===!0&&e.stats.inFrustum++)}function fm(s,e){if(s.canTraverse&&s.canTraverseFrame===e.frameCount)return s.canTraverse;let t=!1;return s.error<=e.errorTarget&&!sl(s)||s.depth>=e.maxDepth||!s.children||s.children.length===0?t=!1:t=!0,s.canTraverse=t,s.canTraverseFrame=e.frameCount,t}function ll(s,e,t=!1){if(e.ensureChildrenArePreprocessed(s),nl(s,e),ol(s,e,t),sl(s)&&gu(s)){const a=s.children;for(let r=0,i=a.length;r<i;r++)ll(a[r],e,t)}}function en(s,e){if(e.ensureChildrenArePreprocessed(s),nl(s,e),!s.inFrustum)return;if(!fm(s,e)){ol(s,e);const n=s.children;if(!s.hasContent&&n&&n.length>0)for(let o=0,l=n.length;o<l;o++){const c=n[o];en(c,e)}return}const a=s.children;let r=!1,i=!1;for(let n=0,o=a.length;n<o;n++){const l=a[n];en(l,e),r=r||vr(l,e.frameCount),i=i||l.inFrustum}if(s.refine==="REPLACE"&&!i&&a.length!==0){s.inFrustum=!1;for(let n=0,o=a.length;n<o;n++)ll(a[n],e,!0);return}if(ol(s,e),s.refine==="REPLACE"&&(r&&s.depth!==0||uu))for(let n=0,o=a.length;n<o;n++)ll(a[n],e)}function cl(s,e){const t=e.frameCount;if(!vr(s,t))return;const a=s.children;let r=!1;for(let i=0,n=a.length;i<n;i++){const o=a[i];r=r||vr(o,t)}if(!r)s.isLeaf=!0;else{let i=!0;for(let n=0,o=a.length;n<o;n++){const l=a[n];if(cl(l,e),vr(l,t)){const c=!sl(l);let f=!l.hasContent||l.hasRenderableContent&&bu(l.loadingState)||l.hasUnrenderableContent&&l.loadingState===_r;f=c&&f||l.allChildrenReady,i=i&&f}}s.allChildrenReady=i}}function pu(s,e){if(e.ensureChildrenArePreprocessed(s),vr(s,e.frameCount)&&(s.hasContent&&e.queueTileForDownload(s),gu(s))){const t=s.children;for(let a=0,r=t.length;a<r;a++)pu(t[a],e)}}function tn(s,e){const t=e.stats;if(!vr(s,e.frameCount))return;if(s.isLeaf){s.loadingState===La?(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++):s.hasContent&&e.queueTileForDownload(s);return}const a=s.children,r=s.hasContent,i=bu(s.loadingState)&&r,n=(e.errorTarget+1)*(e.errorThreshold||1),o=s.error<=n,l=s.refine==="ADD",c=s.allChildrenReady||s.depth===0&&!uu;if(r&&(o||l)&&e.queueTileForDownload(s),(o&&i&&!c||i&&l)&&(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++),!l&&o&&!c)for(let f=0,d=a.length;f<d;f++){const h=a[f];vr(h,e.frameCount)&&pu(h,e)}else for(let f=0,d=a.length;f<d;f++)tn(a[f],e)}function an(s,e){const t=vr(s,e.frameCount);if(t||s.usedLastFrame){let a=!1,r=!1;if(t?(a=s.active,r=s.visible):nl(s,e),s.hasRenderableContent&&s.loadingState===La){const n=s.__wasSetVisible;s.__wasSetActive!==a&&(e.setTileDelayedActive(s,a),s.__wasSetActive=a),n!==r&&(e.setTileDelayedVisible(s,r),s.__wasSetVisible=r)}s.usedLastFrame=t;const i=s.children;for(let n=0,o=i.length;n<o;n++)an(i[n],e)}}class Xr{static s_tmpMatrix=null;_type;_data;_box;get box(){return this._box}_sphere;_matrix;constructor(e){if(Xr.s_tmpMatrix||(Xr.s_tmpMatrix=new R),this._data=e,e.box)this._type="box",this._parseBox(e.box);else if(e.sphere)this._type="sphere",this._parseSphere(e.sphere);else if(e.region)this._type="region",this._parseRegion(e.region);else throw new Error("BoundingVolume: Invalid bounding volume data")}_parseBox(e){if(e.length!==12)throw new Error("BoundingVolume: Box must have 12 elements");const t=new b(e[0],e[1],e[2]),a=new b(e[3],e[4],e[5]),r=new b(e[6],e[7],e[8]),i=new b(e[9],e[10],e[11]),n=a.length,o=r.length,l=i.length,c=a.clone().normalize(),f=r.clone().normalize(),d=i.clone().normalize();this._matrix=new R;const h=this._matrix.rawData;h[0]=c.x,h[1]=c.y,h[2]=c.z,h[3]=0,h[4]=f.x,h[5]=f.y,h[6]=f.z,h[7]=0,h[8]=d.x,h[9]=d.y,h[10]=d.z,h[11]=0,h[12]=t.x,h[13]=t.y,h[14]=t.z,h[15]=1;const u=new b(n*2,o*2,l*2);this._box=new Ce(new b(0,0,0),u)}_parseSphere(e){if(e.length!==4)throw new Error("BoundingVolume: Sphere must have 4 elements");const t=new b(e[0],e[1],e[2]),a=e[3];this._sphere=new Lr(t,a)}_parseRegion(e){if(e.length!==6)throw new Error("BoundingVolume: Region must have 6 elements");const[t,a,r,i,n,o]=e,l=new b((t+r)/2,(a+i)/2,(n+o)/2),c=new b(Math.abs(r-t),Math.abs(i-a),Math.abs(o-n));this._box=new Ce(l,c),this._matrix=new R,this._matrix.identity()}getAABB(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center,r=this._sphere.radius,i=new b(a.x-r,a.y-r,a.z-r),n=new b(a.x+r,a.y+r,a.z+r);if(e.setFromMinMax(i,n),t){const o=[new b(i.x,i.y,i.z),new b(n.x,i.y,i.z),new b(i.x,n.y,i.z),new b(n.x,n.y,i.z),new b(i.x,i.y,n.z),new b(n.x,i.y,n.z),new b(i.x,n.y,n.z),new b(n.x,n.y,n.z)];o.forEach(l=>{const c=new b;t.transformPoint(l,c),l.copyFrom(c)}),e.makeEmpty(),o.forEach(l=>{e.expandByPoint(l)})}return e}else if(this._box){const a=Xr.s_tmpMatrix;if(a.identity(),this._matrix?t?a.multiplyMatrices(t,this._matrix):a.copyFrom(this._matrix):t&&a.copyFrom(t),a){const r=this._box,i=[new b(r.min.x,r.min.y,r.min.z),new b(r.max.x,r.min.y,r.min.z),new b(r.min.x,r.max.y,r.min.z),new b(r.max.x,r.max.y,r.min.z),new b(r.min.x,r.min.y,r.max.z),new b(r.max.x,r.min.y,r.max.z),new b(r.min.x,r.max.y,r.max.z),new b(r.max.x,r.max.y,r.max.z)];i.forEach(n=>{const o=new b;a.transformPoint(n,o),n.copyFrom(o)}),e.makeEmpty(),i.forEach(n=>{e.expandByPoint(n)})}else e.setFromMinMax(this._box.min,this._box.max);return e}throw new Error("BoundingVolume: Invalid state")}getOBB(e,t){this._type==="box"&&this._box&&this._matrix?(e.setFromMinMax(this._box.min,this._box.max),t.copyFrom(this._matrix)):(this.getAABB(e),t.identity())}getSphere(e){if(this._type==="sphere"&&this._sphere)return e.center.copyFrom(this._sphere.center),e.radius=this._sphere.radius,e;const t=new Ce;this.getAABB(t);const a=t.center,i=t.size.length*.5;return e.center.copyFrom(a),e.radius=i,e}get type(){return this._type}distanceToPoint(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center;let r=a;if(t){const o=new b;t.transformPoint(a,o),r=o}const i=this._sphere.radius,n=e.clone().subtract(r).length;return Math.max(0,n-i)}else if(this._box){const a=new Ce;this.getAABB(a,t);const r=a.center,i=a.size,n=Math.max(0,Math.abs(e.x-r.x)-i.x*.5),o=Math.max(0,Math.abs(e.y-r.y)-i.y*.5),l=Math.max(0,Math.abs(e.z-r.z)-i.z*.5);return Math.sqrt(n*n+o*o+l*l)}return 1/0}intersectsFrustum(e,t){if(this._type==="sphere"&&this._sphere){const a=new Ce;return this.getAABB(a,t),e.containsBox2(a)>0}else if(this._box){const a=new Ce;return this.getAABB(a,t),e.containsBox2(a)>0}return!1}}const mu=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.used!==e.used?s.used?1:-1:s.error!==e.error?s.error>e.error?1:-1:s.distanceFromCamera!==e.distanceFromCamera?s.distanceFromCamera>e.distanceFromCamera?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?-1:1:0},Au=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.lastFrameVisited!==e.lastFrameVisited?s.lastFrameVisited>e.lastFrameVisited?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?1:-1:s.loadingState!==e.loadingState?s.loadingState>e.loadingState?-1:1:s.hasUnrenderableContent!==e.hasUnrenderableContent?s.hasUnrenderableContent?-1:1:s.error!==e.error?s.error>e.error?-1:1:0};class dm{rootLoadingState=Br;rootTileSet=null;rootURL=null;fetchOptions={};frameCount=0;isLoading=!1;lruCache;loadQueue;processNodeQueue;plugins=[];_queuedTiles=[];_cachedSinceLoadComplete=new Set;_processedTiles=new WeakSet;_visibleTiles=new Set;_usedSet=new Set;_cacheHits=0;_cacheMisses=0;stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0,inCacheSinceLoad:0};errorTarget=16;errorThreshold=1;maxDepth=30;displayActiveTiles=!1;onRootTileLoaded;rtcOffset=null;_root=null;_activeTiles=new Set;_delayedHideTiles=new Set;_delayedVisibleTiles=new Set;_delayedActiveTiles=new Set;group;cameras=[];_cameraMap=new Map;_cameraInfo=[];_upRotationMatrix=new R;_ellipsoid;_bytesUsed=new WeakMap;_eventListeners=new Map;performanceStats={updateTime:0,traverseTime:0,markUsedTime:0,markVisibleTime:0,toggleTime:0,queueProcessTime:0};constructor(e=null){this.rootURL=e,this.lruCache=new du,this.lruCache.unloadPriorityCallback=Au,this.loadQueue=new il,this.loadQueue.maxJobs=10,this.loadQueue.priorityCallback=mu,this.processNodeQueue=new il,this.processNodeQueue.maxJobs=25,this.group=new ne,this.group.name="TilesRendererGroup"}get root(){return this._root}get loadProgress(){const{stats:e,isLoading:t}=this,a=e.downloading,r=e.inCacheSinceLoad+(t?1:0);return r===0?1:1-a/r}update(){const{lruCache:e,_usedSet:t,stats:a,loadQueue:r,processNodeQueue:i}=this;this.rootLoadingState===Br&&(this.rootLoadingState=al,this.isLoading=!0,this._loadRootTileSet().then(c=>{if(this.rootLoadingState=La,this.rootTileSet=c,c.root){const f=this._getBasePath(this.rootURL||""),d=this.preprocessNode(c.root,f,null);this.queueTileForDownload(d),this._root=d;const h=new Xr(d.boundingVolume),u=new Lr;h.getSphere(u);const m=new Ce;if(h.getAABB(m),this.rtcOffset=new b(-u.center.x,-u.center.y,-u.center.z),this.onRootTileLoaded)try{this.onRootTileLoaded({center:u.center,radius:u.radius,boundingBox:m,rtcOffset:this.rtcOffset})}catch(g){console.warn("Failed to calculate bounding volume for root tile:",g)}}this.dispatchEvent({type:"load-tile-set",tileSet:c,url:this.rootURL})}).catch(c=>{this.rootLoadingState=_r,console.error("Failed to load root tileset:",c),this.dispatchEvent({type:"load-error",tile:null,error:c,url:this.rootURL})}));const n=this.root;if(!n)return;a.inFrustum=0,a.used=0,a.active=0,a.visible=0,this.frameCount++,t.forEach(c=>e.markUnused(c)),t.clear(),this.updateCameraInfo(),this._checkDelayedHideTiles(),this._checkDelayedActiveTiles(),this._checkDelayedVisibleTiles(),en(n,this),cl(n,this),tn(n,this),an(n,this);const o=this._queuedTiles;e.unloadPriorityCallback&&o.sort(e.unloadPriorityCallback);for(let c=0,f=o.length;c<f&&!e.isFull();c++)this.requestTileContents(o[c]);o.length=0,r.update(),i.update(),e.scheduleUnload(),(r.running||i.running)===!1&&this.isLoading===!0&&(this._cachedSinceLoadComplete.clear(),a.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}),this.isLoading=!1)}traverse(e,t,a=!0){this.root&&hu(this.root,(r,i,n)=>(a&&this.ensureChildrenArePreprocessed(r,!0),e?e(r,i,n):!1),t)}registerPlugin(e){if(this.plugins.includes(e))return;const t=e.priority||0;let a=this.plugins.length;for(let r=0;r<this.plugins.length;r++)if((this.plugins[r].priority||0)>t){a=r;break}this.plugins.splice(a,0,e),e.init&&e.init(this)}unregisterPlugin(e){const t=this.plugins;let a;if(typeof e=="string"?a=t.find(r=>r.name===e):a=e,a&&t.includes(a)){const r=t.indexOf(a);return t.splice(r,1),a.dispose&&a.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}calculateTileViewError(e,t){const a=e.cached,r=this.cameras,i=this._cameraInfo,n=a.boundingVolume;if(!n){t.inView=!1,t.error=1/0,t.distanceFromCamera=1/0;return}let o=!1,l=-1/0,c=1/0,f=-1/0,d=1/0;const h=a.worldTransform;for(let u=0,m=r.length;u<m;u++){const g=i[u];let p,D;if(g.isOrthographic){const B=g.pixelSize;p=e.geometricError/B,D=1/0}else{const B=g.sseDenominator;D=n.distanceToPoint(g.position,h),p=D===0?1/0:e.geometricError/(D*B)}const A=i[u].frustum;n.intersectsFrustum(A,h)&&(o=!0,l=Math.max(l,p),c=Math.min(c,D)),f=Math.max(f,p),d=Math.min(d,D)}o?(t.inView=!0,t.error=l,t.distanceFromCamera=c):(t.inView=!1,t.error=f,t.distanceFromCamera=d)}updateCameraInfo(){this._updateCameraInfo()}_updateCameraInfo(){const e=this.cameras,t=this._cameraInfo,a=this._cameraMap;for(;t.length<e.length;)t.push({position:new b,frustum:new On,isOrthographic:!1});for(let r=0;r<e.length;r++){const i=e[r],n=t[r],o=a.get(i);if(!o)continue;const l=i.transform.worldPosition;if(n.position.copyFrom(l),n.frustum=i.frustum,n.isOrthographic=i.type===nt.ortho,n.isOrthographic){const c=i.frustumSize;n.pixelSize=c/o.height}else{const f=i.fov*Math.PI/180;n.sseDenominator=2*Math.tan(f/2)/o.height}}}preprocessNode(e,t,a=null){if(this._processedTiles.has(e))return e;this._processedTiles.add(e);let r;if(e instanceof rl?r=e:r=new rl(e,a),r.content){const c=r.content;!("uri"in c)&&"url"in c&&(c.uri=c.url,delete c.url)}if(r.basePath=t,r.boundingVolume){const c=new Xr(r.boundingVolume);r.cached.boundingVolume=c}const i=new b(r.boundingVolume.box[0],r.boundingVolume.box[1],r.boundingVolume.box[2]),n=new R;if(r.transform){const c=r.transform;for(let f=0;f<16;f++)n.rawData[f]=c[f]}if(!a){n.copyFrom(this._upRotationMatrix);const c=new b;c.copyFrom(i),c.applyMatrix4(n);const f=r.cached.boundingVolume.box,d=[new b(f.min.x,f.min.y,f.min.z),new b(f.max.x,f.min.y,f.min.z),new b(f.min.x,f.max.y,f.min.z),new b(f.max.x,f.max.y,f.min.z),new b(f.min.x,f.min.y,f.max.z),new b(f.max.x,f.min.y,f.max.z),new b(f.min.x,f.max.y,f.max.z),new b(f.max.x,f.max.y,f.max.z)];for(const m of d)m.applyMatrix4(n);const h=new Ce;d.forEach(m=>{h.expandByPoint(m)}),n.rawData[12]=-c.x,n.rawData[13]=-c.y,n.rawData[14]=-c.z;const u=h.min;n.rawData[13]-=u.y}const o=new R;o.copyFrom(n),a&&a.cached.worldTransform&&o.multiplyMatrices(a.cached.worldTransform,n);const l=new R;if(l.copyFrom(o),l.invert(),r.cached.transfrom=n,r.cached.worldTransform=o,r.cached.transformInverse=l,e.children&&e.children.length>0){r.children=[];for(let c=0;c<e.children.length;c++){const f=e.children[c],d=this.preprocessNode(f,t,r);r.children.push(d)}r.childrenProcessed=r.children.length}return r}ensureChildrenArePreprocessed(e,t=!1){const a=e.children;for(let r=0,i=a.length;r<i;r++){const n=a[r];n.basePath!==void 0&&n.basePath!==""||n.cached.boundingVolume||(t?(this.processNodeQueue.remove(n),this.preprocessNode(n,e.basePath,e)):this.processNodeQueue.has(n)||this.processNodeQueue.add(n,o=>{this.preprocessNode(o,e.basePath,e)}))}}_recordCacheHit(){this._cacheHits++}_recordCacheMiss(){this._cacheMisses++}resetCacheStats(){this._cacheHits=0,this._cacheMisses=0}requestTileContents(e){if(e.loadingState!==Br){this._recordCacheHit();return}if(this.lruCache.isFull()){this._recordCacheMiss();return}this._recordCacheMiss(),e.loadingState=al,this.stats.downloading++;const t=e.content||e.contents&&e.contents[0];if(!t||!t.uri){e.loadingState=_r,this.stats.downloading--,this.stats.failed++;return}const a=e.basePath||"",r=t.uri,i=this._resolveURL(a,r);this.loadQueue.add(e,async n=>{try{await this.parseTileContent(n,r,i),this.stats.downloading--}catch(o){n.loadingState=_r,this.stats.downloading--,this.stats.failed++,console.error("Failed to load tile:",o)}})}async parseTileContent(e,t,a){e.loadingState=cu;const i=(c=>{const f=c.split(".");return f.length>1?f[f.length-1]:""})(t),n=a;let o=null;const l=new It;switch(i.toLowerCase()){case"b3dm":{o=(await l.load(n,So,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"i3dm":{o=(await l.load(n,Eo,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"glb":case"gltf":{o=(await l.load(n,xt,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"pnts":{o=(await l.load(n,tu,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"json":try{const c=await _.res.loadJSON(n);e.children.length=0,e.childrenProcessed=0;const f=this._getBasePath(n);if(c.root){const d=this.preprocessNode(c.root,f,e);e.children.push(d),e.childrenProcessed=1,this.dispatchEvent({type:"load-tile-set",tileSet:c,url:n})}e.loadingState=La;return}catch(c){console.error("Failed to load external tileset:",c),e.loadingState=_r,this.stats.failed++;return}break;default:console.warn(`Unknown tile format: ${i}`);break}if(o){e.cached.scene=o;const c=this._estimateBytesUsed(o);this._bytesUsed.set(o,c),this.lruCache.setMemoryUsage(e,c),this.lruCache.has(e)||this.lruCache.add(e,f=>{if(f.cached.scene){const d=f.cached.scene;d.parent&&d.parent.object3D.removeChild(d),d.destroy(!0),f.cached.scene=null}f.loadingState=Br}),this.setTileImmediateActive(e),e.active=!0,e.__wasSetActive=!0,this.stats.active++,this.setTileImmediateVisible(e),e.visible=!0,e.__wasSetVisible=!0,this.stats.visible++,e.loadingState=La,e.usedLastFrame=!0,tn(e,this),an(e,this)}else e.loadingState=_r,this.stats.failed++}markTileUsed(e){this._usedSet.add(e),this.lruCache.markUsed(e)}setTileDelayedActive(e,t){t?(this._activeTiles.add(e),this._delayedHideTiles.has(e)&&this._delayedHideTiles.delete(e),this._delayedActiveTiles.has(e)||this._delayedActiveTiles.add(e)):(this._activeTiles.delete(e),this._delayedHideTiles.has(e)||this._delayedHideTiles.add(e),this._delayedActiveTiles.has(e)&&this._delayedActiveTiles.delete(e))}setTileImmediateActive(e){if(e.hasRenderableContent){const t=e.cached.scene;t&&(this.group.entityChildren.includes(t)||(t.parent&&t.parent.object3D.removeChild(t),this.group.addChild(t)),e.cached.worldTransform&&this._applyWorldTransform(t.transform,e.cached.worldTransform))}}setTileImmediateVisible(e){if(e.hasRenderableContent){const t=e.cached.scene;t&&(t.transform.enable=!0)}}_checkDelayedHideTiles(){if(this.stats.downloading===0)for(const e of this._delayedHideTiles){const t=e.cached.scene;t&&(t.transform.enable=!1,this._delayedHideTiles.delete(e))}}_checkDelayedActiveTiles(){for(const e of this._delayedActiveTiles)if(e.hasRenderableContent){const t=e.cached.scene;t&&(this.group.entityChildren.includes(t)||(t.parent&&t.parent.object3D.removeChild(t),this.group.addChild(t)),e.cached.worldTransform&&this._applyWorldTransform(t.transform,e.cached.worldTransform),this._delayedActiveTiles.delete(e))}else this._delayedActiveTiles.delete(e)}_checkDelayedVisibleTiles(){for(const e of this._delayedVisibleTiles)if(e.hasRenderableContent){const t=e.cached.scene;t&&(t.transform.enable=!0,this._delayedVisibleTiles.delete(e))}else this._delayedVisibleTiles.delete(e)}setTileDelayedVisible(e,t){t?(this._visibleTiles.add(e),this._delayedHideTiles.has(e)&&this._delayedHideTiles.delete(e),this._delayedVisibleTiles.has(e)||this._delayedVisibleTiles.add(e)):(this._visibleTiles.delete(e),this._delayedHideTiles.has(e)||this._delayedHideTiles.add(e),this._delayedVisibleTiles.has(e)&&this._delayedVisibleTiles.delete(e))}queueTileForDownload(e){e.loadingState!==Br||this.lruCache.isFull()||this._queuedTiles.push(e)}dispatchEvent(e){const t=this._eventListeners.get(e.type);t&&t.forEach(a=>{try{a(e)}catch(r){console.error("Error in event listener:",r)}})}async _loadRootTileSet(){if(!this.rootURL)throw new Error("Root URL is not set");const e=await _.res.loadJSON(this.rootURL);return e.asset&&e.asset.gltfUpAxis&&this._setupUpAxisRotation(e.asset.gltfUpAxis),e}_setupUpAxisRotation(e){const t=new R;switch(e.toLowerCase()){case"x":t.makeRotationAxis(b.Y_AXIS,-Math.PI/2);break;case"y":t.identity();break;case"z":t.makeRotationAxis(b.X_AXIS,-Math.PI/2);break;default:console.warn(`Unknown gltfUpAxis: ${e}, using default`),t.identity();break}this._upRotationMatrix=t}_applyLocalTransform(e,t){const a=t.decompose(na.EULER_ANGLES);e.localPosition=a[0];const r=new se;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_applyWorldTransform(e,t){const a=t.decompose(na.EULER_ANGLES);e.localPosition=a[0];const r=new se;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_getBasePath(e){const t=e.lastIndexOf("/");return t!==-1?e.substring(0,t):""}_resolveURL(e,t){return t.startsWith("http://")||t.startsWith("https://")?t:e+"/"+t}_getUrlExtension(e){const t=e.split(".");return t.length>1?t[t.length-1]:""}getMemoryStats(){const e=this.lruCache.getStats(),t=this.lruCache.maxBytesSize,a=e.bytes,r=t-a,i=this._cacheHits+this._cacheMisses,n=i>0?this._cacheHits/i:0;return{totalTiles:e.size,loadedTiles:e.usedCount,cachedTiles:e.size,totalBytes:t,usedBytes:a,freeBytes:r,cacheHitRate:n}}getLoadedTiles(){const e=[];return this.traverse(t=>(t.loadingState===La&&e.push(t),!1),null),e}getVisibleTiles(){return Array.from(this._visibleTiles)}getActiveTiles(){return Array.from(this._activeTiles)}getTileTreeStats(){let e=0,t=0,a=0,r=0,i=0,n=0;return this.traverse(o=>(e++,o.loadingState===La&&t++,o.visible&&a++,o.active&&r++,i=Math.max(i,o.depth),n+=o.depth,!1),null),{totalTiles:e,loadedTiles:t,visibleTiles:a,activeTiles:r,maxDepth:i,averageDepth:e>0?n/e:0}}printDebugInfo(){const e=this.stats,t=this.getMemoryStats(),a=this.getTileTreeStats(),r=this.performanceStats,i=this.lruCache.getStats();console.log("=== TilesRenderer Debug Info ==="),console.log("Stats:",e),console.log("Memory:",t),console.log("Tree:",a),console.log("Performance:",r),console.log("Cache:",i),console.log("Queues:",{load:this.loadQueue.getStats(),process:this.processNodeQueue.getStats()})}setPerformanceOptions(e){e.lruCacheMinSize!==void 0&&(this.lruCache.minSize=e.lruCacheMinSize),e.lruCacheMaxSize!==void 0&&(this.lruCache.maxSize=e.lruCacheMaxSize),e.lruCacheMinBytes!==void 0&&(this.lruCache.minBytesSize=e.lruCacheMinBytes),e.lruCacheMaxBytes!==void 0&&(this.lruCache.maxBytesSize=e.lruCacheMaxBytes),e.lruCacheUnloadPercent!==void 0&&(this.lruCache.unloadPercent=e.lruCacheUnloadPercent),e.downloadQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.downloadQueueMaxJobs),e.parseQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.parseQueueMaxJobs),e.processQueueMaxJobs!==void 0&&(this.processNodeQueue.maxJobs=e.processQueueMaxJobs),e.enablePerformanceStats!==void 0&&(this._enablePerformanceStats=e.enablePerformanceStats),e.enableCacheStats!==void 0&&(this._enableCacheStats=e.enableCacheStats)}dispose(e){[...this.plugins].forEach(a=>this.unregisterPlugin(a)),this.lruCache.clear(),this.loadQueue.clear(),this.processNodeQueue.clear(),this._root=null,this.rootTileSet=null,this.rootLoadingState=Br,this.frameCount=0,this.isLoading=!1,this.resetCacheStats(),this.group.destroy(e)}setCamera(e,t,a){this.cameras.includes(e)||this.cameras.push(e),this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}deleteCamera(e){const t=this.cameras.indexOf(e);t!==-1&&this.cameras.splice(t,1),this._cameraMap.delete(e),this._updateCameraInfo()}setResolution(e,t,a){const r=this._cameraMap.get(e);r?(r.width=t,r.height=a):this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}forEachLoadedModel(e){this.traverse(t=>(t.loadingState===La&&t.cached.scene&&e(t.cached.scene,t),!1),null)}_estimateBytesUsed(e){let t=0;return e.forChild(a=>{const r=a.getComponent(he);r&&r.geometry&&(t+=1024),r&&r.material&&(t+=512)}),t}addEventListener(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.get(e).push(t)}removeEventListener(e,t){const a=this._eventListeners.get(e);if(a){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}async loadTileSet(e,t){const r=(e.endsWith("/")?e.slice(0,-1):e)+"/"+t;this.rootURL=r}get modelList(){const e=[];return this.forEachLoadedModel(t=>{e.push(t)}),e}}class hm{asset;extras;geometricError;properties;refine;root;extensionsUsed;extensionsRequired;extensions}class um{boundingVolume;children;geometricError;transform;content;contents;refine;extensions;extras}class bm{boundingVolume;geometricError;refine;content;contents;children;transform;extensions;extras}class gm{uri;group;metadata}class pm{class;properties}function mm(s,e){let t=0,a=null;return function(...r){const i=Date.now(),n=i-t;n>=e?(t=i,s.apply(this,r)):(a!==null&&clearTimeout(a),a=window.setTimeout(()=>{t=Date.now(),s.apply(this,r),a=null},e-n))}}class Am extends vt{static count=0;constructor(){super(),Y.register("ColorLitShader",Jd),this.shader=new At;let e=new qe("ColorLitShader","ColorLitShader");e.passType=fe.COLOR,this.shader.addRenderPass(e),e.setDefine("USE_BRDF",!0),e.setShaderEntry("VertMain","FragMain"),e.setUniformColor("baseColor",new J),e.setUniformColor("emissiveColor",new J),e.setUniformFloat("envIntensity",1),e.setUniformFloat("normalScale",1),e.setUniformFloat("roughness",0),e.setUniformFloat("metallic",0),e.setUniformFloat("ao",1),e.setUniformFloat("alphaCutoff",0);let t=e.shaderState;t.acceptShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,e.setTexture("normalMap",_.res.normalTexture),e.setTexture("emissiveMap",_.res.blackTexture)}clone(){return null}debug(){}}class Dm extends vt{constructor(){super();let e=new qe("LambertShader","LambertShader");e.setShaderEntry("VertMain","FragMain"),e.passType=fe.COLOR,e.setUniformVector4("transformUV1",new be(0,0,1,1)),e.setUniformVector4("transformUV2",new be(0,0,1,1)),e.setUniformColor("baseColor",new J(1,1,1,1)),e.setUniformFloat("alphaCutoff",.5);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1;let a=new At;a.addRenderPass(e),this.shader=a,this.baseMap=_.res.grayTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}function _m(s,e){}class Bm extends vt{constructor(){super(),this.shader=new $i,this.baseMap=_.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set shadowMap(e){}}class fl{clipName;loopTime;startTime;stopTime;sampleRate;useSkeletonPos;useSkeletonScale;positionCurves=new Map;rotationCurves=new Map;scaleCurves=new Map;floatCurves=new Map;formBytes(e){if(this.clipName=e.readUTF(),this.loopTime=!e.readInt32(),this.startTime=e.readFloat32(),this.stopTime=e.readFloat32(),this.sampleRate=e.readInt32(),this.useSkeletonPos=e.readInt32()>0,this.useSkeletonScale=e.readInt32()>0,this.useSkeletonPos){let r=e.readInt32();for(let i=0;i<r;i++){let n=new xr;n.formBytes(e),this.positionCurves.set(n.path,n)}}let t=e.readInt32();for(let r=0;r<t;r++){let i=new xr;i.formBytes(e),this.rotationCurves.set(i.path,i)}if(this.useSkeletonScale){let r=e.readInt32();for(let i=0;i<r;i++){let n=new xr;n.formBytes(e),this.scaleCurves.set(n.path,n)}}let a=e.readInt32();for(let r=0;r<a;r++){let i=new xr;i.formBytes(e),this.floatCurves.set(i.attribute,i)}}}class xr{path;attribute;propertys;preInfinity;postInfinity;rotationOrder;m_curves;k=0;_cacheValue;_kValue;constructor(e=1){this.k=e,this.m_curves=[],this.check()}check(){for(let e=0;e<this.k;e++)this.m_curves[e]||=new Li;switch(this.k){case 1:this._cacheValue=0;break;case 2:this._cacheValue=new de;break;case 3:this._cacheValue=new b;break;case 4:this._cacheValue=new be;break}}get totalTime(){return this.m_curves[0].totalTime}addKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].addKeyFrame(e.getK(t))}removeKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].removeKeyFrame(e.getK(t))}getValue(e){switch(this.k){case 1:this._cacheValue=this.m_curves[0].getValue(e);break;case 2:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e);break;case 3:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e),this._cacheValue.z=this.m_curves[2].getValue(e);break;case 4:const t=this.m_curves[0].getCurveFramesExtent(e),a=t.lhsIndex,r=t.rhsIndex;e=t.time;let i=this.m_curves[0].getKey(a),n=this.m_curves[0].getKey(r);e%=this.m_curves[0].totalTime;let o=(e-i.time)/(n.time-i.time);se.HELP_0.set(this.m_curves[0].getKey(a).value,this.m_curves[1].getKey(a).value,this.m_curves[2].getKey(a).value,this.m_curves[3].getKey(a).value),se.HELP_1.set(this.m_curves[0].getKey(r).value,this.m_curves[1].getKey(r).value,this.m_curves[2].getKey(r).value,this.m_curves[3].getKey(r).value),se.HELP_2.slerp(se.HELP_0,se.HELP_1,o),this._cacheValue.x=se.HELP_2.x,this._cacheValue.y=se.HELP_2.y,this._cacheValue.z=se.HELP_2.z,this._cacheValue.w=se.HELP_2.w;break}return this._cacheValue}getKeyCount(){return this.m_curves[0].getKeyCount()}getKey(e){let t=[];for(let a=0;a<this.k;a++)t.push(this.m_curves[a].getKey(e));return t}formBytes(e){this.path=e.readUTF(),this.k=e.readInt32(),this.check(),this.attribute=e.readUTF(),this.propertys=this.attribute.split("."),this.preInfinity=e.readInt32(),this.postInfinity=e.readInt32(),this.rotationOrder=e.readInt32();let t=e.readInt32();for(let a=0;a<t;a++){let r=new as(0);r.formBytes(e),this.addKeyFrame(r)}}}class vm extends Map{negtive;constructor(e){if(super(e),this.negtive=new Map,e)for(let t of e)this.negtive.set(t[1],t[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.negtive.delete(t),super.delete(e)}return!1}getKey(e){return this.negtive.get(e)}deleteValue(e){let t=this.negtive.get(e);return t&&this.delete(t),this.negtive.delete(e)}set(e,t){return super.set(e,t),this.negtive.set(t,e),this}clear(){this.negtive.clear(),super.clear()}}class xm{colorArray;constructor(e){this.colorArray=e}getColor(e){let t=e*this.colorArray.length,a=Math.floor(t),r=Math.min(a+1,this.colorArray.length-1),i=this.colorArray[a],n=this.colorArray[r];return J.lerp(t-a,i,n)}}class rn{controlVertices;constructor(e){this.setControlVertices(e)}setControlVertices(e){e.length==4&&(this.controlVertices=e.concat())}getPoint(e){if(!(e>=0&&e<=1))return b.ZERO;let t=1-e,a=t*t*t,r=3*e*t*t,i=3*e*e*t,n=e*e*e;return this.controlVertices[0].mul(a).add(this.controlVertices[1].mul(r)).add(this.controlVertices[2].mul(i)).add(this.controlVertices[3].mul(n))}getTangent(e){if(!(e>=0&&e<=1))return b.ZERO;let t=this.controlVertices,a=t[0].add(t[1].add(t[0]).mul(e)),r=t[1].add(t[2].add(t[1]).mul(e)),i=t[2].add(t[3].add(t[2]).mul(e)),n=a.add(r.subtract(a).mul(e));return r.add(i.subtract(r).mul(e)).subtract(n)}getClosestParam(e,t=1e-6){return this.getClosestParamRec(e,0,1,t)}getClosestParamRec(e,t,a,r){let i=(t+a)/2;if(a-t<r)return i;let n=(t+i)/2,o=(i+a)/2,l=this.getPoint(n),c=this.getPoint(o),f=l.subtract(e).lengthSquared,d=c.subtract(e).lengthSquared;return f<d?a=i:t=i,this.getClosestParamRec(e,t,a,r)}}var Du=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(Du||{});class Um{type=0;numCurveSegments=0;numControlVertices=0;controlVertices=[];constructor(e,t=0){this.setControlVertices(e,t)}getPathType(){return this.type}isClosed(){return this.type==1}isValid(){return this.numCurveSegments>0}clear(){this.controlVertices.length=0,this.type=0,this.numCurveSegments=0,this.numControlVertices=0}computeApproxLength(){if(!this.isValid())return 0;let e=this.numCurveSegments+1;if(e<2)return 0;let t=0,a=this.controlVertices;for(let r=1;r<e;r++){let i=a[(r-1)*3],n=a[r*3];t+=i.subtract(n).lengthSquared}return t==0?0:t}computeApproxParamPerUnitLength(){let e=this.computeApproxLength();return this.numCurveSegments/e}computeApproxNormParamPerUnitLength(){return 1/this.computeApproxLength()}interpolatePoints(e,t){let a=e.length;a<2&&console.error("point count must great 1"),this.clear(),this.type=t;let r=this.controlVertices;switch(t){case 0:{this.numCurveSegments=a-1,this.numControlVertices=3*a-2,r.length=this.numControlVertices;for(let o=0;o<a;o++)r[o*3]=e[o];let i=e[1].subtract(e[0]).mul(.25);r[1]=e[0].add(i);let n=e[a-2].subtract(e[a-1]).mul(.25);r[this.numControlVertices-2]=e[a-1].add(n);for(let o=1;o<this.numCurveSegments;o++){let l=e[o-1].subtract(e[o]),c=e[o+1].subtract(e[o]),f=l.lengthSquared,d=c.lengthSquared;if(f>0&&d>0){let h=(f+d)/8,u=c.div(d).subtract(l.div(f));u.normalize(),u=u.mul(h),r[o*3-1]=e[o].subtract(u),r[o*3+1]=e[o].add(u)}else r[o*3-1]=e[o],r[o*3+1]=e[o]}break}case 1:{this.numCurveSegments=a,this.numControlVertices=3*a+1,r.length=this.numControlVertices;for(let i=0;i<a;i++)r[i*3]=e[i];r[this.numControlVertices-1]=e[0];for(let i=1;i<=this.numCurveSegments;i++){let n=i-1,o=(i+1)%this.numCurveSegments,l=i%this.numCurveSegments,c=e[n].subtract(e[l]),f=e[o].subtract(e[l]),d=c.lengthSquared,h=f.lengthSquared,u=3*i-1,m=(3*i+1)%(this.numControlVertices-1);if(d>0&&h>0){let g=(d+h)/8,p=f.div(h).subtract(c.div(d));p.normalize(),p=p.mul(g),r[u]=e[l].subtract(p),r[m]=e[l].add(p)}else r[u]=e[l],r[m]=e[l]}break}}}setControlVertices(e,t){let a=e.length;a<=0||t==0&&a<4||t==1&&a<7||(a-1)%3==0&&(this.clear(),this.type=t,this.numControlVertices=a,this.numCurveSegments=(a-1)/3,this.controlVertices=e)}getPoint(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=Gt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=[],r=this.controlVertices;return a[0]=r[3*t+0],a[1]=r[3*t+1],a[2]=r[3*t+2],a[3]=r[3*t+3],new rn(a).getPoint(e-t)}getPointNorm(e){return this.getPoint(e*this.numCurveSegments)}getTangent(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=Gt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=this.controlVertices,r=[];return r[0]=a[3*t+0],r[1]=a[3*t+1],r[2]=a[3*t+2],r[3]=a[3*t+3],new rn(r).getTangent(e-t)}getTangentNorm(e){return this.getTangent(e*this.numCurveSegments)}computeClosestParam(e,t){let a=Number.MAX_SAFE_INTEGER,r=0,i=[],n=new rn(i);for(let o=0;o<this.controlVertices.length-1;o+=3){for(let d=0;d<4;d++)i[d]=this.controlVertices[o+d];n.setControlVertices(i);let l=n.getClosestParam(e,t),f=n.getPoint(l).subtract(e).lengthSquared;f<a&&(a=f,r=o/3+l)}return r}computeClosestNormParam(e,t){return this.computeClosestParam(e,t*this.numCurveSegments)}}class ym extends Map{valueList;keyList;isChange=!0;constructor(e,t,a){if(super(e),t&&(this.keyList=[]),a&&(this.valueList=[]),e)for(let r of e)this.valueList?.push(r[1]),this.keyList?.push(r[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.valueList&&this.deleteValue(t),this.keyList&&this.deleteKey(e),this.isChange=!0,super.delete(e)}return!1}deleteValue(e){let t=this.valueList.indexOf(e);return t>=0&&this.valueList.splice(t,1),this}deleteKey(e){let t=this.keyList.indexOf(e);return t>=0&&this.keyList.splice(t,1),this}set(e,t){return this.delete(e),this.keyList?.push(e),this.valueList?.push(t),super.set(e,t),this.isChange=!0,this}clear(){this.valueList&&(this.valueList.length=0),this.keyList&&(this.keyList.length=0),this.isChange=!0,super.clear()}}var _u=(s=>(s[s.kParticleSystemClampVelocityCurveId=322376503]="kParticleSystemClampVelocityCurveId",s[s.kParticleSystemForceCurveId=306581307]="kParticleSystemForceCurveId",s[s.kParticleSystemRotationCurveId=1793934638]="kParticleSystemRotationCurveId",s[s.kParticleSystemRotationBySpeedCurveId=3737431713]="kParticleSystemRotationBySpeedCurveId",s[s.kParticleSystemStartSpeedCurveId=2527743459]="kParticleSystemStartSpeedCurveId",s[s.kParticleSystemSizeCurveId=2368504881]="kParticleSystemSizeCurveId",s[s.kParticleSystemSizeBySpeedCurveId=4085612399]="kParticleSystemSizeBySpeedCurveId",s[s.kParticleSystemVelocityCurveId=3774601268]="kParticleSystemVelocityCurveId",s[s.kParticleSystemUVCurveId=326370691]="kParticleSystemUVCurveId",s[s.kParticleSystemColorGradientId=1494990940]="kParticleSystemColorGradientId",s[s.kParticleSystemColorByVelocityGradientId=1089181156]="kParticleSystemColorByVelocityGradientId",s[s.kParticleSystemMeshSelectionId=3159510623]="kParticleSystemMeshSelectionId",s[s.kParticleSystemUVRowSelectionId=2941263940]="kParticleSystemUVRowSelectionId",s))(_u||{});const Cm=3.141592653589793;class Sm{}function Bu(s,e,t){let a=.3333333333333333,r=.5,i=s*a,n=i*i,l=n*i-i*e*r+t*r,c=-n+e*a,f=c*c*c,d=f+l*l;if(d>=0){let m=Math.sqrt(d)-l;return m=m>0?Math.pow(m,a):-Math.pow(-m,a),-i-c/m+m}let h=Math.sqrt(-f),u=Math.acos(-l/h);return h=Math.pow(h,a),h=h-c/h,u=-i+h*Math.cos(u*a),u}function sn(s,e,t,a){let r=1e-5;if(Math.abs(s)<r)return Math.abs(e)>r?(a.r0=-t/e,1):0;let i=e*e-4*s*t;if(i<0)return 0;let n=.5/s,o=Math.sqrt(i);return a.r0=(o-e)*n,a.r1=(-o-e)*n,2}function vu(s,e,t,a,r){let i=0;if(Math.abs(e)>=1e-4){let n=t/e,o=a/e,l=r/e;s[0]=Bu(n,o,l),i++;let c=e,f=t+e*s[0],d=a+t*s[0]+e*s[0]*s[0];i+=sn(c,f,d,{r0:s[1],r1:s[2]})}else i+=sn(t,a,r,{r0:s[1],r1:s[2]});return i}class Ga{coeff=[];static EvalSegment(e,t){return e*(e*(e*t[0]+t[1])+t[2])+t[3]}}class nr{static kMaxNumSegments=8;segments=[];integrationCache=[];doubleIntegrationCache=[];times=[];segmentCount;constructor(){this.segments[nr.kMaxNumSegments]=new Ga,this.integrationCache[nr.kMaxNumSegments]=0,this.doubleIntegrationCache[nr.kMaxNumSegments]=0,this.times[nr.kMaxNumSegments]=0}calculateMinMax(e,t){e.x=Math.min(e.x,t),e.y=Math.max(e.y,t)}findMinMaxDoubleIntegrated(){let e=de.ZERO.clone(),t=20,a=1/t,r=a;for(let i=0;i<t;i++)this.calculateMinMax(e,this.evaluateDoubleIntegrated(r)),r+=a;return e}findMinMaxIntegrated(){let e=de.ZERO.clone(),t=[],a=[];for(let r=0;r<this.segmentCount;r++){let i=4*this.segments[r].coeff[0],n=3*this.segments[r].coeff[1],o=2*this.segments[r].coeff[2],l=1*this.segments[r].coeff[3],c=[],f=vu(c,i,n,o,l);for(let d=0;d<f;d++){let h=c[d]+t[r];h>=t[r]&&h<a[r]&&this.calculateMinMax(e,this.evaluateIntegrated(h))}this.calculateMinMax(e,this.evaluateIntegrated(a[r])),this.times[r]}return e}generateIntegrationCache(e){e.integrationCache[0]=0;let t=e.times[0],a=0;for(let r=1;r<e.segmentCount;r++){let i=e.segments[r-1].coeff;dl(i);let n=t-a;e.integrationCache[r]=e.integrationCache[r-1]+Ga.EvalSegment(n,i)*n,a=t,t=e.times[r]}}generateDoubleIntegrationCache(e){let t=0,a=0;for(let r=0;r<e.segmentCount;r++){e.doubleIntegrationCache[r]=t;let i=e.times[r]-a;i=Math.max(i,0),t+=Ga.EvalSegment(i,e.segments[r].coeff)*i*i+e.integrationCache[r]*i,a=e.times[r]}}integrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)dl(this.segments[e].coeff)}doubleIntegrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)xu(this.segments[e].coeff);this.generateDoubleIntegrationCache(this)}static isValidCurve(e){let t=e.getKeyCount(),a=t-1;return e.getKey(0).time!=0&&a++,e.getKey(t-1).time!=1&&a++,a<=nr.kMaxNumSegments}evaluateDoubleIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.doubleIntegrationCache[a]+this.integrationCache[a]*r+Ga.EvalSegment(r,this.segments[a].coeff)*r*r}t=this.times[a]}return 1}evaluateIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.integrationCache[a]+Ga.EvalSegment(r,this.segments[a].coeff)*r}t=this.times[a]}return 1}evaluate(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a])return Ga.EvalSegment(e-t,this.segments[a].coeff);t=this.times[a]}return 1}buildCurve(e,t){let a=e.getKeyCount();this.segmentCount=1;let r=1.01;if(this.segments.length=0,this.integrationCache.length=0,this.doubleIntegrationCache.length=0,this.times.length=0,this.times[0]=r,a!=0)if(a==1)this.segments[0]=new Ga,this.segments[0].coeff[3]=e.getKey(0).value*t;else{this.segmentCount=a-1;let i=0;e.getKey(0).time!=0&&(this.segments[0].coeff[3]=e.getKey(0).value,this.times[0]=e.getKey(0).time,i=1);for(let n=0;n<this.segmentCount;n++){let o;e.calculateCacheData(o,n,n+1,0),this.segments[n+i].coeff=o.coeff.concat(),this.times[n+i]=e.getKey(n+1).time}this.segmentCount+=i,e.getKey(a-1).time!=1&&(this.segments[this.segmentCount].coeff[3]=e.getKey(a-1).value,this.segmentCount++),this.times[this.segmentCount-1]=r;for(let n=0;n<this.segmentCount;n++)this.segments[n].coeff[0]*=t,this.segments[n].coeff[1]*=t,this.segments[n].coeff[2]*=t,this.segments[n].coeff[3]*=t}return!0}}function xu(s){s[0]/=20,s[1]/=12,s[2]/=6,s[3]/=2}function dl(s){s[0]/=4,s[1]/=3,s[2]/=2,s[3]/=1}var Uu=(s=>(s[s.kEMScalar=0]="kEMScalar",s[s.kEMOptimized=1]="kEMOptimized",s[s.kEMOptimizedMinMax=2]="kEMOptimizedMinMax",s[s.kEMSlow=3]="kEMSlow",s))(Uu||{}),yu=(s=>(s[s.kMMCScalar=0]="kMMCScalar",s[s.kMMCCurve=1]="kMMCCurve",s[s.kMMCTwoCurves=2]="kMMCTwoCurves",s[s.kMMCTwoConstants=3]="kMMCTwoConstants",s))(yu||{});class Fm{max;min}class km{max;min;integrate(){this.max.integrate(),this.min.integrate()}doubleIntegrate(){this.max.doubleIntegrate(),this.min.doubleIntegrate()}findMinMaxIntegrated(){return null}findMinMaxDoubleIntegrated(){return null}}class Cu{minMaxState;minCurve;maxCurve;_scalar=1;_minScalar;constructor(e=1){this._scalar=e,this.minMaxState=0,this.minCurve=new Li,this.maxCurve=new Li}setScalar(e){this._scalar=e}getScalar(){return this._scalar}static evaluateSlow(e,t,a){let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==2?Mr(e.minCurve.getValue(t)*e.getScalar(),r,a):r}static evaluate(e,t,a=1){if(e.minMaxState==0)return e.getScalar();let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==1?Mr(e.minCurve.getValue(t)*e.getScalar(),r,a):e.minMaxState==3?Mr(e._minScalar,e._scalar,a):e.minMaxState==2?Mr(e.minCurve.getValue(t)*e.getScalar(),r,1*Math.random()):this.evaluateSlow(e,t,1)}unSerialized(e){this.minMaxState=e.minMaxState,this._scalar=e.scalar,this._minScalar=e.minScalar,this.maxCurve.unSerialized(e.maxCurve),this.minCurve.unSerialized(e.minCurve)}}class Em{value=0;mode=0;spread=0;speed=new Cu;unSerialized(e){this.value=e.value,this.mode=e.mode,this.spread=e.spread,this.speed.unSerialized(e.speed)}}function wm(s,e){let t=nr.isValidCurve(s.max);return e!=2&&e!=3?t:t&&nr.isValidCurve(s.min)}function Im(s,e,t,a){s.max.buildCurve(e.max,t),a!=2&&a!=3?s.min.buildCurve(e.max,t):s.min.buildCurve(e.min,t)}function Rm(s,e){let t=e.getKeyCount();if(t!=0)if(t==1)es(s,e.getKey(0).value);else{let a=t-1;es(s,e.getKey(0).value);for(let r=0;r<a;r++){let i=new Lo;e.calculateCacheData(i,r,r+1,0);let n=3*i.coeff[0],o=2*i.coeff[1],l=1*i.coeff[2],c=e.getKey(r).time,f=e.getKey(r+1).time,d=[],h=sn(n,o,l,{r0:d[0],r1:d[1]});for(let u=0;u<h;u++)d[u]>=0&&d[u]+c<f&&es(s,Ga.EvalSegment(d[u],i.coeff));es(s,Ga.EvalSegment(f-c,i.coeff))}}}function es(s,e){s.x=Math.min(s.x,e),s.y=Math.max(s.y,e)}class Vr{static BACK=0;static FRONT=1;static IN=0;static OUT=1;static INTERSECT=2}class Su{a;b;c;d;static ALIGN_ANY=0;static ALIGN_XY_AXIS=1;static ALIGN_YZ_AXIS=2;static ALIGN_XZ_AXIS=3;constructor(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}setTo(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}fromPoints(e,t,a){var r=t.x-e.x,i=t.y-e.y,n=t.z-e.z,o=a.x-e.x,l=a.y-e.y,c=a.z-e.z;this.a=i*c-n*l,this.b=n*o-r*c,this.c=r*l-i*o,this.d=-(this.a*e.x+this.b*e.y+this.c*e.z)}fromNormalAndPoint(e,t){this.a=e.x,this.b=e.y,this.c=e.z,this.d=-(this.a*t.x+this.b*t.y+this.c*t.z)}normalize(){var e=Math.sqrt(this.a*this.a+this.b*this.b+this.c*this.c);if(e>0){var t=1/e;this.a*=t,this.b*=t,this.c*=t,this.d*=t}return e}distance(e){return this.a*e.x+this.b*e.y+this.c*e.z+this.d}classifyPoint(e,t=.01){var a=this.distance(e);return a<-t?Vr.BACK:a>t?Vr.FRONT:Vr.INTERSECT}toString(){return"Plane3D [a:"+this.a+", b:"+this.b+", c:"+this.c+", d:"+this.d+"]"}}function Qm(s,e){return Math.random()*e+Math.random()*s+(e-s)*Math.random()}function Tm(s,e,t){let a=t*Math.random();return Math.random()*e*a+Math.random()*s*a+(e-s)*Math.random()*a}function Fu(s,e,t){let a=0,r=0;for(;a===0;)a=Math.random();for(;r===0;)r=Math.random();let i=Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*r);return i=i/10+.5,(i>1||i<0)&&(i=Fu(s,e,t)),i=Math.pow(i,t),i*=e-s,i+=s,i}function Ca(s){return s>0?Math.floor(s):Math.floor(s)-1}let Ue=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];function hl(s,e){let t=s&15,a=1+(t&7);return t&8&&(a=-a),a*e}function nn(s,e,t){let a=s&7,r=a<4?e:t,i=a<4?t:e;return(a&1?-r:r)+(a&2?-2*i:2*i)}function ts(s,e,t,a){let r=s&15,i=r<8?e:t,n=r<4?t:r==12||r==14?e:a;return(r&1?-i:i)+(r&2?-n:n)}function _i(s,e,t,a,r){let i=s&31,n=i<24?e:t,o=i<16?t:a,l=i<8?a:r;return(i&1?-n:n)+(i&2?-o:o)+(i&4?-l:l)}let ea=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]];function Mm(s){let e=Ca(s),t=e+1,a=s-e,r=a-1,i,n,o=1-a*a;o*=o,i=o*o*hl(Ue[e&255],a);let l=1-r*r;return l*=l,n=l*l*hl(Ue[t&255],r),.25*(i+n)}function Nm(s,e){const t=.366025403,a=.211324865;let r,i,n,o=(s+e)*t,l=s+o,c=e+o,f=Ca(l),d=Ca(c),h=(f+d)*a,u=f-h,m=d-h,g=s-u,p=e-m,D,A;g>p?(D=1,A=0):(D=0,A=1);let B=g-D+a,v=p-A+a,U=g-1+2*a,y=p-1+2*a,S=f&255,F=d&255,C=.5-g*g-p*p;C<0?r=0:(C*=C,r=C*C*nn(Ue[S+Ue[F]],g,p));let w=.5-B*B-v*v;w<0?i=0:(w*=w,i=w*w*nn(Ue[S+D+Ue[F+A]],B,v));let E=.5-U*U-y*y;return E<0?n=0:(E*=E,n=E*E*nn(Ue[S+1+Ue[F+1]],U,y)),40*(r+i+n)}function Pm(s,e,t){const a=.333333333,r=.166666667;let i,n,o,l,c=(s+e+t)*a,f=s+c,d=e+c,h=t+c,u=Ca(f),m=Ca(d),g=Ca(h),p=(u+m+g)*r,D=u-p,A=m-p,B=g-p,v=s-D,U=e-A,y=t-B,S,F,C,w,E,Q;v>=U?U>=y?(S=1,F=0,C=0,w=1,E=1,Q=0):v>=y?(S=1,F=0,C=0,w=1,E=0,Q=1):(S=0,F=0,C=1,w=1,E=0,Q=1):U<y?(S=0,F=0,C=1,w=0,E=1,Q=1):v<y?(S=0,F=1,C=0,w=0,E=1,Q=1):(S=0,F=1,C=0,w=1,E=1,Q=0);let T=v-S+r,j=U-F+r,ue=y-C+r,ee=v-w+2*r,N=U-E+2*r,M=y-Q+2*r,O=v-1+3*r,W=U-1+3*r,ae=y-1+3*r,z=u&255,K=m&255,$=g&255,re=.6-v*v-U*U-y*y;re<0?i=0:(re*=re,i=re*re*ts(Ue[z+Ue[K+Ue[$]]],v,U,y));let ce=.6-T*T-j*j-ue*ue;ce<0?n=0:(ce*=ce,n=ce*ce*ts(Ue[z+S+Ue[K+F+Ue[$+C]]],T,j,ue));let Ae=.6-ee*ee-N*N-M*M;Ae<0?o=0:(Ae*=Ae,o=Ae*Ae*ts(Ue[z+w+Ue[K+E+Ue[$+Q]]],ee,N,M));let Qe=.6-O*O-W*W-ae*ae;return Qe<0?l=0:(Qe*=Qe,l=Qe*Qe*ts(Ue[z+1+Ue[K+1+Ue[$+1]]],O,W,ae)),32*(i+n+o+l)}function Vm(s,e,t,a){const r=.309016994,i=.138196601;let n,o,l,c,f,d=(s+e+t+a)*r,h=s+d,u=e+d,m=t+d,g=a+d,p=Ca(h),D=Ca(u),A=Ca(m),B=Ca(g),v=(p+D+A+B)*i,U=p-v,y=D-v,S=A-v,F=B-v,C=s-U,w=e-y,E=t-S,Q=a-F,T=C>w?32:0,j=C>E?16:0,ue=w>E?8:0,ee=C>Q?4:0,N=w>Q?2:0,M=E>Q?1:0,O=T+j+ue+ee+N+M,W,ae,z,K,$,re,ce,Ae,Qe,Ve,H,ie;W=ea[O][0]>=3?1:0,ae=ea[O][1]>=3?1:0,z=ea[O][2]>=3?1:0,K=ea[O][3]>=3?1:0,$=ea[O][0]>=2?1:0,re=ea[O][1]>=2?1:0,ce=ea[O][2]>=2?1:0,Ae=ea[O][3]>=2?1:0,Qe=ea[O][0]>=1?1:0,Ve=ea[O][1]>=1?1:0,H=ea[O][2]>=1?1:0,ie=ea[O][3]>=1?1:0;let le=C-W+i,ge=w-ae+i,Ie=E-z+i,me=Q-K+i,ye=C-$+2*i,Se=w-re+2*i,Me=E-ce+2*i,Ze=Q-Ae+2*i,$e=C-Qe+3*i,ct=w-Ve+3*i,ja=E-H+3*i,ba=Q-ie+3*i,Ra=C-1+4*i,Xt=w-1+4*i,Qa=E-1+4*i,Ta=Q-1+4*i,Pt=p&255,ga=D&255,pa=A&255,ra=B&255,wr=.6-C*C-w*w-E*E-Q*Q;wr<0?n=0:(wr*=wr,n=wr*wr*_i(Ue[Pt+Ue[ga+Ue[pa+Ue[ra]]]],C,w,E,Q));let Ir=.6-le*le-ge*ge-Ie*Ie-me*me;Ir<0?o=0:(Ir*=Ir,o=Ir*Ir*_i(Ue[Pt+W+Ue[ga+ae+Ue[pa+z+Ue[ra+K]]]],le,ge,Ie,me));let Rr=.6-ye*ye-Se*Se-Me*Me-Ze*Ze;Rr<0?l=0:(Rr*=Rr,l=Rr*Rr*_i(Ue[Pt+$+Ue[ga+re+Ue[pa+ce+Ue[ra+Ae]]]],ye,Se,Me,Ze));let Qr=.6-$e*$e-ct*ct-ja*ja-ba*ba;Qr<0?c=0:(Qr*=Qr,c=Qr*Qr*_i(Ue[Pt+Qe+Ue[ga+Ve+Ue[pa+H+Ue[ra+ie]]]],$e,ct,ja,ba));let Tr=.6-Ra*Ra-Xt*Xt-Qa*Qa-Ta*Ta;return Tr<0?f=0:(Tr*=Tr,f=Tr*Tr*_i(Ue[Pt+1+Ue[ga+1+Ue[pa+1+Ue[ra+1]]]],Ra,Xt,Qa,Ta)),27*(n+o+l+c+f)}class Dl extends de{static uv_0=new Dl;u=0;v=0;constructor(e=0,t=0){super(e,t),this.u=e,this.v=t}length(){return 0}static getUVSheet(e,t,a){let r=Math.floor(e%(t*a)),i=Math.floor(r/t),n=r%t;return new be(i/t,n/a,1/t,1/a)}}class as{serializedVersion="2";time;tangentMode=0;weightedMode=0;propertyKeyFrame;constructor(e=0){this.time=e,this.propertyKeyFrame={}}getK(e){return this.propertyKeyFrame[e]}split(e,t,a){switch(e){case X.single:{let r=this.getKeyFrame(0);r[a]=t}break;case X.float:{let r=this.getKeyFrame(0);r[a]=t}break;case X.vector2:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y}break;case X.vector3:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z}break;case X.vector4:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break;case X.quaternion:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break}}getKeyFrame(e){let t=this.propertyKeyFrame[e];return t||(t=new Js,t.time=this.time,t.tangentMode=this.tangentMode,t.weightedMode=this.weightedMode,this.propertyKeyFrame[e]=t),t}formBytes(e){this.time=e.readFloat32();{let{t,v:a}=Wa.parser(e);this.split(t,a,"value")}{let{t,v:a}=Wa.parser(e);this.split(t,a,"inSlope")}{let{t,v:a}=Wa.parser(e);this.split(t,a,"outSlope")}this.tangentMode=e.readInt32(),this.weightedMode=e.readInt32();{let{t,v:a}=Wa.parser(e);this.split(t,a,"inWeight")}{let{t,v:a}=Wa.parser(e);this.split(t,a,"outWeight")}}}class Om{static sub(e,t){switch(e.constructor.name){case"number":return e-t;case"Vector2":{let r=e,i=t;return new de(r.x-i.x,r.y-i.y)}case"Vector3":{let r=e,i=t;return new b(r.x-i.x,r.y-i.y,r.z-i.z)}case"Vector4":{let r=e,i=t;return new be(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}case"Quaternion":{let r=e,i=t;return new se(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}}}}class rs{_keys=new Array;_values=new Array;getIndexByKey(e){return this._keys.indexOf(e)}getValueByKey(e){var t=this.getIndexByKey(e);return t>-1?this._values[t]:null}put(e,t){if(e==null)return null;var a=this.remove(e);return this._keys.push(e),this._values.push(t),a}remove(e){var t=this._keys.indexOf(e),a;return t>-1&&(a=this._values[t],this._keys.splice(t,1),this._values.splice(t,1)),a}getValues(){return this._values}getKeys(){return this._keys}clear(){this._values.length=0,this._keys.length=0}}class Ur{static WalkAble=1}class is{static SetConst(e){this.EPSILON=e,this.POWER_EPSILON=e*e}static EPSILON=.1;static POWER_EPSILON=this.EPSILON*this.EPSILON}class Qt extends b{static CALC_VECTOR3D1=new b;static CALC_VECTOR3D2=new b;static CALC_VECTOR3D3=new b;static CALC_VECTOR3D4=new b;static CALC_VECTOR3D5=new b;_pointId=0;constructor(e,t,a,r){super(t,a,r,0),this._pointId=e}get id(){return this._pointId}static equalPoint(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)+(e.z-t.z)*(e.z-t.z)<is.POWER_EPSILON}static calcDistance(e,t){return Qt.CALC_VECTOR3D3.setTo(e.x-t.x,e.y-t.y,e.z-t.z),Qt.CALC_VECTOR3D3.length}}class ku{_openedList;_closedList;_endNode;_startNode;_triangleChannel;_navMesh;_findIndex=0;constructor(){this._openedList=new Array,this._closedList=new Array}findPath(e,t,a){return this._findIndex++,this._navMesh=e,this._startNode=t,this._endNode=a,this._openedList.length=0,this._closedList.length=0,this._startNode&&this._endNode?(this._startNode.gg=0,this._startNode.h=0,this._startNode.f=0,this._startNode.parent=null,this.search()):!1}search(){for(var e=this._startNode,t=[],a;e!=this._endNode;){t=e.getNeibourTriangles(t,Ur.WalkAble,Ur.WalkAble);for(a of t)if(a.closeId!=this._findIndex&&!(a==e||!a.walkAble)){var r=e.gg+Qt.calcDistance(a,e)*a.costMultiplier,i=Qt.calcDistance(a,this._endNode),n=r+i;a.openId==this._findIndex?a.f>n&&(a.f=n,a.gg=r,a.h=i,a.parent=e):(a.f=n,a.gg=r,a.h=i,a.parent=e,a.openId=this._findIndex,this._openedList.push(a))}if(e.closeId=this._findIndex,this._closedList.push(e),this._openedList.length==0)return!1;this._openedList.sort(function(o,l){return o.f-l.f}),e=this._openedList.shift()}return this.buildPath(),!0}buildPath(){this._triangleChannel=[];var e=this._endNode;for(this._triangleChannel.push(e);e!=this._startNode;)e=e.parent,this._triangleChannel.unshift(e)}get channel(){return this._triangleChannel}}class Fa extends Qt{_ownerPoint;_ownerEdge;radius=0;constructor(e,t){super(e.id,0,0,0),this._ownerEdge=t,this._ownerPoint=e}get ownerPoint(){return this._ownerPoint}get ownerEdge(){return this._ownerEdge}scalePoint(e=.7){var t=new Fa(this._ownerPoint,this._ownerEdge);return t.copyFrom(this),t.decrementBy(this._ownerPoint),t.scaleBy(e),t.radius=t.length,t.incrementBy(this._ownerPoint),t}}class Ea{_edgeMask=0;_edgeSize=0;_pointA;_pointB;_triangleOwners;_centerPoint;_edgeDirA2B;crossPoint;fatPointA;fatPointB;static CALC_FAT_VECTOR=new b;constructor(e,t){if(this._pointA=e,this._pointB=t,e.id>=t.id)throw new Error("edge point order error!!!");this._triangleOwners=new Array,this._centerPoint=new b,this._edgeMask=Ur.WalkAble,Qt.CALC_VECTOR3D1.setTo(e.x-t.x,e.y-t.y,e.z-t.z),this._edgeSize=Qt.CALC_VECTOR3D1.length,this._centerPoint.setTo((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2)}get size(){return this._edgeSize}get triangleOwners(){return this._triangleOwners}get centerPoint(){return this._centerPoint}initFatPoints(e){this._edgeDirA2B=this._pointB.subtract(this._pointA),this._edgeDirA2B.normalize(),this.fatPointA=this.fatPointA||new Fa(this._pointA,this),this.fatPointB=this.fatPointB||new Fa(this._pointB,this),this.fatPointA.radius!=e&&(Ea.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Ea.CALC_FAT_VECTOR.scaleBy(e),Ea.CALC_FAT_VECTOR.incrementBy(this._pointA),this.fatPointA.copyFrom(Ea.CALC_FAT_VECTOR),this.fatPointA.radius=e),this.fatPointB.radius!=e&&(Ea.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Ea.CALC_FAT_VECTOR.scaleBy(-e),Ea.CALC_FAT_VECTOR.incrementBy(this._pointB),this.fatPointB.copyFrom(Ea.CALC_FAT_VECTOR),this.fatPointB.radius=e)}getFatPoint(e){return e==this._pointA?this.fatPointA:this.fatPointB}getAnotherFatPoint(e){return e==this._pointA?this.fatPointB:this.fatPointA}getAnotherPoint(e){return e==this._pointA?this._pointB:this._pointA}containsPoint(e){return Qt.equalPoint(e,this._pointA)?this._pointA:Qt.equalPoint(e,this._pointB)?this._pointB:null}addTriangleOwners(e){if(e.edges.indexOf(this)==-1)throw new Error("the edge is not belong triangle!!!");this._triangleOwners.indexOf(e)==-1&&this._triangleOwners.push(e)}getPublicPoint(e){return this._pointA==e._pointA||this._pointA==e._pointB?this._pointA:this._pointB==e._pointA||this._pointB==e._pointB?this._pointB:null}getEqualPoint(e){return Qt.equalPoint(e,this._pointA)?this._pointA:Qt.equalPoint(e,this._pointB)?this._pointB:null}get pointA(){return this._pointA}get pointB(){return this._pointB}get walkAble(){return(this._edgeMask&Ur.WalkAble)==Ur.WalkAble}testMask(e){return(this._edgeMask&e)==e}}class _e{endPoint;curPoint;rayA;rayB;rayAPoint;rayBPoint;static RAY_1=new b;static RAY_2=new b;static TEST_RAY=new b;static TEST_RAY_1=new b;static TEST_RAY_2=new b;static CALC_CROSS_POINT=new b;static CALC_CROSS_TEST=new b;cornerPoint;cornerEdge;continuePass(e,t,a){this.resetData(),this.curPoint=e,this.endPoint=t,this.cornerEdge=a}passEdge(e,t,a,r){if((this.rayA==null||this.rayB==null)&&(this.rayA=_e.RAY_1,this.rayB=_e.RAY_2,this.rayAPoint=e.pointA,this.rayBPoint=e.pointB,this.rayA.setTo(this.rayAPoint.x-this.curPoint.x,0,this.rayAPoint.z-this.curPoint.z),this.rayB.setTo(this.rayBPoint.x-this.curPoint.x,0,this.rayBPoint.z-this.curPoint.z)),r)return this.checkEndPoint(a);if(_e.TEST_RAY.setTo(a.x-this.curPoint.x,0,a.z-this.curPoint.z),this.isPointAtCenter(_e.TEST_RAY,this.rayA,this.rayB)){this.hasCrossPoint(t.pointA,t.pointB,this.rayAPoint,this.rayA)?(this.rayB.copyFrom(_e.TEST_RAY),a instanceof Qt?this.rayBPoint=a:this.rayBPoint=null):(this.rayA.copyFrom(_e.TEST_RAY),a instanceof Qt?this.rayAPoint=a:this.rayAPoint=null);var i=t.getAnotherPoint(a);_e.TEST_RAY.setTo(i.x-this.curPoint.x,0,i.z-this.curPoint.z),(i==this.rayAPoint||i==this.rayBPoint||this.isPointAtCenter(_e.TEST_RAY,this.rayA,this.rayB))&&(this.cornerEdge=t)}else{var n;if(_e.TEST_RAY_1.copyFrom(t.pointA),_e.TEST_RAY_1.decrementBy(this.curPoint),_e.TEST_RAY_2.copyFrom(t.pointB),_e.TEST_RAY_2.decrementBy(this.curPoint),_e.TEST_RAY_1.y=0,_e.TEST_RAY_2.y=0,this.isPointAtCenter(this.rayA,_e.TEST_RAY_1,_e.TEST_RAY_2)||this.isPointAtCenter(this.rayB,_e.TEST_RAY_1,_e.TEST_RAY_2)?n=!1:n=!0,n)return this.isPointAtCenter(this.rayA,_e.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1}return!0}checkEndPoint(e){return _e.TEST_RAY.setTo(e.x-this.curPoint.x,0,e.z-this.curPoint.z),this.isPointAtCenter(_e.TEST_RAY,this.rayA,this.rayB)?!0:(this.isPointAtCenter(this.rayA,_e.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1)}calcCrossEdge(e,t,a){return this.calcCrossPoint(e.fatPointA,e.fatPointB,t,a)}calcCrossPoint(e,t,a,r){_e.CALC_CROSS_POINT.copyFrom(t),_e.CALC_CROSS_POINT.decrementBy(e);let i=_e.CALC_CROSS_POINT.x*r.z-r.x*_e.CALC_CROSS_POINT.z;var n=0;return i!=0&&(n=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/i),n>1?n=1:n<0&&(n=0),_e.CALC_CROSS_POINT.scaleBy(n),_e.CALC_CROSS_POINT.incrementBy(e),_e.CALC_CROSS_POINT.clone()}calcCrossPointOut(e,t,a,r){_e.CALC_CROSS_POINT.copyFrom(t),_e.CALC_CROSS_POINT.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(_e.CALC_CROSS_POINT.x*r.z-r.x*_e.CALC_CROSS_POINT.z);return i<=1&&i>=0?null:(_e.CALC_CROSS_POINT.scaleBy(i),_e.CALC_CROSS_POINT.incrementBy(e),_e.CALC_CROSS_POINT.clone())}hasCrossPoint(e,t,a,r){_e.CALC_CROSS_TEST.copyFrom(t),_e.CALC_CROSS_TEST.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(_e.CALC_CROSS_TEST.x*r.z-r.x*_e.CALC_CROSS_TEST.z);return i<=1&&i>=0}isPointAtCenter(e,t,a){var r=t.crossProduct(e);if(r.length==0&&e.length<t.length)return!0;var i=a.crossProduct(e);return i.length==0&&e.length<a.length?!0:(r.normalize(),i.normalize(),r.incrementBy(i),r.length<.01)}resetData(){this.cornerEdge=null,this.cornerPoint=null,this.curPoint=null,this.rayA=this.rayB=null,this.rayAPoint=this.rayBPoint=null,_e.RAY_1.setTo(0,0,0),_e.RAY_2.setTo(0,0,0)}}class sr{_aiRadius=0;_router;_result;_tempPublicEdgeList=new Array;_tempSamePlaneList=new Array;static CROSS_TEST_DIRECTION=new b;constructor(){this._router=new _e}searchPath(e,t,a,r=0){return r<=0&&(r=1),this._aiRadius=r*1.5,this.searchEnable(e,t,a)?(this.search(e,t,a),!0):!1}get path(){return this._result}searchEnable(e,t,a){return!(e==null||t==null||a==null||a[0].plane.classifyPoint(e,is.EPSILON)!=Vr.INTERSECT||a[a.length-1].plane.classifyPoint(t,is.EPSILON)!=Vr.INTERSECT)}search(e,t,a){this._tempPublicEdgeList.length=0,this._tempSamePlaneList.length=0;var r=0,i=a.length-1,n,o,l,c;for(r=0;r<i;r++)o=a[r].getPublicEdge(a[r+1]),o.crossPoint=null,o.initFatPoints(this._aiRadius),this._tempPublicEdgeList.push(o),n=a[r],c=n.plane,n=a[r+1],l=n.getEdgeAgainstPoint(o),this._tempSamePlaneList.push(c.classifyPoint(l,is.EPSILON)==Vr.INTERSECT);this._router.continuePass(e,t,this._tempPublicEdgeList[0]),i=this._tempPublicEdgeList.length;var f,d,h,u;for(r=0;r<i;r++)o=this._tempPublicEdgeList[r],n=a[r+1],u=r==i-1,u?l=t:l=n.getEdgeAgainstPoint(o),h=this._router.passEdge(o,this._tempPublicEdgeList[r+1],l,u),h||(f=this._router.cornerPoint,d=this._router.cornerEdge,r=this._tempPublicEdgeList.indexOf(d),this._router.continuePass(f,t,this._tempPublicEdgeList[r+1]));this.pushAllPathPoint2(e,t),this._result.length>=3&&(this.optimusTerminusFat(),this.optimusByRadius());let m=[];for(let g of this._result)m.push(new b().copyFrom(g));this._result=m}optimusTerminusFat(){var e,t,a;a=this._result[1],a instanceof Fa&&(e=a),a=this._result[this._result.length-2],a instanceof Fa&&(t=a),e&&(this._result[1]=e.scalePoint()),t&&e!=t&&(this._result[this._result.length-2]=t.scalePoint())}pushAllPathPoint2(e,t){var a=this._tempPublicEdgeList.length,r,i;this._result=new Array,this._result.push(e);for(var n=e,o,l,c,f=0;f<a;f++)if(r=this._tempPublicEdgeList[f],l=null,r.crossPoint)l=this.getFatPoint(r,r.crossPoint),l?this._result.push(l):this._result.push(r.crossPoint),n=r.crossPoint;else{i=null,o=null;for(var d=f+1;d<a&&(i=this._tempPublicEdgeList[d],o=i.crossPoint,!o);d++);o==null&&(o=t),l=this.getFatPoint(r,o),l?this._result.push(l):(o==n?c=o.clone():(sr.CROSS_TEST_DIRECTION.setTo(o.x-n.x,0,o.z-n.z),c=this._router.calcCrossEdge(r,n,sr.CROSS_TEST_DIRECTION)),this._result.push(c))}this._result.push(t)}optimusByRadius(){var e=new Array;e.length=this._result.length;var t=this._result.length-2,a,r,i,n,o,l,c,f,d,h,u,m,g;for(g=0;g<t;g++)c=f=d=null,n=o=l=null,u=!1,m=null,a=this._result[g],r=this._result[g+1],i=this._result[g+2],a instanceof Fa&&(n=a),r instanceof Fa&&(o=r),i instanceof Fa&&(l=i),n&&(c=n.ownerPoint),o&&(f=o.ownerPoint),l&&(d=l.ownerPoint),c&&f&&c==f&&f!=d&&(u=!0),d&&f&&d==f&&c!=f&&(u=!0),u&&(sr.CROSS_TEST_DIRECTION.copyFrom(a),sr.CROSS_TEST_DIRECTION.decrementBy(i),h=o.ownerEdge,u=this._router.hasCrossPoint(h.pointA,h.pointB,i,sr.CROSS_TEST_DIRECTION),u&&(m=this._router.calcCrossPointOut(f,r,i,sr.CROSS_TEST_DIRECTION)),m&&(e[g+1]=m))}getFatPoint(e,t){if(e==null)return null;var a;t instanceof Fa&&(a=t);var r;return a?r=a.ownerPoint:r=e.getEqualPoint(t),r==null?null:(a=e.getFatPoint(r),a)}}class Eu extends b{_id=0;_plane;_points=new Array;_edges=new Array;_neibourTriangles=new rs;_pointAgainstEdge=new rs;_edgeAgainstPoint=new rs;_mask=0;_aabbBox;f=0;gg=0;h=0;parent;costMultiplier=1;openId=0;closeId=0;get aabb(){return this._aabbBox}initAABB(){this._aabbBox=new Nt,this._aabbBox.addPoint(this._points[0]),this._aabbBox.addPoint(this._points[1]),this._aabbBox.addPoint(this._points[2])}calcGlobalQuadAABB(){}get isTriangle(){return!0}constructor(e,t,a,r){super(0,0,0,0),this._id=e,this._mask=Ur.WalkAble,this._edges.push(t,a,r);var i;for(i of this._edges)this._points.indexOf(i.pointA)==-1&&this._points.push(i.pointA),this._points.indexOf(i.pointB)==-1&&this._points.push(i.pointB);this.x=(this._points[0].x+this._points[1].x+this._points[2].x)/3,this.y=(this._points[0].y+this._points[1].y+this._points[2].y)/3,this.z=(this._points[0].z+this._points[1].z+this._points[2].z)/3,this._plane=new Su,this._plane.fromPoints(this._points[0],this._points[1],this._points[2]),this._plane.normalize(),this.genarateAgainstData(),this.initAABB()}genarateAgainstData(){var e,t;for(e of this._edges)for(t of this._points)e.pointA!=t&&e.pointB!=t&&(this._edgeAgainstPoint.put(e,t),this._pointAgainstEdge.put(t,e))}get id(){return this._id}get plane(){return this._plane}get points(){return this._points}addNeibour(e,t){if(this._edges.indexOf(e)>=0)this._neibourTriangles.put(e,t);else throw new Error("the edge is not in triangle!!!")}getNeibourTriangles(e=null,t=1,a=1){e=e||new Array,e.length=0;var r,i,n=this._neibourTriangles.getKeys(),o;for(o of n)i=o,i.testMask(t)&&(r=this._neibourTriangles.getValueByKey(i),r.testMask(a)&&e.push(r));return e}getEdges(e=null,t=1){e=e||new Array,e.length=0;var a;for(a of this._edges)a.testMask(t)&&e.push(a);return e}get walkAble(){return this.testMask(Ur.WalkAble)}get edges(){return this._edges}testMask(e){return(this._mask&e)==e}getEdgeAgainstPoint(e){return this._edgeAgainstPoint.getValueByKey(e)}getPointAgainstEdge(e){return this._pointAgainstEdge.getValueByKey(e)}getPublicEdge(e){if(e&&e!=this){var t=this._neibourTriangles.getKeys(),a;for(a of t)if(this._neibourTriangles.getValueByKey(a)==e)return a}return null}loopPublicEdge(e){var t,a;if(e&&e!=this){for(t of this._edges)for(a of e._edges)if(t==a)return t}return null}randomPoint(){var e=this._points[2].subtract(this._points[0]);e.scaleBy(Math.random()),e.incrementBy(this._points[0]);var t=this._points[1].subtract(e);return t.scaleBy(Math.random()),t.incrementBy(e),t}}class Lm{_nav3dPoints;_nav3dEdges;_nav3dTriangles;_path;_edgesDict;_nav3dAstar;_nav3dFunnel;_terrainQuad;_triangleList;get edges(){return this._nav3dEdges}get points(){return this._nav3dPoints}get path(){return this._path}get triangles(){return this._nav3dTriangles}constructor(e,t){this._nav3dPoints=new Array,this._nav3dEdges=new Array,this._nav3dTriangles=new Array,this._edgesDict=new rs,this.initPoints(e),this.initEdgesAndTriangles(t),this.createConnections(),this._nav3dAstar=new ku,this._nav3dFunnel=new sr,this._terrainQuad=new Mh(8,128),this._terrainQuad.createQuadTree(this._nav3dTriangles)}getTriangleAtPoint(e,t=5){return this._terrainQuad.getTriangleAtPoint(e,t)}findPath(e,t,a=5){this._path=null,this._triangleList=null;var r=this.getTriangleAtPoint(e,10),i=this.getTriangleAtPoint(t,10),n=this._nav3dAstar.findPath(this,r,i);return n?(this._triangleList=this._nav3dAstar.channel,n=this._nav3dFunnel.searchPath(e,t,this._triangleList,a),this._path=this._nav3dFunnel.path,n):!1}initPoints(e){for(var t,a,r=e.length,i=0;i<r;i++)t=e[i],a=new Qt(i,t.x,t.y,t.z),this._nav3dPoints.push(a)}initEdgesAndTriangles(e){for(var t,a,r,i,n,o=e.length,l=0;l<o;l++)t=e[l],a=this.tryCreateEdge(t[0],t[1]),r=this.tryCreateEdge(t[1],t[2]),i=this.tryCreateEdge(t[2],t[0]),!(a==null||r==null||i==null)&&(n=new Eu(l,a,r,i),this._nav3dTriangles.push(n))}tryCreateEdge(e,t){if(e==t)throw new Error("edge point index error!!!");if(e>t){var a=e;e=t,t=a}var r=this._edgesDict.getValueByKey(e+"_"+t);return r==null&&(r=new Ea(this._nav3dPoints[e],this._nav3dPoints[t]),this._nav3dEdges.push(r),this._edgesDict.put(e+"_"+t,r)),r}createConnections(){for(var e=this._nav3dTriangles.length,t=this._nav3dTriangles.length,a,r,i,n,o=0;o<e;o++){a=this._nav3dTriangles[o];for(i of a.edges)i.addTriangleOwners(a);for(var l=0;l<t;l++)r=this._nav3dTriangles[l],a!=r&&(n=a.loopPublicEdge(r),n&&(a.addNeibour(n,r),r.addNeibour(n,a)))}}}class _l{x;y;setTo(e,t){this.x=e,this.y=t}equals(e,t){return e==this.x&&t==this.y}equalPoint(e){return this.equals(e.x,e.y)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y)}clone(){var e=new _l;return e.setTo(this.x,this.y),e}normalize(){var e=length;e!=0&&this.setTo(this.x/e,this.y/e)}}class za extends Le{width;height;depth;constructor(e=1,t=1,a=1){super(),this.width=e,this.height=t,this.depth=a,this.initVertex()}initVertex(){let e=this.width/2,t=this.height/2,a=this.depth/2;this.bounds=new Ce(b.ZERO.clone(),new b(this.width,this.height,this.depth));let r=new Float32Array([-e,t,a,e,t,a,e,t,-a,-e,t,-a,-e,t,a,e,t,-a,e,-t,a,-e,-t,a,-e,-t,-a,e,-t,-a,e,-t,a,-e,-t,-a,-e,-t,a,-e,t,a,-e,t,-a,-e,-t,-a,-e,-t,a,-e,t,-a,e,t,a,e,-t,a,e,-t,-a,e,t,-a,e,t,a,e,-t,-a,e,t,a,-e,t,a,-e,-t,a,-e,-t,a,e,-t,a,e,t,a,e,-t,-a,-e,-t,-a,-e,t,-a,e,t,-a,e,-t,-a,-e,t,-a]),i=new Float32Array([0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1]),n=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),o=[0,2,1,3,5,4,6,8,7,9,11,10,12,14,13,15,17,16,18,20,19,21,23,22,24,26,25,27,29,28,30,32,31,33,35,34],l=new Uint16Array(o.reverse());this.setIndices(l),this.setAttribute(G.position,r),this.setAttribute(G.normal,i),this.setAttribute(G.uv,n),this.setAttribute(G.TEXCOORD_1,n),this.addSubGeometry({indexStart:0,indexCount:o.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class wu extends Le{radiusTop;radiusBottom;height;radialSegments;heightSegments;openEnded;thetaStart;thetaLength;constructor(e=1,t=1,a=1,r=8,i=8,n=!1,o=0,l=Math.PI*2){super(),this.radiusTop=e,this.radiusBottom=t,this.height=a,this.radialSegments=r,this.heightSegments=i,this.openEnded=n,this.thetaStart=o,this.thetaLength=l,this.instanceID=zt(),this.buildGeometry()}addGroup(e,t,a){this.addSubGeometry({indexStart:e,indexCount:t,vertexStart:e,vertexCount:0,firstStart:0,index:a,topology:0})}buildGeometry(){const e=this;this.radialSegments=Math.floor(this.radialSegments),this.heightSegments=Math.floor(this.heightSegments);const t=[],a=[],r=[],i=[];let n=0;const o=[],l=this.height/2;let c=0;m(),this.openEnded===!1&&(this.radiusTop>0&&g(!0),this.radiusBottom>0&&g(!1));let f=new Float32Array(t),d=new Float32Array(a),h=new Float32Array(r),u=new Uint16Array(i);this.setAttribute(G.position,f),this.setAttribute(G.normal,d),this.setAttribute(G.uv,h),this.setAttribute(G.TEXCOORD_1,h),this.setIndices(u);function m(){const p=new b,D=new b;let A=0;const B=(e.radiusBottom-e.radiusTop)/e.height;for(let v=0;v<=e.heightSegments;v++){const U=[],y=v/e.heightSegments,S=y*(e.radiusBottom-e.radiusTop)+e.radiusTop;for(let F=0;F<=e.radialSegments;F++){const C=F/e.radialSegments;let w=C*e.thetaLength+e.thetaStart;F==e.radialSegments&&Math.abs(e.thetaLength-e.thetaStart)==Math.PI*2&&(w=0);const E=Math.sin(w),Q=Math.cos(w);D.x=S*E,D.y=-y*e.height+l,D.z=S*Q,t.push(D.x,D.y,D.z),p.set(E,B,Q).normalize(),a.push(p.x,p.y,p.z),r.push(C,1-y),U.push(n++)}o.push(U)}for(let v=0;v<e.radialSegments;v++)for(let U=0;U<e.heightSegments;U++){const y=o[U][v],S=o[U+1][v],F=o[U+1][v+1],C=o[U][v+1];i.push(y,S,C),i.push(S,F,C),A+=6}e.addGroup(c,A,0),c+=A}function g(p){const D=n,A=new de,B=new b;let v=0;const U=p===!0?e.radiusTop:e.radiusBottom,y=p===!0?1:-1;for(let F=1;F<=e.radialSegments;F++)t.push(0,l*y,0),a.push(0,y,0),r.push(.5,.5),n++;const S=n;for(let F=0;F<=e.radialSegments;F++){const w=F/e.radialSegments*e.thetaLength+e.thetaStart,E=Math.cos(w),Q=Math.sin(w);B.x=U*Q,B.y=l*y,B.z=U*E,t.push(B.x,B.y,B.z),a.push(0,y,0),A.x=E*.5+.5,A.y=Q*.5*y+.5,r.push(A.x,A.y),n++}for(let F=0;F<e.radialSegments;F++){const C=D+F,w=S+F;p===!0?i.push(w,w+1,C):i.push(w+1,w,C),v+=3}e.addGroup(c,v,p===!0?1:2),c+=v}}}class Iu extends Le{radius;tube;radialSegments;tubularSegments;constructor(e=.4,t=.1,a=32,r=32){super(),this.radius=e,this.tube=t,this.radialSegments=a,this.tubularSegments=r,this.initVertex()}initVertex(){const e=2*Math.PI,t=this.radius,a=this.tube,r=this.radialSegments,i=this.tubularSegments;this.bounds=new Ce(b.ZERO.clone(),new b(t*2,a*2,t*2));var n=(r+1)*(i+1);let o=new Float32Array(n*3),l=new Float32Array(n*3),c=new Float32Array(n*2),f=new Uint16Array(r*i*2*3),d=0,h=0,u=0,m=0;for(let g=0;g<=r;g++)for(let p=0;p<=i;p++){const D=p/i,A=g/r,B=D*e,v=A*Math.PI*2;if(o[d++]=(t+a*Math.cos(v))*Math.sin(B),o[d++]=a*Math.sin(v),o[d++]=(t+a*Math.cos(v))*Math.cos(B),l[h++]=Math.sin(B)*Math.cos(v),l[h++]=Math.sin(v),l[h++]=Math.cos(B)*Math.cos(v),c[u++]=D,c[u++]=A,p<i&&g<r){const U=i+1,y=U*g+p,S=U*(g+1)+p,F=U*(g+1)+p+1,C=U*g+p+1;f[m++]=y,f[m++]=C,f[m++]=S,f[m++]=C,f[m++]=F,f[m++]=S}}this.setIndices(f),this.setAttribute(G.position,o),this.setAttribute(G.normal,l),this.setAttribute(G.uv,c),this.setAttribute(G.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Gm extends Le{segment;row=0;constructor(e){super(),this.segment=e,this.buildGeometry()}buildGeometry(){this.row=this.segment+1;let e=new Uint32Array(this.segment*6),t=new Float32Array(this.row*3*2),a=new Float32Array(this.row*3*2),r=new Float32Array(this.row*2*2);for(let i=0;i<this.row;i++){t[i*3*2+0]=0,t[i*3*2+1]=0,t[i*3*2+2]=0,t[i*3*2+3]=0,t[i*3*2+4]=0,t[i*3*2+5]=0,a[i*3*2+0]=0,a[i*3*2+1]=0,a[i*3*2+2]=1,a[i*3*2+3]=0,a[i*3*2+4]=0,a[i*3*2+5]=1,r[i*2*2+0]=0,r[i*2*2+1]=i/this.segment,r[i*2*2+2]=1,r[i*2*2+3]=i/this.segment;let n=i*2,o=n,l=n+1,c=n+2,f=n+3;e[i*6+0]=o,e[i*6+1]=l,e[i*6+2]=c,e[i*6+3]=l,e[i*6+4]=f,e[i*6+5]=c}this.setIndices(e),this.setAttribute(G.position,t),this.setAttribute(G.normal,a),this.setAttribute(G.uv,r),this.setAttribute(G.TEXCOORD_1,r),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class zm extends Le{faceCount=0;constructor(e){super(),this.faceCount=e,this.buildGeometry()}buildGeometry(){let e=new Uint32Array(this.faceCount*3),t=new Float32Array(this.faceCount*3*3),a=new Float32Array(this.faceCount*3*3),r=new Float32Array(this.faceCount*3*2),i=new Float32Array(this.faceCount*3*1);for(let n=0;n<this.faceCount;n++){let o=n*3+0,l=n*3+1,c=n*3+2;e[o]=o,e[l]=l,e[c]=c}this.setIndices(e),this.setAttribute(G.position,t),this.setAttribute(G.normal,a),this.setAttribute(G.uv,r),this.setAttribute(G.TEXCOORD_1,r),this.setAttribute(G.vIndex,i),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Wm extends Gs{_internalTexture;_minSize=32;_skyColor;constructor(e){super(),this._skyColor=e,this._internalTexture=new Ts;let t=[];return _.res.fillColor(t,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.create(this._minSize,this._minSize,t,!1),this.createFromTexture(this._minSize,this._internalTexture),this}changeColor(e){return this._skyColor=e,_.res.fillColor(this._internalTexture.floatArray,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.updateTexture(this._minSize,this._minSize,this._internalTexture.floatArray,!1),this._faceData.uploadTexture(0,this._internalTexture),this}get color(){return this._skyColor}set color(e){this.changeColor(e)}}class Jm extends ne{length=100;thickness=.1;constructor(e,t=.1){super(),this.length=e,this.thickness=t,this.init()}init(){let e=new ne,t=new ne,a=new ne,r=new za(2,2,2),i=new za(2,2,2),n=new za(2,2,2),o=new Bt;o.baseColor=new J(1,0,0);let l=new Bt;l.baseColor=new J(0,1,0);let c=new Bt;c.baseColor=new J(0,0,1);let f=e.addComponent(he),d=t.addComponent(he),h=a.addComponent(he);f.geometry=r,f.material=o,f.castShadow=!1,d.geometry=i,d.material=l,d.castShadow=!1,h.geometry=n,h.material=c,h.castShadow=!1,e.localScale=new b(this.length,this.thickness,this.thickness),e.x=this.length,t.localScale=new b(this.thickness,this.length,this.thickness),t.y=this.length,a.localScale=new b(this.thickness,this.thickness,this.length),a.z=this.length,this.addChild(e),this.addChild(t),this.addChild(a)}}class jm{static merge(e,t,a){}static mergeNumber(e,t,a){let r=a||new Le,i=e.getAttribute(G.position).data.length/3,n=new Float32Array(i*t);for(const f of e.vertexAttributeMap){let d=f[1].attribute;if(d==G.indices)continue;let h=e.getAttribute(d).data,u=h.length,m=new Float32Array(u*t);for(let g=0;g<t;g++){m.set(h,u*g);for(let p=0;p<i;p++)n[i*g+p]=g}r.setAttribute(d,m)}r.setAttribute(G.vIndex,n);let o=e.getAttribute(G.indices).data,l=o.length,c=new Uint32Array(o.length*t);for(let f=0;f<t;f++)for(let d=0;d<l;d++){let h=f*i,u=f*l;const m=o[d]+h;c[u+d]=m}return r.setIndices(c),r.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),r}static generateNormal(){}static generateTangent(){}static packUV(){}}class Zm extends ne{size=100;divisions=10;constructor(e=100,t=10){super(),this.size=e,this.divisions=t,this.buildGeometry(),this.addAxis()}buildGeometry(){const e=[],t=[],a=this.size/this.divisions,r=this.size/2,i=this.divisions/2;for(let c=0,f=-r;c<=this.divisions;c++,f+=a)c!==i&&(e.push(-r,0,f,r,0,f),e.push(f,0,-r,f,0,r));for(let c=0;c<e.length/3;c+=2)t.push(c,c+1);let n=new Le;n.setIndices(t.length>Uint16Array.length?new Uint32Array(t):new Uint16Array(t)),n.setAttribute(G.position,new Float32Array(e)),n.addSubGeometry({indexStart:0,indexCount:t.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let o=new Bt;o.topology="line-list",o.baseColor=new J(1,1,1,.15),o.blendMode=De.ADD,o.castReflection=!1;let l=this.addComponent(he);l.geometry=n,l.material=o}addAxis(){const e=this.size/2;let t=new Float32Array([-e,0,0,e,0,0]),a=new Uint16Array([0,1,2,3]),r=new Le;r.setIndices(a),r.setAttribute(G.position,t),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});{let i=new ne,n=i.addComponent(he);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(1,0,0,.5),o.blendMode=De.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}{let i=new ne;i.rotationY=90;let n=i.addComponent(he);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(0,1,0,.5),o.blendMode=De.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}}}class Ym{static color_temperature_to_rgb(e){e<1e3?e=1e3:e>4e4&&(e=4e4);let t=e/100,a=this.get_red(t),r=this.get_green(t),i=this.get_blue(t);return new J(a/255,r/255,i/255,1)}static get_red(e){if(e<=66)return 255;let t=329.698727446*Math.pow(e-60,-.1332047592);return this.bound(t)}static get_green(e){let t=0;return e<=66?t=99.4708025861*Math.log(e)-161.1195681661:t=288.1221695283*Math.pow(e-60,-.0755148492),this.bound(t)}static get_blue(e){let t=0;return e>=66?255:e<=19?0:(t=138.5177312231*Math.log(e-10)-305.0447927307,this.bound(t))}static bound(e,t=0,a=255){let r=Math.max(e,t);return Math.min(r,a)}}class Xm{static boxGeo;static planeGeo;static sphere;static material;static materialMap;static initHeap(){this.boxGeo||(this.boxGeo=new za),this.planeGeo||(this.planeGeo=new si(1,1,1,1,b.UP)),this.sphere||(this.sphere=new Nr(1,35,35)),this.material||(this.material=new ta),this.materialMap||(this.materialMap=new Map)}static get CubeMesh(){return this.initHeap(),this.boxGeo}static get SphereMesh(){return this.initHeap(),this.sphere}static GetCube(){this.initHeap();let e=new ne,t=e.addComponent(he);return t.geometry=this.boxGeo,t.material=this.material.clone(),t.castShadow=!0,e}static GetMaterial(e){let t=this.materialMap.get(e);return t||(t=new ta,t.baseMap=e,this.materialMap.set(e,t)),t.clone()}static GetPlane(e){this.initHeap();let t=new ne,a=t.addComponent(he);a.geometry=this.planeGeo;let r=this.GetMaterial(e);return r.blendMode=De.ADD,r.castShadow=!1,a.material=r,a.castGI=!1,a.castReflection=!1,t}static GetSingleCube(e,t,a,r,i,n){this.initHeap();let o=new ta;o.roughness=.5,o.metallic=.1,o.baseColor=new J(r,i,n,1);let l=new ne,c=l.addComponent(he);return c.castGI=!0,c.geometry=new za(e,t,a),c.material=o,l}static GetSingleSphere(e,t,a,r){this.initHeap();let i=new ta;i.baseColor=new J(t,a,r,1);let n=new ne,o=n.addComponent(he);return o.castGI=!0,o.geometry=new Nr(e,20,20),o.material=i,n}static get Sphere(){this.initHeap();let e=new ne,t=e.addComponent(he);return t.geometry=this.sphere,t.material=this.material,e}static GetSingleCube2(e,t=10){this.initHeap();let a=new ne,r=a.addComponent(he);return r.castShadow=!1,r.geometry=new za(t,t,t),r.material=e,a}static GetPointLight(e,t,a,r,i,n,o=1,l=!0){let c=new ne,f=c.addComponent(oi);f.lightColor=new J(r,i,n,1),f.intensity=o,f.range=a,f.at=8,f.radius=0,f.castShadow=l,c.localPosition=e,c.localRotation=t;let d=this.GetSingleSphere(.1,1,1,1);return c.addChild(d),f}}var P=(s=>(s[s.X=0]="X",s[s.Y=1]="Y",s[s.Z=2]="Z",s[s.XY=3]="XY",s[s.XZ=4]="XZ",s[s.YZ=5]="YZ",s[s.XYZ=6]="XYZ",s[s.MAX=7]="MAX",s[s.NONE=8]="NONE",s))(P||{}),ha=(s=>(s[s.Local=0]="Local",s[s.Global=1]="Global",s))(ha||{});class on extends et{mAxis;mAxisColor;mContainer;mAxisMaterial;mAxisCollider;constructor(){super(),this._enable=!1,this.mAxis=new Array(P.MAX),this.mAxisColor=new Array(P.MAX),this.mAxisMaterial=new Array(P.MAX),this.mAxisCollider=new Array(P.MAX)}get target(){return this.object3D.target}get mX(){return this.object3D.mXObj}get mY(){return this.object3D.mYObj}get mZ(){return this.object3D.mZObj}get transformSpaceMode(){return this.object3D.transformSpaceMode}init(e){this.mContainer=new ne;let t=new Bt;t.baseColor=new J(1,0,0),t.depthCompare=ft.always,this.mAxisColor[P.X]=t.baseColor,this.mAxisMaterial[P.X]=t;let a=new Bt;a.baseColor=new J(0,1,0),a.depthCompare=ft.always,this.mAxisColor[P.Y]=a.baseColor,this.mAxisMaterial[P.Y]=a;let r=new Bt;r.baseColor=new J(0,0,1),r.depthCompare=ft.always,this.mAxisColor[P.Z]=r.baseColor,this.mAxisMaterial[P.Z]=r;let i=this.createCustomAxis(P.X),n=this.createCustomAxis(P.Y),o=this.createCustomAxis(P.Z);this.mContainer.addChild(this.mAxis[P.X]=i),this.mContainer.addChild(this.mAxis[P.Y]=n),this.mContainer.addChild(this.mAxis[P.Z]=o),this.mAxisCollider[P.X]=i.getComponent(da),this.mAxisCollider[P.Y]=n.getComponent(da),this.mAxisCollider[P.Z]=o.getComponent(da)}start(){}onEnable(e){this.object3D.addChild(this.mContainer),this.reset()}onDisable(e){this.object3D.removeChild(this.mContainer)}reset(){switch(this.transformSpaceMode){case ha.Local:{let t=R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).decompose();this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=t[1].x,this.object3D.rotationY=t[1].y,this.object3D.rotationZ=t[1].z,this.object3D.x=t[0].x,this.object3D.y=t[0].y,this.object3D.z=t[0].z}break;case ha.Global:{this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=0,this.object3D.rotationY=0,this.object3D.rotationZ=0;const e=this.mX.transform.worldPosition;this.object3D.x=e.x,this.object3D.y=e.y,this.object3D.z=e.z}break}}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY),r,i;for(let n=0;n<=P.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r&&(!i||i.distance>r.distance||n==P.XYZ)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint},n==P.XYZ)))break}return i}currentAxis=P.NONE;beginPoint=new b;beginMousePos=new b;currentPoint=new b;onMouseDown(e){if(e.mouseCode!=Ys.MOUSE_LEFT)return;let t=this.pickAxis();if(!t)return;this.currentAxis=t.axis,e.stopImmediatePropagation();const r=this.object3D.transform.scene3D.view.camera;let i=r.worldToScreenPoint(this.mX.transform.worldPosition),n=r.screenPointToWorld(_.inputSystem.mouseX,_.inputSystem.mouseY,i.z);this.beginPoint.copyFrom(n),this.beginMousePos.x=_.inputSystem.mouseX,this.beginMousePos.y=_.inputSystem.mouseY}lastMoveObj;lastMoveAxis;onMouseMove(e){if(this.currentAxis==P.NONE){let t=this.lastMoveObj.getComponent(he).material;this.lastMoveObj&&"baseColor"in t&&(t.baseColor=this.mAxisColor[this.lastMoveAxis],this.lastMoveObj=null,this.lastMoveAxis==P.XYZ&&(this.mAxis[P.X].getComponent(he).material.setUniformColor("baseColor",this.mAxisColor[P.X]),this.mAxis[P.Y].getComponent(he).material.setUniformColor("baseColor",this.mAxisColor[P.Y]),this.mAxis[P.Z].getComponent(he).material.setUniformColor("baseColor",this.mAxisColor[P.Z])),this.lastMoveAxis=P.NONE);let a=this.pickAxis();if(!a)return;t.setUniformColor("baseColor",new J(1,1,1)),this.lastMoveObj=a.obj,this.lastMoveAxis=a.axis,this.lastMoveAxis==P.XYZ&&(this.mAxis[P.X].getComponent(he).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[P.Y].getComponent(he).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[P.Z].getComponent(he).material.setUniformColor("baseColor",new J(1,1,1)))}else{const a=this.object3D.transform.scene3D.view.camera;let r=a.worldToScreenPoint(this.mX.transform.worldPosition),i=a.screenPointToWorld(_.inputSystem.mouseX,_.inputSystem.mouseY,r.z);this.currentPoint.copyFrom(i);let n=i.subtract(this.beginPoint);b.HELP_0.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let o=b.distance(b.HELP_0,this.beginMousePos);switch(this.beginMousePos.copyFrom(b.HELP_0),this.transformSpaceMode){case ha.Local:this.applyLocalTransform(this.currentAxis,n,o);break;case ha.Global:this.applyGlobalTransform(this.currentAxis,n,o);break}this.beginPoint.copyFrom(i),this.reset()}}onMouseUp(e){e.mouseCode==Ys.MOUSE_LEFT&&(this.currentAxis=P.NONE,this.reset())}onUpdate(e){let a=b.distance(e.camera.transform.worldPosition,this.object3D.transform.worldPosition)/100;if(this.mContainer.scaleX=this.mContainer.scaleY=this.mContainer.scaleZ=a,this.mX){const r=this.mX.transform.worldPosition;this.object3D.x=r.x,this.object3D.y=r.y,this.object3D.z=r.z}}applyLocalTransform(e,t,a){console.warn("not imp")}applyGlobalTransform(e,t,a){console.warn("not imp")}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=0,a=0,r=0;switch(e){case P.X:t=1;break;case P.Y:a=1;break;case P.Z:r=1;break}let i=.4+t*20,n=.4+a*20,o=.4+r*20,l=new ne;l.x=i*.5,l.y=n*.5,l.z=o*.5;let c=l.addComponent(he);c.geometry=new za(i,n,o),c.material=this.mAxisMaterial[e];let f=l.addComponent(da),d=new bi;return d.setFromCenterAndSize(new b(0,0,0),new b(i+1,n+1,o+1)),f.shape=d,l}}class Ru extends on{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(.9,.9,.9),t.depthCompare=ft.always,this.mAxisColor[P.XYZ]=t.baseColor,this.mAxisMaterial[P.XYZ]=t;let a=new ne,r=a.addComponent(he);r.geometry=new za(2,2,2),r.material=this.mAxisMaterial[P.XYZ];let i=a.addComponent(da),n=new bi;n.setFromCenterAndSize(new b(0,0,0),new b(2,2,2)),i.shape=n,this.mContainer.addChild(this.mAxis[P.XYZ]=a),this.mAxisCollider[P.XYZ]=a.getComponent(da)}applyLocalTransform(e,t,a){switch(this.currentAxis){case P.XYZ:{let r=0;Math.abs(t.x)>Math.abs(t.y)?Math.abs(t.x)>Math.abs(t.z)?r=t.x:r=t.z:r=t.y,this.mX.scaleX+=r,this.mX.scaleY+=r,this.mX.scaleZ+=r}break;default:this.mX.transform.worldMatrix.transformVector(t,t),(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ)&&(this.mX.scaleX=Math.abs(this.mX.scaleX+t.x)),(this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ)&&(this.mX.scaleY=Math.abs(this.mX.scaleY+t.y)),(this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ)&&(this.mX.scaleZ=Math.abs(this.mX.scaleZ+t.z));break}}applyGlobalTransform(e,t,a){let r=b.HELP_0;r.set(0,0,0),(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ)&&(r.x=t.x),(this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ)&&(r.y=t.y),(this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ)&&(r.z=t.z),this.mX.transform.worldMatrix.transformVector(r,b.HELP_1),this.mX.scaleX+=b.HELP_1.x,this.mX.scaleY+=b.HELP_1.y,this.mX.scaleZ+=b.HELP_1.z}createCustomAxis(e){let t=super.createAxis(e),a=this.createBox(e);return t.addChild(a),t}createBox(e){let t=0,a=0,r=0,i=new ne;switch(e){case P.X:t=1,i.rotationZ=-90;break;case P.Y:a=1;break;case P.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(he);return c.geometry=new za(2,2,2),c.material=this.mAxisMaterial[e],i}}var mt=(s=>(s[s.Scale=0]="Scale",s[s.Rotation=1]="Rotation",s[s.Translation=2]="Translation",s[s.NONE=3]="NONE",s))(mt||{});class Qu extends on{applyLocalTransform(e,t,a){if(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ,this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.identity(),R.help_matrix_1.createByRotation(1,b.Y_AXIS),R.help_matrix_2.multiplyMatrices(R.help_matrix_1,R.help_matrix_0),R.help_matrix_2.invert(),R.help_matrix_1.multiplyMatrices(R.help_matrix_2,R.help_matrix_0);let r=R.help_matrix_1.decompose();this.mX.rotationX+=r[1].x,this.mY.rotationY+=r[1].y,this.mZ.rotationZ+=r[1].z}this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ}getAngle(){const t=this.object3D.transform.scene3D.view.camera,a=this.mZ.transform.worldPosition;if(t.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY),this.currentAxis==P.X){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.x-a.x>0&&(n=360-n),n}if(this.currentAxis==P.Y){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.y-a.y>0&&(n=360-n),n}if(this.currentAxis==P.Z){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.z-a.z>0&&(n=360-n),n}return 0}mLastAngle=0;applyGlobalTransform(e,t,a){if(this.currentAxis==P.X||this.currentAxis==P.Y||this.currentAxis==P.Z){let r=this.getAngle();switch(R.help_matrix_0.identity(),this.currentAxis){case P.X:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.X_AXIS);break;case P.Y:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Y_AXIS);break;case P.Z:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Z_AXIS);break}R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let n=R.help_matrix_1.decompose(na.QUATERNION)[1];se.HELP_0.set(n.x,n.y,n.z,n.w),this.mLastAngle=r,this.mX.transform.localRotQuat=se.HELP_0}}onMouseDown(e){super.onMouseDown(e),this.currentAxis!=P.NONE&&(this.mAxis[P.X].getComponent(he).enable=!1,this.mAxis[P.Y].getComponent(he).enable=!1,this.mAxis[P.Z].getComponent(he).enable=!1,this.mAxis[this.currentAxis].getComponent(he).enable=!0,this.mLastAngle=this.getAngle())}onMouseUp(e){super.onMouseUp(e),this.currentAxis==P.NONE&&(this.mAxis[P.X].getComponent(he).enable=!0,this.mAxis[P.Y].getComponent(he).enable=!0,this.mAxis[P.Z].getComponent(he).enable=!0)}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=new ne;switch(e){case P.X:t.rotationZ=90;break;case P.Y:break;case P.Z:t.rotationX=90;break}let a=t.addComponent(he);a.geometry=new Iu(20,.4),a.material=this.mAxisMaterial[e];let r=t.addComponent(da),i=new bi;return i.setFromCenterAndSize(new b,new b(40,.4,40)),r.shape=i,t}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY),r,i;for(let n=0;n<=P.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r)){let l=b.distance(r.intersectPoint,o.shape.center);if(l>20+.8||l<20-.8)continue;(!i||i.distance>r.distance)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint})}}return i}}class Tu extends on{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(0,0,1),t.depthCompare=ft.always,this.mAxisColor[P.XY]=t.baseColor,this.mAxisMaterial[P.XY]=t;let a=new Bt;a.doubleSide=!0,a.baseColor=new J(0,1,0),a.depthCompare=ft.always,this.mAxisColor[P.XZ]=a.baseColor,this.mAxisMaterial[P.XZ]=a;let r=new Bt;r.doubleSide=!0,r.baseColor=new J(1,0,0),r.depthCompare=ft.always,this.mAxisColor[P.YZ]=r.baseColor,this.mAxisMaterial[P.YZ]=r;let i=this.createPlane(P.XY),n=this.createPlane(P.XZ),o=this.createPlane(P.YZ);this.mContainer.addChild(this.mAxis[P.XY]=i),this.mContainer.addChild(this.mAxis[P.XZ]=n),this.mContainer.addChild(this.mAxis[P.YZ]=o),this.mAxisCollider[P.XY]=i.getComponent(da),this.mAxisCollider[P.XZ]=n.getComponent(da),this.mAxisCollider[P.YZ]=o.getComponent(da)}applyLocalTransform(e,t,a){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).invert(),R.help_matrix_0.transformVector(t,b.HELP_0),this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ||(b.HELP_0.x=0),this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ||(b.HELP_0.y=0),this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ||(b.HELP_0.z=0),this.mX.transform.worldMatrix.transformVector(b.HELP_0,b.HELP_1),this.mX.x+=b.HELP_1.x,this.mX.y+=b.HELP_1.y,this.mX.z+=b.HELP_1.z}applyGlobalTransform(e,t,a){R.help_matrix_0.identity(),(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ)&&R.help_matrix_0.appendTranslation(t.x,0,0),(this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ)&&R.help_matrix_0.appendTranslation(0,t.y,0),(this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ)&&R.help_matrix_0.appendTranslation(0,0,t.z),R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let r=R.help_matrix_1.decompose(na.QUATERNION);this.mX.transform.localPosition=r[0],console.log(this.target.localPosition)}createCustomAxis(e){let t=super.createAxis(e),a=this.createArrows(e);return t.addChild(a),t}createArrows(e){let t=0,a=0,r=0,i=new ne;switch(e){case P.X:t=1,i.rotationZ=-90;break;case P.Y:a=1,i.rotationY=-90;break;case P.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(he);return c.geometry=new wu(0,1,4),c.material=this.mAxisMaterial[e],i}createPlane(e){let t=new ne,a=t.addComponent(he);a.material=this.mAxisMaterial[e];let r=t.addComponent(da),i=new bi;switch(r.shape=i,e){case P.XY:a.geometry=new si(4,4,1,1,b.Z_AXIS),t.x=8,t.y=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,4,.1));break;case P.XZ:a.geometry=new si(4,4,1,1,b.Y_AXIS),t.x=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,.1,4));break;case P.YZ:a.geometry=new si(4,4,1,1,b.X_AXIS),t.y=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(.1,4,4));break}return t}}class Bl extends ne{static _instance;static get instance(){return this._instance||(this._instance=new Bl),this._instance}mTarget;mTransformMode=mt.NONE;mTransformSpaceType=ha.Global;mControllers;mXObj;mYObj;mZObj;constructor(){super(),this.mControllers=[null,null,null],this.mControllers[mt.Scale]=this.addComponent(Ru),this.mControllers[mt.Rotation]=this.addComponent(Qu),this.mControllers[mt.Translation]=this.addComponent(Tu),this.mControllers[mt.Scale].enable=!1,this.mControllers[mt.Rotation].enable=!1,this.mControllers[mt.Translation].enable=!1,this.mXObj=new ne,this.mYObj=new ne,this.mZObj=new ne,this.mXObj.addChild(this.mYObj),this.mYObj.addChild(this.mZObj)}get transformMode(){return this.mTransformMode}get transformSpaceMode(){return this.mTransformSpaceType}active(e){e.addChild(this),e.addChild(this.mXObj)}unActive(e){e.removeChild(this)}get target(){return this.mTarget}selectObject(e,t,a){this.mTarget!=e&&(e?this.activate():this.unactivate(),this.mTarget=e,this.mXObj.localPosition=e.transform.worldPosition.clone()),t!=null&&this.selectTransformMode(t),a!=null&&this.selectTransformSpaceMode(a)}selectTransformMode(e){this.mTransformMode!=e&&(this.mTransformMode!=mt.NONE&&(this.mControllers[this.mTransformMode].enable=!1),this.mTransformMode=e,this.mTransformMode!=mt.NONE&&(this.mControllers[this.mTransformMode].enable=!0))}selectTransformSpaceMode(e){this.mTransformSpaceType!=e&&(this.mTransformSpaceType=e,this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].reset())}activate(){_.inputSystem.addEventListener(Ma.KEY_DOWN,this.onKeyDown,this),_.inputSystem.addEventListener(Z.POINTER_DOWN,this.onMouseDown,this,null,99999),_.inputSystem.addEventListener(Z.POINTER_MOVE,this.onMouseMove,this,null,99999),_.inputSystem.addEventListener(Z.POINTER_UP,this.onMouseUp,this,null,99999)}unactivate(){_.inputSystem.removeEventListener(Ma.KEY_DOWN,this.onKeyDown,this),_.inputSystem.removeEventListener(Z.POINTER_DOWN,this.onMouseDown,this),_.inputSystem.removeEventListener(Z.POINTER_MOVE,this.onMouseMove,this),_.inputSystem.removeEventListener(Z.POINTER_UP,this.onMouseUp,this)}onKeyDown(e){switch(e.keyCode){case tt.Key_R:this.selectTransformMode(mt.Scale),this.selectTransformSpaceMode(ha.Local);break;case tt.Key_E:this.selectTransformMode(mt.Rotation),this.selectTransformSpaceMode(ha.Global);break;case tt.Key_W:this.selectTransformMode(mt.Translation),this.selectTransformSpaceMode(ha.Global);break;case tt.Key_A:this.selectTransformSpaceMode(ha.Local);break;case tt.Key_S:this.selectTransformSpaceMode(ha.Global);break}}onMouseDown(e){this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].onMouseDown(e)}onMouseMove(e){this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].onMouseMove(e)}onMouseUp(e){this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].onMouseUp(e)}}const Hm=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{mf as AccelerateDecelerateInterpolator,gf as AccelerateInterpolator,Li as AnimationCurve,xr as AnimationCurveT,Yr as AnimationMonitor,er as AnimatorComponent,xg as AnimatorEventKeyframe,_f as AnticipateInterpolator,As as AnticipateOvershootInterpolator,Ju as ArrayHas,ju as ArrayItemIndex,od as AtlasParser,gg as AtmosphericComponent,Kd as AtmosphericScatteringSky,Hd as AtmosphericScatteringSkySetting,Xd as AtmosphericScatteringSky_shader,sh as AttributeAnimCurve,Jm as AxisObject,rr as B3DMLoader,Yf as B3DMLoaderBase,ko as B3DMParseUtil,So as B3DMParser,ed as BRDFLUT,td as BRDFLUTGenerate,rc as BRDF_frag,Ls as BatchTable,vm as BiMap,fs as BillboardComponent,pr as BillboardType,Ec as BitUtil,$a as BitmapTexture2D,Kc as BitmapTexture2DArray,Bo as BitmapTextureCube,Xc as Blend,Hc as BlendFactor,De as BlendMode,tl as BlendShapeData,el as BlendShapePropertyData,_p as BloomPost,Vf as BlurEffectCreatorBlur_cs,Pf as BlurEffectCreatorSample_cs,Of as BlurTexture2DBufferCreator,aa as BounceInterpolator,qn as BoundUtil,Ce as BoundingBox,Lr as BoundingSphere,Xr as BoundingVolume,bi as BoxColliderShape,za as BoxGeometry,Zl as BrdfLut_frag,sc as BsDF_frag,ic as BxDF_frag,cc as BxdfDebug_frag,Dn as BytesArray,pt as CEvent,Za as CEventDispatcher,ys as CEventListener,lr as CResizeEvent,sa as CSM,ti as Camera3D,Ig as CameraControllerBase,nt as CameraType,bt as CameraUtil,$g as CapsuleColliderShape,d0 as CastPointShadowMaterialPass,f0 as CastShadowMaterialPass,nc as Clearcoat_frag,z0 as ClusterBoundsSource_cs,Et as ClusterConfig,Tl as ClusterDebug_frag,mc as ClusterLight,G0 as ClusterLightingBuffer,J0 as ClusterLightingRender,W0 as ClusterLighting_cs,g0 as CollectInfo,da as ColliderComponent,gt as ColliderShape,ui as ColliderShapeType,J as Color,xm as ColorGradient,Am as ColorLitMaterial,Jd as ColorLitShader,ng as ColorPassFragmentOutput,L0 as ColorPassRenderer,Fs as ColorUtil,_n as ComData,Pd as Combine_cs,Jl as Common_frag,jl as Common_vert,et as ComponentBase,Oe as ComponentCollect,ni as ComputeGPUBuffer,Fe as ComputeShader,Fl as Context3D,io as CubeCamera,Lf as CubeMapFaceEnum,Sn as CubeSky_Shader,rn as CubicBezierCurve,Um as CubicBezierPath,Du as CubicBezierType,Bf as CycleInterpolator,wu as CylinderGeometry,of as DDGIIrradianceComputePass,vs as DDGIIrradianceGPUBufferReader,R0 as DDGIIrradianceVolume,nf as DDGIIrradiance_shader,df as DDGILightingPass,ff as DDGILighting_shader,cf as DDGIMultiBouncePass,hf as DDGIProbeRenderer,Dt as DEGREES_TO_RADIANS,Uf as DRACO_DECODER_GLTF_JS,pf as DecelerateInterpolator,Vd as Denoising_cs,X0 as Depth2DTextureArray,Z0 as DepthCubeArrayTexture,h0 as DepthMaterialPass,Bp as DepthOfFieldPost,vd as DepthOfView_cs,Qi as DirectLight,rs as DoubleArray,Kr as EditorInspector,_ as Engine3D,I0 as Entity,p0 as EntityBatchCollect,q as EntityCollect,Yl as EnvMap_frag,Yt as ErpImage2CubeMap,Gf as ErpImage2CubeMapCreateCube_cs,zf as ErpImage2CubeMapRgbe2rgba_cs,ip as ExtrudeGeometry,_r as FAILED,Ca as FASTFLOOR,so as FXAAPost,af as FXAAShader,Hl as FastMathShader,wh as FatLineGeometry,qh as FatLineMaterial,mi as FatLineRenderer,Ki as FatLineShader,Mc as FatLine_FS,Tc as FatLine_VS,Mi as FeatureTable,It as FileLoader,Rg as FirstPersonCameraController,Ts as Float16ArrayTexture,w0 as Float32ArrayTexture,Qg as FlyCameraController,id as FontChar,ad as FontInfo,rd as FontPage,ir as FontParser,bf as ForwardRenderJob,En as FragmentOutput,ql as FragmentVarying,Lo as FrameCache,On as Frustum,Yc as FrustumCSM,sg as FrustumCulling_cs,fc as FullQuad_vert_wgsl,ve as GBufferFrame,c0 as GBufferPass,vp as GBufferPost,wc as GBufferStand,wn as GBuffer_pass,Do as GILighting,Fh as GIProbeMaterial,jo as GIProbeMaterialType,jd as GIProbeShader,no as GIRenderCompleteEvent,Ms as GIRenderStartEvent,Mf as GLBChunk,Tf as GLBHeader,_o as GLBParser,qc as GLSLLexer,Ui as GLSLLexerToken,$c as GLSLPreprocessor,r0 as GLSLSyntax,Kf as GLTFBinaryExtension,zp as GLTFMaterial,xt as GLTFParser,Ps as GLTFSubParser,yf as GLTFSubParserCamera,Qf as GLTFSubParserConverter,Sf as GLTFSubParserMaterial,Cf as GLTFSubParserMesh,Ao as GLTFSubParserSkeleton,Ff as GLTFSubParserSkin,oa as GLTFType,fb as GLTF_Accessors,Ns as GLTF_Info,nb as GLTF_Light,cb as GLTF_Mesh,ob as GLTF_Node,lb as GLTF_Primitives,sb as GLTF_Scene,Kt as GPUAddressMode,Zu as GPUBlendFactor,Ya as GPUBufferBase,Aa as GPUBufferType,ft as GPUCompareFunction,k as GPUContext,Lt as GPUCullMode,hr as GPUFilterMode,Ss as GPUPrimitiveTopology,oe as GPUTextureFormat,xi as GPUVertexFormat,Hu as GPUVertexStepMode,Ai as GSplatFormat,Xn as GSplatGeometry,Yn as GSplatMaterial,ii as GSplatRenderer,Si as GSplatShader,Zi as GSplatStreamRenderer,_0 as GSplat_FS,D0 as GSplat_VS,xp as GTAOPost,xd as GTAO_cs,nd as GUIAtlasTexture,ds as GUICanvas,Pr as GUIConfig,dh as GUIGeometry,uh as GUIGeometryRebuild,Wo as GUIMaterial,uf as GUIPassRenderer,mh as GUIPick,_h as GUIPickHelper,Ja as GUIQuad,ot as GUIQuadAttrEnum,bh as GUIRenderer,zo as GUIShader,fa as GUISpace,ci as GUISprite,Fr as GUITexture,Vp as GaussianSplatParser,gc as GenerayRandomDir,Lp as GeoJsonParser,Gp as GeoJsonUtil,Xs as GeoType,Le as GeometryBase,x0 as GeometryIndicesBuffer,jm as GeometryUtil,B0 as GeometryVertexBuffer,kt as GeometryVertexType,kl as GetComponentClass,yn as GetCountInstanceID,s2 as GetRepeat,El as GetShader,og as GlassShader,xe as GlobalBindGroup,Ln as GlobalBindGroupLayout,Up as GlobalFog,Oo as GlobalFog_shader,Zg as GlobalIlluminationComponent,Fn as GlobalUniform,$n as GlobalUniformGroup,yp as GodRayPost,Ud as GodRay_cs,Zm as GridObject,xo as HDRTexture,Os as HDRTextureCube,Ac as Hair_frag,lg as Hair_shader_op,cg as Hair_shader_tr,Is as HaltonSeq,xh as Horizontal,Tg as HoverCameraController,ka as I3DMLoader,qf as I3DMLoaderBase,Eo as I3DMParser,jf as IBLEnvMapCreator,Jf as IBLEnvMapCreator_cs,Ia as IESProfiles,ec as IESProfiles_frag,op as IKDTreeUserData,hi as ImageType,v0 as IndicesGPUBuffer,Wl as Inline_vert,Sl as InputSystem,Yg as InstanceDrawComponent,Xl as InstanceUniform,$f as InstancedMesh,Sr as Interpolator,oo as InterpolatorEnum,Gh as IrradianceDataReaderCompleteEvent,zl as IrradianceVolumeData_frag,ac as Irradiance_frag,zu as IsEditorInspector,xn as IsNonSerialize,kf as Joint,mo as JointPose,Df as JumperInterpolator,cp as KDTreeEntity,yr as KDTreeNode,Rh as KDTreeRange,Qh as KDTreeSpace,gs as KDTreeUUID,po as KHR_draco_mesh_compression,Wp as KHR_lights_punctual,wf as KHR_materials_clearcoat,If as KHR_materials_emissive_strength,Jp as KHR_materials_ior,Rf as KHR_materials_unlit,gd as KMZParser,$o as KV,Ym as KelvinUtil,tt as KeyCode,Ma as KeyEvent,Js as Keyframe,as as KeyframeT,Kh as LASLoader,Yp as LASParser,Jt as LASUtils,Di as LASVisualizationMode,Gs as LDRTextureCube,La as LOADED,al as LOADING,du as LRUCache,Dm as LambertMaterial,_c as Lambert_shader,js as Light,Ri as LightBase,ws as LightData,Q0 as LightEntries,ht as LightType,Ml as LightingFunction_frag,Ut as Line,Ah as LineClassification,Af as LinearInterpolator,ta as LitMaterial,Ks as LitSSSShader,qs as LitShader,oc as Lit_shader,Er as LoaderBase,fp as LoaderEvent,An as LoaderManager,e2 as MAX_VALUE,t2 as MIN_VALUE,vt as Material,o0 as MaterialDataUniformGPUBuffer,Hs as MaterialUtilities,Nl as MathShader,Gt as MathUtil,Gr as Matrix3,R as Matrix4,N0 as MatrixBindGroup,M0 as MatrixGPUBuffer,pc as MatrixShader,cr as MemoryDO,Il as MemoryInfo,up as MergeRGBACreator,yd as MergeRGBA_cs,mn as MeshColliderShape,Zs as MeshFilter,he as MeshRenderer,Fm as MinMaxAnimationCurves,Cu as MinMaxCurve,yu as MinMaxCurveState,km as MinMaxPolyCurves,mp as MorePassParser,Oh as MorePassShader,Cg as MorphTargetBlender,V0 as MorphTargetData,Sg as MorphTargetFrame,lh as MorphTargetTransformKey,Ht as MorphTarget_shader,Ys as MouseCode,lf as MultiBouncePass_cs,ku as Navi3DAstar,is as Navi3DConst,Ea as Navi3DEdge,sr as Navi3DFunnel,Ur as Navi3DMaskType,Lm as Navi3DMesh,Qt as Navi3DPoint,_l as Navi3DPoint2D,Fa as Navi3DPointFat,_e as Navi3DRouter,Eu as Navi3DTriangle,vn as NonSerialize,Kl as NormalMap_frag,Ef as OAnimationEvent,Ds as OBJParser,ne as Object3D,dp as Object3DEvent,Bl as Object3DTransformTools,Xm as Object3DUtil,nh as ObjectAnimClip,ro as OcclusionSystem,Cr as Octree,A0 as OctreeEntity,Mg as OrbitController,ym as OrderMap,na as Orientation3D,Cd as OutLineBlendColor_cs,Sd as OutlineCalcOutline_cs,fg as OutlinePass,Cp as OutlinePost,Wh as OutlinePostData,Jh as OutlinePostManager,zh as OutlinePostSlot,Fd as Outline_cs,vf as OvershootInterpolator,cu as PARSING,lc as PBRLItShader,Zd as PBRLitSSSShader,lm as PLUGIN_REGISTERED,eu as PNTSLoader,$h as PNTSLoaderBase,tu as PNTSParser,it as ParserBase,je as ParserFormat,Uu as ParticleSystemCurveEvalMode,_u as ParticleSystemRandomnessIds,yi as PassGenerate,Lh as PassShader,fe as PassType,Pl as PhysicMaterialUniform_frag,kh as PickCompute,Eh as PickFire,yt as PickGUIEvent3D,jh as PickResult,kd as Picker_cs,In as PingPong,Jn as PipelinePool,Su as Plane3D,Vr as PlaneClassification,si as PlaneGeometry,ya as PlyMode,Al as PlyParser,Hh as PlyStreamParser,Dh as PointClassification,Kn as PointCloudGeometry,E0 as PointCloudMaterial,qa as PointCloudRenderer,ki as PointCloudShader,k0 as PointCloud_FS,F0 as PointCloud_VS,oi as PointLight,Y0 as PointLightShadowRenderer,j0 as PointShadowCubeCamera,Z as PointerEvent3D,Ga as Polynomial,nr as PolynomialCurve,Sm as Polynomials,gh as PoolNode,Wt as PostBase,md as PostProcessingComponent,$0 as PostRenderer,K0 as PreDepthPassRenderer,ef as PreFilteredEnvironment_cs,qb as PreFilteredEnvironment_cs2,Ed as PreIntegratedLut,Vh as PreIntegratedLutCompute,qo as PrefabAvatarData,au as PrefabAvatarParser,Ko as PrefabBoneData,iu as PrefabMaterialParser,su as PrefabMeshData,nu as PrefabMeshParser,xs as PrefabNode,lu as PrefabParser,em as PrefabStringUtil,ru as PrefabTextureData,ou as PrefabTextureParser,Da as Preprocessor,il as PriorityQueue,Sh as Probe,bp as ProbeEntries,sf as ProbeGBufferFrame,dt as ProfilerUtil,vg as PropertyAnimClip,oh as PropertyAnimTag,ul as PropertyAnimation,fl as PropertyAnimationClip,ih as PropertyAnimationClipState,zi as PropertyAnimationEvent,Gi as PropertyHelp,Nt as QuadAABB,vc as QuadGlsl_fs,Bc as QuadGlsl_vs,Mh as QuadRoot,Ei as QuadShader,Th as QuadTree,kr as QuadTreeCell,Ku as Quad_depth2dArray_frag_wgsl,uc as Quad_depth2d_frag_wgsl,bc as Quad_depthCube_frag_wgsl,hc as Quad_frag_wgsl,dc as Quad_vert_wgsl,se as Quaternion,Qs as R32UintTexture,$r as RADIANS_TO_DEGREES,Wf as RGBEErrorCode,Uo as RGBEHeader,yo as RGBEParser,Je as RTDescriptor,lt as RTFrame,Pa as RTResourceConfig,Mt as RTResourceMap,ns as Rand,n2 as RandomSeed,ua as Ray,Bi as RayCastMeshDetail,ai as Reader,ps as Rect,ke as Reference,$d as Reflection,Rc as ReflectionCG,T0 as ReflectionEntries,th as ReflectionMaterial,tf as ReflectionRenderer,eh as ReflectionShader,Ic as ReflectionShader_shader,Ot as RegisterComponent,Na as RegisterShader,ao as RenderContext,Ci as RenderLayer,jn as RenderLayerUtil,Ba as RenderNode,m0 as RenderShaderCollect,Ph as RenderShaderCompute,qe as RenderShaderPass,Rt as RenderTexture,Va as RendererBase,rf as RendererJob,q0 as RendererMap,Ne as RendererMask,ia as RendererMaskUtil,O0 as RendererPassState,Rn as RepeatSE,pd as Res,Qu as RotationControlComponents,Qc as SHCommon_frag,ms as SN_ArrayConstant,br as SN_BinaryOperation,N2 as SN_Break,Sa as SN_CodeBlock,ar as SN_Constant,fn as SN_Continue,rt as SN_Declaration,P2 as SN_Discard,M2 as SN_DoWhileLoop,we as SN_Expression,Jr as SN_ForLoop,ln as SN_Function,cn as SN_FunctionArgs,Wr as SN_FunctionCall,Or as SN_IFBranch,Xa as SN_Identifier,Zr as SN_IndexOperation,cs as SN_Layout,t0 as SN_ParenExpression,dn as SN_Precision,os as SN_Return,ls as SN_SelectOperation,tr as SN_Struct,a0 as SN_TernaryOperation,ri as SN_UnaryOperation,jr as SN_WhileLoop,$b as SSAO_cs,wd as SSGI2_cs,Sp as SSGIPost,Fp as SSRPost,Id as SSR_BlendColor_cs,kp as SSR_IS_Kernel,Rd as SSR_IS_cs,Qd as SSR_RayTrace_cs,Ru as ScaleControlComponents,tp as Scene3D,At as Shader,Wn as ShaderAttributeInfo,i0 as ShaderConverter,s0 as ShaderConverterResult,Y as ShaderLib,Cn as ShaderPassBase,Tt as ShaderReflection,_a as ShaderStage,n0 as ShaderState,zn as ShaderUniformInfo,Ha as ShaderUtil,$l as ShadingInput,jt as ShadowLightsCollect,H0 as ShadowMapPassRenderer,tc as ShadowMapping_frag,Fg as Skeleton,hn as SkeletonAnimationClip,rh as SkeletonAnimationClipState,mr as SkeletonAnimationComponent,kg as SkeletonAnimationCompute,qr as SkeletonAnimation_shader,Eg as SkeletonBlendComputeArgs,Ii as SkeletonPose,wg as SkeletonTransformComputeArgs,Yi as SkinnedMeshRenderer,Dr as SkinnedMeshRenderer2,l0 as SkyGBufferPass,xc as SkyGBuffer_pass,qd as SkyMaterial,Ws as SkyRenderer,Oi as SkyShader,Wm as SolidColorSky,ep as SphereColliderShape,Nr as SphereGeometry,ah as SphereReflection,Ti as SpotLight,Nf as StandShader,Ge as StatementNode,Pe as StorageGPUBuffer,Ip as StreamLoader,Op as StreamingGaussianSplatParser,wt as StringUtil,vi as Struct,gp as StructStorageGPUBuffer,U0 as SubGeometry,Td as TAACopyTex_cs,Ep as TAAPost,Md as TAASharpTex_cs,Nd as TAA_cs,Od as TestComputeLoadBuffer,Bh as TextAnchor,yh as TextFieldLayout,Uh as TextFieldLine,ut as Texture,Vs as TextureCube,Co as TextureCubeFaceData,un as TextureCubeStdCreator,vo as TextureCubeUtils,pp as TextureMipmapCompute,wa as TextureMipmapGenerator,Nh as TextureScaleCompute,Pg as ThirdPersonCameraController,rl as Tile,hm as TileSet,bm as TileSetChild,gm as TileSetChildContent,pm as TileSetChildContentMetaData,um as TileSetRoot,dm as TilesRenderer,We as Time,x as TokenType,Iu as TorusGeometry,Cl as TouchData,Gm as TrailGeometry,Zt as Transform,P as TransformAxisEnum,on as TransformControllerBaseComponent,mt as TransformMode,ha as TransformSpaceMode,Tu as TranslationControlComponents,Gn as TranslatorContext,zm as TriGeometry,us as Triangle,bl as UIButton,Ch as UIButtonTransition,Jo as UIComponentBase,hp as UIEvent,zr as UIImage,gl as UIImageGroup,pn as UIInteractive,at as UIInteractiveStyle,hs as UIPanel,ji as UIRenderAble,pl as UIShadow,ml as UITextField,or as UITransform,Br as UNLOADED,zt as UUID,Dl as UV,Hn as Uint32ArrayTexture,Fi as Uint8ArrayTexture,Dc as UnLit,Bt as UnLitMaterial,Vl as UnLitMaterialUniform_frag,qi as UnLitShader,Bm as UnLitTexArrayMaterial,$i as UnLitTexArrayShader,Yd as UnLitTextureArray,Ol as UnLit_frag,Ct as UniformGPUBuffer,fr as UniformNode,St as UniformType,X as ValueEnumType,Om as ValueOp,Wa as ValueParser,Em as ValueSpread,de as Vector2,b as Vector3,Wi as Vector3Ex,be as Vector4,np as VertexAttribute,Wd as VertexAttributeIndexShader,G as VertexAttributeName,dr as VertexAttributeSize,Ih as VertexAttributeStride,Ll as VertexAttributes_vert,sp as VertexBufferLayout,Ql as VertexFormat,Rs as VertexGPUBuffer,vh as Vertical,Gl as VideoUniform_frag,ap as View3D,bn as ViewPanel,to as ViewQuad,Te as VirtualTexture,nm as WGS84_FLATTENING,om as WGS84_HEIGHT,sm as WGS84_RADIUS,e0 as WGSLTranslator,Bs as WayLines3D,_s as WayPoint3D,He as WebGPUDescriptorCreator,kn as WorldMatrixUniform,gn as WorldPanel,gi as WrapMode,Ar as WrapTimeMode,Dp as ZCullingCompute,zd as ZPassShader_cs,kc as ZPassShader_fs,Fc as ZPassShader_vs,u0 as ZSorterUtil,Zc as append,Zf as arrayToString,Yu as blendComponent,Im as buildCurves,$t as byteSizeOfType,Rm as calculateCurveRangesValue,es as calculateMinMax,yc as castPointShadowMap_vert,Be as clamp,F2 as clampRepeat,Zo as computeAABBFromPositions,D2 as cos,y2 as crossProduct,Bu as cubicPolynomialRoot,vu as cubicPolynomialRootsGeneric,wm as curvesSupportProcedural,p2 as deg2Rad,Zh as detectGSplatFormat,Sc as directionShadowCastMap_frag,Ft as dot,xu as doubleIntegrateSegment,_d as downSample,Jc as fastInvSqrt,Wc as floorfToIntPos,fi as fonts,C2 as generateRandom,S2 as generateRandom3,Oc as getFloatFromInt,vb as getGLTypeFromTypedArray,Bb as getGLTypeFromTypedArrayType,_2 as getGlobalRandomSeed,xb as getTypedArray,go as getTypedArrayTypeFromGLType,hl as grad1,nn as grad2,ts as grad3,_i as grad4,Xo as inferSHOrder,dl as integrateSegment,Ap as irradianceDataReader,Cm as kPI,Mr as lerp,i2 as lerpByte,r2 as lerpColor,a2 as lerpVector3,Au as lruPriorityCallback,Tn as magnitude,Ib as makeAloneSprite,sd as makeGUISprite,Es as makeMatrix44,cl as markUsedSetLeaves,en as markUsedTiles,tn as markVisibleTiles,Vn as matrixMultiply,I2 as matrixRotate,w2 as matrixRotateY,Cs as mergeFunctions,jc as multiplyMatrices4x4REF,Fu as normal_distribution,U2 as normalizeFast,Vc as normalizeSafe,x2 as normalizedToByte,v2 as normalizedToWord,Ua as outlinePostData,wp as outlinePostManager,Ho as parsePlyGaussianSplat,Hi as parsePlyHeader,Yh as parsePlyMesh,Xh as parsePlyPointCloud,Ue as perm,Bd as post,mu as priorityCallback,sn as quadraticPolynomialRootsGeneric,m2 as rad2Deg,ei as random01,g2 as randomBarycentricCoord,b2 as randomPointBetweenEllipsoid,h2 as randomPointBetweenSphere,f2 as randomPointInsideCube,d2 as randomPointInsideEllipsoid,u2 as randomPointInsideUnitCircle,Gc as randomPointInsideUnitSphere,l2 as randomQuaternion,c2 as randomQuaternionUniformDistribution,zc as randomSeed,ks as randomUnitVector,Lc as randomUnitVector2,_t as rangedRandomFloat,o2 as rangedRandomInt,pe as readByType,li as readMagicBytes,_m as registerMaterial,Pn as repeat,E2 as rotMatrix,$u as rotateVectorByQuat,Mn as roundfToIntPos,Qn as scale,Cc as shadowCastMap_frag,Uc as shadowCastMap_vert,ea as simplex,A2 as sin,Mm as snoise1,Nm as snoise2,Pm as snoise3,Vm as snoise4,Yo as splatColorProperties,Xi as splatProperties,Nn as sqrMagnitude,Pc as sqrtImpl,Xu as stencilStateFace,B2 as swap,Ld as textureCompress,Dd as threshold,mm as throttle,Ka as toHalfFloat,an as toggleTiles,cm as traverseAncestors,hu as traverseSet,ig as tw,Qm as uniform_real_distribution,Tm as uniform_real_distribution2,Vo as upSample,I as webGPUContext,b0 as zSorterUtil};
11827
+ `).filter(Boolean),i=[];for(const n of r){const o=Jt.parseParameterLine(n);o.mnemonic&&i.push(o.mnemonic)}if(i.length===0)throw new Error("LASLoader: No headers found in ~CURVE section");return i}parseData(e,t,a){const r=e.match(/~A(?:[\x20-\x7E])*(?:\r\n|\r|\n)([\s\S]*?)(?=~|$)/);if(!r||!r[1])throw new Error("LASLoader: ~A data section not found");const i=r[1].trim();if(!i)throw new Error("LASLoader: Data section is empty");const n=i.split(/\s+/).filter(c=>c.trim().length>0).map(c=>Jt.convertToValue(c.trim()));if(n.length===0)throw new Error("LASLoader: No data values found");const o=Math.floor(n.length/t.length);if(o===0)throw new Error("LASLoader: Insufficient data values");const l=[];for(let c=0;c<o;c++){const f=[];for(let d=0;d<t.length;d++){const h=c*t.length+d;h<n.length&&f.push(n[h])}f.length===t.length&&l.push(f)}return l}}var Di=(s=>(s.PointCloud="pointcloud",s.Curve="curve",s.WellTrajectory="trajectory",s))(Di||{}),jp=Object.getOwnPropertyDescriptor,Zp=(s,e,t,a)=>{for(var r=a>1?void 0:a?jp(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Ki=class extends At{constructor(){super();const s=new qe("FatLine_VS","FatLine_FS");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);const e=s.shaderState;e.acceptShadow=!1,e.castShadow=!1,e.receiveEnv=!1,e.acceptGI=!1,e.useLight=!1,e.cullMode=Lt.none,e.depthWriteEnabled=!0,this.setDefault()}setDefault(){this.setUniformColor("baseColor",new J(1,1,1,1)),this.setUniformFloat("lineWidth",1),this.setUniformFloat("opacity",1),this.setUniformVector2("resolution",new de(1920,1080));const s=new R;this.getDefaultColorShader().setUniform("modelMatrix",s.rawData)}};Ki=Zp([Na(Ki,"FatLineShader")],Ki);class qh extends vt{constructor(){super(),this.shader=new Ki,this.transparent=!0}setInstanceBuffer(e){this.shader.setStorageBuffer("instances",e)}setModelMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set lineWidth(e){this.shader.setUniformFloat("lineWidth",e)}get lineWidth(){return this.shader.getUniformFloat("lineWidth")}set opacity(e){this.shader.setUniformFloat("opacity",e)}get opacity(){return this.shader.getUniformFloat("opacity")}set resolution(e){this.shader.setUniformVector2("resolution",e)}get resolution(){return this.shader.getUniformVector2("resolution")}}class Yp extends it{static format=je.BIN;visualizationMode=Di.PointCloud;async parseBuffer(e){const a=await new Kh().parse(e);await this.createVisualization(a)}async createVisualization(e){if("format"in e&&e.format==="binary")this.data=this.createBinaryPointCloudVisualization(e);else{const t=e;let a;switch(this.visualizationMode){case Di.PointCloud:a=this.createPointCloudVisualization(t);break;case Di.Curve:a=this.createCurveVisualization(t);break;case Di.WellTrajectory:a=this.createWellTrajectoryVisualization(t);break;default:a=this.createPointCloudVisualization(t)}a.lasData=t,a.wellParams=t.wellParams,a.curveParams=t.curveParams,this.data=a}}createBinaryPointCloudVisualization(e){const t=new ne;t.name="LASPointCloud";const a=new ne;a.name="LASPointCloudRoot",t.addChild(a);const r=a.addComponent(qa);return r.initFromData(e.positions,e.colors,e.numPoints),r.setPointShape("circle"),r.setPointSize(4),t.lasFormat="binary",t.lasVersion=e.version,t.numPoints=e.numPoints,t.pointDataFormat=e.pointDataFormat,t.bbox=e.bbox,t}verification(){if(this.data)return!0;throw new Error("LASParser: Parse failed")}createPointCloudVisualization(e){const{headers:t,data:a,nullValue:r}=e,i=t.findIndex(D=>D.toUpperCase()==="DEPTH"||D.toUpperCase()==="DEPT");if(i<0)throw new Error("LASParser: DEPTH column not found");const n=t.map((D,A)=>A).filter(D=>D!==i).slice(0,2),o=a.filter(D=>!D.some(A=>A===r||A===+r));if(o.length===0)throw new Error("LASParser: No valid data points after filtering");const l=o.length,c=new Float32Array(l*3),f=new Uint8Array(l*4);let d=1/0,h=-1/0,u=1/0,m=-1/0;if(n.length>0){const D=o.map(A=>+A[n[0]]).filter(A=>!isNaN(A));if(d=Math.min(...D),h=Math.max(...D),n.length>1){const A=o.map(B=>+B[n[1]]).filter(B=>!isNaN(B));u=Math.min(...A),m=Math.max(...A)}}for(let D=0;D<o.length;D++){const A=o[D],B=D*3,v=D*4;if(c[B+2]=+A[i],n.length>0){const U=+A[n[0]],y=h!==d?(U-d)/(h-d):0;if(c[B+0]=y*10,n.length>1){const S=+A[n[1]],F=m!==u?(S-u)/(m-u):0;c[B+1]=F*10}else c[B+1]=0}else c[B+0]=0,c[B+1]=0;if(n.length>0){const U=+A[n[0]],y=h!==d?(U-d)/(h-d):0;this.mapValueToColor(y,f,v)}else f[v+0]=255,f[v+1]=255,f[v+2]=255,f[v+3]=255}const g=new ne;g.name="LASPointCloud";const p=g.addComponent(qa);return p.initFromData(c,f,l),p.setPointShape("circle"),p.setPointSize(4),g}createCurveVisualization(e){const{headers:t,data:a,nullValue:r}=e,i=t.findIndex(D=>D.toUpperCase()==="DEPTH"||D.toUpperCase()==="DEPT");if(i<0)throw new Error("LASParser: DEPTH column not found");const n=t.map((D,A)=>A).find(D=>D!==i);if(n===void 0)throw new Error("LASParser: No curve column found");const o=a.filter(D=>{const A=+D[i],B=+D[n];return!isNaN(A)&&!isNaN(B)&&B!==r&&B!==+r});if(o.length===0)throw new Error("LASParser: No valid data points");const l=o.map(D=>+D[n]),c=Math.min(...l),d=Math.max(...l)-c,h=new Float32Array(o.length*3);for(let D=0;D<o.length;D++){const A=o[D],B=D*3,v=+A[i],U=+A[n];h[B+2]=v;const y=d>0?(U-c)/d:0;h[B+0]=y*10,h[B+1]=0}const u=new wh;u.setPositions(h);const m=new qh;m.baseColor=new J(1,0,0,1),m.lineWidth=2;const g=new ne;g.name=`LASCurve_${t[n]}`;const p=g.addComponent(mi);return p.geometry=u,p.material=m,g}createWellTrajectoryVisualization(e){throw new Error("LASParser: Well trajectory visualization not yet implemented")}normalizeValue(e,t,a){const r=t.map(o=>+o[a]).filter(o=>!isNaN(o)),i=Math.min(...r),n=Math.max(...r);return n!==i?(e-i)/(n-i):0}mapValueToColor(e,t,a){const r=Math.floor(e*255),i=Math.floor((1-e)*255);t[a+0]=r,t[a+1]=0,t[a+2]=i,t[a+3]=255}}class Al extends it{static format=je.BIN;static cloudImageProcessParam="";async parseBuffer(e){switch(Hi(e).mode){case ya.Splat:{const a=Ho(e),r={count:a.vertexCount,position:a.position,rotation:a.rotation,scale:a.scale,opacity:a.opacity,sh:a.sh};r.bbox=Zo(a.position);const i=new ne;i.name="GaussianSplat",i.addComponent(ii).initAsset(r),this.data=i;break}case ya.PointCloud:{const a=Xh(e),r=new ne;r.name="PLYPointCloud";const i=new ne;i.name="PLYPointCloudRoot",r.addChild(i);const n=i.addComponent(qa);if(a.color)n.initFromData(a.position,a.color,a.vertexCount);else{const o=new Uint8Array(a.vertexCount*4);o.fill(255),n.initFromData(a.position,o,a.vertexCount)}n.setPointShape("circle"),n.setPointSize(4),this.data=r;break}case ya.Mesh:{const a=Yh(e),r=new ne;r.name="PLYMesh";const i=new Map;if(a.triangleTexnumbers&&a.triangleTexnumbers.length>0)for(let o=0;o<a.triangleTexnumbers.length;o++){const l=a.triangleTexnumbers[o];i.has(l)||i.set(l,[]),i.get(l).push(o)}else{const o=a.indices.length/3,l=[];for(let c=0;c<o;c++)l.push(c);i.set(0,l)}const n=new Map;if(a.textureFiles&&a.textureFiles.length>0){const o=[];for(let l=0;l<a.textureFiles.length;l++){const c=new ta,f=wt.normalizePath(this.baseUrl+a.textureFiles[l]);o.push(_.res.loadTexture(f+Al.cloudImageProcessParam).then(d=>{c.baseMap=d,n.set(l,c)}))}await Promise.all(o)}n.size===0&&n.set(0,new ta);for(const[o,l]of i){const c=[];for(const m of l){const g=m*3;c.push(a.indices[g+0],a.indices[g+1],a.indices[g+2])}const f=new Le;f.setAttribute(G.position,a.position),f.setAttribute(G.normal,a.normal),a.uv&&f.setAttribute(G.uv,a.uv),a.color&&f.setAttribute(G.color,a.color),f.setIndices(new Uint32Array(c)),f.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let d=n.get(o);d||(d=n.values().next().value||new ta);const h=new ne;h.name=`PLYMesh_Texture_${o}`;const u=h.addComponent(he);u.geometry=f,u.material=d,r.addChild(h)}this.data=r;break}}}verification(){return!!this.data}}class $h{async parse(e){const t=new DataView(e),a=li(t);console.assert(a==="pnts");const r=t.getUint32(4,!0);console.assert(r===1);const i=t.getUint32(8,!0);console.assert(i===e.byteLength);const n=t.getUint32(12,!0),o=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0),f=28,d=new Mi(e,f,n,o),h=f+n+o,u=d.header.POINTS_LENGTH||0,m=new Ls(e,u,h,l,c);return{version:r,featureTable:d,batchTable:m}}}class eu extends $h{async parse(e){const t=await super.parse(e),{featureTable:a,batchTable:r}=t,i=a.header.POINTS_LENGTH;if(!i||i<=0)throw new Error("PNTSLoader: POINTS_LENGTH must be defined and greater than zero");const o=a.header.extensions?.["3DTILES_draco_point_compression"];let l,c;if(o){const u=await this.parseDraco(a,o,i);l=u.positions,c=u.colors,u.normals}else l=this.parsePositions(a,i),c=this.parseColors(a,i),this.parseNormals(a,i);const f=new ne,d=f.addComponent(qa);d.initFromData(l,c,i),d.setPointShape("circle"),d.setPointSize(4);const h=a.getData("RTC_CENTER",1,"FLOAT","VEC3");return h&&f.transform.localPosition.set(h[0],h[1],h[2]),f.batchTable=r,f.featureTable=a,f}parsePositions(e,t){let a=e.getData("POSITION",t,"FLOAT","VEC3");if(a)return a;const r=e.getData("POSITION_QUANTIZED",t,"UNSIGNED_SHORT","VEC3");if(!r)throw new Error("PNTSLoader: Either POSITION or POSITION_QUANTIZED must be defined");const i=e.getData("QUANTIZED_VOLUME_SCALE",1,"FLOAT","VEC3"),n=e.getData("QUANTIZED_VOLUME_OFFSET",1,"FLOAT","VEC3");if(!i||!n)throw new Error("PNTSLoader: QUANTIZED_VOLUME_SCALE and QUANTIZED_VOLUME_OFFSET must be defined for quantized positions");const o=new Float32Array(t*3),l=65535;for(let c=0;c<t;c++){const f=c*3;o[f+0]=r[f+0]/l*i[0]+n[0],o[f+1]=r[f+1]/l*i[1]+n[1],o[f+2]=r[f+2]/l*i[2]+n[2]}return o}parseColors(e,t){let a=e.getData("RGBA",t,"UNSIGNED_BYTE","VEC4");if(a)return a;const r=e.getData("RGB",t,"UNSIGNED_BYTE","VEC3");if(r){const l=new Uint8Array(t*4);for(let c=0;c<t;c++){const f=c*3,d=c*4;l[d+0]=r[f+0],l[d+1]=r[f+1],l[d+2]=r[f+2],l[d+3]=255}return l}const i=e.getData("RGB565",t,"UNSIGNED_SHORT","SCALAR");if(i){const l=new Uint8Array(t*4);for(let c=0;c<t;c++){const f=this.decodeRGB565(i[c]),d=c*4;l[d+0]=f[0],l[d+1]=f[1],l[d+2]=f[2],l[d+3]=255}return l}const n=e.getData("CONSTANT_RGBA",1,"UNSIGNED_BYTE","VEC4");if(n){const l=new Uint8Array(t*4);for(let c=0;c<t;c++){const f=c*4;l[f+0]=n[0],l[f+1]=n[1],l[f+2]=n[2],l[f+3]=n[3]}return l}const o=new Uint8Array(t*4);return o.fill(255),o}parseNormals(e,t){let a=e.getData("NORMAL",t,"FLOAT","VEC3");if(a)return a;const r=e.getData("NORMAL_OCT16P",t,"UNSIGNED_BYTE","VEC2");return r?this.decodeOctNormals(r,t):null}decodeRGB565(e){const t=(e>>11&31)<<3,a=(e>>5&63)<<2,r=(e&31)<<3;return[t,a,r]}decodeOctNormals(e,t){const a=new Float32Array(t*3);for(let r=0;r<t;r++){const i=r*2,n=e[i]/255,o=e[i+1]/255,l=n*2-1,c=o*2-1,f=1-Math.abs(l)-Math.abs(c);let d,h;f<0?(d=(l>=0?1:-1)*(1-Math.abs(c)),h=(c>=0?1:-1)*(1-Math.abs(l))):(d=l,h=c);const u=Math.sqrt(d*d+h*h+f*f),m=r*3;a[m+0]=d/u,a[m+1]=h/u,a[m+2]=f/u}return a}async parseDraco(e,t,a){throw new Error("Draco compression not yet implemented")}}class tu extends it{static format=je.BIN;async parseBuffer(e){const a=await new eu().parse(e),r=new ne;r.name="PNTS",r.addChild(a),this.data=r}verification(){if(this.data)return!0;throw new Error("PNTSParser: Parse failed")}}class Ko{boneName;bonePath;parentBoneName;boneID;parentBoneID;instanceID;parentInstanceID;t;q;s;formBytes(e){this.boneName=e.readUTF(),this.bonePath=e.readUTF(),this.parentBoneName=e.readUTF(),this.boneID=e.readInt32(),this.parentBoneID=e.readInt32(),this.instanceID=e.readUTF(),this.parentInstanceID=e.readUTF(),this.t=e.readVector3(),this.q=e.readQuaternion(),this.s=e.readVector3()}}class qo{name;count;boneData;boneMap;formBytes(e){this.boneData=[],this.boneMap=new Map,this.name=e.readUTF(),this.count=e.readInt32();for(let t=0;t<this.count;t++){let a=new Ko;a.formBytes(e.readBytesArray()),this.boneData[t]=a,this.boneMap.set(a.boneName,a)}}}class au extends it{static format=je.BIN;static parser(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new qo;i.formBytes(e.readBytesArray()),_.res.addObj(i.name,i)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}G.position,G.normal,G.color,G.TANGENT,G.uv,G.TEXCOORD_1,G.TEXCOORD_2,G.TEXCOORD_2,G.TEXCOORD_4,G.TEXCOORD_5,G.TEXCOORD_6,G.TEXCOORD_7,G.joints0,G.weights0;var X=(s=>(s[s.single=0]="single",s[s.boolean=1]="boolean",s[s.int=2]="int",s[s.int16=3]="int16",s[s.int32=4]="int32",s[s.float=5]="float",s[s.long=6]="long",s[s.uint=7]="uint",s[s.uint32=8]="uint32",s[s.uint64=9]="uint64",s[s.double=10]="double",s[s.string=11]="string",s[s.singleArray=12]="singleArray",s[s.stringArray=13]="stringArray",s[s.floatArray=14]="floatArray",s[s.vector2=15]="vector2",s[s.vector3=16]="vector3",s[s.vector4=17]="vector4",s[s.color=18]="color",s[s.color32=19]="color32",s[s.animationCurve=20]="animationCurve",s[s.quaternion=21]="quaternion",s[s.matrix4x4=22]="matrix4x4",s[s.mesh=23]="mesh",s[s.texture=24]="texture",s[s.material=25]="material",s[s.materials=26]="materials",s[s.skeleton=27]="skeleton",s[s.animClip=28]="animClip",s[s.vector2Int=29]="vector2Int",s[s.int32List=30]="int32List",s[s.colorList=31]="colorList",s[s.color32List=32]="color32List",s))(X||{});class Hs{static GetMaterial(e){let t=e,a=t.split("/");t=a[a.length-1],a=t.split("."),t=a[a.length-1];let r=El(t);if(r){let i=new vt;return i.shader=new r,i}else throw new Error("not found shader, shader name is "+t)}static applyMaterialTexture(e,t){for(let a=0;a<t.length;a++){const r=t[a];r.property in e?e[r.property]=r.texture:r.property in e.shader?e.shader[r.property]=r.texture:e.setTexture(r.property,r.texture)}}static applyMaterialProperties(e,t){for(let a=0;a<t.length;a++){const r=t[a],i=r.key;switch(r.type){case X.color:case X.color32:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformColor(i,n)}break;case X.single:case X.float:case X.int:case X.int16:case X.int32:case X.uint:case X.uint32:case X.uint64:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case X.singleArray:{let n=r.getValue()[0];i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case X.vector2:case X.vector2Int:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector2(i,n)}break;case X.vector3:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector3(i,n)}break;case X.vector4:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector4(i,n)}break}}}}class Wa{static parser(e){switch(e.readInt32()){case X.single:return{t:X.single,v:e.readFloat32()};case X.boolean:return{t:X.boolean,v:e.readBoolean()};case X.int:return{t:X.int,v:e.readInt32()};case X.int16:return{t:X.int16,v:e.readInt16()};case X.int32:return{t:X.int32,v:e.readInt32()};case X.float:return{t:X.float,v:e.readFloat32()};case X.long:return{t:X.long,v:e.readFloat64()};case X.uint:return{t:X.uint,v:e.readUnit32()};case X.uint32:return{t:X.uint32,v:e.readUnit32()};case X.uint64:return{t:X.uint64,v:e.readUnit32()};case X.double:return{t:X.double,v:e.readFloat64()};case X.string:return{t:X.string,v:e.readUTF()};case X.singleArray:return{t:X.singleArray,v:e.readFloatArray()};case X.stringArray:return{t:X.stringArray,v:e.readStringArray()};case X.floatArray:return{t:X.floatArray,v:e.readFloatArray()};case X.vector2:return{t:X.vector2,v:e.readVector2()};case X.vector3:return{t:X.vector3,v:e.readVector3()};case X.vector4:return{t:X.vector4,v:e.readVector4()};case X.color:return{t:X.color,v:e.readColor()};case X.color32:return{t:X.color32,v:e.readColor()};case X.animationCurve:return{t:X.animationCurve,v:null};case X.quaternion:return{t:X.quaternion,v:e.readQuaternion()};case X.matrix4x4:return{t:X.matrix4x4,v:null};case X.mesh:{let o=e.readUTF(),l=_.res.getGeometry(o);return{t:X.mesh,v:l}}case X.texture:{let o=e.readUTF(),l=_.res.getTexture(o);return{t:X.texture,v:l}}case X.material:{let o=e.readUTF(),l=_.res.getMat(o);return{t:X.material,v:l}}case X.materials:{let o=e.readStringArray(),l=[];for(let c=0;c<o.length;c++){const f=o[c];let d=_.res.getMat(f);l.push(d)}return{t:X.materials,v:l}}case X.skeleton:break;case X.animClip:{let o=[],l=e.readInt32();for(let c=0;c<l;c++){let f=new fl;f.formBytes(e),o.push(f)}return{t:X.animClip,v:o}}case X.vector2Int:return{t:X.vector2Int,v:e.readVector2int()};case X.int32List:return{t:X.int32List,v:e.readInt32List()};case X.colorList:let a=e.readInt32(),r=[];for(let o=0;o<a;o++){const l=Wa.parser(e).v;r.push(l)}return{t:X.colorList,v:r};case X.color32List:let i=e.readInt32(),n=[];for(let o=0;o<i;o++){const l=Wa.parser(e).v;n.push(l)}return{t:X.color32List,v:n}}}}class $o{key;type;_data;getValue(){return this._data}formBytes(e){this.key=e.readUTF();let{t,v:a}=Wa.parser(e);this.type=t,this._data=a}}class ru{property;name;texture;texelSize;wrapModeU;wrapModeV;wrapModeW;wrapMode;anisoLevel;dimension;filterMode}class iu extends it{static format=je.TEXT;static parserMaterial(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=e.readBytesArray(),n=i.readUTF(),o=i.readUTF();i.readUTF();let l=i.readStringArray();i.readVector4(),i.readVector4();let c=i.readUTF(),f=[],d=[],h=i.readInt32();for(let g=0;g<h;g++){let p=new $o;p.formBytes(i),f.push(p)}let u=i.readInt32();for(let g=0;g<u;g++){let p=i.readBytesArray(),D=new ru;D.property=p.readUTF(),D.name=p.readUTF(),D.texture=_.res.getTexture(D.name),D.texelSize=p.readVector2(),D.wrapModeU=p.readUnit32(),D.wrapModeV=p.readUnit32(),D.wrapModeW=p.readUnit32(),D.wrapMode=p.readUnit32(),D.anisoLevel=p.readUnit32(),D.dimension=p.readUnit32(),D.filterMode=p.readUnit32(),d.push(D)}let m=Hs.GetMaterial(c);m.name=n;for(let g=0;g<l.length;g++){const p=l[g];m.shader.setDefine(p,!0)}Hs.applyMaterialTexture(m,d),Hs.applyMaterialProperties(m,f),_.res.addMat(o,m)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class el{shapeName;shapeIndex;frameCount;blendPositionList=new Float32Array;blendNormalList=new Float32Array;formBytes(e){let t=e.readBytesArray();this.shapeName=t.readUTF(),this.shapeIndex=t.readInt32(),this.frameCount=t.readInt32();let a=t.readInt32();this.blendPositionList=t.readFloat32Array(a*3);let r=t.readInt32();this.blendNormalList=t.readFloat32Array(r*3)}}class tl{vertexCount;shapeNames;shapeIndexs;blendCount;blendShapePropertyDatas;blendShapeMap;formBytes(e){this.blendShapeMap=new Map,this.blendShapePropertyDatas=[];let t=e.readBytesArray();this.vertexCount=t.readInt32(),this.shapeNames=t.readStringArray(),this.shapeIndexs=t.readIntArray(),this.blendCount=t.readInt32();for(let a=0;a<this.blendCount;a++){let r=new el;r.formBytes(t),this.blendShapePropertyDatas.push(r),this.blendShapeMap.set(r.shapeName,r)}return e}}class su{name;meshName;meshID;vertexCount;vertexStrip;vertexBuffer;indices;attributes;bones;bindPose;blendShapeData}class nu extends it{static format=je.BIN;async parseBuffer(e){}static parserMeshs(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new su,n=e.readBytesArray();i.meshName=n.readUTF(),i.meshID=n.readUTF(),n.readFloat32()>0,n.readFloat32()>0,n.readFloat32()>0;let o=n.readFloat32()>0,l=n.readFloat32()>0;o&&(i.bones=n.readStringArray(),i.bindPose=n.readMatrix44Array()),l&&(i.blendShapeData=new tl,i.blendShapeData.formBytes(n));let c=n.readBytesArray(),f=n.readBytesArray(),d=c.readInt32(),h=0,u=[];for(let A=0;A<d;A++)u[A]={},u[A].att=Xp[c.readUTF()],u[A].dim=c.readInt32(),h+=u[A].dim,u[A].format=c.readUTF();i.vertexCount=c.readInt32(),i.vertexBuffer=f.getFloat32Array();let m=n.readInt32Array(),g=[],p=n.readInt32();for(let A=0;A<p;A++){let B=n.readInt32(),v=n.readInt32(),U=n.readInt32(),y=n.readInt32(),S=n.readInt32(),F=n.readInt32();n.readVector3(),n.readVector3();let C={indexStart:v,indexCount:U,vertexStart:y,vertexCount:F,firstStart:S,topology:B,index:A};g.push(C)}m.length>65535?i.indices=new Uint32Array(m):i.indices=new Uint16Array(m);let D=new Le;if(D.vertexDim=h,D.geometryType=kt.compose_bin,D.setIndices(i.indices),D.setAttribute(G.all,i.vertexBuffer),o&&(D.skinNames=i.bones,D.bindPose=i.bindPose),l){D.blendShapeData=i.blendShapeData,D.morphTargetsRelative=!0,D.morphTargetDictionary={};for(let A=0;A<i.blendShapeData.blendCount;A++){D.setAttribute("a_morphPositions_"+A,i.blendShapeData.blendShapePropertyDatas[A].blendPositionList),D.setAttribute("a_morphNormals_"+A,i.blendShapeData.blendShapePropertyDatas[A].blendNormalList);for(let B=0;B<i.blendShapeData.blendCount;B++){let v=i.blendShapeData.shapeNames[B],U=i.blendShapeData.shapeIndexs[B];D.morphTargetDictionary[v]=U}}}for(let A=0;A<u.length;A++){const B=u[A].att;D.setAttribute(B,null)}for(let A=0;A<g.length;A++){const B=g[A];D.addSubGeometry(B)}D.name=i.meshName,_.res.addGeometry(i.meshID,D)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}let Xp={Position:G.position,Normal:G.normal,Color:G.color,Tangent:G.TANGENT,TexCoord0:G.uv,TexCoord1:G.TEXCOORD_1,TexCoord2:G.TEXCOORD_2,TexCoord3:G.TEXCOORD_2,TexCoord4:G.TEXCOORD_4,TexCoord5:G.TEXCOORD_5,TexCoord6:G.TEXCOORD_6,TexCoord7:G.vIndex,BlendIndices:G.joints0,BlendWeight:G.weights0};class Dn extends DataView{get buffer(){return super.buffer}get byteOffset(){return super.byteOffset}get byteLength(){return super.byteLength}getInt16(e,t){return super.getInt16(e,t)}getInt32(e,t){return super.getInt32(e,t)}getFloat32(e,t){return super.getFloat32(e,t)}getFloat64(e,t){return super.getFloat64(e,t)}getUint8(e){return super.getUint8(e)}getUint32(e,t){return super.getUint32(e,t)}getInt8(e){return super.getInt8(e)}getUint16(e,t){return super.getUint16(e,t)}position=0;littleEndian=!0;constructor(e,t,a){super(e,t,a),this.position=0,this.position+=this.byteOffset}readUTF(){let e=this.readInt32(),t=e%4;t>0&&t<4&&(t=4-t);let a="",r=new Int8Array(this.buffer,this.position,e);return this.position+=e*Int8Array.BYTES_PER_ELEMENT,a+=String.fromCharCode.apply(null,r),this.position+=t*Int8Array.BYTES_PER_ELEMENT,a}readStringArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readUTF());return e}readByte(){let e=this.buffer[this.position];return this.position+=1,e}readBoolean(){let e=this.readInt32();return this.position+=4,e==1}readBytes(e){let t=new DataView(this.buffer,this.position,e);return this.position+=e,t.buffer}readBytesArray(){let e=this.readInt32(),t=new Dn(this.buffer.slice(this.position,this.position+e));return this.position+=e,t}readUnit8(){let e=this.getUint8(this.position);return this.position+=Uint8Array.BYTES_PER_ELEMENT,e}readUnit16(){let e=this.getUint16(this.position);return this.position+=Uint16Array.BYTES_PER_ELEMENT,e}readUnit32(){let e=this.getUint32(this.position);return this.position+=Uint32Array.BYTES_PER_ELEMENT,e}readInt8(){let e=this.getInt8(this.position);return this.position+=Int8Array.BYTES_PER_ELEMENT,e}readInt16(){let e=this.getInt16(this.position,this.littleEndian);return this.position+=Int16Array.BYTES_PER_ELEMENT,e}readInt32(){let e=this.getInt32(this.position,this.littleEndian);return this.position+=Int32Array.BYTES_PER_ELEMENT,e}readFloat32(){let e=this.getFloat32(this.position,this.littleEndian);return this.position+=Float32Array.BYTES_PER_ELEMENT,e}readFloat64(){let e=this.getFloat64(this.position,this.littleEndian);return this.position+=Float64Array.BYTES_PER_ELEMENT,e}readInt32Array(){let e=this.readInt32(),t=new Int32Array(this.buffer,this.position,e);return t=t.slice(0,e),this.position+=t.byteLength,t}readInt32List(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++)t.push(this.readInt32());return t}readFloatArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readFloat32();t.push(r)}return t}readIntArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readInt32();t.push(r)}return t}readVector2int(){let e=new de;return e.x=this.readInt32(),e.y=this.readInt32(),e}readVector2(){let e=new de;return e.x=this.readFloat32(),e.y=this.readFloat32(),e}readVector3(){let e=new b;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e}readVector3Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector3());return e}readVector4(){let e=new be;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readVector4Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector4());return e}readColor(){let e=new J;return e.r=this.readFloat32(),e.g=this.readFloat32(),e.b=this.readFloat32(),e.a=this.readFloat32(),e}readColorArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readColor());return e}readQuaternion(){let e=new se;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readQuaternionArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readQuaternion());return e}readMatrix44(){let e=new R,t=e.rawData;return t[0]=this.readFloat32(),t[1]=this.readFloat32(),t[2]=this.readFloat32(),t[3]=this.readFloat32(),t[4]=this.readFloat32(),t[5]=this.readFloat32(),t[6]=this.readFloat32(),t[7]=this.readFloat32(),t[8]=this.readFloat32(),t[9]=this.readFloat32(),t[10]=this.readFloat32(),t[11]=this.readFloat32(),t[12]=this.readFloat32(),t[13]=this.readFloat32(),t[14]=this.readFloat32(),t[15]=this.readFloat32(),e}readMatrix44Array(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readMatrix44();t.push(r)}return t}readFloat32Array(e){let t=new DataView(this.buffer),a=new Float32Array(e);for(let r=0;r<e;r++)a[r]=t.getFloat32(this.position+r*Float32Array.BYTES_PER_ELEMENT,this.littleEndian);return this.position+=e*Float32Array.BYTES_PER_ELEMENT,a}getFloat32Array(){let e=new Float32Array(this.buffer,this.byteOffset,this.byteLength/Float32Array.BYTES_PER_ELEMENT);return e=e.slice(0,this.byteLength),e}}class ou extends it{static format=je.TEXT;static async parserTexture(e,t,a){let r=e.readInt32(),i=[];for(let o=0;o<r;o++){let l=e.readUTF();lu.useWebp?(l=l.replace("png","webp"),l=l.replace("jpb","webp"),i.push(t.baseUrl+"webp/"+l)):i.push(t.baseUrl+l)}let n=await _.res.loadBitmapTextures(i,_.setting.loader.numConcurrent,a,!0);for(const o of n)_.res.addTexture(o.name,o)}verification(){if(this.data)return!0;throw new Error("verify failed.")}}var Hp=Object.getOwnPropertyDescriptor,Kp=(s,e,t,a)=>{for(var r=a>1?void 0:a?Hp(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Ks=class extends At{constructor(){super(),Y.register("PBRLitSSSShader",Zd);let s=new qe("PBRLitSSSShader","PBRLitSSSShader");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!0,e.castShadow=!0,e.receiveEnv=!0,e.acceptGI=!0,e.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefine("USE_CUSTOMUNIFORM",!0),this.setDefault(),this.computes=[new Vh(this)]}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(1,1,1)),this.setUniformVector4("materialF0",new be(.04,.04,.04,1)),this.setUniformColor("specularColor",new J(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new J(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformColor("skinColor",new J(1,0,0)),this.setUniformFloat("skinPower",3.4),this.setUniformFloat("skinColorIns",.5),this.setUniformFloat("curveFactor",1)}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _SSSMap(s){this.setTexture("sssMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SkinColor(s){this.setUniformColor("skinColor",s)}set _SkinPower(s){this.setUniformFloat("skinPower",s)}set _SkinColorIns(s){this.setUniformFloat("skinColorIns",s)}set curveFactor(s){this.setUniformFloat("curveFactor",s)}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};Ks=Kp([Na(Ks,"LitSSSShader")],Ks);var qp=Object.getOwnPropertyDescriptor,$p=(s,e,t,a)=>{for(var r=a>1?void 0:a?qp(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let qs=class extends At{constructor(){super();let s=new qe("PBRLItShader","PBRLItShader");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!0,e.castShadow=!0,e.receiveEnv=!0,e.acceptGI=!0,e.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(0,0,0)),this.setUniformVector4("materialF0",new be(.04,.04,.04,1)),this.setUniformColor("specularColor",new J(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new J(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this._MainTex=_.res.grayTexture,this._BumpMap=_.res.normalTexture,this._MaskTex=_.res.maskTexture}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};qs=$p([Na(qs,"LitShader")],qs);class _n{comName;data;static parser(e){let t=e.readBytesArray(),a=new _n;a.comName=t.readUTF(),a.data=[];let r=t.readInt32();for(let i=0;i<r;i++){let n=new $o;n.formBytes(t),a.data.push(n)}return a}}class xs{name;parentName;position;rotation;scale;comDatas;child;static parser(e){let t=e.readBytesArray(),a=new xs;a.name=t.readUTF(),a.parentName=t.readUTF(),a.position=t.readVector3(),a.rotation=t.readQuaternion(),a.scale=t.readVector3(),a.comDatas=[],a.child=[];let r=t.readInt32();for(let n=0;n<r;n++){const o=_n.parser(t);a.comDatas.push(o)}let i=t.readInt32();for(let n=0;n<i;n++){const o=xs.parser(t);a.child.push(o)}return a}}class lu extends it{static useWebp=!0;static format=je.BIN;avatarDic;nodeData;async parseBuffer(e){this.avatarDic={};let t=new Dn(e,0);await ou.parserTexture(t,this,this.loaderFunctions),au.parser(t,this),nu.parserMeshs(t,this),iu.parserMaterial(t,this),this.nodeData=this.parserPrefabNode(t),this.data=this.data=this.parserNodeTree(this.nodeData)}parserPrefabNode(e){return xs.parser(e)}parserNodeTree(e){let t=new ne;if(t.localPosition=b.serialize(e.position),t.localQuaternion=se.serialize(e.rotation),t.localScale=b.serialize(e.scale),t.name=e.name,e.comDatas)for(let a=0;a<e.comDatas.length;a++){const r=e.comDatas[a];let i=null,n=kl(r.comName);if(n){i=t.getOrAddComponent(n);for(let o=0;o<r.data.length;o++){const l=r.data[o];l.key in i&&(i[l.key]=l.getValue())}}}if(e.child&&e.child.length>0)for(let a=0;a<e.child.length;a++){let r=this.parserNodeTree(e.child[a]);t.addChild(r)}return t}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class em{static getNumber(e){return parseFloat(e)}static getInt(e){return parseInt(e)}static getBoolean(e){return e=="true"}static getNumberArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(",");for(let r=0;r<a.length;r++)parseFloat(a[r]);return t}static getStringArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(","),r=[];for(let i=0;i<a.length;i++){const n=a[i];r.push(n)}return r}static getVector2(e){}static getVector3(e){}static getVector4(e){}static getQuaternion(e){}static getColor(e){}}var tm=Object.getOwnPropertyDescriptor,am=(s,e,t,a)=>{for(var r=a>1?void 0:a?tm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let qi=class extends At{constructor(){super();let s=new qe("UnLit","UnLit");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!1,e.castShadow=!1,e.receiveEnv=!1,e.acceptGI=!1,e.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};qi=am([Na(qi,"UnLitShader")],qi);var rm=Object.getOwnPropertyDescriptor,im=(s,e,t,a)=>{for(var r=a>1?void 0:a?rm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let $i=class extends At{constructor(){super(),Y.register("VertexAttributeIndexShader",Wd),Y.register("UnLitTextureArray",Yd);let s=new qe("UnLitTextureArray","UnLitTextureArray");s.setShaderEntry("VertMain","FragMain"),this.addRenderPass(s);let e=s.shaderState;e.acceptShadow=!1,e.castShadow=!1,e.receiveEnv=!1,e.acceptGI=!1,e.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new be(0,0,1,1)),this.setUniformVector4("transformUV2",new be(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(s){this.setTexture("baseMap",s)}set _BumpMap(s){this.setTexture("normalMap",s)}set _MaskTex(s){this.setTexture("maskMap",s)}set _UVTransform(s){this.setUniformVector4("transformUV1",s)}set _Metallic(s){this.setUniformFloat("metallic",s)}set _Roughness(s){this.setUniformFloat("roughness",s)}set _MainColor(s){this.setUniformColor("baseColor",s)}set _AlphaCutoff(s){this.setUniformFloat("alphaCutoff",s)}set _DoubleSidedEnable(s){let e=this.getDefaultColorShader();e.shaderState.cullMode=s?Lt.none:e.shaderState.cullMode}set _SurfaceType(s){let e=this.getDefaultColorShader();s==0?e.blendMode=De.NONE:e.blendMode=De.ALPHA}set _AlphaCutoffEnable(s){s==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}};$i=im([Na($i,"UnLitTexArrayShader")],$i);const _r=-1,Br=0,al=1,cu=2,La=3,sm=6378137,nm=1/298.257223563,om=6356752314245179e-9,lm=Symbol("PLUGIN_REGISTERED");class rl{boundingVolume;geometricError;refine;content;contents;transform;extensions;extras;parent=null;children=[];loadingState=Br;used=!1;visible=!1;active=!1;inFrustum=!1;error=1/0;distanceFromCamera=1/0;depth=0;depthFromRenderedParent=0;lastFrameVisited=-1;isLeaf=!1;allChildrenReady=!1;hasContent=!1;hasRenderableContent=!1;hasUnrenderableContent=!1;childrenProcessed=0;usedLastFrame=!1;priority;canTraverse=!1;canTraverseFrame=-1;basePath="";cached={};constructor(e,t=null){if(this.boundingVolume=e.boundingVolume,this.geometricError=e.geometricError,this.refine=e.refine,this.content=e.content,this.contents=e.contents,this.transform=e.transform,this.extensions=e.extensions,this.extras=e.extras,this.parent=t,this.depth=t?t.depth+1:0,this.depthFromRenderedParent=t?.hasContent?0:t?t.depthFromRenderedParent+1:0,this.hasContent=!!(this.content||this.contents&&this.contents.length>0),this.content?.uri){const a=this.content.uri.toLowerCase();this.hasUnrenderableContent=a.endsWith("tileset.json"),this.hasRenderableContent=!this.hasUnrenderableContent}else this.contents&&this.contents.length>0&&(this.hasRenderableContent=!0)}addChild(e){e.parent=this,e.depth=this.depth+1,e.depthFromRenderedParent=this.hasContent?0:this.depthFromRenderedParent+1,this.children.push(e)}resetFrameState(e){this.lastFrameVisited!==e&&(this.lastFrameVisited=e,this.used=!1,this.inFrustum=!1,this.isLeaf=!1,this.visible=!1,this.active=!1,this.error=1/0,this.distanceFromCamera=1/0,this.allChildrenReady=!1)}}const fu=2**30;class du{minSize=6e3;maxSize=8e3;minBytesSize=.3*fu;maxBytesSize=.4*fu;unloadPercent=.05;autoMarkUnused=!0;_itemSet=new Map;_itemList=[];_usedSet=new Set;_callbacks=new Map;_unloadingHandle=-1;_cachedBytes=0;_bytesMap=new Map;_loadedSet=new Set;_unloadPriorityCallback=null;set unloadPriorityCallback(e){this._unloadPriorityCallback=e}get unloadPriorityCallback(){return this._unloadPriorityCallback}isFull(){return this._itemSet.size>=this.maxSize||this._cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this._bytesMap.get(e)||0}setMemoryUsage(e,t){if(!this._itemSet.has(e))return;const a=this._bytesMap.get(e)||0;this._cachedBytes-=a,this._bytesMap.set(e,t),this._cachedBytes+=t}add(e,t){return this._itemSet.has(e)||this.isFull()?!1:(this._itemList.push(e),this._usedSet.add(e),this._itemSet.set(e,Date.now()),this._callbacks.set(e,t),this._loadedSet.add(e),!0)}has(e){return this._itemSet.has(e)}remove(e){if(!this._itemSet.has(e))return!1;const t=this._bytesMap.get(e)||0;this._cachedBytes-=t,this._bytesMap.delete(e);const a=this._callbacks.get(e);a&&a(e);const r=this._itemList.indexOf(e);return r!==-1&&this._itemList.splice(r,1),this._usedSet.delete(e),this._itemSet.delete(e),this._callbacks.delete(e),this._loadedSet.delete(e),!0}markUsed(e){this._itemSet.has(e)&&(this._usedSet.add(e),this._itemSet.set(e,Date.now()))}markUnused(e){this._usedSet.delete(e)}scheduleUnload(){this._unloadingHandle===-1&&(this._unloadingHandle=requestAnimationFrame(()=>{this._unloadingHandle=-1,this._performUnload()}))}_performUnload(){if(!(this._itemSet.size>this.minSize||this._cachedBytes>this.minBytesSize))return;this.autoMarkUnused&&this._itemSet.forEach((o,l)=>{this._usedSet.has(l)||this.markUnused(l)});const t=[];this._itemList.forEach(o=>{this._usedSet.has(o)||t.push(o)}),this._unloadPriorityCallback&&t.sort(this._unloadPriorityCallback);const a=Math.floor(this._itemSet.size*(1-this.unloadPercent)),r=this._cachedBytes-(this._cachedBytes-this.minBytesSize);let i=0,n=0;for(let o=0;o<t.length;o++){const l=t[o];if(this._itemSet.size-i<=a&&this._cachedBytes-n<=r)break;const c=this._bytesMap.get(l)||0;this.remove(l)&&(i++,n+=c)}}clear(){Array.from(this._itemSet.keys()).forEach(t=>this.remove(t))}getStats(){return{size:this._itemSet.size,bytes:this._cachedBytes,usedCount:this._usedSet.size}}}class il{maxJobs=6;priorityCallback=null;_items=[];_callbacks=new Map;_currJobs=0;get running(){return this._items.length!==0||this._currJobs!==0}sort(){this.priorityCallback&&this._items.sort(this.priorityCallback)}has(e){return this._callbacks.has(e)}add(e,t){if(this._callbacks.has(e))return this._callbacks.get(e).promise;let a,r;const i=new Promise((o,l)=>{a=o,r=l}),n={callback:t,promise:i,resolve:a,reject:r};return this._items.unshift(e),this._callbacks.set(e,n),i}remove(e){const t=this._items.indexOf(e);if(t!==-1){const a=this._callbacks.get(e);a&&(a.promise.catch(()=>{}),a.reject(new Error("PriorityQueue: Item removed."))),this._items.splice(t,1),this._callbacks.delete(e)}}removeByFilter(e){const t=[];this._items.forEach(a=>{e(a)&&t.push(a)}),t.forEach(a=>this.remove(a))}update(){this._tryRunJobs()}_tryRunJobs(){this.sort();const e=this.maxJobs;let t=0;const a=()=>{this._currJobs--};for(;e>this._currJobs&&this._items.length>0&&t<e;){this._currJobs++,t++;const r=this._items.shift(),i=this._callbacks.get(r);this._callbacks.delete(r),Promise.resolve(i.callback(r)).then(()=>{i.resolve(),a()}).catch(n=>{i.reject(n),a()})}}clear(){Array.from(this._items).forEach(t=>this.remove(t))}getStats(){return{queued:this._items.length,running:this._currJobs}}}function hu(s,e=null,t=null){const a=[];for(a.push(s),a.push(null),a.push(0);a.length>0;){const r=a.pop(),i=a.pop(),n=a.pop();if(e&&e(n,i,r)===!0){t&&t(n,i,r);return}const o=n.children;if(o&&o.length>0)for(let l=o.length-1;l>=0;l--)a.push(o[l]),a.push(n),a.push(r+1);if(t&&t(n,i,r)===!0)return}}function cm(s,e){let t=s;for(;t;){const a=t.depth,r=t.parent;e(t,r,a),t=r}}const $s={inView:!1,error:1/0,distanceFromCamera:1/0},uu=!0;function bu(s){return s===La||s===_r}function vr(s,e){return s.lastFrameVisited===e&&s.used}function gu(s){return s.childrenProcessed===s.children.length}function sl(s){return s.hasUnrenderableContent||s.parent!==null&&s.parent.geometricError<s.geometricError}function nl(s,e){s.lastFrameVisited!==e.frameCount&&(s.usedLastFrame=s.used,s.lastFrameVisited=e.frameCount,s.used=!1,s.inFrustum=!1,s.isLeaf=!1,s.visible=!1,s.active=!1,s.error=1/0,s.distanceFromCamera=1/0,s.allChildrenReady=!1,e.calculateTileViewError(s,$s),s.inFrustum=$s.inView,s.error=$s.error,s.distanceFromCamera=$s.distanceFromCamera)}function ol(s,e,t=!1){s.used||(t||(s.used=!0,e.stats.used++),e.markTileUsed(s),s.inFrustum===!0&&e.stats.inFrustum++)}function fm(s,e){if(s.canTraverse&&s.canTraverseFrame===e.frameCount)return s.canTraverse;let t=!1;return s.error<=e.errorTarget&&!sl(s)||s.depth>=e.maxDepth||!s.children||s.children.length===0?t=!1:t=!0,s.canTraverse=t,s.canTraverseFrame=e.frameCount,t}function ll(s,e,t=!1){if(e.ensureChildrenArePreprocessed(s),nl(s,e),ol(s,e,t),sl(s)&&gu(s)){const a=s.children;for(let r=0,i=a.length;r<i;r++)ll(a[r],e,t)}}function en(s,e){if(e.ensureChildrenArePreprocessed(s),nl(s,e),!s.inFrustum)return;if(!fm(s,e)){ol(s,e);const n=s.children;if(!s.hasContent&&n&&n.length>0)for(let o=0,l=n.length;o<l;o++){const c=n[o];en(c,e)}return}const a=s.children;let r=!1,i=!1;for(let n=0,o=a.length;n<o;n++){const l=a[n];en(l,e),r=r||vr(l,e.frameCount),i=i||l.inFrustum}if(s.refine==="REPLACE"&&!i&&a.length!==0){s.inFrustum=!1;for(let n=0,o=a.length;n<o;n++)ll(a[n],e,!0);return}if(ol(s,e),s.refine==="REPLACE"&&(r&&s.depth!==0||uu))for(let n=0,o=a.length;n<o;n++)ll(a[n],e)}function cl(s,e){const t=e.frameCount;if(!vr(s,t))return;const a=s.children;let r=!1;for(let i=0,n=a.length;i<n;i++){const o=a[i];r=r||vr(o,t)}if(!r)s.isLeaf=!0;else{let i=!0;for(let n=0,o=a.length;n<o;n++){const l=a[n];if(cl(l,e),vr(l,t)){const c=!sl(l);let f=!l.hasContent||l.hasRenderableContent&&bu(l.loadingState)||l.hasUnrenderableContent&&l.loadingState===_r;f=c&&f||l.allChildrenReady,i=i&&f}}s.allChildrenReady=i}}function pu(s,e){if(e.ensureChildrenArePreprocessed(s),vr(s,e.frameCount)&&(s.hasContent&&e.queueTileForDownload(s),gu(s))){const t=s.children;for(let a=0,r=t.length;a<r;a++)pu(t[a],e)}}function tn(s,e){const t=e.stats;if(!vr(s,e.frameCount))return;if(s.isLeaf){s.loadingState===La?(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++):s.hasContent&&e.queueTileForDownload(s);return}const a=s.children,r=s.hasContent,i=bu(s.loadingState)&&r,n=(e.errorTarget+1)*(e.errorThreshold||1),o=s.error<=n,l=s.refine==="ADD",c=s.allChildrenReady||s.depth===0&&!uu;if(r&&(o||l)&&e.queueTileForDownload(s),(o&&i&&!c||i&&l)&&(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++),!l&&o&&!c)for(let f=0,d=a.length;f<d;f++){const h=a[f];vr(h,e.frameCount)&&pu(h,e)}else for(let f=0,d=a.length;f<d;f++)tn(a[f],e)}function an(s,e){const t=vr(s,e.frameCount);if(t||s.usedLastFrame){let a=!1,r=!1;if(t?(a=s.active,r=s.visible):nl(s,e),s.hasRenderableContent&&s.loadingState===La){const n=s.__wasSetVisible;s.__wasSetActive!==a&&(e.setTileDelayedActive(s,a),s.__wasSetActive=a),n!==r&&(e.setTileDelayedVisible(s,r),s.__wasSetVisible=r)}s.usedLastFrame=t;const i=s.children;for(let n=0,o=i.length;n<o;n++)an(i[n],e)}}class Xr{static s_tmpMatrix=null;_type;_data;_box;get box(){return this._box}_sphere;_matrix;constructor(e){if(Xr.s_tmpMatrix||(Xr.s_tmpMatrix=new R),this._data=e,e.box)this._type="box",this._parseBox(e.box);else if(e.sphere)this._type="sphere",this._parseSphere(e.sphere);else if(e.region)this._type="region",this._parseRegion(e.region);else throw new Error("BoundingVolume: Invalid bounding volume data")}_parseBox(e){if(e.length!==12)throw new Error("BoundingVolume: Box must have 12 elements");const t=new b(e[0],e[1],e[2]),a=new b(e[3],e[4],e[5]),r=new b(e[6],e[7],e[8]),i=new b(e[9],e[10],e[11]),n=a.length,o=r.length,l=i.length,c=a.clone().normalize(),f=r.clone().normalize(),d=i.clone().normalize();this._matrix=new R;const h=this._matrix.rawData;h[0]=c.x,h[1]=c.y,h[2]=c.z,h[3]=0,h[4]=f.x,h[5]=f.y,h[6]=f.z,h[7]=0,h[8]=d.x,h[9]=d.y,h[10]=d.z,h[11]=0,h[12]=t.x,h[13]=t.y,h[14]=t.z,h[15]=1;const u=new b(n*2,o*2,l*2);this._box=new Ce(new b(0,0,0),u)}_parseSphere(e){if(e.length!==4)throw new Error("BoundingVolume: Sphere must have 4 elements");const t=new b(e[0],e[1],e[2]),a=e[3];this._sphere=new Lr(t,a)}_parseRegion(e){if(e.length!==6)throw new Error("BoundingVolume: Region must have 6 elements");const[t,a,r,i,n,o]=e,l=new b((t+r)/2,(a+i)/2,(n+o)/2),c=new b(Math.abs(r-t),Math.abs(i-a),Math.abs(o-n));this._box=new Ce(l,c),this._matrix=new R,this._matrix.identity()}getAABB(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center,r=this._sphere.radius,i=new b(a.x-r,a.y-r,a.z-r),n=new b(a.x+r,a.y+r,a.z+r);if(e.setFromMinMax(i,n),t){const o=[new b(i.x,i.y,i.z),new b(n.x,i.y,i.z),new b(i.x,n.y,i.z),new b(n.x,n.y,i.z),new b(i.x,i.y,n.z),new b(n.x,i.y,n.z),new b(i.x,n.y,n.z),new b(n.x,n.y,n.z)];o.forEach(l=>{const c=new b;t.transformPoint(l,c),l.copyFrom(c)}),e.makeEmpty(),o.forEach(l=>{e.expandByPoint(l)})}return e}else if(this._box){const a=Xr.s_tmpMatrix;if(a.identity(),this._matrix?t?a.multiplyMatrices(t,this._matrix):a.copyFrom(this._matrix):t&&a.copyFrom(t),a){const r=this._box,i=[new b(r.min.x,r.min.y,r.min.z),new b(r.max.x,r.min.y,r.min.z),new b(r.min.x,r.max.y,r.min.z),new b(r.max.x,r.max.y,r.min.z),new b(r.min.x,r.min.y,r.max.z),new b(r.max.x,r.min.y,r.max.z),new b(r.min.x,r.max.y,r.max.z),new b(r.max.x,r.max.y,r.max.z)];i.forEach(n=>{const o=new b;a.transformPoint(n,o),n.copyFrom(o)}),e.makeEmpty(),i.forEach(n=>{e.expandByPoint(n)})}else e.setFromMinMax(this._box.min,this._box.max);return e}throw new Error("BoundingVolume: Invalid state")}getOBB(e,t){this._type==="box"&&this._box&&this._matrix?(e.setFromMinMax(this._box.min,this._box.max),t.copyFrom(this._matrix)):(this.getAABB(e),t.identity())}getSphere(e){if(this._type==="sphere"&&this._sphere)return e.center.copyFrom(this._sphere.center),e.radius=this._sphere.radius,e;const t=new Ce;this.getAABB(t);const a=t.center,i=t.size.length*.5;return e.center.copyFrom(a),e.radius=i,e}get type(){return this._type}distanceToPoint(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center;let r=a;if(t){const o=new b;t.transformPoint(a,o),r=o}const i=this._sphere.radius,n=e.clone().subtract(r).length;return Math.max(0,n-i)}else if(this._box){const a=new Ce;this.getAABB(a,t);const r=a.center,i=a.size,n=Math.max(0,Math.abs(e.x-r.x)-i.x*.5),o=Math.max(0,Math.abs(e.y-r.y)-i.y*.5),l=Math.max(0,Math.abs(e.z-r.z)-i.z*.5);return Math.sqrt(n*n+o*o+l*l)}return 1/0}intersectsFrustum(e,t){if(this._type==="sphere"&&this._sphere){const a=new Ce;return this.getAABB(a,t),e.containsBox2(a)>0}else if(this._box){const a=new Ce;return this.getAABB(a,t),e.containsBox2(a)>0}return!1}}const mu=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.used!==e.used?s.used?1:-1:s.error!==e.error?s.error>e.error?1:-1:s.distanceFromCamera!==e.distanceFromCamera?s.distanceFromCamera>e.distanceFromCamera?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?-1:1:0},Au=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.lastFrameVisited!==e.lastFrameVisited?s.lastFrameVisited>e.lastFrameVisited?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?1:-1:s.loadingState!==e.loadingState?s.loadingState>e.loadingState?-1:1:s.hasUnrenderableContent!==e.hasUnrenderableContent?s.hasUnrenderableContent?-1:1:s.error!==e.error?s.error>e.error?-1:1:0};class dm{rootLoadingState=Br;rootTileSet=null;rootURL=null;fetchOptions={};frameCount=0;isLoading=!1;lruCache;loadQueue;processNodeQueue;plugins=[];_queuedTiles=[];_cachedSinceLoadComplete=new Set;_processedTiles=new WeakSet;_visibleTiles=new Set;_usedSet=new Set;_cacheHits=0;_cacheMisses=0;stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0,sceneCount:0,inCacheSinceLoad:0};errorTarget=16;errorThreshold=1;maxDepth=30;displayActiveTiles=!1;onRootTileLoaded;rtcOffset=null;_root=null;_activeTiles=new Set;_delayedHideTiles=new Set;_delayedVisibleTiles=new Set;_delayedActiveTiles=new Set;group;cameras=[];_cameraMap=new Map;_cameraInfo=[];_upRotationMatrix=new R;_ellipsoid;_bytesUsed=new WeakMap;_eventListeners=new Map;performanceStats={updateTime:0,traverseTime:0,markUsedTime:0,markVisibleTime:0,toggleTime:0,queueProcessTime:0};constructor(e=null){this.rootURL=e,this.lruCache=new du,this.lruCache.unloadPriorityCallback=Au,this.loadQueue=new il,this.loadQueue.maxJobs=10,this.loadQueue.priorityCallback=mu,this.processNodeQueue=new il,this.processNodeQueue.maxJobs=25,this.group=new ne,this.group.name="TilesRendererGroup"}get root(){return this._root}get loadProgress(){const{stats:e,isLoading:t}=this,a=e.downloading,r=e.inCacheSinceLoad+(t?1:0);return r===0?1:1-a/r}update(){const{lruCache:e,_usedSet:t,stats:a,loadQueue:r,processNodeQueue:i}=this;this.rootLoadingState===Br&&(this.rootLoadingState=al,this.isLoading=!0,this._loadRootTileSet().then(c=>{if(this.rootLoadingState=La,this.rootTileSet=c,c.root){const f=this._getBasePath(this.rootURL||""),d=this.preprocessNode(c.root,f,null);this.queueTileForDownload(d),this._root=d;const h=new Xr(d.boundingVolume),u=new Lr;h.getSphere(u);const m=new Ce;if(h.getAABB(m),this.rtcOffset=new b(-u.center.x,-u.center.y,-u.center.z),this.onRootTileLoaded)try{this.onRootTileLoaded({center:u.center,radius:u.radius,boundingBox:m,rtcOffset:this.rtcOffset})}catch(g){console.warn("Failed to calculate bounding volume for root tile:",g)}}this.dispatchEvent({type:"load-tile-set",tileSet:c,url:this.rootURL})}).catch(c=>{this.rootLoadingState=_r,console.error("Failed to load root tileset:",c),this.dispatchEvent({type:"load-error",tile:null,error:c,url:this.rootURL})}));const n=this.root;if(!n)return;a.inFrustum=0,a.used=0,a.active=0,a.visible=0,this.frameCount++,t.forEach(c=>e.markUnused(c)),t.clear(),this.updateCameraInfo(),this._checkDelayedHideTiles(),this._checkDelayedActiveTiles(),this._checkDelayedVisibleTiles(),en(n,this),cl(n,this),tn(n,this),an(n,this);const o=this._queuedTiles;e.unloadPriorityCallback&&o.sort(e.unloadPriorityCallback);for(let c=0,f=o.length;c<f&&!e.isFull();c++)this.requestTileContents(o[c]);o.length=0,r.update(),i.update(),e.scheduleUnload(),(r.running||i.running)===!1&&this.isLoading===!0&&(this._cachedSinceLoadComplete.clear(),a.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}),this.isLoading=!1)}traverse(e,t,a=!0){this.root&&hu(this.root,(r,i,n)=>(a&&this.ensureChildrenArePreprocessed(r,!0),e?e(r,i,n):!1),t)}registerPlugin(e){if(this.plugins.includes(e))return;const t=e.priority||0;let a=this.plugins.length;for(let r=0;r<this.plugins.length;r++)if((this.plugins[r].priority||0)>t){a=r;break}this.plugins.splice(a,0,e),e.init&&e.init(this)}unregisterPlugin(e){const t=this.plugins;let a;if(typeof e=="string"?a=t.find(r=>r.name===e):a=e,a&&t.includes(a)){const r=t.indexOf(a);return t.splice(r,1),a.dispose&&a.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}calculateTileViewError(e,t){const a=e.cached,r=this.cameras,i=this._cameraInfo,n=a.boundingVolume;if(!n){t.inView=!1,t.error=1/0,t.distanceFromCamera=1/0;return}let o=!1,l=-1/0,c=1/0,f=-1/0,d=1/0;const h=a.worldTransform;for(let u=0,m=r.length;u<m;u++){const g=i[u];let p,D;if(g.isOrthographic){const B=g.pixelSize;p=e.geometricError/B,D=1/0}else{const B=g.sseDenominator;D=n.distanceToPoint(g.position,h),p=D===0?1/0:e.geometricError/(D*B)}const A=i[u].frustum;n.intersectsFrustum(A,h)&&(o=!0,l=Math.max(l,p),c=Math.min(c,D)),f=Math.max(f,p),d=Math.min(d,D)}o?(t.inView=!0,t.error=l,t.distanceFromCamera=c):(t.inView=!1,t.error=f,t.distanceFromCamera=d)}updateCameraInfo(){this._updateCameraInfo()}_updateCameraInfo(){const e=this.cameras,t=this._cameraInfo,a=this._cameraMap;for(;t.length<e.length;)t.push({position:new b,frustum:new On,isOrthographic:!1});for(let r=0;r<e.length;r++){const i=e[r],n=t[r],o=a.get(i);if(!o)continue;const l=i.transform.worldPosition;if(n.position.copyFrom(l),n.frustum=i.frustum,n.isOrthographic=i.type===nt.ortho,n.isOrthographic){const c=i.frustumSize;n.pixelSize=c/o.height}else{const f=i.fov*Math.PI/180;n.sseDenominator=2*Math.tan(f/2)/o.height}}}preprocessNode(e,t,a=null){if(this._processedTiles.has(e))return e;this._processedTiles.add(e);let r;if(e instanceof rl?r=e:r=new rl(e,a),r.content){const c=r.content;!("uri"in c)&&"url"in c&&(c.uri=c.url,delete c.url)}if(r.basePath=t,r.boundingVolume){const c=new Xr(r.boundingVolume);r.cached.boundingVolume=c}const i=new b(r.boundingVolume.box[0],r.boundingVolume.box[1],r.boundingVolume.box[2]),n=new R;if(r.transform){const c=r.transform;for(let f=0;f<16;f++)n.rawData[f]=c[f]}if(!a){n.copyFrom(this._upRotationMatrix);const c=new b;c.copyFrom(i),c.applyMatrix4(n);const f=r.cached.boundingVolume.box,d=[new b(f.min.x,f.min.y,f.min.z),new b(f.max.x,f.min.y,f.min.z),new b(f.min.x,f.max.y,f.min.z),new b(f.max.x,f.max.y,f.min.z),new b(f.min.x,f.min.y,f.max.z),new b(f.max.x,f.min.y,f.max.z),new b(f.min.x,f.max.y,f.max.z),new b(f.max.x,f.max.y,f.max.z)];for(const m of d)m.applyMatrix4(n);const h=new Ce;d.forEach(m=>{h.expandByPoint(m)}),n.rawData[12]=-c.x,n.rawData[13]=-c.y,n.rawData[14]=-c.z;const u=h.min;n.rawData[13]-=u.y}const o=new R;o.copyFrom(n),a&&a.cached.worldTransform&&o.multiplyMatrices(a.cached.worldTransform,n);const l=new R;if(l.copyFrom(o),l.invert(),r.cached.transfrom=n,r.cached.worldTransform=o,r.cached.transformInverse=l,e.children&&e.children.length>0){r.children=[];for(let c=0;c<e.children.length;c++){const f=e.children[c],d=this.preprocessNode(f,t,r);r.children.push(d)}r.childrenProcessed=r.children.length}return r}ensureChildrenArePreprocessed(e,t=!1){const a=e.children;for(let r=0,i=a.length;r<i;r++){const n=a[r];n.basePath!==void 0&&n.basePath!==""||n.cached.boundingVolume||(t?(this.processNodeQueue.remove(n),this.preprocessNode(n,e.basePath,e)):this.processNodeQueue.has(n)||this.processNodeQueue.add(n,o=>{this.preprocessNode(o,e.basePath,e)}))}}_recordCacheHit(){this._cacheHits++}_recordCacheMiss(){this._cacheMisses++}resetCacheStats(){this._cacheHits=0,this._cacheMisses=0}requestTileContents(e){if(e.loadingState!==Br){this._recordCacheHit();return}if(this.lruCache.isFull()){this._recordCacheMiss();return}this._recordCacheMiss(),e.loadingState=al,this.stats.downloading++;const t=e.content||e.contents&&e.contents[0];if(!t||!t.uri){e.loadingState=_r,this.stats.downloading--,this.stats.failed++;return}const a=e.basePath||"",r=t.uri,i=this._resolveURL(a,r);this.loadQueue.add(e,async n=>{try{await this.parseTileContent(n,r,i),this.stats.downloading--}catch(o){n.loadingState=_r,this.stats.downloading--,this.stats.failed++,console.error("Failed to load tile:",o)}})}async parseTileContent(e,t,a){e.loadingState=cu;const i=(c=>{const f=c.split(".");return f.length>1?f[f.length-1]:""})(t),n=a;let o=null;const l=new It;switch(i.toLowerCase()){case"b3dm":{o=(await l.load(n,So,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"i3dm":{o=(await l.load(n,Eo,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"glb":case"gltf":{o=(await l.load(n,xt,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"pnts":{o=(await l.load(n,tu,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"json":try{const c=await _.res.loadJSON(n);e.children.length=0,e.childrenProcessed=0;const f=this._getBasePath(n);if(c.root){const d=this.preprocessNode(c.root,f,e);e.children.push(d),e.childrenProcessed=1,this.dispatchEvent({type:"load-tile-set",tileSet:c,url:n})}e.loadingState=La;return}catch(c){console.error("Failed to load external tileset:",c),e.loadingState=_r,this.stats.failed++;return}break;default:console.warn(`Unknown tile format: ${i}`);break}if(o){e.cached.scene=o;const c=this._estimateBytesUsed(o);this._bytesUsed.set(o,c),this.lruCache.setMemoryUsage(e,c),this.lruCache.has(e)||this.lruCache.add(e,f=>{if(f.cached.scene){const d=f.cached.scene;d.parent&&d.parent.object3D.removeChild(d),d.destroy(!0),f.cached.scene=null}f.loadingState=Br}),this.setTileImmediateActive(e),e.active=!0,e.__wasSetActive=!0,this.stats.active++,this.setTileImmediateVisible(e),e.visible=!0,e.__wasSetVisible=!0,this.stats.visible++,this.stats.sceneCount++,e.loadingState=La,e.usedLastFrame=!0,tn(e,this),an(e,this)}else e.loadingState=_r,this.stats.failed++}markTileUsed(e){this._usedSet.add(e),this.lruCache.markUsed(e)}setTileDelayedActive(e,t){t?(this._activeTiles.add(e),this._delayedHideTiles.has(e)&&this._delayedHideTiles.delete(e),this._delayedActiveTiles.has(e)||this._delayedActiveTiles.add(e)):(this._activeTiles.delete(e),this._delayedHideTiles.has(e)||this._delayedHideTiles.add(e),this._delayedActiveTiles.has(e)&&this._delayedActiveTiles.delete(e))}setTileImmediateActive(e){if(e.hasRenderableContent){const t=e.cached.scene;t&&(this.group.entityChildren.includes(t)||(t.parent&&t.parent.object3D.removeChild(t),this.group.addChild(t)),e.cached.worldTransform&&this._applyWorldTransform(t.transform,e.cached.worldTransform))}}setTileImmediateVisible(e){if(e.hasRenderableContent){const t=e.cached.scene;t&&(t.transform.enable=!0)}}_checkDelayedHideTiles(){if(this.stats.downloading===0)for(const e of this._delayedHideTiles){const t=e.cached.scene;t&&(t.transform.enable=!1,this._delayedHideTiles.delete(e))}}_checkDelayedActiveTiles(){for(const e of this._delayedActiveTiles)if(e.hasRenderableContent){const t=e.cached.scene;t&&(this.group.entityChildren.includes(t)||(t.parent&&t.parent.object3D.removeChild(t),this.group.addChild(t)),e.cached.worldTransform&&this._applyWorldTransform(t.transform,e.cached.worldTransform),this._delayedActiveTiles.delete(e))}else this._delayedActiveTiles.delete(e)}_checkDelayedVisibleTiles(){for(const e of this._delayedVisibleTiles)if(e.hasRenderableContent){const t=e.cached.scene;t&&(t.transform.enable=!0,this._delayedVisibleTiles.delete(e))}else this._delayedVisibleTiles.delete(e)}setTileDelayedVisible(e,t){t?(this._visibleTiles.add(e),this._delayedHideTiles.has(e)&&this._delayedHideTiles.delete(e),this._delayedVisibleTiles.has(e)||this._delayedVisibleTiles.add(e)):(this._visibleTiles.delete(e),this._delayedHideTiles.has(e)||this._delayedHideTiles.add(e),this._delayedVisibleTiles.has(e)&&this._delayedVisibleTiles.delete(e))}queueTileForDownload(e){e.loadingState!==Br||this.lruCache.isFull()||this._queuedTiles.push(e)}dispatchEvent(e){const t=this._eventListeners.get(e.type);t&&t.forEach(a=>{try{a(e)}catch(r){console.error("Error in event listener:",r)}})}async _loadRootTileSet(){if(!this.rootURL)throw new Error("Root URL is not set");const e=await _.res.loadJSON(this.rootURL);return e.asset&&e.asset.gltfUpAxis&&this._setupUpAxisRotation(e.asset.gltfUpAxis),e}_setupUpAxisRotation(e){const t=new R;switch(e.toLowerCase()){case"x":t.makeRotationAxis(b.Y_AXIS,-Math.PI/2);break;case"y":t.identity();break;case"z":t.makeRotationAxis(b.X_AXIS,-Math.PI/2);break;default:console.warn(`Unknown gltfUpAxis: ${e}, using default`),t.identity();break}this._upRotationMatrix=t}_applyLocalTransform(e,t){const a=t.decompose(na.EULER_ANGLES);e.localPosition=a[0];const r=new se;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_applyWorldTransform(e,t){const a=t.decompose(na.EULER_ANGLES);e.localPosition=a[0];const r=new se;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_getBasePath(e){const t=e.lastIndexOf("/");return t!==-1?e.substring(0,t):""}_resolveURL(e,t){return t.startsWith("http://")||t.startsWith("https://")?t:e+"/"+t}_getUrlExtension(e){const t=e.split(".");return t.length>1?t[t.length-1]:""}getMemoryStats(){const e=this.lruCache.getStats(),t=this.lruCache.maxBytesSize,a=e.bytes,r=t-a,i=this._cacheHits+this._cacheMisses,n=i>0?this._cacheHits/i:0;return{totalTiles:e.size,loadedTiles:e.usedCount,cachedTiles:e.size,totalBytes:t,usedBytes:a,freeBytes:r,cacheHitRate:n}}getLoadedTiles(){const e=[];return this.traverse(t=>(t.loadingState===La&&e.push(t),!1),null),e}getVisibleTiles(){return Array.from(this._visibleTiles)}getActiveTiles(){return Array.from(this._activeTiles)}getTileTreeStats(){let e=0,t=0,a=0,r=0,i=0,n=0;return this.traverse(o=>(e++,o.loadingState===La&&t++,o.visible&&a++,o.active&&r++,i=Math.max(i,o.depth),n+=o.depth,!1),null),{totalTiles:e,loadedTiles:t,visibleTiles:a,activeTiles:r,maxDepth:i,averageDepth:e>0?n/e:0}}printDebugInfo(){const e=this.stats,t=this.getMemoryStats(),a=this.getTileTreeStats(),r=this.performanceStats,i=this.lruCache.getStats();console.log("=== TilesRenderer Debug Info ==="),console.log("Stats:",e),console.log("Memory:",t),console.log("Tree:",a),console.log("Performance:",r),console.log("Cache:",i),console.log("Queues:",{load:this.loadQueue.getStats(),process:this.processNodeQueue.getStats()})}setPerformanceOptions(e){e.lruCacheMinSize!==void 0&&(this.lruCache.minSize=e.lruCacheMinSize),e.lruCacheMaxSize!==void 0&&(this.lruCache.maxSize=e.lruCacheMaxSize),e.lruCacheMinBytes!==void 0&&(this.lruCache.minBytesSize=e.lruCacheMinBytes),e.lruCacheMaxBytes!==void 0&&(this.lruCache.maxBytesSize=e.lruCacheMaxBytes),e.lruCacheUnloadPercent!==void 0&&(this.lruCache.unloadPercent=e.lruCacheUnloadPercent),e.downloadQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.downloadQueueMaxJobs),e.parseQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.parseQueueMaxJobs),e.processQueueMaxJobs!==void 0&&(this.processNodeQueue.maxJobs=e.processQueueMaxJobs),e.enablePerformanceStats!==void 0&&(this._enablePerformanceStats=e.enablePerformanceStats),e.enableCacheStats!==void 0&&(this._enableCacheStats=e.enableCacheStats)}dispose(e){[...this.plugins].forEach(a=>this.unregisterPlugin(a)),this.lruCache.clear(),this.loadQueue.clear(),this.processNodeQueue.clear(),this._root=null,this.rootTileSet=null,this.rootLoadingState=Br,this.frameCount=0,this.isLoading=!1,this.resetCacheStats(),this.group.destroy(e)}setCamera(e,t,a){this.cameras.includes(e)||this.cameras.push(e),this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}deleteCamera(e){const t=this.cameras.indexOf(e);t!==-1&&this.cameras.splice(t,1),this._cameraMap.delete(e),this._updateCameraInfo()}setResolution(e,t,a){const r=this._cameraMap.get(e);r?(r.width=t,r.height=a):this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}forEachLoadedModel(e){this.traverse(t=>(t.loadingState===La&&t.cached.scene&&e(t.cached.scene,t),!1),null)}_estimateBytesUsed(e){let t=0;return e.forChild(a=>{const r=a.getComponent(he);r&&r.geometry&&(t+=1024),r&&r.material&&(t+=512)}),t}addEventListener(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.get(e).push(t)}removeEventListener(e,t){const a=this._eventListeners.get(e);if(a){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}async loadTileSet(e,t){const r=(e.endsWith("/")?e.slice(0,-1):e)+"/"+t;this.rootURL=r}get modelList(){const e=[];return this.forEachLoadedModel(t=>{e.push(t)}),e}}class hm{asset;extras;geometricError;properties;refine;root;extensionsUsed;extensionsRequired;extensions}class um{boundingVolume;children;geometricError;transform;content;contents;refine;extensions;extras}class bm{boundingVolume;geometricError;refine;content;contents;children;transform;extensions;extras}class gm{uri;group;metadata}class pm{class;properties}function mm(s,e){let t=0,a=null;return function(...r){const i=Date.now(),n=i-t;n>=e?(t=i,s.apply(this,r)):(a!==null&&clearTimeout(a),a=window.setTimeout(()=>{t=Date.now(),s.apply(this,r),a=null},e-n))}}class Am extends vt{static count=0;constructor(){super(),Y.register("ColorLitShader",Jd),this.shader=new At;let e=new qe("ColorLitShader","ColorLitShader");e.passType=fe.COLOR,this.shader.addRenderPass(e),e.setDefine("USE_BRDF",!0),e.setShaderEntry("VertMain","FragMain"),e.setUniformColor("baseColor",new J),e.setUniformColor("emissiveColor",new J),e.setUniformFloat("envIntensity",1),e.setUniformFloat("normalScale",1),e.setUniformFloat("roughness",0),e.setUniformFloat("metallic",0),e.setUniformFloat("ao",1),e.setUniformFloat("alphaCutoff",0);let t=e.shaderState;t.acceptShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,e.setTexture("normalMap",_.res.normalTexture),e.setTexture("emissiveMap",_.res.blackTexture)}clone(){return null}debug(){}}class Dm extends vt{constructor(){super();let e=new qe("LambertShader","LambertShader");e.setShaderEntry("VertMain","FragMain"),e.passType=fe.COLOR,e.setUniformVector4("transformUV1",new be(0,0,1,1)),e.setUniformVector4("transformUV2",new be(0,0,1,1)),e.setUniformColor("baseColor",new J(1,1,1,1)),e.setUniformFloat("alphaCutoff",.5);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1;let a=new At;a.addRenderPass(e),this.shader=a,this.baseMap=_.res.grayTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}function _m(s,e){}class Bm extends vt{constructor(){super(),this.shader=new $i,this.baseMap=_.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set shadowMap(e){}}class fl{clipName;loopTime;startTime;stopTime;sampleRate;useSkeletonPos;useSkeletonScale;positionCurves=new Map;rotationCurves=new Map;scaleCurves=new Map;floatCurves=new Map;formBytes(e){if(this.clipName=e.readUTF(),this.loopTime=!e.readInt32(),this.startTime=e.readFloat32(),this.stopTime=e.readFloat32(),this.sampleRate=e.readInt32(),this.useSkeletonPos=e.readInt32()>0,this.useSkeletonScale=e.readInt32()>0,this.useSkeletonPos){let r=e.readInt32();for(let i=0;i<r;i++){let n=new xr;n.formBytes(e),this.positionCurves.set(n.path,n)}}let t=e.readInt32();for(let r=0;r<t;r++){let i=new xr;i.formBytes(e),this.rotationCurves.set(i.path,i)}if(this.useSkeletonScale){let r=e.readInt32();for(let i=0;i<r;i++){let n=new xr;n.formBytes(e),this.scaleCurves.set(n.path,n)}}let a=e.readInt32();for(let r=0;r<a;r++){let i=new xr;i.formBytes(e),this.floatCurves.set(i.attribute,i)}}}class xr{path;attribute;propertys;preInfinity;postInfinity;rotationOrder;m_curves;k=0;_cacheValue;_kValue;constructor(e=1){this.k=e,this.m_curves=[],this.check()}check(){for(let e=0;e<this.k;e++)this.m_curves[e]||=new Li;switch(this.k){case 1:this._cacheValue=0;break;case 2:this._cacheValue=new de;break;case 3:this._cacheValue=new b;break;case 4:this._cacheValue=new be;break}}get totalTime(){return this.m_curves[0].totalTime}addKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].addKeyFrame(e.getK(t))}removeKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].removeKeyFrame(e.getK(t))}getValue(e){switch(this.k){case 1:this._cacheValue=this.m_curves[0].getValue(e);break;case 2:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e);break;case 3:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e),this._cacheValue.z=this.m_curves[2].getValue(e);break;case 4:const t=this.m_curves[0].getCurveFramesExtent(e),a=t.lhsIndex,r=t.rhsIndex;e=t.time;let i=this.m_curves[0].getKey(a),n=this.m_curves[0].getKey(r);e%=this.m_curves[0].totalTime;let o=(e-i.time)/(n.time-i.time);se.HELP_0.set(this.m_curves[0].getKey(a).value,this.m_curves[1].getKey(a).value,this.m_curves[2].getKey(a).value,this.m_curves[3].getKey(a).value),se.HELP_1.set(this.m_curves[0].getKey(r).value,this.m_curves[1].getKey(r).value,this.m_curves[2].getKey(r).value,this.m_curves[3].getKey(r).value),se.HELP_2.slerp(se.HELP_0,se.HELP_1,o),this._cacheValue.x=se.HELP_2.x,this._cacheValue.y=se.HELP_2.y,this._cacheValue.z=se.HELP_2.z,this._cacheValue.w=se.HELP_2.w;break}return this._cacheValue}getKeyCount(){return this.m_curves[0].getKeyCount()}getKey(e){let t=[];for(let a=0;a<this.k;a++)t.push(this.m_curves[a].getKey(e));return t}formBytes(e){this.path=e.readUTF(),this.k=e.readInt32(),this.check(),this.attribute=e.readUTF(),this.propertys=this.attribute.split("."),this.preInfinity=e.readInt32(),this.postInfinity=e.readInt32(),this.rotationOrder=e.readInt32();let t=e.readInt32();for(let a=0;a<t;a++){let r=new as(0);r.formBytes(e),this.addKeyFrame(r)}}}class vm extends Map{negtive;constructor(e){if(super(e),this.negtive=new Map,e)for(let t of e)this.negtive.set(t[1],t[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.negtive.delete(t),super.delete(e)}return!1}getKey(e){return this.negtive.get(e)}deleteValue(e){let t=this.negtive.get(e);return t&&this.delete(t),this.negtive.delete(e)}set(e,t){return super.set(e,t),this.negtive.set(t,e),this}clear(){this.negtive.clear(),super.clear()}}class xm{colorArray;constructor(e){this.colorArray=e}getColor(e){let t=e*this.colorArray.length,a=Math.floor(t),r=Math.min(a+1,this.colorArray.length-1),i=this.colorArray[a],n=this.colorArray[r];return J.lerp(t-a,i,n)}}class rn{controlVertices;constructor(e){this.setControlVertices(e)}setControlVertices(e){e.length==4&&(this.controlVertices=e.concat())}getPoint(e){if(!(e>=0&&e<=1))return b.ZERO;let t=1-e,a=t*t*t,r=3*e*t*t,i=3*e*e*t,n=e*e*e;return this.controlVertices[0].mul(a).add(this.controlVertices[1].mul(r)).add(this.controlVertices[2].mul(i)).add(this.controlVertices[3].mul(n))}getTangent(e){if(!(e>=0&&e<=1))return b.ZERO;let t=this.controlVertices,a=t[0].add(t[1].add(t[0]).mul(e)),r=t[1].add(t[2].add(t[1]).mul(e)),i=t[2].add(t[3].add(t[2]).mul(e)),n=a.add(r.subtract(a).mul(e));return r.add(i.subtract(r).mul(e)).subtract(n)}getClosestParam(e,t=1e-6){return this.getClosestParamRec(e,0,1,t)}getClosestParamRec(e,t,a,r){let i=(t+a)/2;if(a-t<r)return i;let n=(t+i)/2,o=(i+a)/2,l=this.getPoint(n),c=this.getPoint(o),f=l.subtract(e).lengthSquared,d=c.subtract(e).lengthSquared;return f<d?a=i:t=i,this.getClosestParamRec(e,t,a,r)}}var Du=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(Du||{});class Um{type=0;numCurveSegments=0;numControlVertices=0;controlVertices=[];constructor(e,t=0){this.setControlVertices(e,t)}getPathType(){return this.type}isClosed(){return this.type==1}isValid(){return this.numCurveSegments>0}clear(){this.controlVertices.length=0,this.type=0,this.numCurveSegments=0,this.numControlVertices=0}computeApproxLength(){if(!this.isValid())return 0;let e=this.numCurveSegments+1;if(e<2)return 0;let t=0,a=this.controlVertices;for(let r=1;r<e;r++){let i=a[(r-1)*3],n=a[r*3];t+=i.subtract(n).lengthSquared}return t==0?0:t}computeApproxParamPerUnitLength(){let e=this.computeApproxLength();return this.numCurveSegments/e}computeApproxNormParamPerUnitLength(){return 1/this.computeApproxLength()}interpolatePoints(e,t){let a=e.length;a<2&&console.error("point count must great 1"),this.clear(),this.type=t;let r=this.controlVertices;switch(t){case 0:{this.numCurveSegments=a-1,this.numControlVertices=3*a-2,r.length=this.numControlVertices;for(let o=0;o<a;o++)r[o*3]=e[o];let i=e[1].subtract(e[0]).mul(.25);r[1]=e[0].add(i);let n=e[a-2].subtract(e[a-1]).mul(.25);r[this.numControlVertices-2]=e[a-1].add(n);for(let o=1;o<this.numCurveSegments;o++){let l=e[o-1].subtract(e[o]),c=e[o+1].subtract(e[o]),f=l.lengthSquared,d=c.lengthSquared;if(f>0&&d>0){let h=(f+d)/8,u=c.div(d).subtract(l.div(f));u.normalize(),u=u.mul(h),r[o*3-1]=e[o].subtract(u),r[o*3+1]=e[o].add(u)}else r[o*3-1]=e[o],r[o*3+1]=e[o]}break}case 1:{this.numCurveSegments=a,this.numControlVertices=3*a+1,r.length=this.numControlVertices;for(let i=0;i<a;i++)r[i*3]=e[i];r[this.numControlVertices-1]=e[0];for(let i=1;i<=this.numCurveSegments;i++){let n=i-1,o=(i+1)%this.numCurveSegments,l=i%this.numCurveSegments,c=e[n].subtract(e[l]),f=e[o].subtract(e[l]),d=c.lengthSquared,h=f.lengthSquared,u=3*i-1,m=(3*i+1)%(this.numControlVertices-1);if(d>0&&h>0){let g=(d+h)/8,p=f.div(h).subtract(c.div(d));p.normalize(),p=p.mul(g),r[u]=e[l].subtract(p),r[m]=e[l].add(p)}else r[u]=e[l],r[m]=e[l]}break}}}setControlVertices(e,t){let a=e.length;a<=0||t==0&&a<4||t==1&&a<7||(a-1)%3==0&&(this.clear(),this.type=t,this.numControlVertices=a,this.numCurveSegments=(a-1)/3,this.controlVertices=e)}getPoint(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=Gt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=[],r=this.controlVertices;return a[0]=r[3*t+0],a[1]=r[3*t+1],a[2]=r[3*t+2],a[3]=r[3*t+3],new rn(a).getPoint(e-t)}getPointNorm(e){return this.getPoint(e*this.numCurveSegments)}getTangent(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=Gt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=this.controlVertices,r=[];return r[0]=a[3*t+0],r[1]=a[3*t+1],r[2]=a[3*t+2],r[3]=a[3*t+3],new rn(r).getTangent(e-t)}getTangentNorm(e){return this.getTangent(e*this.numCurveSegments)}computeClosestParam(e,t){let a=Number.MAX_SAFE_INTEGER,r=0,i=[],n=new rn(i);for(let o=0;o<this.controlVertices.length-1;o+=3){for(let d=0;d<4;d++)i[d]=this.controlVertices[o+d];n.setControlVertices(i);let l=n.getClosestParam(e,t),f=n.getPoint(l).subtract(e).lengthSquared;f<a&&(a=f,r=o/3+l)}return r}computeClosestNormParam(e,t){return this.computeClosestParam(e,t*this.numCurveSegments)}}class ym extends Map{valueList;keyList;isChange=!0;constructor(e,t,a){if(super(e),t&&(this.keyList=[]),a&&(this.valueList=[]),e)for(let r of e)this.valueList?.push(r[1]),this.keyList?.push(r[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.valueList&&this.deleteValue(t),this.keyList&&this.deleteKey(e),this.isChange=!0,super.delete(e)}return!1}deleteValue(e){let t=this.valueList.indexOf(e);return t>=0&&this.valueList.splice(t,1),this}deleteKey(e){let t=this.keyList.indexOf(e);return t>=0&&this.keyList.splice(t,1),this}set(e,t){return this.delete(e),this.keyList?.push(e),this.valueList?.push(t),super.set(e,t),this.isChange=!0,this}clear(){this.valueList&&(this.valueList.length=0),this.keyList&&(this.keyList.length=0),this.isChange=!0,super.clear()}}var _u=(s=>(s[s.kParticleSystemClampVelocityCurveId=322376503]="kParticleSystemClampVelocityCurveId",s[s.kParticleSystemForceCurveId=306581307]="kParticleSystemForceCurveId",s[s.kParticleSystemRotationCurveId=1793934638]="kParticleSystemRotationCurveId",s[s.kParticleSystemRotationBySpeedCurveId=3737431713]="kParticleSystemRotationBySpeedCurveId",s[s.kParticleSystemStartSpeedCurveId=2527743459]="kParticleSystemStartSpeedCurveId",s[s.kParticleSystemSizeCurveId=2368504881]="kParticleSystemSizeCurveId",s[s.kParticleSystemSizeBySpeedCurveId=4085612399]="kParticleSystemSizeBySpeedCurveId",s[s.kParticleSystemVelocityCurveId=3774601268]="kParticleSystemVelocityCurveId",s[s.kParticleSystemUVCurveId=326370691]="kParticleSystemUVCurveId",s[s.kParticleSystemColorGradientId=1494990940]="kParticleSystemColorGradientId",s[s.kParticleSystemColorByVelocityGradientId=1089181156]="kParticleSystemColorByVelocityGradientId",s[s.kParticleSystemMeshSelectionId=3159510623]="kParticleSystemMeshSelectionId",s[s.kParticleSystemUVRowSelectionId=2941263940]="kParticleSystemUVRowSelectionId",s))(_u||{});const Cm=3.141592653589793;class Sm{}function Bu(s,e,t){let a=.3333333333333333,r=.5,i=s*a,n=i*i,l=n*i-i*e*r+t*r,c=-n+e*a,f=c*c*c,d=f+l*l;if(d>=0){let m=Math.sqrt(d)-l;return m=m>0?Math.pow(m,a):-Math.pow(-m,a),-i-c/m+m}let h=Math.sqrt(-f),u=Math.acos(-l/h);return h=Math.pow(h,a),h=h-c/h,u=-i+h*Math.cos(u*a),u}function sn(s,e,t,a){let r=1e-5;if(Math.abs(s)<r)return Math.abs(e)>r?(a.r0=-t/e,1):0;let i=e*e-4*s*t;if(i<0)return 0;let n=.5/s,o=Math.sqrt(i);return a.r0=(o-e)*n,a.r1=(-o-e)*n,2}function vu(s,e,t,a,r){let i=0;if(Math.abs(e)>=1e-4){let n=t/e,o=a/e,l=r/e;s[0]=Bu(n,o,l),i++;let c=e,f=t+e*s[0],d=a+t*s[0]+e*s[0]*s[0];i+=sn(c,f,d,{r0:s[1],r1:s[2]})}else i+=sn(t,a,r,{r0:s[1],r1:s[2]});return i}class Ga{coeff=[];static EvalSegment(e,t){return e*(e*(e*t[0]+t[1])+t[2])+t[3]}}class nr{static kMaxNumSegments=8;segments=[];integrationCache=[];doubleIntegrationCache=[];times=[];segmentCount;constructor(){this.segments[nr.kMaxNumSegments]=new Ga,this.integrationCache[nr.kMaxNumSegments]=0,this.doubleIntegrationCache[nr.kMaxNumSegments]=0,this.times[nr.kMaxNumSegments]=0}calculateMinMax(e,t){e.x=Math.min(e.x,t),e.y=Math.max(e.y,t)}findMinMaxDoubleIntegrated(){let e=de.ZERO.clone(),t=20,a=1/t,r=a;for(let i=0;i<t;i++)this.calculateMinMax(e,this.evaluateDoubleIntegrated(r)),r+=a;return e}findMinMaxIntegrated(){let e=de.ZERO.clone(),t=[],a=[];for(let r=0;r<this.segmentCount;r++){let i=4*this.segments[r].coeff[0],n=3*this.segments[r].coeff[1],o=2*this.segments[r].coeff[2],l=1*this.segments[r].coeff[3],c=[],f=vu(c,i,n,o,l);for(let d=0;d<f;d++){let h=c[d]+t[r];h>=t[r]&&h<a[r]&&this.calculateMinMax(e,this.evaluateIntegrated(h))}this.calculateMinMax(e,this.evaluateIntegrated(a[r])),this.times[r]}return e}generateIntegrationCache(e){e.integrationCache[0]=0;let t=e.times[0],a=0;for(let r=1;r<e.segmentCount;r++){let i=e.segments[r-1].coeff;dl(i);let n=t-a;e.integrationCache[r]=e.integrationCache[r-1]+Ga.EvalSegment(n,i)*n,a=t,t=e.times[r]}}generateDoubleIntegrationCache(e){let t=0,a=0;for(let r=0;r<e.segmentCount;r++){e.doubleIntegrationCache[r]=t;let i=e.times[r]-a;i=Math.max(i,0),t+=Ga.EvalSegment(i,e.segments[r].coeff)*i*i+e.integrationCache[r]*i,a=e.times[r]}}integrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)dl(this.segments[e].coeff)}doubleIntegrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)xu(this.segments[e].coeff);this.generateDoubleIntegrationCache(this)}static isValidCurve(e){let t=e.getKeyCount(),a=t-1;return e.getKey(0).time!=0&&a++,e.getKey(t-1).time!=1&&a++,a<=nr.kMaxNumSegments}evaluateDoubleIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.doubleIntegrationCache[a]+this.integrationCache[a]*r+Ga.EvalSegment(r,this.segments[a].coeff)*r*r}t=this.times[a]}return 1}evaluateIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.integrationCache[a]+Ga.EvalSegment(r,this.segments[a].coeff)*r}t=this.times[a]}return 1}evaluate(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a])return Ga.EvalSegment(e-t,this.segments[a].coeff);t=this.times[a]}return 1}buildCurve(e,t){let a=e.getKeyCount();this.segmentCount=1;let r=1.01;if(this.segments.length=0,this.integrationCache.length=0,this.doubleIntegrationCache.length=0,this.times.length=0,this.times[0]=r,a!=0)if(a==1)this.segments[0]=new Ga,this.segments[0].coeff[3]=e.getKey(0).value*t;else{this.segmentCount=a-1;let i=0;e.getKey(0).time!=0&&(this.segments[0].coeff[3]=e.getKey(0).value,this.times[0]=e.getKey(0).time,i=1);for(let n=0;n<this.segmentCount;n++){let o;e.calculateCacheData(o,n,n+1,0),this.segments[n+i].coeff=o.coeff.concat(),this.times[n+i]=e.getKey(n+1).time}this.segmentCount+=i,e.getKey(a-1).time!=1&&(this.segments[this.segmentCount].coeff[3]=e.getKey(a-1).value,this.segmentCount++),this.times[this.segmentCount-1]=r;for(let n=0;n<this.segmentCount;n++)this.segments[n].coeff[0]*=t,this.segments[n].coeff[1]*=t,this.segments[n].coeff[2]*=t,this.segments[n].coeff[3]*=t}return!0}}function xu(s){s[0]/=20,s[1]/=12,s[2]/=6,s[3]/=2}function dl(s){s[0]/=4,s[1]/=3,s[2]/=2,s[3]/=1}var Uu=(s=>(s[s.kEMScalar=0]="kEMScalar",s[s.kEMOptimized=1]="kEMOptimized",s[s.kEMOptimizedMinMax=2]="kEMOptimizedMinMax",s[s.kEMSlow=3]="kEMSlow",s))(Uu||{}),yu=(s=>(s[s.kMMCScalar=0]="kMMCScalar",s[s.kMMCCurve=1]="kMMCCurve",s[s.kMMCTwoCurves=2]="kMMCTwoCurves",s[s.kMMCTwoConstants=3]="kMMCTwoConstants",s))(yu||{});class Fm{max;min}class km{max;min;integrate(){this.max.integrate(),this.min.integrate()}doubleIntegrate(){this.max.doubleIntegrate(),this.min.doubleIntegrate()}findMinMaxIntegrated(){return null}findMinMaxDoubleIntegrated(){return null}}class Cu{minMaxState;minCurve;maxCurve;_scalar=1;_minScalar;constructor(e=1){this._scalar=e,this.minMaxState=0,this.minCurve=new Li,this.maxCurve=new Li}setScalar(e){this._scalar=e}getScalar(){return this._scalar}static evaluateSlow(e,t,a){let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==2?Mr(e.minCurve.getValue(t)*e.getScalar(),r,a):r}static evaluate(e,t,a=1){if(e.minMaxState==0)return e.getScalar();let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==1?Mr(e.minCurve.getValue(t)*e.getScalar(),r,a):e.minMaxState==3?Mr(e._minScalar,e._scalar,a):e.minMaxState==2?Mr(e.minCurve.getValue(t)*e.getScalar(),r,1*Math.random()):this.evaluateSlow(e,t,1)}unSerialized(e){this.minMaxState=e.minMaxState,this._scalar=e.scalar,this._minScalar=e.minScalar,this.maxCurve.unSerialized(e.maxCurve),this.minCurve.unSerialized(e.minCurve)}}class Em{value=0;mode=0;spread=0;speed=new Cu;unSerialized(e){this.value=e.value,this.mode=e.mode,this.spread=e.spread,this.speed.unSerialized(e.speed)}}function wm(s,e){let t=nr.isValidCurve(s.max);return e!=2&&e!=3?t:t&&nr.isValidCurve(s.min)}function Im(s,e,t,a){s.max.buildCurve(e.max,t),a!=2&&a!=3?s.min.buildCurve(e.max,t):s.min.buildCurve(e.min,t)}function Rm(s,e){let t=e.getKeyCount();if(t!=0)if(t==1)es(s,e.getKey(0).value);else{let a=t-1;es(s,e.getKey(0).value);for(let r=0;r<a;r++){let i=new Lo;e.calculateCacheData(i,r,r+1,0);let n=3*i.coeff[0],o=2*i.coeff[1],l=1*i.coeff[2],c=e.getKey(r).time,f=e.getKey(r+1).time,d=[],h=sn(n,o,l,{r0:d[0],r1:d[1]});for(let u=0;u<h;u++)d[u]>=0&&d[u]+c<f&&es(s,Ga.EvalSegment(d[u],i.coeff));es(s,Ga.EvalSegment(f-c,i.coeff))}}}function es(s,e){s.x=Math.min(s.x,e),s.y=Math.max(s.y,e)}class Vr{static BACK=0;static FRONT=1;static IN=0;static OUT=1;static INTERSECT=2}class Su{a;b;c;d;static ALIGN_ANY=0;static ALIGN_XY_AXIS=1;static ALIGN_YZ_AXIS=2;static ALIGN_XZ_AXIS=3;constructor(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}setTo(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}fromPoints(e,t,a){var r=t.x-e.x,i=t.y-e.y,n=t.z-e.z,o=a.x-e.x,l=a.y-e.y,c=a.z-e.z;this.a=i*c-n*l,this.b=n*o-r*c,this.c=r*l-i*o,this.d=-(this.a*e.x+this.b*e.y+this.c*e.z)}fromNormalAndPoint(e,t){this.a=e.x,this.b=e.y,this.c=e.z,this.d=-(this.a*t.x+this.b*t.y+this.c*t.z)}normalize(){var e=Math.sqrt(this.a*this.a+this.b*this.b+this.c*this.c);if(e>0){var t=1/e;this.a*=t,this.b*=t,this.c*=t,this.d*=t}return e}distance(e){return this.a*e.x+this.b*e.y+this.c*e.z+this.d}classifyPoint(e,t=.01){var a=this.distance(e);return a<-t?Vr.BACK:a>t?Vr.FRONT:Vr.INTERSECT}toString(){return"Plane3D [a:"+this.a+", b:"+this.b+", c:"+this.c+", d:"+this.d+"]"}}function Qm(s,e){return Math.random()*e+Math.random()*s+(e-s)*Math.random()}function Tm(s,e,t){let a=t*Math.random();return Math.random()*e*a+Math.random()*s*a+(e-s)*Math.random()*a}function Fu(s,e,t){let a=0,r=0;for(;a===0;)a=Math.random();for(;r===0;)r=Math.random();let i=Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*r);return i=i/10+.5,(i>1||i<0)&&(i=Fu(s,e,t)),i=Math.pow(i,t),i*=e-s,i+=s,i}function Ca(s){return s>0?Math.floor(s):Math.floor(s)-1}let Ue=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];function hl(s,e){let t=s&15,a=1+(t&7);return t&8&&(a=-a),a*e}function nn(s,e,t){let a=s&7,r=a<4?e:t,i=a<4?t:e;return(a&1?-r:r)+(a&2?-2*i:2*i)}function ts(s,e,t,a){let r=s&15,i=r<8?e:t,n=r<4?t:r==12||r==14?e:a;return(r&1?-i:i)+(r&2?-n:n)}function _i(s,e,t,a,r){let i=s&31,n=i<24?e:t,o=i<16?t:a,l=i<8?a:r;return(i&1?-n:n)+(i&2?-o:o)+(i&4?-l:l)}let ea=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]];function Mm(s){let e=Ca(s),t=e+1,a=s-e,r=a-1,i,n,o=1-a*a;o*=o,i=o*o*hl(Ue[e&255],a);let l=1-r*r;return l*=l,n=l*l*hl(Ue[t&255],r),.25*(i+n)}function Nm(s,e){const t=.366025403,a=.211324865;let r,i,n,o=(s+e)*t,l=s+o,c=e+o,f=Ca(l),d=Ca(c),h=(f+d)*a,u=f-h,m=d-h,g=s-u,p=e-m,D,A;g>p?(D=1,A=0):(D=0,A=1);let B=g-D+a,v=p-A+a,U=g-1+2*a,y=p-1+2*a,S=f&255,F=d&255,C=.5-g*g-p*p;C<0?r=0:(C*=C,r=C*C*nn(Ue[S+Ue[F]],g,p));let w=.5-B*B-v*v;w<0?i=0:(w*=w,i=w*w*nn(Ue[S+D+Ue[F+A]],B,v));let E=.5-U*U-y*y;return E<0?n=0:(E*=E,n=E*E*nn(Ue[S+1+Ue[F+1]],U,y)),40*(r+i+n)}function Pm(s,e,t){const a=.333333333,r=.166666667;let i,n,o,l,c=(s+e+t)*a,f=s+c,d=e+c,h=t+c,u=Ca(f),m=Ca(d),g=Ca(h),p=(u+m+g)*r,D=u-p,A=m-p,B=g-p,v=s-D,U=e-A,y=t-B,S,F,C,w,E,Q;v>=U?U>=y?(S=1,F=0,C=0,w=1,E=1,Q=0):v>=y?(S=1,F=0,C=0,w=1,E=0,Q=1):(S=0,F=0,C=1,w=1,E=0,Q=1):U<y?(S=0,F=0,C=1,w=0,E=1,Q=1):v<y?(S=0,F=1,C=0,w=0,E=1,Q=1):(S=0,F=1,C=0,w=1,E=1,Q=0);let T=v-S+r,j=U-F+r,ue=y-C+r,ee=v-w+2*r,N=U-E+2*r,M=y-Q+2*r,O=v-1+3*r,W=U-1+3*r,ae=y-1+3*r,z=u&255,K=m&255,$=g&255,re=.6-v*v-U*U-y*y;re<0?i=0:(re*=re,i=re*re*ts(Ue[z+Ue[K+Ue[$]]],v,U,y));let ce=.6-T*T-j*j-ue*ue;ce<0?n=0:(ce*=ce,n=ce*ce*ts(Ue[z+S+Ue[K+F+Ue[$+C]]],T,j,ue));let Ae=.6-ee*ee-N*N-M*M;Ae<0?o=0:(Ae*=Ae,o=Ae*Ae*ts(Ue[z+w+Ue[K+E+Ue[$+Q]]],ee,N,M));let Qe=.6-O*O-W*W-ae*ae;return Qe<0?l=0:(Qe*=Qe,l=Qe*Qe*ts(Ue[z+1+Ue[K+1+Ue[$+1]]],O,W,ae)),32*(i+n+o+l)}function Vm(s,e,t,a){const r=.309016994,i=.138196601;let n,o,l,c,f,d=(s+e+t+a)*r,h=s+d,u=e+d,m=t+d,g=a+d,p=Ca(h),D=Ca(u),A=Ca(m),B=Ca(g),v=(p+D+A+B)*i,U=p-v,y=D-v,S=A-v,F=B-v,C=s-U,w=e-y,E=t-S,Q=a-F,T=C>w?32:0,j=C>E?16:0,ue=w>E?8:0,ee=C>Q?4:0,N=w>Q?2:0,M=E>Q?1:0,O=T+j+ue+ee+N+M,W,ae,z,K,$,re,ce,Ae,Qe,Ve,H,ie;W=ea[O][0]>=3?1:0,ae=ea[O][1]>=3?1:0,z=ea[O][2]>=3?1:0,K=ea[O][3]>=3?1:0,$=ea[O][0]>=2?1:0,re=ea[O][1]>=2?1:0,ce=ea[O][2]>=2?1:0,Ae=ea[O][3]>=2?1:0,Qe=ea[O][0]>=1?1:0,Ve=ea[O][1]>=1?1:0,H=ea[O][2]>=1?1:0,ie=ea[O][3]>=1?1:0;let le=C-W+i,ge=w-ae+i,Ie=E-z+i,me=Q-K+i,ye=C-$+2*i,Se=w-re+2*i,Me=E-ce+2*i,Ze=Q-Ae+2*i,$e=C-Qe+3*i,ct=w-Ve+3*i,ja=E-H+3*i,ba=Q-ie+3*i,Ra=C-1+4*i,Xt=w-1+4*i,Qa=E-1+4*i,Ta=Q-1+4*i,Pt=p&255,ga=D&255,pa=A&255,ra=B&255,wr=.6-C*C-w*w-E*E-Q*Q;wr<0?n=0:(wr*=wr,n=wr*wr*_i(Ue[Pt+Ue[ga+Ue[pa+Ue[ra]]]],C,w,E,Q));let Ir=.6-le*le-ge*ge-Ie*Ie-me*me;Ir<0?o=0:(Ir*=Ir,o=Ir*Ir*_i(Ue[Pt+W+Ue[ga+ae+Ue[pa+z+Ue[ra+K]]]],le,ge,Ie,me));let Rr=.6-ye*ye-Se*Se-Me*Me-Ze*Ze;Rr<0?l=0:(Rr*=Rr,l=Rr*Rr*_i(Ue[Pt+$+Ue[ga+re+Ue[pa+ce+Ue[ra+Ae]]]],ye,Se,Me,Ze));let Qr=.6-$e*$e-ct*ct-ja*ja-ba*ba;Qr<0?c=0:(Qr*=Qr,c=Qr*Qr*_i(Ue[Pt+Qe+Ue[ga+Ve+Ue[pa+H+Ue[ra+ie]]]],$e,ct,ja,ba));let Tr=.6-Ra*Ra-Xt*Xt-Qa*Qa-Ta*Ta;return Tr<0?f=0:(Tr*=Tr,f=Tr*Tr*_i(Ue[Pt+1+Ue[ga+1+Ue[pa+1+Ue[ra+1]]]],Ra,Xt,Qa,Ta)),27*(n+o+l+c+f)}class Dl extends de{static uv_0=new Dl;u=0;v=0;constructor(e=0,t=0){super(e,t),this.u=e,this.v=t}length(){return 0}static getUVSheet(e,t,a){let r=Math.floor(e%(t*a)),i=Math.floor(r/t),n=r%t;return new be(i/t,n/a,1/t,1/a)}}class as{serializedVersion="2";time;tangentMode=0;weightedMode=0;propertyKeyFrame;constructor(e=0){this.time=e,this.propertyKeyFrame={}}getK(e){return this.propertyKeyFrame[e]}split(e,t,a){switch(e){case X.single:{let r=this.getKeyFrame(0);r[a]=t}break;case X.float:{let r=this.getKeyFrame(0);r[a]=t}break;case X.vector2:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y}break;case X.vector3:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z}break;case X.vector4:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break;case X.quaternion:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break}}getKeyFrame(e){let t=this.propertyKeyFrame[e];return t||(t=new Js,t.time=this.time,t.tangentMode=this.tangentMode,t.weightedMode=this.weightedMode,this.propertyKeyFrame[e]=t),t}formBytes(e){this.time=e.readFloat32();{let{t,v:a}=Wa.parser(e);this.split(t,a,"value")}{let{t,v:a}=Wa.parser(e);this.split(t,a,"inSlope")}{let{t,v:a}=Wa.parser(e);this.split(t,a,"outSlope")}this.tangentMode=e.readInt32(),this.weightedMode=e.readInt32();{let{t,v:a}=Wa.parser(e);this.split(t,a,"inWeight")}{let{t,v:a}=Wa.parser(e);this.split(t,a,"outWeight")}}}class Om{static sub(e,t){switch(e.constructor.name){case"number":return e-t;case"Vector2":{let r=e,i=t;return new de(r.x-i.x,r.y-i.y)}case"Vector3":{let r=e,i=t;return new b(r.x-i.x,r.y-i.y,r.z-i.z)}case"Vector4":{let r=e,i=t;return new be(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}case"Quaternion":{let r=e,i=t;return new se(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}}}}class rs{_keys=new Array;_values=new Array;getIndexByKey(e){return this._keys.indexOf(e)}getValueByKey(e){var t=this.getIndexByKey(e);return t>-1?this._values[t]:null}put(e,t){if(e==null)return null;var a=this.remove(e);return this._keys.push(e),this._values.push(t),a}remove(e){var t=this._keys.indexOf(e),a;return t>-1&&(a=this._values[t],this._keys.splice(t,1),this._values.splice(t,1)),a}getValues(){return this._values}getKeys(){return this._keys}clear(){this._values.length=0,this._keys.length=0}}class Ur{static WalkAble=1}class is{static SetConst(e){this.EPSILON=e,this.POWER_EPSILON=e*e}static EPSILON=.1;static POWER_EPSILON=this.EPSILON*this.EPSILON}class Qt extends b{static CALC_VECTOR3D1=new b;static CALC_VECTOR3D2=new b;static CALC_VECTOR3D3=new b;static CALC_VECTOR3D4=new b;static CALC_VECTOR3D5=new b;_pointId=0;constructor(e,t,a,r){super(t,a,r,0),this._pointId=e}get id(){return this._pointId}static equalPoint(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)+(e.z-t.z)*(e.z-t.z)<is.POWER_EPSILON}static calcDistance(e,t){return Qt.CALC_VECTOR3D3.setTo(e.x-t.x,e.y-t.y,e.z-t.z),Qt.CALC_VECTOR3D3.length}}class ku{_openedList;_closedList;_endNode;_startNode;_triangleChannel;_navMesh;_findIndex=0;constructor(){this._openedList=new Array,this._closedList=new Array}findPath(e,t,a){return this._findIndex++,this._navMesh=e,this._startNode=t,this._endNode=a,this._openedList.length=0,this._closedList.length=0,this._startNode&&this._endNode?(this._startNode.gg=0,this._startNode.h=0,this._startNode.f=0,this._startNode.parent=null,this.search()):!1}search(){for(var e=this._startNode,t=[],a;e!=this._endNode;){t=e.getNeibourTriangles(t,Ur.WalkAble,Ur.WalkAble);for(a of t)if(a.closeId!=this._findIndex&&!(a==e||!a.walkAble)){var r=e.gg+Qt.calcDistance(a,e)*a.costMultiplier,i=Qt.calcDistance(a,this._endNode),n=r+i;a.openId==this._findIndex?a.f>n&&(a.f=n,a.gg=r,a.h=i,a.parent=e):(a.f=n,a.gg=r,a.h=i,a.parent=e,a.openId=this._findIndex,this._openedList.push(a))}if(e.closeId=this._findIndex,this._closedList.push(e),this._openedList.length==0)return!1;this._openedList.sort(function(o,l){return o.f-l.f}),e=this._openedList.shift()}return this.buildPath(),!0}buildPath(){this._triangleChannel=[];var e=this._endNode;for(this._triangleChannel.push(e);e!=this._startNode;)e=e.parent,this._triangleChannel.unshift(e)}get channel(){return this._triangleChannel}}class Fa extends Qt{_ownerPoint;_ownerEdge;radius=0;constructor(e,t){super(e.id,0,0,0),this._ownerEdge=t,this._ownerPoint=e}get ownerPoint(){return this._ownerPoint}get ownerEdge(){return this._ownerEdge}scalePoint(e=.7){var t=new Fa(this._ownerPoint,this._ownerEdge);return t.copyFrom(this),t.decrementBy(this._ownerPoint),t.scaleBy(e),t.radius=t.length,t.incrementBy(this._ownerPoint),t}}class Ea{_edgeMask=0;_edgeSize=0;_pointA;_pointB;_triangleOwners;_centerPoint;_edgeDirA2B;crossPoint;fatPointA;fatPointB;static CALC_FAT_VECTOR=new b;constructor(e,t){if(this._pointA=e,this._pointB=t,e.id>=t.id)throw new Error("edge point order error!!!");this._triangleOwners=new Array,this._centerPoint=new b,this._edgeMask=Ur.WalkAble,Qt.CALC_VECTOR3D1.setTo(e.x-t.x,e.y-t.y,e.z-t.z),this._edgeSize=Qt.CALC_VECTOR3D1.length,this._centerPoint.setTo((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2)}get size(){return this._edgeSize}get triangleOwners(){return this._triangleOwners}get centerPoint(){return this._centerPoint}initFatPoints(e){this._edgeDirA2B=this._pointB.subtract(this._pointA),this._edgeDirA2B.normalize(),this.fatPointA=this.fatPointA||new Fa(this._pointA,this),this.fatPointB=this.fatPointB||new Fa(this._pointB,this),this.fatPointA.radius!=e&&(Ea.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Ea.CALC_FAT_VECTOR.scaleBy(e),Ea.CALC_FAT_VECTOR.incrementBy(this._pointA),this.fatPointA.copyFrom(Ea.CALC_FAT_VECTOR),this.fatPointA.radius=e),this.fatPointB.radius!=e&&(Ea.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Ea.CALC_FAT_VECTOR.scaleBy(-e),Ea.CALC_FAT_VECTOR.incrementBy(this._pointB),this.fatPointB.copyFrom(Ea.CALC_FAT_VECTOR),this.fatPointB.radius=e)}getFatPoint(e){return e==this._pointA?this.fatPointA:this.fatPointB}getAnotherFatPoint(e){return e==this._pointA?this.fatPointB:this.fatPointA}getAnotherPoint(e){return e==this._pointA?this._pointB:this._pointA}containsPoint(e){return Qt.equalPoint(e,this._pointA)?this._pointA:Qt.equalPoint(e,this._pointB)?this._pointB:null}addTriangleOwners(e){if(e.edges.indexOf(this)==-1)throw new Error("the edge is not belong triangle!!!");this._triangleOwners.indexOf(e)==-1&&this._triangleOwners.push(e)}getPublicPoint(e){return this._pointA==e._pointA||this._pointA==e._pointB?this._pointA:this._pointB==e._pointA||this._pointB==e._pointB?this._pointB:null}getEqualPoint(e){return Qt.equalPoint(e,this._pointA)?this._pointA:Qt.equalPoint(e,this._pointB)?this._pointB:null}get pointA(){return this._pointA}get pointB(){return this._pointB}get walkAble(){return(this._edgeMask&Ur.WalkAble)==Ur.WalkAble}testMask(e){return(this._edgeMask&e)==e}}class _e{endPoint;curPoint;rayA;rayB;rayAPoint;rayBPoint;static RAY_1=new b;static RAY_2=new b;static TEST_RAY=new b;static TEST_RAY_1=new b;static TEST_RAY_2=new b;static CALC_CROSS_POINT=new b;static CALC_CROSS_TEST=new b;cornerPoint;cornerEdge;continuePass(e,t,a){this.resetData(),this.curPoint=e,this.endPoint=t,this.cornerEdge=a}passEdge(e,t,a,r){if((this.rayA==null||this.rayB==null)&&(this.rayA=_e.RAY_1,this.rayB=_e.RAY_2,this.rayAPoint=e.pointA,this.rayBPoint=e.pointB,this.rayA.setTo(this.rayAPoint.x-this.curPoint.x,0,this.rayAPoint.z-this.curPoint.z),this.rayB.setTo(this.rayBPoint.x-this.curPoint.x,0,this.rayBPoint.z-this.curPoint.z)),r)return this.checkEndPoint(a);if(_e.TEST_RAY.setTo(a.x-this.curPoint.x,0,a.z-this.curPoint.z),this.isPointAtCenter(_e.TEST_RAY,this.rayA,this.rayB)){this.hasCrossPoint(t.pointA,t.pointB,this.rayAPoint,this.rayA)?(this.rayB.copyFrom(_e.TEST_RAY),a instanceof Qt?this.rayBPoint=a:this.rayBPoint=null):(this.rayA.copyFrom(_e.TEST_RAY),a instanceof Qt?this.rayAPoint=a:this.rayAPoint=null);var i=t.getAnotherPoint(a);_e.TEST_RAY.setTo(i.x-this.curPoint.x,0,i.z-this.curPoint.z),(i==this.rayAPoint||i==this.rayBPoint||this.isPointAtCenter(_e.TEST_RAY,this.rayA,this.rayB))&&(this.cornerEdge=t)}else{var n;if(_e.TEST_RAY_1.copyFrom(t.pointA),_e.TEST_RAY_1.decrementBy(this.curPoint),_e.TEST_RAY_2.copyFrom(t.pointB),_e.TEST_RAY_2.decrementBy(this.curPoint),_e.TEST_RAY_1.y=0,_e.TEST_RAY_2.y=0,this.isPointAtCenter(this.rayA,_e.TEST_RAY_1,_e.TEST_RAY_2)||this.isPointAtCenter(this.rayB,_e.TEST_RAY_1,_e.TEST_RAY_2)?n=!1:n=!0,n)return this.isPointAtCenter(this.rayA,_e.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1}return!0}checkEndPoint(e){return _e.TEST_RAY.setTo(e.x-this.curPoint.x,0,e.z-this.curPoint.z),this.isPointAtCenter(_e.TEST_RAY,this.rayA,this.rayB)?!0:(this.isPointAtCenter(this.rayA,_e.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1)}calcCrossEdge(e,t,a){return this.calcCrossPoint(e.fatPointA,e.fatPointB,t,a)}calcCrossPoint(e,t,a,r){_e.CALC_CROSS_POINT.copyFrom(t),_e.CALC_CROSS_POINT.decrementBy(e);let i=_e.CALC_CROSS_POINT.x*r.z-r.x*_e.CALC_CROSS_POINT.z;var n=0;return i!=0&&(n=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/i),n>1?n=1:n<0&&(n=0),_e.CALC_CROSS_POINT.scaleBy(n),_e.CALC_CROSS_POINT.incrementBy(e),_e.CALC_CROSS_POINT.clone()}calcCrossPointOut(e,t,a,r){_e.CALC_CROSS_POINT.copyFrom(t),_e.CALC_CROSS_POINT.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(_e.CALC_CROSS_POINT.x*r.z-r.x*_e.CALC_CROSS_POINT.z);return i<=1&&i>=0?null:(_e.CALC_CROSS_POINT.scaleBy(i),_e.CALC_CROSS_POINT.incrementBy(e),_e.CALC_CROSS_POINT.clone())}hasCrossPoint(e,t,a,r){_e.CALC_CROSS_TEST.copyFrom(t),_e.CALC_CROSS_TEST.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(_e.CALC_CROSS_TEST.x*r.z-r.x*_e.CALC_CROSS_TEST.z);return i<=1&&i>=0}isPointAtCenter(e,t,a){var r=t.crossProduct(e);if(r.length==0&&e.length<t.length)return!0;var i=a.crossProduct(e);return i.length==0&&e.length<a.length?!0:(r.normalize(),i.normalize(),r.incrementBy(i),r.length<.01)}resetData(){this.cornerEdge=null,this.cornerPoint=null,this.curPoint=null,this.rayA=this.rayB=null,this.rayAPoint=this.rayBPoint=null,_e.RAY_1.setTo(0,0,0),_e.RAY_2.setTo(0,0,0)}}class sr{_aiRadius=0;_router;_result;_tempPublicEdgeList=new Array;_tempSamePlaneList=new Array;static CROSS_TEST_DIRECTION=new b;constructor(){this._router=new _e}searchPath(e,t,a,r=0){return r<=0&&(r=1),this._aiRadius=r*1.5,this.searchEnable(e,t,a)?(this.search(e,t,a),!0):!1}get path(){return this._result}searchEnable(e,t,a){return!(e==null||t==null||a==null||a[0].plane.classifyPoint(e,is.EPSILON)!=Vr.INTERSECT||a[a.length-1].plane.classifyPoint(t,is.EPSILON)!=Vr.INTERSECT)}search(e,t,a){this._tempPublicEdgeList.length=0,this._tempSamePlaneList.length=0;var r=0,i=a.length-1,n,o,l,c;for(r=0;r<i;r++)o=a[r].getPublicEdge(a[r+1]),o.crossPoint=null,o.initFatPoints(this._aiRadius),this._tempPublicEdgeList.push(o),n=a[r],c=n.plane,n=a[r+1],l=n.getEdgeAgainstPoint(o),this._tempSamePlaneList.push(c.classifyPoint(l,is.EPSILON)==Vr.INTERSECT);this._router.continuePass(e,t,this._tempPublicEdgeList[0]),i=this._tempPublicEdgeList.length;var f,d,h,u;for(r=0;r<i;r++)o=this._tempPublicEdgeList[r],n=a[r+1],u=r==i-1,u?l=t:l=n.getEdgeAgainstPoint(o),h=this._router.passEdge(o,this._tempPublicEdgeList[r+1],l,u),h||(f=this._router.cornerPoint,d=this._router.cornerEdge,r=this._tempPublicEdgeList.indexOf(d),this._router.continuePass(f,t,this._tempPublicEdgeList[r+1]));this.pushAllPathPoint2(e,t),this._result.length>=3&&(this.optimusTerminusFat(),this.optimusByRadius());let m=[];for(let g of this._result)m.push(new b().copyFrom(g));this._result=m}optimusTerminusFat(){var e,t,a;a=this._result[1],a instanceof Fa&&(e=a),a=this._result[this._result.length-2],a instanceof Fa&&(t=a),e&&(this._result[1]=e.scalePoint()),t&&e!=t&&(this._result[this._result.length-2]=t.scalePoint())}pushAllPathPoint2(e,t){var a=this._tempPublicEdgeList.length,r,i;this._result=new Array,this._result.push(e);for(var n=e,o,l,c,f=0;f<a;f++)if(r=this._tempPublicEdgeList[f],l=null,r.crossPoint)l=this.getFatPoint(r,r.crossPoint),l?this._result.push(l):this._result.push(r.crossPoint),n=r.crossPoint;else{i=null,o=null;for(var d=f+1;d<a&&(i=this._tempPublicEdgeList[d],o=i.crossPoint,!o);d++);o==null&&(o=t),l=this.getFatPoint(r,o),l?this._result.push(l):(o==n?c=o.clone():(sr.CROSS_TEST_DIRECTION.setTo(o.x-n.x,0,o.z-n.z),c=this._router.calcCrossEdge(r,n,sr.CROSS_TEST_DIRECTION)),this._result.push(c))}this._result.push(t)}optimusByRadius(){var e=new Array;e.length=this._result.length;var t=this._result.length-2,a,r,i,n,o,l,c,f,d,h,u,m,g;for(g=0;g<t;g++)c=f=d=null,n=o=l=null,u=!1,m=null,a=this._result[g],r=this._result[g+1],i=this._result[g+2],a instanceof Fa&&(n=a),r instanceof Fa&&(o=r),i instanceof Fa&&(l=i),n&&(c=n.ownerPoint),o&&(f=o.ownerPoint),l&&(d=l.ownerPoint),c&&f&&c==f&&f!=d&&(u=!0),d&&f&&d==f&&c!=f&&(u=!0),u&&(sr.CROSS_TEST_DIRECTION.copyFrom(a),sr.CROSS_TEST_DIRECTION.decrementBy(i),h=o.ownerEdge,u=this._router.hasCrossPoint(h.pointA,h.pointB,i,sr.CROSS_TEST_DIRECTION),u&&(m=this._router.calcCrossPointOut(f,r,i,sr.CROSS_TEST_DIRECTION)),m&&(e[g+1]=m))}getFatPoint(e,t){if(e==null)return null;var a;t instanceof Fa&&(a=t);var r;return a?r=a.ownerPoint:r=e.getEqualPoint(t),r==null?null:(a=e.getFatPoint(r),a)}}class Eu extends b{_id=0;_plane;_points=new Array;_edges=new Array;_neibourTriangles=new rs;_pointAgainstEdge=new rs;_edgeAgainstPoint=new rs;_mask=0;_aabbBox;f=0;gg=0;h=0;parent;costMultiplier=1;openId=0;closeId=0;get aabb(){return this._aabbBox}initAABB(){this._aabbBox=new Nt,this._aabbBox.addPoint(this._points[0]),this._aabbBox.addPoint(this._points[1]),this._aabbBox.addPoint(this._points[2])}calcGlobalQuadAABB(){}get isTriangle(){return!0}constructor(e,t,a,r){super(0,0,0,0),this._id=e,this._mask=Ur.WalkAble,this._edges.push(t,a,r);var i;for(i of this._edges)this._points.indexOf(i.pointA)==-1&&this._points.push(i.pointA),this._points.indexOf(i.pointB)==-1&&this._points.push(i.pointB);this.x=(this._points[0].x+this._points[1].x+this._points[2].x)/3,this.y=(this._points[0].y+this._points[1].y+this._points[2].y)/3,this.z=(this._points[0].z+this._points[1].z+this._points[2].z)/3,this._plane=new Su,this._plane.fromPoints(this._points[0],this._points[1],this._points[2]),this._plane.normalize(),this.genarateAgainstData(),this.initAABB()}genarateAgainstData(){var e,t;for(e of this._edges)for(t of this._points)e.pointA!=t&&e.pointB!=t&&(this._edgeAgainstPoint.put(e,t),this._pointAgainstEdge.put(t,e))}get id(){return this._id}get plane(){return this._plane}get points(){return this._points}addNeibour(e,t){if(this._edges.indexOf(e)>=0)this._neibourTriangles.put(e,t);else throw new Error("the edge is not in triangle!!!")}getNeibourTriangles(e=null,t=1,a=1){e=e||new Array,e.length=0;var r,i,n=this._neibourTriangles.getKeys(),o;for(o of n)i=o,i.testMask(t)&&(r=this._neibourTriangles.getValueByKey(i),r.testMask(a)&&e.push(r));return e}getEdges(e=null,t=1){e=e||new Array,e.length=0;var a;for(a of this._edges)a.testMask(t)&&e.push(a);return e}get walkAble(){return this.testMask(Ur.WalkAble)}get edges(){return this._edges}testMask(e){return(this._mask&e)==e}getEdgeAgainstPoint(e){return this._edgeAgainstPoint.getValueByKey(e)}getPointAgainstEdge(e){return this._pointAgainstEdge.getValueByKey(e)}getPublicEdge(e){if(e&&e!=this){var t=this._neibourTriangles.getKeys(),a;for(a of t)if(this._neibourTriangles.getValueByKey(a)==e)return a}return null}loopPublicEdge(e){var t,a;if(e&&e!=this){for(t of this._edges)for(a of e._edges)if(t==a)return t}return null}randomPoint(){var e=this._points[2].subtract(this._points[0]);e.scaleBy(Math.random()),e.incrementBy(this._points[0]);var t=this._points[1].subtract(e);return t.scaleBy(Math.random()),t.incrementBy(e),t}}class Lm{_nav3dPoints;_nav3dEdges;_nav3dTriangles;_path;_edgesDict;_nav3dAstar;_nav3dFunnel;_terrainQuad;_triangleList;get edges(){return this._nav3dEdges}get points(){return this._nav3dPoints}get path(){return this._path}get triangles(){return this._nav3dTriangles}constructor(e,t){this._nav3dPoints=new Array,this._nav3dEdges=new Array,this._nav3dTriangles=new Array,this._edgesDict=new rs,this.initPoints(e),this.initEdgesAndTriangles(t),this.createConnections(),this._nav3dAstar=new ku,this._nav3dFunnel=new sr,this._terrainQuad=new Mh(8,128),this._terrainQuad.createQuadTree(this._nav3dTriangles)}getTriangleAtPoint(e,t=5){return this._terrainQuad.getTriangleAtPoint(e,t)}findPath(e,t,a=5){this._path=null,this._triangleList=null;var r=this.getTriangleAtPoint(e,10),i=this.getTriangleAtPoint(t,10),n=this._nav3dAstar.findPath(this,r,i);return n?(this._triangleList=this._nav3dAstar.channel,n=this._nav3dFunnel.searchPath(e,t,this._triangleList,a),this._path=this._nav3dFunnel.path,n):!1}initPoints(e){for(var t,a,r=e.length,i=0;i<r;i++)t=e[i],a=new Qt(i,t.x,t.y,t.z),this._nav3dPoints.push(a)}initEdgesAndTriangles(e){for(var t,a,r,i,n,o=e.length,l=0;l<o;l++)t=e[l],a=this.tryCreateEdge(t[0],t[1]),r=this.tryCreateEdge(t[1],t[2]),i=this.tryCreateEdge(t[2],t[0]),!(a==null||r==null||i==null)&&(n=new Eu(l,a,r,i),this._nav3dTriangles.push(n))}tryCreateEdge(e,t){if(e==t)throw new Error("edge point index error!!!");if(e>t){var a=e;e=t,t=a}var r=this._edgesDict.getValueByKey(e+"_"+t);return r==null&&(r=new Ea(this._nav3dPoints[e],this._nav3dPoints[t]),this._nav3dEdges.push(r),this._edgesDict.put(e+"_"+t,r)),r}createConnections(){for(var e=this._nav3dTriangles.length,t=this._nav3dTriangles.length,a,r,i,n,o=0;o<e;o++){a=this._nav3dTriangles[o];for(i of a.edges)i.addTriangleOwners(a);for(var l=0;l<t;l++)r=this._nav3dTriangles[l],a!=r&&(n=a.loopPublicEdge(r),n&&(a.addNeibour(n,r),r.addNeibour(n,a)))}}}class _l{x;y;setTo(e,t){this.x=e,this.y=t}equals(e,t){return e==this.x&&t==this.y}equalPoint(e){return this.equals(e.x,e.y)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y)}clone(){var e=new _l;return e.setTo(this.x,this.y),e}normalize(){var e=length;e!=0&&this.setTo(this.x/e,this.y/e)}}class za extends Le{width;height;depth;constructor(e=1,t=1,a=1){super(),this.width=e,this.height=t,this.depth=a,this.initVertex()}initVertex(){let e=this.width/2,t=this.height/2,a=this.depth/2;this.bounds=new Ce(b.ZERO.clone(),new b(this.width,this.height,this.depth));let r=new Float32Array([-e,t,a,e,t,a,e,t,-a,-e,t,-a,-e,t,a,e,t,-a,e,-t,a,-e,-t,a,-e,-t,-a,e,-t,-a,e,-t,a,-e,-t,-a,-e,-t,a,-e,t,a,-e,t,-a,-e,-t,-a,-e,-t,a,-e,t,-a,e,t,a,e,-t,a,e,-t,-a,e,t,-a,e,t,a,e,-t,-a,e,t,a,-e,t,a,-e,-t,a,-e,-t,a,e,-t,a,e,t,a,e,-t,-a,-e,-t,-a,-e,t,-a,e,t,-a,e,-t,-a,-e,t,-a]),i=new Float32Array([0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1]),n=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),o=[0,2,1,3,5,4,6,8,7,9,11,10,12,14,13,15,17,16,18,20,19,21,23,22,24,26,25,27,29,28,30,32,31,33,35,34],l=new Uint16Array(o.reverse());this.setIndices(l),this.setAttribute(G.position,r),this.setAttribute(G.normal,i),this.setAttribute(G.uv,n),this.setAttribute(G.TEXCOORD_1,n),this.addSubGeometry({indexStart:0,indexCount:o.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class wu extends Le{radiusTop;radiusBottom;height;radialSegments;heightSegments;openEnded;thetaStart;thetaLength;constructor(e=1,t=1,a=1,r=8,i=8,n=!1,o=0,l=Math.PI*2){super(),this.radiusTop=e,this.radiusBottom=t,this.height=a,this.radialSegments=r,this.heightSegments=i,this.openEnded=n,this.thetaStart=o,this.thetaLength=l,this.instanceID=zt(),this.buildGeometry()}addGroup(e,t,a){this.addSubGeometry({indexStart:e,indexCount:t,vertexStart:e,vertexCount:0,firstStart:0,index:a,topology:0})}buildGeometry(){const e=this;this.radialSegments=Math.floor(this.radialSegments),this.heightSegments=Math.floor(this.heightSegments);const t=[],a=[],r=[],i=[];let n=0;const o=[],l=this.height/2;let c=0;m(),this.openEnded===!1&&(this.radiusTop>0&&g(!0),this.radiusBottom>0&&g(!1));let f=new Float32Array(t),d=new Float32Array(a),h=new Float32Array(r),u=new Uint16Array(i);this.setAttribute(G.position,f),this.setAttribute(G.normal,d),this.setAttribute(G.uv,h),this.setAttribute(G.TEXCOORD_1,h),this.setIndices(u);function m(){const p=new b,D=new b;let A=0;const B=(e.radiusBottom-e.radiusTop)/e.height;for(let v=0;v<=e.heightSegments;v++){const U=[],y=v/e.heightSegments,S=y*(e.radiusBottom-e.radiusTop)+e.radiusTop;for(let F=0;F<=e.radialSegments;F++){const C=F/e.radialSegments;let w=C*e.thetaLength+e.thetaStart;F==e.radialSegments&&Math.abs(e.thetaLength-e.thetaStart)==Math.PI*2&&(w=0);const E=Math.sin(w),Q=Math.cos(w);D.x=S*E,D.y=-y*e.height+l,D.z=S*Q,t.push(D.x,D.y,D.z),p.set(E,B,Q).normalize(),a.push(p.x,p.y,p.z),r.push(C,1-y),U.push(n++)}o.push(U)}for(let v=0;v<e.radialSegments;v++)for(let U=0;U<e.heightSegments;U++){const y=o[U][v],S=o[U+1][v],F=o[U+1][v+1],C=o[U][v+1];i.push(y,S,C),i.push(S,F,C),A+=6}e.addGroup(c,A,0),c+=A}function g(p){const D=n,A=new de,B=new b;let v=0;const U=p===!0?e.radiusTop:e.radiusBottom,y=p===!0?1:-1;for(let F=1;F<=e.radialSegments;F++)t.push(0,l*y,0),a.push(0,y,0),r.push(.5,.5),n++;const S=n;for(let F=0;F<=e.radialSegments;F++){const w=F/e.radialSegments*e.thetaLength+e.thetaStart,E=Math.cos(w),Q=Math.sin(w);B.x=U*Q,B.y=l*y,B.z=U*E,t.push(B.x,B.y,B.z),a.push(0,y,0),A.x=E*.5+.5,A.y=Q*.5*y+.5,r.push(A.x,A.y),n++}for(let F=0;F<e.radialSegments;F++){const C=D+F,w=S+F;p===!0?i.push(w,w+1,C):i.push(w+1,w,C),v+=3}e.addGroup(c,v,p===!0?1:2),c+=v}}}class Iu extends Le{radius;tube;radialSegments;tubularSegments;constructor(e=.4,t=.1,a=32,r=32){super(),this.radius=e,this.tube=t,this.radialSegments=a,this.tubularSegments=r,this.initVertex()}initVertex(){const e=2*Math.PI,t=this.radius,a=this.tube,r=this.radialSegments,i=this.tubularSegments;this.bounds=new Ce(b.ZERO.clone(),new b(t*2,a*2,t*2));var n=(r+1)*(i+1);let o=new Float32Array(n*3),l=new Float32Array(n*3),c=new Float32Array(n*2),f=new Uint16Array(r*i*2*3),d=0,h=0,u=0,m=0;for(let g=0;g<=r;g++)for(let p=0;p<=i;p++){const D=p/i,A=g/r,B=D*e,v=A*Math.PI*2;if(o[d++]=(t+a*Math.cos(v))*Math.sin(B),o[d++]=a*Math.sin(v),o[d++]=(t+a*Math.cos(v))*Math.cos(B),l[h++]=Math.sin(B)*Math.cos(v),l[h++]=Math.sin(v),l[h++]=Math.cos(B)*Math.cos(v),c[u++]=D,c[u++]=A,p<i&&g<r){const U=i+1,y=U*g+p,S=U*(g+1)+p,F=U*(g+1)+p+1,C=U*g+p+1;f[m++]=y,f[m++]=C,f[m++]=S,f[m++]=C,f[m++]=F,f[m++]=S}}this.setIndices(f),this.setAttribute(G.position,o),this.setAttribute(G.normal,l),this.setAttribute(G.uv,c),this.setAttribute(G.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Gm extends Le{segment;row=0;constructor(e){super(),this.segment=e,this.buildGeometry()}buildGeometry(){this.row=this.segment+1;let e=new Uint32Array(this.segment*6),t=new Float32Array(this.row*3*2),a=new Float32Array(this.row*3*2),r=new Float32Array(this.row*2*2);for(let i=0;i<this.row;i++){t[i*3*2+0]=0,t[i*3*2+1]=0,t[i*3*2+2]=0,t[i*3*2+3]=0,t[i*3*2+4]=0,t[i*3*2+5]=0,a[i*3*2+0]=0,a[i*3*2+1]=0,a[i*3*2+2]=1,a[i*3*2+3]=0,a[i*3*2+4]=0,a[i*3*2+5]=1,r[i*2*2+0]=0,r[i*2*2+1]=i/this.segment,r[i*2*2+2]=1,r[i*2*2+3]=i/this.segment;let n=i*2,o=n,l=n+1,c=n+2,f=n+3;e[i*6+0]=o,e[i*6+1]=l,e[i*6+2]=c,e[i*6+3]=l,e[i*6+4]=f,e[i*6+5]=c}this.setIndices(e),this.setAttribute(G.position,t),this.setAttribute(G.normal,a),this.setAttribute(G.uv,r),this.setAttribute(G.TEXCOORD_1,r),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class zm extends Le{faceCount=0;constructor(e){super(),this.faceCount=e,this.buildGeometry()}buildGeometry(){let e=new Uint32Array(this.faceCount*3),t=new Float32Array(this.faceCount*3*3),a=new Float32Array(this.faceCount*3*3),r=new Float32Array(this.faceCount*3*2),i=new Float32Array(this.faceCount*3*1);for(let n=0;n<this.faceCount;n++){let o=n*3+0,l=n*3+1,c=n*3+2;e[o]=o,e[l]=l,e[c]=c}this.setIndices(e),this.setAttribute(G.position,t),this.setAttribute(G.normal,a),this.setAttribute(G.uv,r),this.setAttribute(G.TEXCOORD_1,r),this.setAttribute(G.vIndex,i),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Wm extends Gs{_internalTexture;_minSize=32;_skyColor;constructor(e){super(),this._skyColor=e,this._internalTexture=new Ts;let t=[];return _.res.fillColor(t,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.create(this._minSize,this._minSize,t,!1),this.createFromTexture(this._minSize,this._internalTexture),this}changeColor(e){return this._skyColor=e,_.res.fillColor(this._internalTexture.floatArray,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.updateTexture(this._minSize,this._minSize,this._internalTexture.floatArray,!1),this._faceData.uploadTexture(0,this._internalTexture),this}get color(){return this._skyColor}set color(e){this.changeColor(e)}}class Jm extends ne{length=100;thickness=.1;constructor(e,t=.1){super(),this.length=e,this.thickness=t,this.init()}init(){let e=new ne,t=new ne,a=new ne,r=new za(2,2,2),i=new za(2,2,2),n=new za(2,2,2),o=new Bt;o.baseColor=new J(1,0,0);let l=new Bt;l.baseColor=new J(0,1,0);let c=new Bt;c.baseColor=new J(0,0,1);let f=e.addComponent(he),d=t.addComponent(he),h=a.addComponent(he);f.geometry=r,f.material=o,f.castShadow=!1,d.geometry=i,d.material=l,d.castShadow=!1,h.geometry=n,h.material=c,h.castShadow=!1,e.localScale=new b(this.length,this.thickness,this.thickness),e.x=this.length,t.localScale=new b(this.thickness,this.length,this.thickness),t.y=this.length,a.localScale=new b(this.thickness,this.thickness,this.length),a.z=this.length,this.addChild(e),this.addChild(t),this.addChild(a)}}class jm{static merge(e,t,a){}static mergeNumber(e,t,a){let r=a||new Le,i=e.getAttribute(G.position).data.length/3,n=new Float32Array(i*t);for(const f of e.vertexAttributeMap){let d=f[1].attribute;if(d==G.indices)continue;let h=e.getAttribute(d).data,u=h.length,m=new Float32Array(u*t);for(let g=0;g<t;g++){m.set(h,u*g);for(let p=0;p<i;p++)n[i*g+p]=g}r.setAttribute(d,m)}r.setAttribute(G.vIndex,n);let o=e.getAttribute(G.indices).data,l=o.length,c=new Uint32Array(o.length*t);for(let f=0;f<t;f++)for(let d=0;d<l;d++){let h=f*i,u=f*l;const m=o[d]+h;c[u+d]=m}return r.setIndices(c),r.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),r}static generateNormal(){}static generateTangent(){}static packUV(){}}class Zm extends ne{size=100;divisions=10;constructor(e=100,t=10){super(),this.size=e,this.divisions=t,this.buildGeometry(),this.addAxis()}buildGeometry(){const e=[],t=[],a=this.size/this.divisions,r=this.size/2,i=this.divisions/2;for(let c=0,f=-r;c<=this.divisions;c++,f+=a)c!==i&&(e.push(-r,0,f,r,0,f),e.push(f,0,-r,f,0,r));for(let c=0;c<e.length/3;c+=2)t.push(c,c+1);let n=new Le;n.setIndices(t.length>Uint16Array.length?new Uint32Array(t):new Uint16Array(t)),n.setAttribute(G.position,new Float32Array(e)),n.addSubGeometry({indexStart:0,indexCount:t.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let o=new Bt;o.topology="line-list",o.baseColor=new J(1,1,1,.15),o.blendMode=De.ADD,o.castReflection=!1;let l=this.addComponent(he);l.geometry=n,l.material=o}addAxis(){const e=this.size/2;let t=new Float32Array([-e,0,0,e,0,0]),a=new Uint16Array([0,1,2,3]),r=new Le;r.setIndices(a),r.setAttribute(G.position,t),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});{let i=new ne,n=i.addComponent(he);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(1,0,0,.5),o.blendMode=De.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}{let i=new ne;i.rotationY=90;let n=i.addComponent(he);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(0,1,0,.5),o.blendMode=De.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}}}class Ym{static color_temperature_to_rgb(e){e<1e3?e=1e3:e>4e4&&(e=4e4);let t=e/100,a=this.get_red(t),r=this.get_green(t),i=this.get_blue(t);return new J(a/255,r/255,i/255,1)}static get_red(e){if(e<=66)return 255;let t=329.698727446*Math.pow(e-60,-.1332047592);return this.bound(t)}static get_green(e){let t=0;return e<=66?t=99.4708025861*Math.log(e)-161.1195681661:t=288.1221695283*Math.pow(e-60,-.0755148492),this.bound(t)}static get_blue(e){let t=0;return e>=66?255:e<=19?0:(t=138.5177312231*Math.log(e-10)-305.0447927307,this.bound(t))}static bound(e,t=0,a=255){let r=Math.max(e,t);return Math.min(r,a)}}class Xm{static boxGeo;static planeGeo;static sphere;static material;static materialMap;static initHeap(){this.boxGeo||(this.boxGeo=new za),this.planeGeo||(this.planeGeo=new si(1,1,1,1,b.UP)),this.sphere||(this.sphere=new Nr(1,35,35)),this.material||(this.material=new ta),this.materialMap||(this.materialMap=new Map)}static get CubeMesh(){return this.initHeap(),this.boxGeo}static get SphereMesh(){return this.initHeap(),this.sphere}static GetCube(){this.initHeap();let e=new ne,t=e.addComponent(he);return t.geometry=this.boxGeo,t.material=this.material.clone(),t.castShadow=!0,e}static GetMaterial(e){let t=this.materialMap.get(e);return t||(t=new ta,t.baseMap=e,this.materialMap.set(e,t)),t.clone()}static GetPlane(e){this.initHeap();let t=new ne,a=t.addComponent(he);a.geometry=this.planeGeo;let r=this.GetMaterial(e);return r.blendMode=De.ADD,r.castShadow=!1,a.material=r,a.castGI=!1,a.castReflection=!1,t}static GetSingleCube(e,t,a,r,i,n){this.initHeap();let o=new ta;o.roughness=.5,o.metallic=.1,o.baseColor=new J(r,i,n,1);let l=new ne,c=l.addComponent(he);return c.castGI=!0,c.geometry=new za(e,t,a),c.material=o,l}static GetSingleSphere(e,t,a,r){this.initHeap();let i=new ta;i.baseColor=new J(t,a,r,1);let n=new ne,o=n.addComponent(he);return o.castGI=!0,o.geometry=new Nr(e,20,20),o.material=i,n}static get Sphere(){this.initHeap();let e=new ne,t=e.addComponent(he);return t.geometry=this.sphere,t.material=this.material,e}static GetSingleCube2(e,t=10){this.initHeap();let a=new ne,r=a.addComponent(he);return r.castShadow=!1,r.geometry=new za(t,t,t),r.material=e,a}static GetPointLight(e,t,a,r,i,n,o=1,l=!0){let c=new ne,f=c.addComponent(oi);f.lightColor=new J(r,i,n,1),f.intensity=o,f.range=a,f.at=8,f.radius=0,f.castShadow=l,c.localPosition=e,c.localRotation=t;let d=this.GetSingleSphere(.1,1,1,1);return c.addChild(d),f}}var P=(s=>(s[s.X=0]="X",s[s.Y=1]="Y",s[s.Z=2]="Z",s[s.XY=3]="XY",s[s.XZ=4]="XZ",s[s.YZ=5]="YZ",s[s.XYZ=6]="XYZ",s[s.MAX=7]="MAX",s[s.NONE=8]="NONE",s))(P||{}),ha=(s=>(s[s.Local=0]="Local",s[s.Global=1]="Global",s))(ha||{});class on extends et{mAxis;mAxisColor;mContainer;mAxisMaterial;mAxisCollider;constructor(){super(),this._enable=!1,this.mAxis=new Array(P.MAX),this.mAxisColor=new Array(P.MAX),this.mAxisMaterial=new Array(P.MAX),this.mAxisCollider=new Array(P.MAX)}get target(){return this.object3D.target}get mX(){return this.object3D.mXObj}get mY(){return this.object3D.mYObj}get mZ(){return this.object3D.mZObj}get transformSpaceMode(){return this.object3D.transformSpaceMode}init(e){this.mContainer=new ne;let t=new Bt;t.baseColor=new J(1,0,0),t.depthCompare=ft.always,this.mAxisColor[P.X]=t.baseColor,this.mAxisMaterial[P.X]=t;let a=new Bt;a.baseColor=new J(0,1,0),a.depthCompare=ft.always,this.mAxisColor[P.Y]=a.baseColor,this.mAxisMaterial[P.Y]=a;let r=new Bt;r.baseColor=new J(0,0,1),r.depthCompare=ft.always,this.mAxisColor[P.Z]=r.baseColor,this.mAxisMaterial[P.Z]=r;let i=this.createCustomAxis(P.X),n=this.createCustomAxis(P.Y),o=this.createCustomAxis(P.Z);this.mContainer.addChild(this.mAxis[P.X]=i),this.mContainer.addChild(this.mAxis[P.Y]=n),this.mContainer.addChild(this.mAxis[P.Z]=o),this.mAxisCollider[P.X]=i.getComponent(da),this.mAxisCollider[P.Y]=n.getComponent(da),this.mAxisCollider[P.Z]=o.getComponent(da)}start(){}onEnable(e){this.object3D.addChild(this.mContainer),this.reset()}onDisable(e){this.object3D.removeChild(this.mContainer)}reset(){switch(this.transformSpaceMode){case ha.Local:{let t=R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).decompose();this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=t[1].x,this.object3D.rotationY=t[1].y,this.object3D.rotationZ=t[1].z,this.object3D.x=t[0].x,this.object3D.y=t[0].y,this.object3D.z=t[0].z}break;case ha.Global:{this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=0,this.object3D.rotationY=0,this.object3D.rotationZ=0;const e=this.mX.transform.worldPosition;this.object3D.x=e.x,this.object3D.y=e.y,this.object3D.z=e.z}break}}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY),r,i;for(let n=0;n<=P.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r&&(!i||i.distance>r.distance||n==P.XYZ)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint},n==P.XYZ)))break}return i}currentAxis=P.NONE;beginPoint=new b;beginMousePos=new b;currentPoint=new b;onMouseDown(e){if(e.mouseCode!=Ys.MOUSE_LEFT)return;let t=this.pickAxis();if(!t)return;this.currentAxis=t.axis,e.stopImmediatePropagation();const r=this.object3D.transform.scene3D.view.camera;let i=r.worldToScreenPoint(this.mX.transform.worldPosition),n=r.screenPointToWorld(_.inputSystem.mouseX,_.inputSystem.mouseY,i.z);this.beginPoint.copyFrom(n),this.beginMousePos.x=_.inputSystem.mouseX,this.beginMousePos.y=_.inputSystem.mouseY}lastMoveObj;lastMoveAxis;onMouseMove(e){if(this.currentAxis==P.NONE){let t=this.lastMoveObj.getComponent(he).material;this.lastMoveObj&&"baseColor"in t&&(t.baseColor=this.mAxisColor[this.lastMoveAxis],this.lastMoveObj=null,this.lastMoveAxis==P.XYZ&&(this.mAxis[P.X].getComponent(he).material.setUniformColor("baseColor",this.mAxisColor[P.X]),this.mAxis[P.Y].getComponent(he).material.setUniformColor("baseColor",this.mAxisColor[P.Y]),this.mAxis[P.Z].getComponent(he).material.setUniformColor("baseColor",this.mAxisColor[P.Z])),this.lastMoveAxis=P.NONE);let a=this.pickAxis();if(!a)return;t.setUniformColor("baseColor",new J(1,1,1)),this.lastMoveObj=a.obj,this.lastMoveAxis=a.axis,this.lastMoveAxis==P.XYZ&&(this.mAxis[P.X].getComponent(he).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[P.Y].getComponent(he).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[P.Z].getComponent(he).material.setUniformColor("baseColor",new J(1,1,1)))}else{const a=this.object3D.transform.scene3D.view.camera;let r=a.worldToScreenPoint(this.mX.transform.worldPosition),i=a.screenPointToWorld(_.inputSystem.mouseX,_.inputSystem.mouseY,r.z);this.currentPoint.copyFrom(i);let n=i.subtract(this.beginPoint);b.HELP_0.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let o=b.distance(b.HELP_0,this.beginMousePos);switch(this.beginMousePos.copyFrom(b.HELP_0),this.transformSpaceMode){case ha.Local:this.applyLocalTransform(this.currentAxis,n,o);break;case ha.Global:this.applyGlobalTransform(this.currentAxis,n,o);break}this.beginPoint.copyFrom(i),this.reset()}}onMouseUp(e){e.mouseCode==Ys.MOUSE_LEFT&&(this.currentAxis=P.NONE,this.reset())}onUpdate(e){let a=b.distance(e.camera.transform.worldPosition,this.object3D.transform.worldPosition)/100;if(this.mContainer.scaleX=this.mContainer.scaleY=this.mContainer.scaleZ=a,this.mX){const r=this.mX.transform.worldPosition;this.object3D.x=r.x,this.object3D.y=r.y,this.object3D.z=r.z}}applyLocalTransform(e,t,a){console.warn("not imp")}applyGlobalTransform(e,t,a){console.warn("not imp")}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=0,a=0,r=0;switch(e){case P.X:t=1;break;case P.Y:a=1;break;case P.Z:r=1;break}let i=.4+t*20,n=.4+a*20,o=.4+r*20,l=new ne;l.x=i*.5,l.y=n*.5,l.z=o*.5;let c=l.addComponent(he);c.geometry=new za(i,n,o),c.material=this.mAxisMaterial[e];let f=l.addComponent(da),d=new bi;return d.setFromCenterAndSize(new b(0,0,0),new b(i+1,n+1,o+1)),f.shape=d,l}}class Ru extends on{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(.9,.9,.9),t.depthCompare=ft.always,this.mAxisColor[P.XYZ]=t.baseColor,this.mAxisMaterial[P.XYZ]=t;let a=new ne,r=a.addComponent(he);r.geometry=new za(2,2,2),r.material=this.mAxisMaterial[P.XYZ];let i=a.addComponent(da),n=new bi;n.setFromCenterAndSize(new b(0,0,0),new b(2,2,2)),i.shape=n,this.mContainer.addChild(this.mAxis[P.XYZ]=a),this.mAxisCollider[P.XYZ]=a.getComponent(da)}applyLocalTransform(e,t,a){switch(this.currentAxis){case P.XYZ:{let r=0;Math.abs(t.x)>Math.abs(t.y)?Math.abs(t.x)>Math.abs(t.z)?r=t.x:r=t.z:r=t.y,this.mX.scaleX+=r,this.mX.scaleY+=r,this.mX.scaleZ+=r}break;default:this.mX.transform.worldMatrix.transformVector(t,t),(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ)&&(this.mX.scaleX=Math.abs(this.mX.scaleX+t.x)),(this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ)&&(this.mX.scaleY=Math.abs(this.mX.scaleY+t.y)),(this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ)&&(this.mX.scaleZ=Math.abs(this.mX.scaleZ+t.z));break}}applyGlobalTransform(e,t,a){let r=b.HELP_0;r.set(0,0,0),(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ)&&(r.x=t.x),(this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ)&&(r.y=t.y),(this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ)&&(r.z=t.z),this.mX.transform.worldMatrix.transformVector(r,b.HELP_1),this.mX.scaleX+=b.HELP_1.x,this.mX.scaleY+=b.HELP_1.y,this.mX.scaleZ+=b.HELP_1.z}createCustomAxis(e){let t=super.createAxis(e),a=this.createBox(e);return t.addChild(a),t}createBox(e){let t=0,a=0,r=0,i=new ne;switch(e){case P.X:t=1,i.rotationZ=-90;break;case P.Y:a=1;break;case P.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(he);return c.geometry=new za(2,2,2),c.material=this.mAxisMaterial[e],i}}var mt=(s=>(s[s.Scale=0]="Scale",s[s.Rotation=1]="Rotation",s[s.Translation=2]="Translation",s[s.NONE=3]="NONE",s))(mt||{});class Qu extends on{applyLocalTransform(e,t,a){if(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ,this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.identity(),R.help_matrix_1.createByRotation(1,b.Y_AXIS),R.help_matrix_2.multiplyMatrices(R.help_matrix_1,R.help_matrix_0),R.help_matrix_2.invert(),R.help_matrix_1.multiplyMatrices(R.help_matrix_2,R.help_matrix_0);let r=R.help_matrix_1.decompose();this.mX.rotationX+=r[1].x,this.mY.rotationY+=r[1].y,this.mZ.rotationZ+=r[1].z}this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ}getAngle(){const t=this.object3D.transform.scene3D.view.camera,a=this.mZ.transform.worldPosition;if(t.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY),this.currentAxis==P.X){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.x-a.x>0&&(n=360-n),n}if(this.currentAxis==P.Y){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.y-a.y>0&&(n=360-n),n}if(this.currentAxis==P.Z){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(_.inputSystem.mouseX,_.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.z-a.z>0&&(n=360-n),n}return 0}mLastAngle=0;applyGlobalTransform(e,t,a){if(this.currentAxis==P.X||this.currentAxis==P.Y||this.currentAxis==P.Z){let r=this.getAngle();switch(R.help_matrix_0.identity(),this.currentAxis){case P.X:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.X_AXIS);break;case P.Y:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Y_AXIS);break;case P.Z:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Z_AXIS);break}R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let n=R.help_matrix_1.decompose(na.QUATERNION)[1];se.HELP_0.set(n.x,n.y,n.z,n.w),this.mLastAngle=r,this.mX.transform.localRotQuat=se.HELP_0}}onMouseDown(e){super.onMouseDown(e),this.currentAxis!=P.NONE&&(this.mAxis[P.X].getComponent(he).enable=!1,this.mAxis[P.Y].getComponent(he).enable=!1,this.mAxis[P.Z].getComponent(he).enable=!1,this.mAxis[this.currentAxis].getComponent(he).enable=!0,this.mLastAngle=this.getAngle())}onMouseUp(e){super.onMouseUp(e),this.currentAxis==P.NONE&&(this.mAxis[P.X].getComponent(he).enable=!0,this.mAxis[P.Y].getComponent(he).enable=!0,this.mAxis[P.Z].getComponent(he).enable=!0)}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=new ne;switch(e){case P.X:t.rotationZ=90;break;case P.Y:break;case P.Z:t.rotationX=90;break}let a=t.addComponent(he);a.geometry=new Iu(20,.4),a.material=this.mAxisMaterial[e];let r=t.addComponent(da),i=new bi;return i.setFromCenterAndSize(new b,new b(40,.4,40)),r.shape=i,t}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(_.inputSystem.mouseX,_.inputSystem.mouseY),r,i;for(let n=0;n<=P.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r)){let l=b.distance(r.intersectPoint,o.shape.center);if(l>20+.8||l<20-.8)continue;(!i||i.distance>r.distance)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint})}}return i}}class Tu extends on{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(0,0,1),t.depthCompare=ft.always,this.mAxisColor[P.XY]=t.baseColor,this.mAxisMaterial[P.XY]=t;let a=new Bt;a.doubleSide=!0,a.baseColor=new J(0,1,0),a.depthCompare=ft.always,this.mAxisColor[P.XZ]=a.baseColor,this.mAxisMaterial[P.XZ]=a;let r=new Bt;r.doubleSide=!0,r.baseColor=new J(1,0,0),r.depthCompare=ft.always,this.mAxisColor[P.YZ]=r.baseColor,this.mAxisMaterial[P.YZ]=r;let i=this.createPlane(P.XY),n=this.createPlane(P.XZ),o=this.createPlane(P.YZ);this.mContainer.addChild(this.mAxis[P.XY]=i),this.mContainer.addChild(this.mAxis[P.XZ]=n),this.mContainer.addChild(this.mAxis[P.YZ]=o),this.mAxisCollider[P.XY]=i.getComponent(da),this.mAxisCollider[P.XZ]=n.getComponent(da),this.mAxisCollider[P.YZ]=o.getComponent(da)}applyLocalTransform(e,t,a){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).invert(),R.help_matrix_0.transformVector(t,b.HELP_0),this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ||(b.HELP_0.x=0),this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ||(b.HELP_0.y=0),this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ||(b.HELP_0.z=0),this.mX.transform.worldMatrix.transformVector(b.HELP_0,b.HELP_1),this.mX.x+=b.HELP_1.x,this.mX.y+=b.HELP_1.y,this.mX.z+=b.HELP_1.z}applyGlobalTransform(e,t,a){R.help_matrix_0.identity(),(this.currentAxis==P.X||this.currentAxis==P.XY||this.currentAxis==P.XZ)&&R.help_matrix_0.appendTranslation(t.x,0,0),(this.currentAxis==P.Y||this.currentAxis==P.XY||this.currentAxis==P.YZ)&&R.help_matrix_0.appendTranslation(0,t.y,0),(this.currentAxis==P.Z||this.currentAxis==P.XZ||this.currentAxis==P.YZ)&&R.help_matrix_0.appendTranslation(0,0,t.z),R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let r=R.help_matrix_1.decompose(na.QUATERNION);this.mX.transform.localPosition=r[0],console.log(this.target.localPosition)}createCustomAxis(e){let t=super.createAxis(e),a=this.createArrows(e);return t.addChild(a),t}createArrows(e){let t=0,a=0,r=0,i=new ne;switch(e){case P.X:t=1,i.rotationZ=-90;break;case P.Y:a=1,i.rotationY=-90;break;case P.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(he);return c.geometry=new wu(0,1,4),c.material=this.mAxisMaterial[e],i}createPlane(e){let t=new ne,a=t.addComponent(he);a.material=this.mAxisMaterial[e];let r=t.addComponent(da),i=new bi;switch(r.shape=i,e){case P.XY:a.geometry=new si(4,4,1,1,b.Z_AXIS),t.x=8,t.y=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,4,.1));break;case P.XZ:a.geometry=new si(4,4,1,1,b.Y_AXIS),t.x=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,.1,4));break;case P.YZ:a.geometry=new si(4,4,1,1,b.X_AXIS),t.y=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(.1,4,4));break}return t}}class Bl extends ne{static _instance;static get instance(){return this._instance||(this._instance=new Bl),this._instance}mTarget;mTransformMode=mt.NONE;mTransformSpaceType=ha.Global;mControllers;mXObj;mYObj;mZObj;constructor(){super(),this.mControllers=[null,null,null],this.mControllers[mt.Scale]=this.addComponent(Ru),this.mControllers[mt.Rotation]=this.addComponent(Qu),this.mControllers[mt.Translation]=this.addComponent(Tu),this.mControllers[mt.Scale].enable=!1,this.mControllers[mt.Rotation].enable=!1,this.mControllers[mt.Translation].enable=!1,this.mXObj=new ne,this.mYObj=new ne,this.mZObj=new ne,this.mXObj.addChild(this.mYObj),this.mYObj.addChild(this.mZObj)}get transformMode(){return this.mTransformMode}get transformSpaceMode(){return this.mTransformSpaceType}active(e){e.addChild(this),e.addChild(this.mXObj)}unActive(e){e.removeChild(this)}get target(){return this.mTarget}selectObject(e,t,a){this.mTarget!=e&&(e?this.activate():this.unactivate(),this.mTarget=e,this.mXObj.localPosition=e.transform.worldPosition.clone()),t!=null&&this.selectTransformMode(t),a!=null&&this.selectTransformSpaceMode(a)}selectTransformMode(e){this.mTransformMode!=e&&(this.mTransformMode!=mt.NONE&&(this.mControllers[this.mTransformMode].enable=!1),this.mTransformMode=e,this.mTransformMode!=mt.NONE&&(this.mControllers[this.mTransformMode].enable=!0))}selectTransformSpaceMode(e){this.mTransformSpaceType!=e&&(this.mTransformSpaceType=e,this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].reset())}activate(){_.inputSystem.addEventListener(Ma.KEY_DOWN,this.onKeyDown,this),_.inputSystem.addEventListener(Z.POINTER_DOWN,this.onMouseDown,this,null,99999),_.inputSystem.addEventListener(Z.POINTER_MOVE,this.onMouseMove,this,null,99999),_.inputSystem.addEventListener(Z.POINTER_UP,this.onMouseUp,this,null,99999)}unactivate(){_.inputSystem.removeEventListener(Ma.KEY_DOWN,this.onKeyDown,this),_.inputSystem.removeEventListener(Z.POINTER_DOWN,this.onMouseDown,this),_.inputSystem.removeEventListener(Z.POINTER_MOVE,this.onMouseMove,this),_.inputSystem.removeEventListener(Z.POINTER_UP,this.onMouseUp,this)}onKeyDown(e){switch(e.keyCode){case tt.Key_R:this.selectTransformMode(mt.Scale),this.selectTransformSpaceMode(ha.Local);break;case tt.Key_E:this.selectTransformMode(mt.Rotation),this.selectTransformSpaceMode(ha.Global);break;case tt.Key_W:this.selectTransformMode(mt.Translation),this.selectTransformSpaceMode(ha.Global);break;case tt.Key_A:this.selectTransformSpaceMode(ha.Local);break;case tt.Key_S:this.selectTransformSpaceMode(ha.Global);break}}onMouseDown(e){this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].onMouseDown(e)}onMouseMove(e){this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].onMouseMove(e)}onMouseUp(e){this.mTransformMode!=mt.NONE&&this.mControllers[this.mTransformMode].onMouseUp(e)}}const Hm=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{mf as AccelerateDecelerateInterpolator,gf as AccelerateInterpolator,Li as AnimationCurve,xr as AnimationCurveT,Yr as AnimationMonitor,er as AnimatorComponent,xg as AnimatorEventKeyframe,_f as AnticipateInterpolator,As as AnticipateOvershootInterpolator,Ju as ArrayHas,ju as ArrayItemIndex,od as AtlasParser,gg as AtmosphericComponent,Kd as AtmosphericScatteringSky,Hd as AtmosphericScatteringSkySetting,Xd as AtmosphericScatteringSky_shader,sh as AttributeAnimCurve,Jm as AxisObject,rr as B3DMLoader,Yf as B3DMLoaderBase,ko as B3DMParseUtil,So as B3DMParser,ed as BRDFLUT,td as BRDFLUTGenerate,rc as BRDF_frag,Ls as BatchTable,vm as BiMap,fs as BillboardComponent,pr as BillboardType,Ec as BitUtil,$a as BitmapTexture2D,Kc as BitmapTexture2DArray,Bo as BitmapTextureCube,Xc as Blend,Hc as BlendFactor,De as BlendMode,tl as BlendShapeData,el as BlendShapePropertyData,_p as BloomPost,Vf as BlurEffectCreatorBlur_cs,Pf as BlurEffectCreatorSample_cs,Of as BlurTexture2DBufferCreator,aa as BounceInterpolator,qn as BoundUtil,Ce as BoundingBox,Lr as BoundingSphere,Xr as BoundingVolume,bi as BoxColliderShape,za as BoxGeometry,Zl as BrdfLut_frag,sc as BsDF_frag,ic as BxDF_frag,cc as BxdfDebug_frag,Dn as BytesArray,pt as CEvent,Za as CEventDispatcher,ys as CEventListener,lr as CResizeEvent,sa as CSM,ti as Camera3D,Ig as CameraControllerBase,nt as CameraType,bt as CameraUtil,$g as CapsuleColliderShape,d0 as CastPointShadowMaterialPass,f0 as CastShadowMaterialPass,nc as Clearcoat_frag,z0 as ClusterBoundsSource_cs,Et as ClusterConfig,Tl as ClusterDebug_frag,mc as ClusterLight,G0 as ClusterLightingBuffer,J0 as ClusterLightingRender,W0 as ClusterLighting_cs,g0 as CollectInfo,da as ColliderComponent,gt as ColliderShape,ui as ColliderShapeType,J as Color,xm as ColorGradient,Am as ColorLitMaterial,Jd as ColorLitShader,ng as ColorPassFragmentOutput,L0 as ColorPassRenderer,Fs as ColorUtil,_n as ComData,Pd as Combine_cs,Jl as Common_frag,jl as Common_vert,et as ComponentBase,Oe as ComponentCollect,ni as ComputeGPUBuffer,Fe as ComputeShader,Fl as Context3D,io as CubeCamera,Lf as CubeMapFaceEnum,Sn as CubeSky_Shader,rn as CubicBezierCurve,Um as CubicBezierPath,Du as CubicBezierType,Bf as CycleInterpolator,wu as CylinderGeometry,of as DDGIIrradianceComputePass,vs as DDGIIrradianceGPUBufferReader,R0 as DDGIIrradianceVolume,nf as DDGIIrradiance_shader,df as DDGILightingPass,ff as DDGILighting_shader,cf as DDGIMultiBouncePass,hf as DDGIProbeRenderer,Dt as DEGREES_TO_RADIANS,Uf as DRACO_DECODER_GLTF_JS,pf as DecelerateInterpolator,Vd as Denoising_cs,X0 as Depth2DTextureArray,Z0 as DepthCubeArrayTexture,h0 as DepthMaterialPass,Bp as DepthOfFieldPost,vd as DepthOfView_cs,Qi as DirectLight,rs as DoubleArray,Kr as EditorInspector,_ as Engine3D,I0 as Entity,p0 as EntityBatchCollect,q as EntityCollect,Yl as EnvMap_frag,Yt as ErpImage2CubeMap,Gf as ErpImage2CubeMapCreateCube_cs,zf as ErpImage2CubeMapRgbe2rgba_cs,ip as ExtrudeGeometry,_r as FAILED,Ca as FASTFLOOR,so as FXAAPost,af as FXAAShader,Hl as FastMathShader,wh as FatLineGeometry,qh as FatLineMaterial,mi as FatLineRenderer,Ki as FatLineShader,Mc as FatLine_FS,Tc as FatLine_VS,Mi as FeatureTable,It as FileLoader,Rg as FirstPersonCameraController,Ts as Float16ArrayTexture,w0 as Float32ArrayTexture,Qg as FlyCameraController,id as FontChar,ad as FontInfo,rd as FontPage,ir as FontParser,bf as ForwardRenderJob,En as FragmentOutput,ql as FragmentVarying,Lo as FrameCache,On as Frustum,Yc as FrustumCSM,sg as FrustumCulling_cs,fc as FullQuad_vert_wgsl,ve as GBufferFrame,c0 as GBufferPass,vp as GBufferPost,wc as GBufferStand,wn as GBuffer_pass,Do as GILighting,Fh as GIProbeMaterial,jo as GIProbeMaterialType,jd as GIProbeShader,no as GIRenderCompleteEvent,Ms as GIRenderStartEvent,Mf as GLBChunk,Tf as GLBHeader,_o as GLBParser,qc as GLSLLexer,Ui as GLSLLexerToken,$c as GLSLPreprocessor,r0 as GLSLSyntax,Kf as GLTFBinaryExtension,zp as GLTFMaterial,xt as GLTFParser,Ps as GLTFSubParser,yf as GLTFSubParserCamera,Qf as GLTFSubParserConverter,Sf as GLTFSubParserMaterial,Cf as GLTFSubParserMesh,Ao as GLTFSubParserSkeleton,Ff as GLTFSubParserSkin,oa as GLTFType,fb as GLTF_Accessors,Ns as GLTF_Info,nb as GLTF_Light,cb as GLTF_Mesh,ob as GLTF_Node,lb as GLTF_Primitives,sb as GLTF_Scene,Kt as GPUAddressMode,Zu as GPUBlendFactor,Ya as GPUBufferBase,Aa as GPUBufferType,ft as GPUCompareFunction,k as GPUContext,Lt as GPUCullMode,hr as GPUFilterMode,Ss as GPUPrimitiveTopology,oe as GPUTextureFormat,xi as GPUVertexFormat,Hu as GPUVertexStepMode,Ai as GSplatFormat,Xn as GSplatGeometry,Yn as GSplatMaterial,ii as GSplatRenderer,Si as GSplatShader,Zi as GSplatStreamRenderer,_0 as GSplat_FS,D0 as GSplat_VS,xp as GTAOPost,xd as GTAO_cs,nd as GUIAtlasTexture,ds as GUICanvas,Pr as GUIConfig,dh as GUIGeometry,uh as GUIGeometryRebuild,Wo as GUIMaterial,uf as GUIPassRenderer,mh as GUIPick,_h as GUIPickHelper,Ja as GUIQuad,ot as GUIQuadAttrEnum,bh as GUIRenderer,zo as GUIShader,fa as GUISpace,ci as GUISprite,Fr as GUITexture,Vp as GaussianSplatParser,gc as GenerayRandomDir,Lp as GeoJsonParser,Gp as GeoJsonUtil,Xs as GeoType,Le as GeometryBase,x0 as GeometryIndicesBuffer,jm as GeometryUtil,B0 as GeometryVertexBuffer,kt as GeometryVertexType,kl as GetComponentClass,yn as GetCountInstanceID,s2 as GetRepeat,El as GetShader,og as GlassShader,xe as GlobalBindGroup,Ln as GlobalBindGroupLayout,Up as GlobalFog,Oo as GlobalFog_shader,Zg as GlobalIlluminationComponent,Fn as GlobalUniform,$n as GlobalUniformGroup,yp as GodRayPost,Ud as GodRay_cs,Zm as GridObject,xo as HDRTexture,Os as HDRTextureCube,Ac as Hair_frag,lg as Hair_shader_op,cg as Hair_shader_tr,Is as HaltonSeq,xh as Horizontal,Tg as HoverCameraController,ka as I3DMLoader,qf as I3DMLoaderBase,Eo as I3DMParser,jf as IBLEnvMapCreator,Jf as IBLEnvMapCreator_cs,Ia as IESProfiles,ec as IESProfiles_frag,op as IKDTreeUserData,hi as ImageType,v0 as IndicesGPUBuffer,Wl as Inline_vert,Sl as InputSystem,Yg as InstanceDrawComponent,Xl as InstanceUniform,$f as InstancedMesh,Sr as Interpolator,oo as InterpolatorEnum,Gh as IrradianceDataReaderCompleteEvent,zl as IrradianceVolumeData_frag,ac as Irradiance_frag,zu as IsEditorInspector,xn as IsNonSerialize,kf as Joint,mo as JointPose,Df as JumperInterpolator,cp as KDTreeEntity,yr as KDTreeNode,Rh as KDTreeRange,Qh as KDTreeSpace,gs as KDTreeUUID,po as KHR_draco_mesh_compression,Wp as KHR_lights_punctual,wf as KHR_materials_clearcoat,If as KHR_materials_emissive_strength,Jp as KHR_materials_ior,Rf as KHR_materials_unlit,gd as KMZParser,$o as KV,Ym as KelvinUtil,tt as KeyCode,Ma as KeyEvent,Js as Keyframe,as as KeyframeT,Kh as LASLoader,Yp as LASParser,Jt as LASUtils,Di as LASVisualizationMode,Gs as LDRTextureCube,La as LOADED,al as LOADING,du as LRUCache,Dm as LambertMaterial,_c as Lambert_shader,js as Light,Ri as LightBase,ws as LightData,Q0 as LightEntries,ht as LightType,Ml as LightingFunction_frag,Ut as Line,Ah as LineClassification,Af as LinearInterpolator,ta as LitMaterial,Ks as LitSSSShader,qs as LitShader,oc as Lit_shader,Er as LoaderBase,fp as LoaderEvent,An as LoaderManager,e2 as MAX_VALUE,t2 as MIN_VALUE,vt as Material,o0 as MaterialDataUniformGPUBuffer,Hs as MaterialUtilities,Nl as MathShader,Gt as MathUtil,Gr as Matrix3,R as Matrix4,N0 as MatrixBindGroup,M0 as MatrixGPUBuffer,pc as MatrixShader,cr as MemoryDO,Il as MemoryInfo,up as MergeRGBACreator,yd as MergeRGBA_cs,mn as MeshColliderShape,Zs as MeshFilter,he as MeshRenderer,Fm as MinMaxAnimationCurves,Cu as MinMaxCurve,yu as MinMaxCurveState,km as MinMaxPolyCurves,mp as MorePassParser,Oh as MorePassShader,Cg as MorphTargetBlender,V0 as MorphTargetData,Sg as MorphTargetFrame,lh as MorphTargetTransformKey,Ht as MorphTarget_shader,Ys as MouseCode,lf as MultiBouncePass_cs,ku as Navi3DAstar,is as Navi3DConst,Ea as Navi3DEdge,sr as Navi3DFunnel,Ur as Navi3DMaskType,Lm as Navi3DMesh,Qt as Navi3DPoint,_l as Navi3DPoint2D,Fa as Navi3DPointFat,_e as Navi3DRouter,Eu as Navi3DTriangle,vn as NonSerialize,Kl as NormalMap_frag,Ef as OAnimationEvent,Ds as OBJParser,ne as Object3D,dp as Object3DEvent,Bl as Object3DTransformTools,Xm as Object3DUtil,nh as ObjectAnimClip,ro as OcclusionSystem,Cr as Octree,A0 as OctreeEntity,Mg as OrbitController,ym as OrderMap,na as Orientation3D,Cd as OutLineBlendColor_cs,Sd as OutlineCalcOutline_cs,fg as OutlinePass,Cp as OutlinePost,Wh as OutlinePostData,Jh as OutlinePostManager,zh as OutlinePostSlot,Fd as Outline_cs,vf as OvershootInterpolator,cu as PARSING,lc as PBRLItShader,Zd as PBRLitSSSShader,lm as PLUGIN_REGISTERED,eu as PNTSLoader,$h as PNTSLoaderBase,tu as PNTSParser,it as ParserBase,je as ParserFormat,Uu as ParticleSystemCurveEvalMode,_u as ParticleSystemRandomnessIds,yi as PassGenerate,Lh as PassShader,fe as PassType,Pl as PhysicMaterialUniform_frag,kh as PickCompute,Eh as PickFire,yt as PickGUIEvent3D,jh as PickResult,kd as Picker_cs,In as PingPong,Jn as PipelinePool,Su as Plane3D,Vr as PlaneClassification,si as PlaneGeometry,ya as PlyMode,Al as PlyParser,Hh as PlyStreamParser,Dh as PointClassification,Kn as PointCloudGeometry,E0 as PointCloudMaterial,qa as PointCloudRenderer,ki as PointCloudShader,k0 as PointCloud_FS,F0 as PointCloud_VS,oi as PointLight,Y0 as PointLightShadowRenderer,j0 as PointShadowCubeCamera,Z as PointerEvent3D,Ga as Polynomial,nr as PolynomialCurve,Sm as Polynomials,gh as PoolNode,Wt as PostBase,md as PostProcessingComponent,$0 as PostRenderer,K0 as PreDepthPassRenderer,ef as PreFilteredEnvironment_cs,qb as PreFilteredEnvironment_cs2,Ed as PreIntegratedLut,Vh as PreIntegratedLutCompute,qo as PrefabAvatarData,au as PrefabAvatarParser,Ko as PrefabBoneData,iu as PrefabMaterialParser,su as PrefabMeshData,nu as PrefabMeshParser,xs as PrefabNode,lu as PrefabParser,em as PrefabStringUtil,ru as PrefabTextureData,ou as PrefabTextureParser,Da as Preprocessor,il as PriorityQueue,Sh as Probe,bp as ProbeEntries,sf as ProbeGBufferFrame,dt as ProfilerUtil,vg as PropertyAnimClip,oh as PropertyAnimTag,ul as PropertyAnimation,fl as PropertyAnimationClip,ih as PropertyAnimationClipState,zi as PropertyAnimationEvent,Gi as PropertyHelp,Nt as QuadAABB,vc as QuadGlsl_fs,Bc as QuadGlsl_vs,Mh as QuadRoot,Ei as QuadShader,Th as QuadTree,kr as QuadTreeCell,Ku as Quad_depth2dArray_frag_wgsl,uc as Quad_depth2d_frag_wgsl,bc as Quad_depthCube_frag_wgsl,hc as Quad_frag_wgsl,dc as Quad_vert_wgsl,se as Quaternion,Qs as R32UintTexture,$r as RADIANS_TO_DEGREES,Wf as RGBEErrorCode,Uo as RGBEHeader,yo as RGBEParser,Je as RTDescriptor,lt as RTFrame,Pa as RTResourceConfig,Mt as RTResourceMap,ns as Rand,n2 as RandomSeed,ua as Ray,Bi as RayCastMeshDetail,ai as Reader,ps as Rect,ke as Reference,$d as Reflection,Rc as ReflectionCG,T0 as ReflectionEntries,th as ReflectionMaterial,tf as ReflectionRenderer,eh as ReflectionShader,Ic as ReflectionShader_shader,Ot as RegisterComponent,Na as RegisterShader,ao as RenderContext,Ci as RenderLayer,jn as RenderLayerUtil,Ba as RenderNode,m0 as RenderShaderCollect,Ph as RenderShaderCompute,qe as RenderShaderPass,Rt as RenderTexture,Va as RendererBase,rf as RendererJob,q0 as RendererMap,Ne as RendererMask,ia as RendererMaskUtil,O0 as RendererPassState,Rn as RepeatSE,pd as Res,Qu as RotationControlComponents,Qc as SHCommon_frag,ms as SN_ArrayConstant,br as SN_BinaryOperation,N2 as SN_Break,Sa as SN_CodeBlock,ar as SN_Constant,fn as SN_Continue,rt as SN_Declaration,P2 as SN_Discard,M2 as SN_DoWhileLoop,we as SN_Expression,Jr as SN_ForLoop,ln as SN_Function,cn as SN_FunctionArgs,Wr as SN_FunctionCall,Or as SN_IFBranch,Xa as SN_Identifier,Zr as SN_IndexOperation,cs as SN_Layout,t0 as SN_ParenExpression,dn as SN_Precision,os as SN_Return,ls as SN_SelectOperation,tr as SN_Struct,a0 as SN_TernaryOperation,ri as SN_UnaryOperation,jr as SN_WhileLoop,$b as SSAO_cs,wd as SSGI2_cs,Sp as SSGIPost,Fp as SSRPost,Id as SSR_BlendColor_cs,kp as SSR_IS_Kernel,Rd as SSR_IS_cs,Qd as SSR_RayTrace_cs,Ru as ScaleControlComponents,tp as Scene3D,At as Shader,Wn as ShaderAttributeInfo,i0 as ShaderConverter,s0 as ShaderConverterResult,Y as ShaderLib,Cn as ShaderPassBase,Tt as ShaderReflection,_a as ShaderStage,n0 as ShaderState,zn as ShaderUniformInfo,Ha as ShaderUtil,$l as ShadingInput,jt as ShadowLightsCollect,H0 as ShadowMapPassRenderer,tc as ShadowMapping_frag,Fg as Skeleton,hn as SkeletonAnimationClip,rh as SkeletonAnimationClipState,mr as SkeletonAnimationComponent,kg as SkeletonAnimationCompute,qr as SkeletonAnimation_shader,Eg as SkeletonBlendComputeArgs,Ii as SkeletonPose,wg as SkeletonTransformComputeArgs,Yi as SkinnedMeshRenderer,Dr as SkinnedMeshRenderer2,l0 as SkyGBufferPass,xc as SkyGBuffer_pass,qd as SkyMaterial,Ws as SkyRenderer,Oi as SkyShader,Wm as SolidColorSky,ep as SphereColliderShape,Nr as SphereGeometry,ah as SphereReflection,Ti as SpotLight,Nf as StandShader,Ge as StatementNode,Pe as StorageGPUBuffer,Ip as StreamLoader,Op as StreamingGaussianSplatParser,wt as StringUtil,vi as Struct,gp as StructStorageGPUBuffer,U0 as SubGeometry,Td as TAACopyTex_cs,Ep as TAAPost,Md as TAASharpTex_cs,Nd as TAA_cs,Od as TestComputeLoadBuffer,Bh as TextAnchor,yh as TextFieldLayout,Uh as TextFieldLine,ut as Texture,Vs as TextureCube,Co as TextureCubeFaceData,un as TextureCubeStdCreator,vo as TextureCubeUtils,pp as TextureMipmapCompute,wa as TextureMipmapGenerator,Nh as TextureScaleCompute,Pg as ThirdPersonCameraController,rl as Tile,hm as TileSet,bm as TileSetChild,gm as TileSetChildContent,pm as TileSetChildContentMetaData,um as TileSetRoot,dm as TilesRenderer,We as Time,x as TokenType,Iu as TorusGeometry,Cl as TouchData,Gm as TrailGeometry,Zt as Transform,P as TransformAxisEnum,on as TransformControllerBaseComponent,mt as TransformMode,ha as TransformSpaceMode,Tu as TranslationControlComponents,Gn as TranslatorContext,zm as TriGeometry,us as Triangle,bl as UIButton,Ch as UIButtonTransition,Jo as UIComponentBase,hp as UIEvent,zr as UIImage,gl as UIImageGroup,pn as UIInteractive,at as UIInteractiveStyle,hs as UIPanel,ji as UIRenderAble,pl as UIShadow,ml as UITextField,or as UITransform,Br as UNLOADED,zt as UUID,Dl as UV,Hn as Uint32ArrayTexture,Fi as Uint8ArrayTexture,Dc as UnLit,Bt as UnLitMaterial,Vl as UnLitMaterialUniform_frag,qi as UnLitShader,Bm as UnLitTexArrayMaterial,$i as UnLitTexArrayShader,Yd as UnLitTextureArray,Ol as UnLit_frag,Ct as UniformGPUBuffer,fr as UniformNode,St as UniformType,X as ValueEnumType,Om as ValueOp,Wa as ValueParser,Em as ValueSpread,de as Vector2,b as Vector3,Wi as Vector3Ex,be as Vector4,np as VertexAttribute,Wd as VertexAttributeIndexShader,G as VertexAttributeName,dr as VertexAttributeSize,Ih as VertexAttributeStride,Ll as VertexAttributes_vert,sp as VertexBufferLayout,Ql as VertexFormat,Rs as VertexGPUBuffer,vh as Vertical,Gl as VideoUniform_frag,ap as View3D,bn as ViewPanel,to as ViewQuad,Te as VirtualTexture,nm as WGS84_FLATTENING,om as WGS84_HEIGHT,sm as WGS84_RADIUS,e0 as WGSLTranslator,Bs as WayLines3D,_s as WayPoint3D,He as WebGPUDescriptorCreator,kn as WorldMatrixUniform,gn as WorldPanel,gi as WrapMode,Ar as WrapTimeMode,Dp as ZCullingCompute,zd as ZPassShader_cs,kc as ZPassShader_fs,Fc as ZPassShader_vs,u0 as ZSorterUtil,Zc as append,Zf as arrayToString,Yu as blendComponent,Im as buildCurves,$t as byteSizeOfType,Rm as calculateCurveRangesValue,es as calculateMinMax,yc as castPointShadowMap_vert,Be as clamp,F2 as clampRepeat,Zo as computeAABBFromPositions,D2 as cos,y2 as crossProduct,Bu as cubicPolynomialRoot,vu as cubicPolynomialRootsGeneric,wm as curvesSupportProcedural,p2 as deg2Rad,Zh as detectGSplatFormat,Sc as directionShadowCastMap_frag,Ft as dot,xu as doubleIntegrateSegment,_d as downSample,Jc as fastInvSqrt,Wc as floorfToIntPos,fi as fonts,C2 as generateRandom,S2 as generateRandom3,Oc as getFloatFromInt,vb as getGLTypeFromTypedArray,Bb as getGLTypeFromTypedArrayType,_2 as getGlobalRandomSeed,xb as getTypedArray,go as getTypedArrayTypeFromGLType,hl as grad1,nn as grad2,ts as grad3,_i as grad4,Xo as inferSHOrder,dl as integrateSegment,Ap as irradianceDataReader,Cm as kPI,Mr as lerp,i2 as lerpByte,r2 as lerpColor,a2 as lerpVector3,Au as lruPriorityCallback,Tn as magnitude,Ib as makeAloneSprite,sd as makeGUISprite,Es as makeMatrix44,cl as markUsedSetLeaves,en as markUsedTiles,tn as markVisibleTiles,Vn as matrixMultiply,I2 as matrixRotate,w2 as matrixRotateY,Cs as mergeFunctions,jc as multiplyMatrices4x4REF,Fu as normal_distribution,U2 as normalizeFast,Vc as normalizeSafe,x2 as normalizedToByte,v2 as normalizedToWord,Ua as outlinePostData,wp as outlinePostManager,Ho as parsePlyGaussianSplat,Hi as parsePlyHeader,Yh as parsePlyMesh,Xh as parsePlyPointCloud,Ue as perm,Bd as post,mu as priorityCallback,sn as quadraticPolynomialRootsGeneric,m2 as rad2Deg,ei as random01,g2 as randomBarycentricCoord,b2 as randomPointBetweenEllipsoid,h2 as randomPointBetweenSphere,f2 as randomPointInsideCube,d2 as randomPointInsideEllipsoid,u2 as randomPointInsideUnitCircle,Gc as randomPointInsideUnitSphere,l2 as randomQuaternion,c2 as randomQuaternionUniformDistribution,zc as randomSeed,ks as randomUnitVector,Lc as randomUnitVector2,_t as rangedRandomFloat,o2 as rangedRandomInt,pe as readByType,li as readMagicBytes,_m as registerMaterial,Pn as repeat,E2 as rotMatrix,$u as rotateVectorByQuat,Mn as roundfToIntPos,Qn as scale,Cc as shadowCastMap_frag,Uc as shadowCastMap_vert,ea as simplex,A2 as sin,Mm as snoise1,Nm as snoise2,Pm as snoise3,Vm as snoise4,Yo as splatColorProperties,Xi as splatProperties,Nn as sqrMagnitude,Pc as sqrtImpl,Xu as stencilStateFace,B2 as swap,Ld as textureCompress,Dd as threshold,mm as throttle,Ka as toHalfFloat,an as toggleTiles,cm as traverseAncestors,hu as traverseSet,ig as tw,Qm as uniform_real_distribution,Tm as uniform_real_distribution2,Vo as upSample,I as webGPUContext,b0 as zSorterUtil};
11828
11828
  //# sourceMappingURL=rings.es.js.map